npm.io
0.0.20 • Published 3 years ago

eslint-plugin-lucky-fsd

Licence
ISC
Version
0.0.20
Deps
3
Size
23 kB
Vulns
0
Weekly
0

eslint-plugin-lucky-fsd

Plugin for Feature-Sliced Design(it was developed for Windows and may not work on Mac)

  1. Checks that the paths inside the component are relative. Also supports checking with aliases.
  2. Prohibits importing from non-public api
  3. Prohibits import from overlying layers

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-lucky-fsd:

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

Usage

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

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

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

'lucky-fsd/path-checker' - checks that the paths inside the component are relative. Also supports checking with aliases. 'lucky-fsd/public-api-imports' - prohibits importing from non-public api 'lucky-fsd/layer-imports' - prohibits import from overlying layers

{
    rules: {
      'lucky-fsd/path-checker': ['error', { alias: '@' }],
      'lucky-fsd/public-api-imports': [
        'error',
        {
          alias: '@',
          testFilesPatterns: ['**/*.test.*', '**/*.stories.*', '**/StoreDecorator.tsx'],
        }
      ],
      'lucky-fsd/layer-imports': [
        'error',
        {
          alias: '@',
          ignoreImportPatterns: [ '**/StoreProvider' ],
        }
      ]
    },
}

Keywords