GithubHelp home page GithubHelp logo

case-police's Introduction

🚨 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.

npm i -D eslint-plugin-case-police
// .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.

For example:

// @case-police-ignore Uri

console.log(something.Uri.path)

Sponsors

Related Projects

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

License

MIT License Β© 2021 Anthony Fu

case-police's People

Contributors

antfu avatar aucker avatar chenli1989 avatar cloydlau avatar evavic44 avatar fffzlfk avatar holazz avatar johannpinson avatar justineo avatar lencx avatar leon-fong avatar levix avatar malloryhayr avatar namchee avatar ntnyq avatar pinkchampagne17 avatar rubiin avatar sajadhsm avatar sulco avatar superpung avatar sxzz avatar thecuvii avatar timursaurus avatar tsuyoshi84 avatar userquin avatar webfansplz avatar wey-gu avatar wjdnb avatar zongzi531 avatar zyyv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

case-police's Issues

Rules with a dot in them are ignored if a prior rule matches at least part of it

Describe the bug

If you add rules as :

{
"abc" : "Abc",
"abc.def":"Abc.Def"
}

then

abc.def  
Abc.def
AbC.DeF
AbC

will match as :

AbC β†’ Abc 
AbC β†’ Abc  

but if you add them as :

{
"abc.def":"Abc.Def",
"abc" : "Abc"
}

then the same text

abc.def  
Abc.def
AbC.DeF
AbC

will match as :

Abc.def β†’ Abc.Def 
AbC.DeF β†’ Abc.Def  
AbC β†’ Abc  

A fix could be to sort the keys by size (to have the "closest" match first)

Reproduction

https://stackblitz.com/edit/stackblitz-starters-zc8y2r?file=test.md

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
    Memory: 12.17 GB / 15.62 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
Binaries:
    Node: 16.20.1 - /usr/local/bin/node
    npm: 8.19.4 - /usr/local/bin/npm
    pnpm: 8.9.2 - /mnt/c/Dev/ArmoniK/ArmoniK.Community/node_modules/.bin/pnpm

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Confusing about contributing guidelines

Thinking about this rule:

  • Since case-police will only fix words that have both lowercase and uppercase letters, it WON'T convert java to Java. If correct form is a single capitalized word, there is no need to add it to the dictionary.

, is that means if I have a entry:

{
  // ...
  "eslint": "ESLint"
  // ...
}

, case-police will not change eslint to ESLint?

But eslint have already in dict.json, is this guidelines express with confusing?

False positive for curl command in sh file

Describe the bug

RESPONSE=$(curl -sSL -H "${AUTH_HEADER}" -H "${HEADER}" --user "${GITHUB_ACTOR}" -X GET --data "${DATA}" ${PULLS_URL})
case-police tells me that sSL should be SSL
though this is a curl shorthand rather than a word

Reproduction

https://stackblitz.com/edit/vitejs-vite-5bjczq?file=run.sh

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (16) x64 AMD EPYC 7B13
    Memory: 19.95 GB / 62.81 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.16.0/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm

Used Package Manager

yarn

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

`NATs` -> `NATS`

Describe the bug

case-police flags NATs as incorrect, I'm trying to describe the plural of a Network Address Translator

Reproduction

Lint a file with NATs in it

System Info

System:
    OS: macOS 12.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 14.20 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.7.0 - ~/.volta/tools/image/node/18.7.0/bin/node
    Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn
    npm: 8.17.0 - ~/.volta/tools/image/npm/8.17.0/bin/npm
  Browsers:
    Firefox: 103.0.2
    Safari: 15.6

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Names with spaces not caught.

Example: misspelling of VS Code, where word after space is not correctly cased.

text.txt

VS code

Output: All good, well done!
Expected: test.txt:0 VS code -> VS Code

VSCode Plugin

Clear and concise description of the problem

Would love to contribute to one if it does not exist. :)

Suggested solution

empty

Alternative

No response

Additional context

No response

Validations

ESLint Plugin

Would love to contribute to one if it does not exist. :)

allow capitalize for word at the beginning of sentence

Describe the bug

some words like webpack allow using 'Webpack' at the beginning of sentence, is there a way to allow this?

Reproduction

https://stackblitz.com/edit/node-essghk?file=package.json

System Info

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 114.20 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.19.0 - ~/Library/Caches/fnm_multishells/89917_1677131463820/bin/node
    Yarn: 1.11.1 - ~/Library/Caches/fnm_multishells/89917_1677131463820/bin/yarn
    npm: 8.19.3 - ~/Library/Caches/fnm_multishells/89917_1677131463820/bin/npm
  Browsers:
    Chrome: 110.0.5481.100
    Firefox Developer Edition: 111.0
    Safari: 15.6.1

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.