0.0.16 • Published 12 months ago
eslint-plugin-path-import-validation-plugin v0.0.16
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.
0.0.10
12 months ago
0.0.11
12 months ago
0.0.12
12 months ago
0.0.13
12 months ago
0.0.14
12 months ago
0.0.3
1 year ago
0.0.15
12 months ago
0.0.9
12 months ago
0.0.16
12 months ago
0.0.8
12 months ago
0.0.5
12 months ago
0.0.4
12 months ago
0.0.7
12 months ago
0.0.6
12 months ago
0.0.2
1 year ago
0.0.1
1 year ago
0.0.0
1 year ago