Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new ESLint rule to enforce comment case/punctuation #34964

Open
wants to merge 33 commits into
base: trunk
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cb82a9e
Add comment case/punctuation rule
opr Sep 20, 2021
552bce9
Add tests for comment-case rule
opr Sep 20, 2021
e46a966
Add comment case rule
opr Sep 20, 2021
39e16da
Change rule type to problem instead of layout
opr Sep 20, 2021
192d32e
Update createFixerFunction to take an error type and handle other rules
opr Sep 21, 2021
99584b5
Add messages for missing space and capital letter rule
opr Sep 21, 2021
1c44644
Add function to check if comment is on the same line as code
opr Sep 21, 2021
8afb43a
Check if comment is followed/preceded directly by another comment
opr Sep 21, 2021
a6b3f06
Add check to ensure comment token is followed by a space
opr Sep 21, 2021
eeb1cee
Add rule to check for capital letter at the start of comments
opr Sep 21, 2021
b26dc87
Refactor missingPunctuation rule
opr Sep 21, 2021
acff091
Add test cases for rule
opr Sep 21, 2021
b1a66a8
Modify fixer function to work with block comments
opr Sep 23, 2021
2191b86
Handle same-line Block comments and skip translator comments
opr Sep 23, 2021
b400c30
Update test cases for new rules
opr Sep 23, 2021
e73d289
Remove fixer function
opr Sep 24, 2021
dcde0f3
Update regex to handle translator comments in the same match
opr Sep 24, 2021
a582723
Update tests following removal of fixer function
opr Sep 24, 2021
97d7536
Add checks for pragmas, URLs, common words, and variable uses
opr Nov 24, 2021
0a7e3dd
Ensure standalone comments on consecutive lines are handled
opr Nov 24, 2021
7e2c99a
Add tests for further cases
opr Nov 24, 2021
892fbef
Match non-words on trimmed value only
opr Nov 25, 2021
c84fa52
Add rule to regex to cater for prettier pragma
opr Nov 25, 2021
67319d1
Add tests for ignoring prettier pragma in eslint rule
opr Nov 25, 2021
2b4ded5
Allow iPad, iMac, iOS, iPhone to be ignored by eslint rule
opr Nov 25, 2021
2722062
Add comment about what is ignored in commonWordsRegex
opr Nov 25, 2021
879dc54
Update pragrma regex and tests to cater for ts-nocheck and globals
opr Nov 25, 2021
c8cfd70
Add noinspection exception to pragma regex
opr Nov 25, 2021
4fa0719
Add istanbul to pragma exceptions
opr Nov 25, 2021
b28158c
Add flow pragmas to exception
opr Nov 25, 2021
0b7dc83
Change comment-case severity from error to warning
opr Nov 26, 2021
5966672
Ensure excluded words only match at the start of the comment
opr Nov 30, 2021
0b0145f
Only skip identifier if it matches the whole identifier with a space
opr Nov 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure excluded words only match at the start of the comment
  • Loading branch information
opr committed Nov 30, 2021
commit 59666727f6ec81241d4eb6977cc63d2feb3dddb2
2 changes: 1 addition & 1 deletion packages/eslint-plugin/rules/comment-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {

// Ignore known common words that don't need to be capitalized.
// Includes npm, lint, id, v1, v2 etc. (when referring to versions), and the Apple products.
const commonWordRegex = /i(Pad|Phone|Mac|OS)|npm-?\w*|lint-?\w*|id|v\d+/;
const commonWordRegex = /^i(Pad|Phone|Mac|OS)|^npm-?\w*|^lint-?\w*|^id|^v\d+/;

// Ignore if comment contains a URL.
const regexTests = [
Expand Down