@susiandjames/eslint-plugin-id-denylist-regexp

1.0.3 • Public • Published

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.

Package Sidebar

Install

npm i @susiandjames/eslint-plugin-id-denylist-regexp

Weekly Downloads

36

Version

1.0.3

License

MIT

Unpacked Size

14.3 kB

Total Files

7

Last publish

Collaborators

  • fnogatz
  • juliangerhardsaj