npm.io
0.0.15 • Published 1 year ago

eslint-plugin-import-checker-plugin

Licence
ISC
Version
0.0.15
Deps
2
Size
21 kB
Vulns
0
Weekly
0

Import checker plugin

Plugin checks absolute and relative paths in the project

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-import-checker-plugin:

npm install eslint-plugin-import-checker-plugin --save-dev

Usage

Add import-checker-plugin to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "import-checker-plugin"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "import-checker-plugin/rule-name": ["error", { "alias": "@" }],
        "import-checker-plugin/public-api-imports": [
          "error", 
          {
            "alias": "@",
            "testFilesPatterns": [",**/*.test.ts", ",**/*.story.*", ",**/StoreDecorator.tsx"]
          }
        ],
        "import-checker-plugin/layer-imports": [
          "error",
          {
            "alias": "@",
            "ignoreImportPatterns": ["**/StoreProvider"]
          }
        ]
    }
}

Rules

Name Description
path-checker Within a single slice, all paths must be relative
public-api-imports Absolute import is only allowed from Public API (index.ts)
layer-imports A layer can only import underlying layers into itself

Keywords