Skip to content

CheIIau/eslint-plugin-dubious-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-dubious-plugin npm

Check import paths according to FSD

The plugin contain 5 rules:

  1. different-layer-absolute-import (Prevents the use of relative import to import from other layers)
  2. underlying-layer-imports (Prevents to import a layer from underlying layer)
  3. public-api-import-slice (Check if a module was imported using a public API)
  4. different-layer-export (Prevents exporting a module from another layer)
  5. same-slice-local-import (Prevents the use of absolute import within one slice)

Rule options

First 4 rules (different-layer-absolute-import, underlying-layer-imports, public-api-import-slice, different-layer-export) have all the options below. The last one (same-slice-local-import) has only alias option. Also public-api-import-slice, public-api-import-slice and same-slice-local-import rules have autofix.

{
        alias: string, // alias for absolute import folder (e.g. "src" or "@")
        ignoreFiles: string[], // ignored files to check with the given pattern (e.g. '**/*.test.*')
        ignoreImportPatterns: string[] // ignored import declaration string to check with the given pattern (e.g. '**/StoreProvider/**')
},

Example of use

// .eslintrc.js

{
       'dubious-plugin/public-api-import-slice': [
            'error',
            { alias: 'src', ignoreFiles: ['**/*.test.*', '**/*.stories.*'] },
        ],
        'dubious-plugin/underlying-layer-imports': [
            'error',
            {
                alias: 'src',
                ignoreImportPatterns: ['**.scss', '**/StoreProvider/**'],
                ignoreFiles: ['**/*.test.*', '**/*.stories.*'],
            },
        ],
        'dubious-plugin/different-layer-absolute-import': [
            'error',
            {
                alias: 'src',
                ignoreFiles: ['**/*.test.*', '**/*.stories.*'],
            },
        ],
},

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published