plugin for checking FSD architecture and import paths inside react projects
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-fsd-by-korkhn
:
npm install eslint-plugin-fsd-by-korkhn --save-dev
or
npm i -D eslint-plugin-fsd-by-korkhn
Add eslint-plugin-fsd-by-korkh
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["fsd-by-korkh"]
}
Then configure the rules you want to use under the rules section. To control relative an absolute path for modules (slices) use:
{
"rules": {
"fsd-by-korkh/path-checker": "error"
}
}
If there is alias used in the project, f.ex. "@":
{
"rules": {
"fsd-by-korkh/path-checker": ["error", { "alias": "@" }]
}
}
If in your project you are using storybook with Decorators, or tests (jest or other) and want to isolate some reducers, can be used public API as (testing.ts or testing.js) needs to pass following patterns to eslint:
{
"rules": {
"fsd-by-korkh/path-checker": [
"error",
{
"alias": "@",
"testFilesPatterns": [
"**/*.test.*",
"**/*.stories.*",
"**/StoreDecorator.tsx"
]
}
]
}
}