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

Style: rename functions startsWith check and returns boolean #591

Open
fisker opened this issue Mar 11, 2020 · 6 comments
Open

Style: rename functions startsWith check and returns boolean #591

fisker opened this issue Mar 11, 2020 · 6 comments
Labels
meta Issues related to the plugin itself

Comments

@fisker
Copy link
Collaborator

fisker commented Mar 11, 2020

We have a lot of functions named check…, those functions don't return a boolean value are fine, but when I read some function like this

, it's really hard to understand what true mean.

Check result with `unicorn/no-keyword-prefix` rule

  test\integration\test.js:59:2
  ‼    59:2   Unexpected todo comment.                                                no-warning-comments
  ‼    82:2   Unexpected todo comment.                                                no-warning-comments

test\prefer-node-remove.js:61:3
‼ 61:3 Unexpected todo comment. no-warning-comments

test\number-literal-case.js:20:1
‼ 20:1 Unexpected todo comment. no-warning-comments

rules\prefer-node-remove.js:13:1
‼ 13:1 Unexpected todo comment. no-warning-comments

rules\expiring-todo-comments.js:252:2
‼ 252:2 Function processComment has a complexity of 27. Maximum allowed is 20. complexity

index.js:58:5
‼ 58:5 Unexpected todo comment. no-warning-comments

test\prevent-abbreviations.js:63:3
× 63:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 69:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 75:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 77:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 78:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 79:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 81:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 111:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 115:7 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 117:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 296:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 301:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 306:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 311:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 316:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 336:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 341:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 346:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 351:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 356:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 373:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 378:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 394:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 399:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 471:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 706:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 715:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 720:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 725:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 730:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 740:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 746:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 751:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 756:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 801:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 806:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 1420:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 1481:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 1490:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 1499:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 1505:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 1510:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 1519:13 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\prevent-abbreviations.js:222:2
× 222:2 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 223:2 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 225:2 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 226:2 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 227:2 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 229:2 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 246:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 247:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 249:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 250:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 251:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 253:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 582:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 624:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 699:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 703:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 707:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 784:4 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 787:4 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 790:4 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 797:4 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 804:4 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 807:4 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

test\no-keyword-prefix.js:60:15
× 60:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 64:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 68:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 72:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 76:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 80:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 84:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 88:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 92:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 150:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 155:15 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\no-unused-properties.js:100:8
× 100:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 115:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 188:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 198:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 212:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 216:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 220:8 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\no-keyword-prefix.js:9:2
× 9:2 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 17:3 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 50:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 71:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 200:4 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\explicit-length-check.js:23:10
× 23:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 38:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 102:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 114:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\prefer-modern-dom-apis.js:32:7
‼ 66:2 Unexpected todo comment. no-warning-comments
‼ 68:2 Unexpected todo comment. no-warning-comments
‼ 95:3 Unexpected todo comment. no-warning-comments
× 32:7 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 79:7 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\consistent-function-scoping.js:14:10
× 14:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix
× 78:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\no-hex-escape.js:5:10
× 5:10 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\no-for-loop.js:104:7
× 104:7 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

rules\error-message.js:71:7
× 71:7 Do not prefix identifiers with keyword check. unicorn/no-keyword-prefix

10 warnings
100 errors

@fisker fisker changed the title Style: rename functions starts with check and return boolean Style: rename functions startsWith check and returns boolean Mar 11, 2020
@sindresorhus
Copy link
Owner

I agree. We should prefix with is, has, or can if they return a boolean.

@EvgenyOrekhov
Copy link
Contributor

@sindresorhus What about other verbs like should or are? Examples: shouldAbortEarly, areSettingsValid.

@fregante
Copy link
Collaborator

fregante commented Mar 19, 2020

will, does, was, did as well.

These could either be boolean, () => boolean, or Promise<boolean>

@fisker
Copy link
Collaborator Author

fisker commented Mar 20, 2020

Guys, I'm taking about code style on our codebase, should I change this to a rule proposal? 😆

@fregante
Copy link
Collaborator

should I change this to a rule proposal? 😆

No need: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md

It should be configured in XO because it's a generic rule.

Found via typescript-eslint/typescript-eslint#515 via sindresorhus/meta#12

@fregante
Copy link
Collaborator

fregante commented Jan 8, 2023

Has this been added to TS-ESlint? typescript-eslint/typescript-eslint#1318

@fregante fregante added the meta Issues related to the plugin itself label Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta Issues related to the plugin itself
Projects
None yet
Development

No branches or pull requests

4 participants