0.0.15 • Published 1 year ago
eslint-plugin-import-checker-plugin v0.0.15
Import checker plugin
Plugin checks absolute and relative paths in the project
Installation
You'll first need to install ESLint:
npm i eslint --save-devNext, install eslint-plugin-import-checker-plugin:
npm install eslint-plugin-import-checker-plugin --save-devUsage
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 |