eslint-plugin-case-police
raw JSON → 2.2.1 verified Sat Apr 25 auth: no javascript
ESLint plugin that enforces correct casing of brand names, technologies, and terms (e.g., 'GitHub', 'npm', 'TypeScript') by linting against a curated dictionary. Version 2.2.1 is current; requires ESLint ^9.9.0 or ^10.0.0. Uses flat config (ESLint 9+). Maintained by Anthony Fu with regular updates to dictionary entries. Differentiates from style linting rules by focusing exclusively on known proper nouns.
Common errors
error Error: Failed to load plugin 'case-police' declared in 'plugins': Cannot find module 'eslint-plugin-case-police' ↓
cause Missing or incorrect plugin import in flat config.
fix
Ensure you have installed the package and imported it correctly:
import casePolice from 'eslint-plugin-case-police' error Configuration for rule 'case-police/no-case-police' is invalid ↓
cause Using .eslintrc config instead of flat config.
fix
Switch to eslint.config.js with plugins object.
error TypeError: Cannot read properties of undefined (reading 'getFilename') ↓
cause Plugin expects ESLint 10+ compatibility fix; ensure v2.2.0+ is installed.
fix
Update to eslint-plugin-case-police@2.2.0 or later.
Warnings
breaking V2.0.0 drops support for .eslintrc config; requires flat config (ESLint 9+). ↓
fix Migrate to flat config (eslint.config.js).
breaking V0.7.0 drops support for ESLint <9. ↓
fix Upgrade ESLint to version 9 or later.
gotcha Plugin only checks tokens against known dictionary; does not enforce arbitrary capitalization. ↓
fix Extend dictionary if needed via `case-police` package or wait for upstream updates.
Install
npm install eslint-plugin-case-police yarn add eslint-plugin-case-police pnpm add eslint-plugin-case-police Imports
- default wrong
const casePolice = require('eslint-plugin-case-police')correctimport casePolice from 'eslint-plugin-case-police' - plugin wrong
import { casePolice } from 'eslint-plugin-case-police'correctimport casePolice from 'eslint-plugin-case-police' - rule in flat config wrong
rules: { 'case-police/no-case-police': 'error' } without pluginscorrectplugins: { 'case-police': casePolice }, rules: { 'case-police/no-case-police': 'error' }
Quickstart
// eslint.config.js
import casePolice from 'eslint-plugin-case-police';
export default [
{
plugins: {
'case-police': casePolice,
},
rules: {
'case-police/no-case-police': 'error',
},
},
];