Registry / testing / eslint-plugin-literal-blacklist

eslint-plugin-literal-blacklist

JSON →
library1.2.0jsnpmunverified

An ESLint micro plugin (v1.2.0) that allows you to define a blacklist of strings (string or regex) or objects with custom messages and ignoreCase option in literal expressions. No recent updates, simple rule set. Differentiators: lightweight, supports regex and custom messages per rule, minimal configuration.

npm install eslint-plugin-literal-blacklist
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-LITE
E
eslint-plugin-literal-blacklist
testingjavascriptv1.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default import of plugin
✓ module.exports = { plugins: ['literal-blacklist'], rules: { 'literal-blacklist/literal-blacklist': [2, ['bad']] } };
✗ // Incorrect: missing quotes or wrong shape module.exports = { plugins: [literal-blacklist], // ReferenceError rules: { 'literal-blacklist': [2, ['bad']] } // missing rule namespace };
The plugin registers as 'literal-blacklist' and the rule must be referenced as 'literal-blacklist/literal-blacklist'.
Rules in flat config (ESLint 9+)
✓ import literalBlacklist from 'eslint-plugin-literal-blacklist'; export default [ { plugins: { 'literal-blacklist': literalBlacklist }, rules: { 'literal-blacklist/literal-blacklist': ['error', ['bad']] } } ];
✗ // Wrong: using plugins array instead of object import literalBlacklist from 'eslint-plugin-literal-blacklist'; export default [ { plugins: [literalBlacklist], rules: { ... } } // breaks ESLint 9+ ];
ESLint flat config requires plugins to be an object with custom namespace. The plugin exports a single object, not an array.
Rule severity as string
✓ "literal-blacklist/literal-blacklist": ["error", ["bad"]]
✗ "literal-blacklist/literal-blacklist": [2, ["bad"]] // numeric severity works but string is preferred in modern ESLint
Both numeric (0,1,2) and string ('off','warn','error') severity levels work. Only 'error' (or 2) will block build.

Shows installation and ESLint rule configuration with string, regex, and object with custom message and ignoreCase.

// Install: npm install eslint-plugin-literal-blacklist --save-dev // .eslintrc.js module.exports = { plugins: ['literal-blacklist'], rules: { 'literal-blacklist/literal-blacklist': ['error', [ 'badword', /^secret_/, { term: 'password', message: 'Avoid using password literal', ignoreCase: true } ]] } };
Debug
Known issues
gotchaRule applies to all string literals, including in template literals and object property values, but not to comments or identifiers.
fix
Be aware that only literal expressions (AST Literal nodes) are checked; template literals with expressions are partially checked.
affects: >=1.0.0
gotchaThe ignoreCase option only works when you provide an object with { term: 'string' } — not with regex or plain strings.
fix
Use object form with 'ignoreCase: true' for case-insensitive matching of string terms. Regex already supports case-insensitive flags (/pattern/i).
affects: >=1.0.0
gotchaTerm objects with 'term' property must be strings; if you pass a regex as term it will be converted to string via toString, likely breaking.
fix
Use regex directly in the array, not inside an object's term property. Example: [2, [/bad/i]] works.
affects: >=1.0.0
Errors
Common errors & fixes
ESLintError: Failed to load plugin 'literal-blacklist': Cannot find module 'eslint-plugin-literal-blacklist'
Plugin not installed or installed as devDependency but not in right place.
fix
Run `npm install eslint-plugin-literal-blacklist --save-dev` from project root.
Configuration for rule "literal-blacklist/literal-blacklist" is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '"error"').
Using numeric severity as a string or vice versa in old ESLint versions.
fix
Use integer severity: [2, ['bad']] or standard ESLint expects either 0/1/2 or 'off'/'warn'/'error'. Some config parsers may be picky. Try: ['error', ['bad']].
Error: Invalid term in literal-blacklist rule: expected a string or object with term property.
Passed something other than string, RegExp, or object.
fix
Ensure each entry in the array is a string, a RegExp, or an object with a 'term' string property.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
eslint-plugin-literal-blacklist — npm install eslint-plugin-literal-blacklist · libregistry