-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): add prefer-string-starts-ends-with rule (fixes #285) #289
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
+ Coverage 96.96% 97.14% +0.17%
==========================================
Files 72 73 +1
Lines 2705 2868 +163
Branches 436 473 +37
==========================================
+ Hits 2623 2786 +163
Misses 49 49
Partials 33 33
|
The return value of `s.match` is an `Array` object or `null`.
packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
Outdated
Show resolved
Hide resolved
…th.md Co-Authored-By: mysticatea <star.ctor@gmail.com>
some test cases were rejected by node selectors unintentionally.
…s-ends-with/new # Conflicts: # packages/eslint-plugin/package.json # packages/eslint-plugin/typings/ts-eslint.d.ts
packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
Outdated
Show resolved
Hide resolved
…h.ts Co-Authored-By: mysticatea <star.ctor@gmail.com>
…h.ts Co-Authored-By: mysticatea <star.ctor@gmail.com>
…th.md Co-Authored-By: mysticatea <star.ctor@gmail.com>
…th.md Co-Authored-By: mysticatea <star.ctor@gmail.com>
packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
Outdated
Show resolved
Hide resolved
…th.md Co-Authored-By: mysticatea <star.ctor@gmail.com>
Thank you for the review! |
…s-ends-with/new # Conflicts: # packages/eslint-plugin/package.json
@JamesHenry Would you review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two nits otherwise LGTM
packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If @bradzacher comments could be addressed and the conflicts resolved then this looks great!
# Conflicts: # packages/eslint-plugin/package.json
I apologize for my late response. I updated this PR. |
@mysticatea Supported Rules |
This rule can now also extended to include /^wow/.test(stringOrUndefined!);
// becomes
stringOrUndefined?.startsWith('wow') |
On second thought, no, because the former returns |
Fixes #285.
This PR adds a new rule:
@typescript-eslint/prefer-string-starts-ends-with
.(probably there are better names)
eslint
has depended on those packages already, so this add will not increase install time and disk size.