eslint-plugin-path-import-validation-plugin
v0.0.16
Published
plugin is designed to detect illegal import of a components, according to the FSD methodology
Downloads
22
Maintainers
Readme
eslint-plugin-relative-path-import-validation-plugin
plugin is designed to detect illegal imports, according to the FSD methodology such as:
- absolute import inside one module
- import from lower layer to upper
- absolute import from external module not from Public API
- absolute import from testing API to external business components
Installation
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-relative-path-import-validation-plugin
:
npm install eslint-plugin-relative-path-import-validation-plugin --save-dev
Usage
Add relative-path-import-validation-plugin
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"relative-path-import-validation-plugin"
]
}
Then configure the rules you want to use under the rules section.
- Rule for detecting illegal absolute import of a component into a single module, according to the FSD methodology
{
"rules": {
"path-import-validation-plugin/relative-path-import-checker": [
"error",
{ "alias": "@" } // specify an alias if necessary
]
}
}
- Rule for detecting incorrect component imports from the internals of the module but not from the public API
{
"rules": {
"path-import-validation-plugin/public-api-imports": [
"error",
{
"alias": "@", // specify an alias if necessary
"testFilesPatterns": ["**/*.test.*", "**/*.stories.tsx", "**/StoreDecorator.tsx"] // specify the files for which import from the testing API will be allowed
}
]
}
}
- Rule for detecting illegal imports from one layer to another according to the FSD methodology
{
"rules": {
"path-import-validation-plugin/layer-imports": [
"error",
{
"alias": "@", // specify an alias if necessary
"ignoreImportPatterns": ["**/StoreProvider", "**/testing"] // specify an exception
}
]
}
}
Rules
TODO: Run eslint-doc-generator to generate the rules list.