Skip to content

Drop-in replacement for ESLint's rule id-denylist with support for regular expressions

License

Notifications You must be signed in to change notification settings

SUSIandJames/eslint-plugin-id-denylist-regexp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-id-denylist-regexp

Drop-in replacement for ESLint's rule id-denylist with support for regular expressions.

Installation

You'll first need to install ESLint:

npm install eslint --save-dev

Next, install eslint-plugin-id-denylist-regexp:

npm install @susiandjames/eslint-plugin-id-denylist-regexp --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-id-denylist-regexp globally.

Usage

Extend your eslint.config.js by the rule susiandjames/id-denylist as follows:

import susiandjames from "@susiandjames/eslint-plugin-id-denylist-regexp";

export default [
  {
    plugins: {
      susiandjames,
    },
    rules: {
      "susiandjames/id-denylist": [
        "warn",
        "/[0-9]+$/", // Disallow identifiers ending with numbers, e.g., `tmp0`
        "/(black|white)list/i", // Disallow identifiers containing the words "blacklist" and "whitelist" independent of their case sensitivity 
      ],
    },
  },
];

Note: Since ESLint's options need to be serializable you have to specify regular expressions as strings with a leading slash instead of using JavaScript's RegExp() constructor.

About

Drop-in replacement for ESLint's rule id-denylist with support for regular expressions

Resources

License

Stars

Watchers

Forks

Releases

No releases published