0.0.16 • Published 14 days ago

eslint-plugin-fsd-project v0.0.16

Weekly downloads
-
License
ISC
Repository
-
Last release
14 days ago

eslint-plugin-fsd-project

Check imports for FSD architecture

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-fsd-project:

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

Usage

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

{
    "plugins": [
        "fsd-project"
    ]
}

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

{
    "rules": {
        "fsd-project/path-checker": [
            "error", 
            { "alias": "@", "srcPath": "src" }
        ],
        "fsd-project/public-api-imports": [
            "error", 
            {
                "alias": "@",
                "testFilesPatterns": ["**/*.test.ts", "**/*.test.tsx", "**/StoreDecorator.tsx"],
            }
        ],
        "fsd-project/layer-imports": [
            "error", {
                "alias": "@",
                "srcPath": "src",
                "ignoreImportPatterns": ["**/StoreProvider", "**/testing"],
            }
        ],
    }
}

Rules

path-checker

Описание

Пути импорта в рамках одного слайса должны бить относительными.

Сообщение В рамках одного слайса все пути должны быть относительными

Исключением является слайс shared

Аргументы

alias: string = '' - строка-символ псевдонима путей

srcPath: string = 'src' - строка - относительный путь от root до папки с src


public-api-imports

Описание

Абсолютные пути импорда должны быть из Public API

Сообщение

  • Абсолютный импорт разрешен только из Public API (index.ts)
  • Тестовые данные необходимо импортировать из publicApi/testing.ts

Исключением является слайс shared

Аргументы

alias: string = '' - строка-символ псевдонима путей

testFilesPatterns: string[] = [] - массив паттернов файлов для тестирования


layer-imports

Описание

Проверяет корректный импорт между слоями в рамках концепции FSD:

Правила импортов:

app <-- pages, widgets, features, shared, entities

pages <-- widgets, features, shared, entities

widgets <-- features, shared, entities

features <-- shared, entities

entities <-- shared, entities

shared <-- shared

Сообщение Слой может импортировать в себя только нижележащие слои (shared, entities, features, widgets, pages, app)

Аргументы

alias: string = '' - строка-символ псевдонима путей

srcPath: string = 'src' - строка - относительный путь от root до папки с src

ignoreImportPatterns: string[] = [] - массив паттернов файлов для исключений

0.0.15

14 days ago

0.0.16

14 days ago

0.0.14

1 month ago

0.0.12

2 months ago

0.0.13

2 months ago

0.0.10

3 months ago

0.0.11

3 months ago

0.0.9

3 months ago

0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

3 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago