eslint-plugin-fsd-stable
v0.0.15
Published
The plugin checks the correctness of imports, according to the FSD architectural methodology
Downloads
41
Maintainers
Readme
eslint-plugin-fsd-stable
The plugin checks the correctness of imports, according to the FSD architectural methodology.
Installation
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-fsd-stable
:
npm install eslint-plugin-fsd-stable --save-dev
Usage
Add fsd-stable
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"fsd-stable"
]
}
Then configure the rules you want to use under the rules section.
Supported rules:
fsd-paths-checker
The rule checks the correctness of relative and absolute imports within the same slice. Autofix included.
{
"rules": {
"fsd-stable/fsd-paths-checker": "error"
}
}
public-api-imports-only
The rule allows absolute imports only from the Public API (index.ts). Autofix included.
{
"rules": {
"fsd-stable/public-api-imports-only": "error"
}
}
Supported options for public-api-imports-only rule:
"testFilesPatterns"
The option allows you to enable import verification for test environments. Import to tests is only possible from a special Public API for testing (testing.ts), which is located next to the regular Public API (index.ts). The key takes an array of strings as a value.
{
"rules": {
"fsd-stable/public-api-imports-only": [
"error",
{
"testFilesPatterns": ["**/*.test.ts", "**/*.test.ts", "**/StoreDecorator.tsx"]
}
]
}
}
fsd-layer-imports
The rule allows imports into a layer only from underlying layers.
{
"rules": {
"fsd-stable/fsd-layer-imports": "error"
}
}
Supported options for fsd-layer-imports:
"ignoreImportPatterns"
The option allows you to exclude the required imports from the check. Can be useful when using Redux and layer conflicts at the type level. The key takes an array of strings as a value.
{
"rules": {
"fsd-stable/fsd-layer-imports": [
"error",
{
"ignoreImportPatterns": ["**/StoreProvider"]
}
]
}
}
Supported options for all rules:
"alias"
Adds work with aliases, if they are in your project. Just specify the one you want. The key accepts any string value.
{
"rules": {
"fsd-stable/rule": [
"error",
{
"alias": "@"
}
]
}
}