{"id":19821,"library":"eslint-plugin-literal-blacklist","title":"ESLint Plugin Literal Blacklist","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/kyaido/eslint-plugin-literal-blacklist","tags":["javascript","eslint","eslint-plugin","eslintplugin"],"install":[{"cmd":"npm install eslint-plugin-literal-blacklist","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-literal-blacklist","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-literal-blacklist","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The plugin registers as 'literal-blacklist' and the rule must be referenced as 'literal-blacklist/literal-blacklist'.","wrong":"// Incorrect: missing quotes or wrong shape\nmodule.exports = {\n  plugins: [literal-blacklist], // ReferenceError\n  rules: { 'literal-blacklist': [2, ['bad']] } // missing rule namespace\n};","symbol":"default import of plugin","correct":"module.exports = {\n  plugins: ['literal-blacklist'],\n  rules: { 'literal-blacklist/literal-blacklist': [2, ['bad']] }\n};"},{"note":"ESLint flat config requires plugins to be an object with custom namespace. The plugin exports a single object, not an array.","wrong":"// Wrong: using plugins array instead of object\nimport literalBlacklist from 'eslint-plugin-literal-blacklist';\nexport default [\n  { plugins: [literalBlacklist], rules: { ... } } // breaks ESLint 9+\n];","symbol":"Rules in flat config (ESLint 9+)","correct":"import literalBlacklist from 'eslint-plugin-literal-blacklist';\nexport default [\n  {\n    plugins: { 'literal-blacklist': literalBlacklist },\n    rules: { 'literal-blacklist/literal-blacklist': ['error', ['bad']] }\n  }\n];"},{"note":"Both numeric (0,1,2) and string ('off','warn','error') severity levels work. Only 'error' (or 2) will block build.","wrong":"\"literal-blacklist/literal-blacklist\": [2, [\"bad\"]] // numeric severity works but string is preferred in modern ESLint","symbol":"Rule severity as string","correct":"\"literal-blacklist/literal-blacklist\": [\"error\", [\"bad\"]]"}],"quickstart":{"code":"// Install: npm install eslint-plugin-literal-blacklist --save-dev\n// .eslintrc.js\nmodule.exports = {\n  plugins: ['literal-blacklist'],\n  rules: {\n    'literal-blacklist/literal-blacklist': ['error', [\n      'badword',\n      /^secret_/,\n      { term: 'password', message: 'Avoid using password literal', ignoreCase: true }\n    ]]\n  }\n};","lang":"javascript","description":"Shows installation and ESLint rule configuration with string, regex, and object with custom message and ignoreCase."},"warnings":[{"fix":"Be aware that only literal expressions (AST Literal nodes) are checked; template literals with expressions are partially checked.","message":"Rule applies to all string literals, including in template literals and object property values, but not to comments or identifiers.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use object form with 'ignoreCase: true' for case-insensitive matching of string terms. Regex already supports case-insensitive flags (/pattern/i).","message":"The ignoreCase option only works when you provide an object with { term: 'string' } — not with regex or plain strings.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use regex directly in the array, not inside an object's term property. Example: [2, [/bad/i]] works.","message":"Term objects with 'term' property must be strings; if you pass a regex as term it will be converted to string via toString, likely breaking.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install eslint-plugin-literal-blacklist --save-dev` from project root.","cause":"Plugin not installed or installed as devDependency but not in right place.","error":"ESLintError: Failed to load plugin 'literal-blacklist': Cannot find module 'eslint-plugin-literal-blacklist'"},{"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']].","cause":"Using numeric severity as a string or vice versa in old ESLint versions.","error":"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\"')."},{"fix":"Ensure each entry in the array is a string, a RegExp, or an object with a 'term' string property.","cause":"Passed something other than string, RegExp, or object.","error":"Error: Invalid term in literal-blacklist rule: expected a string or object with term property."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}