Plugin checks absolute and relative paths in the project
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
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"]
}
]
}
}
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 |