Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antfu/case-police
🚨 Make the case correct, PLEASE!
https://github.com/antfu/case-police
Last synced: 21 days ago
JSON representation
🚨 Make the case correct, PLEASE!
- Host: GitHub
- URL: https://github.com/antfu/case-police
- Owner: antfu
- License: mit
- Created: 2022-03-31T10:19:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-16T08:16:32.000Z (3 months ago)
- Last Synced: 2024-10-01T15:02:17.985Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 396 KB
- Stars: 1,125
- Watchers: 2
- Forks: 80
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- starred - antfu/case-police - 🚨 Make the case correct, PLEASE! (TypeScript)
- awesome-docs - case-police
- awesome - antfu/case-police - 🚨 Make the case correct, PLEASE! (TypeScript)
- awesome-documentation - CasePolice - Scan all your source files and fix the cases of known names. (General Tools / Checker & Formatter)
README
# 🚨 CasePolice
[![NPM version](https://img.shields.io/npm/v/case-police?color=a1b858&label=)](https://www.npmjs.com/package/case-police)
- Git**H**ub, not _Github_
- Type**S**cript, not _Typescript_
- **m**acOS, not _MacOS_
- **VS C**ode, not _Vscode_
- [...](./packages/case-police/dict)Make the case correct, PLEASE!
## Usage
**Make sure you have committed all unsaved works**, and then
```bash
npx case-police --fix
```It will scan all your source files and fix the cases of [known names](./packages/case-police/dict).
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.
```bash
npm i -D eslint-plugin-case-police
``````jsonc
// .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.
```bash
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 ` | Custom dictionary JSON, will be merged with original dict |
| `-p, --presets ` | Filter the default [presets](./packages/case-police/dict), comma separated |
| `--no-default` | Disable the default dictionary |
| `--disable ` | Disable rules, comma separated |
| `--ignore ` | 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.
For example:
```ts
// @case-police-ignore Uriconsole.log(something.Uri.path)
```## Sponsors
## Related Projects
[actions-case-police](https://github.com/Namchee/actions-case-police). Use the correct letter case in GitHub issues and pull requests
## License
[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)