0.0.15 • Published 1 year ago

eslint-plugin-fsd-stable v0.0.15

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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": "@"
      }
    ]
  }
}

more fsd rules and options in the following versions

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago