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

feat(eslint-plugin): add prefer-nullish-coalescing #1069

Merged
merged 7 commits into from Nov 25, 2019

Conversation

bradzacher
Copy link
Member

@bradzacher bradzacher commented Oct 11, 2019

The intention of this rule is two fold:

  1. to help migrate a codebase to nullish coalescing
  2. to help educate / remind devs whilst upskilling on nullish coalescing.

By default, I disabled the rule on conditional tests. I found in our codebase that usually having || for nullish types within a conditional test was intentional, and fixing it to a nullish coalesce actually caused a bug.

Additionally, I disabled the rule on mixed operator logical expressions (i.e. expressions with both && and ||). I think that if people have mixed operators, they are probably intending to do logical expressions.

@bradzacher bradzacher added the enhancement: new plugin rule New rule request for eslint-plugin label Oct 11, 2019
@typescript-eslint

This comment has been minimized.

@bradzacher bradzacher changed the base branch from 3-7-syntax-parsing to master October 14, 2019 16:54
@bradzacher bradzacher marked this pull request as ready for review October 14, 2019 17:10
@codecov
Copy link

codecov bot commented Nov 25, 2019

Codecov Report

Merging #1069 into master will decrease coverage by <.01%.
The diff coverage is 93.75%.

@@            Coverage Diff             @@
##           master    #1069      +/-   ##
==========================================
- Coverage   94.19%   94.18%   -0.01%     
==========================================
  Files         129      130       +1     
  Lines        5631     5679      +48     
  Branches     1582     1594      +12     
==========================================
+ Hits         5304     5349      +45     
- Misses        181      182       +1     
- Partials      146      148       +2
Impacted Files Coverage Δ
packages/eslint-plugin/src/rules/index.ts 100% <100%> (ø) ⬆️
...lint-plugin/src/rules/prefer-nullish-coalescing.ts 93.61% <93.61%> (ø)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new plugin rule New rule request for eslint-plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants