0.0.16 • Published 2 years ago

eslint-plugin-path-import-validation-plugin v0.0.16

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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.

  1. 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
      ]
    }
}
  1. 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
        }
      ]
    }
}
  1. 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

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.3

2 years ago

0.0.15

2 years ago

0.0.9

2 years ago

0.0.16

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago