1.2.1 ā€¢ Published 5 months ago

eslint-plugin-restrict-replace-import v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

eslint-plugin-restrict-replace-import

ESLint Plugin for Restricting and Replacing Import.

Automatically fixable with replacement package!

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-restrict-replace-import:

npm install eslint-plugin-restrict-replace-import --save-dev

Usage

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

{
  "plugins": ["restrict-import"]
}

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

{
  "rules": {
    "restrict-replace-import/restrict-import": [
      "error",
      ["restricted-package1", "restricted-package2"]
    ]
  }
}

You can also specify an alternative package to import instead:

{
  "rules": {
    "restrict-replace-import/restrict-import": [
      "error",
      [
        {
          "target": "restricted-package1",
          "replacement": "replacement-package1"
        },
        {
          "target": "restricted-package2",
          "replacement": "replacement-package2"
        }
      ]
    ]
  }
}

You can use RegExp for package name:

{
  "rules": {
    "restrict-replace-import/restrict-import": [
      "error",
      [
        "with(?:-regex)?-support",
        {
          "target": "restricted-.*",
          "replacement": "replacement-package"
        }
      ]
    ]
  }
}

Rules

šŸ”§ Automatically fixable by the --fix CLI option.

NameDescriptionšŸ”§
restrict-importPrevent the Import of a Specific PackagešŸ”§
1.2.1

5 months ago

1.2.0

5 months ago

1.1.0

5 months ago

1.0.0

5 months ago