Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-import-isolation

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-import-isolation

ESLint plugin for restricting imports between specified directories.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-import-isolation

The Problem

Suppose you have two subdirectories under pages:

my-project
└── pages
   └── a
   └── b

You don't want modules under a to import anything from b. Existing plugins like eslint-plugin-import and eslint-plugin-code-import-patterns address this issue well. However, when you have tens of subdirectories under pages, configuring the rules becomes burdensome. This plugin is designed to solve this problem.

Usage

To use this plugin, configure ESLint as following:

plugins: ['import-isolation'],
rules: {
    'import-isolation/isolation': [
        'error',
        {
            isolationGroups: [
                {
                    directories: [
                        "modules/*",
                        // equivalent to
                        // "modules/a"
                        // "modules/b"
                        // ...
                    ]
                },
                {
                    directories: [
                        "modules/*/pages/*",
                        // equivalent to
                        // "modules/a/pages/aa",
                        // "modules/a/pages/ab",
                        // "modules/b/pages/ba",
                        // ...
                    ]
                },
            ]
        }
    ]
}
  • isolationGroups includes several "isolation groups", where each group uses directories to specify multiple directories.
  • All directories inside one isolation group cannot import from each other.
  • You can use the wildcard * to specify multiple directories.
  • Taking the example above, modules/a/a.js cannot import from modules/b/b.js, and modules/a/pages/pa.js cannot import from either modules/a/pages/pb.js or modules/b/pages/pa.js.

FAQs

Package last updated on 31 Aug 2023

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