MCPcopy Index your code
hub / github.com/antfu/case-police

github.com/antfu/case-police @v2.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.2.1 ↗ · + Follow
20 symbols 82 edges 21 files 1 documented · 5% 3 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

🚨 CasePolice

NPM version

  • GitHub, not Github
  • TypeScript, not Typescript
  • macOS, not MacOS
  • VS Code, not Vscode
  • ...

Make the case correct, PLEASE!

Usage

Make sure you have committed all unsaved works, and then

npx case-police --fix

It will scan all your source files and fix the cases of known names.

Only the word including both uppercase and lowercase will be fixed. (e.g. Github -> GitHub; github and GITHUB will be left untouched).

Use in ESLint

We also provide an ESLint plugin that can be used to lint your codebase.

Flat Config

npm i -D eslint-plugin-case-police
// .eslint.config.js
import pluginCasePolice from "eslint-plugin-case-police";

export default [
  ...pluginCasePolice.configs.recommended,
];

OR

// .eslint.config.js
import pluginCasePolice from "eslint-plugin-case-police";

export default [
  {
    name: 'case-police',
    files: ['**/*.?([cm])[jt]s?(x)'],
    plugins: {
      'case-police': pluginCasePolice,
    },
    rules: {
      'case-police/string-check': 'warn',
    },
  },
]

Legacy Config

Since v2.0.0, we only support the flat config style. If you are using the legacy config, please use the version 1.x.x of the plugin.

npm i -D eslint-plugin-case-police@^1.0.0
// .eslintrc
{
  "extends": [
    "plugin:case-police/recommended"
  ]
}

Use in CI

Simply add case-police (without --fix) to your workflow and it will exit with a non-zero code for your CI to catch it.

Specific files

By default it will scan all the text files under the current directory (respects .gitignore), if you want it to check only specific files, you can pass the file paths of glob patterns to it.

npx case-police "**/*.md" path/to/file.html

CLI Options

Options Description
[...globs] Files or glob to be checked, if not provided, all the text files will be check
--fix Rewrite changes to file
-d, --dict <path> Custom dictionary JSON, will be merged with original dict
-p, --presets <presets> Filter the default presets, comma separated
--no-default Disable the default dictionary
--disable <rules> Disable rules, comma separated
--ignore <globs> Files or globs to be ignore, comma separated

Ignores

You can add @case-police-disable in your file to disable the case check for the particular file, or add @case-police-ignore xxx to ignore certain words in that file (use comma to separate mutliple words).

For example:

// @case-police-ignore Uri

console.log(something.Uri.path)

Sponsors

Sponsors

Related Projects

actions-case-police. Use the correct letter case in GitHub issues and pull requests

License

MIT License © 2021 Anthony Fu

Extension points exported contracts — how you extend this code

Section (Interface)
(no doc)
packages/case-police/src/shim.d.ts
RuleOption (Interface)
(no doc)
packages/eslint-plugin-case-police/src/types.ts
ParsedResult (Interface)
(no doc)
packages/case-police/src/shim.d.ts
ParseOptions (Interface)
(no doc)
packages/case-police/src/shim.d.ts

Core symbols most depended-on inside this repo

replace
called by 6
packages/case-police/src/utils.ts
checkText
called by 5
packages/eslint-plugin-case-police/src/rule/string-check.ts
resolvePreset
called by 3
packages/case-police/src/utils.ts
loadAllPresets
called by 3
packages/case-police/src/utils.ts
buildRegex
called by 2
packages/case-police/src/utils.ts
replaceCore
called by 2
packages/case-police/src/utils.ts
loadDictPresets
called by 2
packages/case-police/src/utils.ts
run
called by 2
packages/case-police/src/cli.ts

Shape

Function 16
Interface 4

Languages

TypeScript100%

Modules by API surface

packages/case-police/src/utils.ts8 symbols
packages/eslint-plugin-case-police/src/rule/string-check.ts3 symbols
packages/case-police/src/shim.d.ts3 symbols
packages/eslint-plugin-case-police/src/utils.ts2 symbols
packages/eslint-plugin-case-police/src/types.ts1 symbols
packages/eslint-plugin-case-police/src/configs/recommended.ts1 symbols
packages/eslint-plugin-case-police/fixture/src/app.tsx1 symbols
packages/case-police/src/cli.ts1 symbols

Used by 3 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add case-police \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page