Skip to content

microlabig/eslint-plugin-bzm-fsd-plugin

Repository files navigation

eslint-plugin-bzm-fsd-plugin

For FSD Architecture eslint rules:

  • path-checker: check import relative paths for current slice by FSD:
    • "В рамках одного слайса все пути должны быть относительными" (+ fixer)
  • fsd-public-api-imports: public api imports for FSD:
    • "Абсолютный импорт разрешен только из Public API (index.ts)" (+ fixer)
    • "Тестовые данные необходимо импортировать из publicApi/testing.ts"
  • layer-imports: check import paths for current layer (low coupling, high cohesion)
    • Слой может импортировать в себя только нижележащие слои

Git: https://github.com/microlabig/eslint-plugin-bzm-fsd-plugin


Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-bzm-fsd-plugin:

npm install eslint-plugin-bzm-fsd-plugin --save-dev

Usage

Add bzm-fsd-plugin to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "bzm-fsd-plugin"
    ]
}

Then configure the rules you want to use under the rules section.

{
    rules: {
        // ... other rules

        // for 'path-checker'
        "bzm-fsd-plugin/path-checker": [
            "error",
            {
                alias: "@", // 
            },
        ],

        // for 'fsd-public-api-imports'
        "bzm-fsd-plugin/fsd-public-api-imports": [
            "error",
            {
                alias: "@",
                testFilesPatterns: ["**/*.test.*", "**/*.story.*", "**/StoreDecorator.tsx"], // file patterns for testing
            },
        ],

        // for 'layer-imports'
        "bzm-fsd-plugin/layer-imports": [
            "error",
            {
                alias: "@",
                ignoreImportPatterns: ["**/StoreProvider", "**/testing"],  // file patterns for ignore
            },
        ],
    }
}

Rules

TODO: Run eslint-doc-generator to generate the rules list.

About

Eslint plugins for production project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published