Socket
Socket
Sign inDemoInstall

eslint-plugin-strict-dependencies

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-strict-dependencies

Restrict imports between files according to the configured dependency rules.


Version published
Weekly downloads
20K
increased by17.98%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-strict-dependencies

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 or not the target module itself can import on the target module

Usage

.eslintrc:

"plugins": [
  "strict-dependencies",
],
"rules": {
  "strict-dependencies/strict-dependencies": [
    "error",
    [
      /**
       * example:
       * Components only allow 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:
       * Don't import next/router directly, always import it through libs/router.
       */
      {
        "module": "next/router",
        "allowReferenceFrom": ["src/libs/router.ts"],
        "allowSameModule": false
      },
    ],
  ],
}

License

MIT

FAQs

Package last updated on 29 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc