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.

testing
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

The plugin registers as 'literal-blacklist' and the rule must be referenced as 'literal-blacklist/literal-blacklist'.

module.exports = { plugins: ['literal-blacklist'], rules: { 'literal-blacklist/literal-blacklist': [2, ['bad']] } };

ESLint flat config requires plugins to be an object with custom namespace. The plugin exports a single object, not an array.

import literalBlacklist from 'eslint-plugin-literal-blacklist'; export default [ { plugins: { 'literal-blacklist': literalBlacklist }, rules: { 'literal-blacklist/literal-blacklist': ['error', ['bad']] } } ];

Both numeric (0,1,2) and string ('off','warn','error') severity levels work. Only 'error' (or 2) will block build.

"literal-blacklist/literal-blacklist": ["error", ["bad"]]

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 footguns
gotchaRule applies to all string literals, including in template literals and object property values, but not to comments or identifiers.
gotchaThe ignoreCase option only works when you provide an object with { term: 'string' } — not with regex or plain strings.
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.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
13 hits · last 30 days
gptbot
4
ahrefsbot
4
amazonbot
4
script
1
Resources