Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 1.75 KB

README.md

File metadata and controls

68 lines (50 loc) · 1.75 KB

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