All Projects → knowledge-work → eslint-plugin-strict-dependencies

knowledge-work / eslint-plugin-strict-dependencies

Licence: MIT license
ESlint plugin to define custom module dependency rules.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to eslint-plugin-strict-dependencies

Eslint Plugin Css Modules
Project status: NOT MAINTAINED; Checks that you are using the existent css/scss classes, no more no less
Stars: ✭ 115 (-19.01%)
Mutual labels:  eslint-plugin
Eslint Plugin Eslint Comments
Additional ESLint rules for directive comments of ESLint.
Stars: ✭ 221 (+55.63%)
Mutual labels:  eslint-plugin
eslint-plugin-license-header
Rules to validate the presence of license headers in source files.
Stars: ✭ 21 (-85.21%)
Mutual labels:  eslint-plugin
Eslint Plugin Unicorn
Various awesome ESLint rules
Stars: ✭ 2,157 (+1419.01%)
Mutual labels:  eslint-plugin
Eslint Plugin Lodash
ESLint rules for lodash
Stars: ✭ 208 (+46.48%)
Mutual labels:  eslint-plugin
Eslint Plugin Ember
An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
Stars: ✭ 240 (+69.01%)
Mutual labels:  eslint-plugin
Typescript Eslint
✨ Monorepo for all the tooling which enables ESLint to support TypeScript
Stars: ✭ 10,831 (+7527.46%)
Mutual labels:  eslint-plugin
eslint-plugin-aura
Salesforce Lightning (Aura) specific linting rules for ESLint
Stars: ✭ 24 (-83.1%)
Mutual labels:  eslint-plugin
Eslint Plugin Ava
ESLint rules for AVA
Stars: ✭ 209 (+47.18%)
Mutual labels:  eslint-plugin
ultimate-hot-boilerplate
🚀 node-react universal app boilerplate with everything on hot reload, SSR, GraphQL, Flow included
Stars: ✭ 35 (-75.35%)
Mutual labels:  eslint-plugin
Eslint Plugin Boundaries
Eslint plugin checking architecture boundaries between elements
Stars: ✭ 157 (+10.56%)
Mutual labels:  eslint-plugin
You Dont Need Lodash Underscore
List of JavaScript methods which you can use natively + ESLint Plugin
Stars: ✭ 13,915 (+9699.3%)
Mutual labels:  eslint-plugin
Eslint Plugin Svelte3
An ESLint plugin for Svelte v3 components.
Stars: ✭ 248 (+74.65%)
Mutual labels:  eslint-plugin
Eslint Import Resolver Alias
a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias
Stars: ✭ 121 (-14.79%)
Mutual labels:  eslint-plugin
eslint-plugin-no-only-tests
ESLint rule for catching focused/only test blocks
Stars: ✭ 67 (-52.82%)
Mutual labels:  eslint-plugin
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (-28.87%)
Mutual labels:  eslint-plugin
Eslint Import Resolver Babel Module
Custom eslint resolve for babel-plugin-module-resolver
Stars: ✭ 236 (+66.2%)
Mutual labels:  eslint-plugin
eslint-plugin-array-func
Rules for Array functions and methods.
Stars: ✭ 77 (-45.77%)
Mutual labels:  eslint-plugin
eslint-plugin-gridsome
ESLint plugin for Gridsome
Stars: ✭ 45 (-68.31%)
Mutual labels:  eslint-plugin
Eslint Plugin Mocha
ESLint rules for mocha
Stars: ✭ 249 (+75.35%)
Mutual labels:  eslint-plugin

eslint-plugin-strict-dependencies

ESlint plugin to define custom module dependency rules.

NOTE: eslint-plugin-strict-dependencies uses tsconfig, tsconfig.json must be present.

Installation

npm install eslint-plugin-strict-dependencies --save-dev

Supported Rules

  • strict-dependencies
    • module: string (Glob or Forward matching string)
      • target module path
    • allowReferenceFrom: string[] (Glob or Forward matching string)
      • Paths of files where target module imports are allowed.
    • allowSameModule: boolean
      • Whether it can be imported by other files in the same directory

Options

  • resolveRelativeImport: boolean[default = false]
    • Whether to resolve relative import as in the following example
    • src/components/aaa.ts
      import bbb from './bbb';
      • resolveRelativeImport = false: Resolve as ./bbb (excluded from lint target)
      • resolveRelativeImport = true: Resolve as src/components/bbb: (included from lint target)

Usage

.eslintrc:

"plugins": [
  "strict-dependencies",
],
"rules": {
  "strict-dependencies/strict-dependencies": [
    "error",
    [
      /**
       * Example:
       * Limit the dependencies in the following directions
       * pages -> components/page -> components/ui
       */
      {
        "module": "src/components/page",
        "allowReferenceFrom": ["src/pages"],
        // components/page can't import other components/page
        "allowSameModule": false
      },
      {
        "module": "src/components/ui",
        "allowReferenceFrom": ["src/components/page"],
        // components/ui can import other components/ui
        "allowSameModule": true
      },

      /**
       * example:
       * Disallow to import `next/router` directly. it should always be imported using `libs/router.ts`.
       */
      {
        "module": "next/router",
        "allowReferenceFrom": ["src/libs/router.ts"],
        "allowSameModule": false
      },
    ],
    // options
    // {
    //   "resolveRelativeImport": true
    // }
  ]
}

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].