-
Notifications
You must be signed in to change notification settings - Fork 1
fix: correctly configure @typescript-eslint/prefer-nullish-coalescing #1594
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
@@ -250,9 +250,9 @@ module.exports = { | |||
'@typescript-eslint/prefer-nullish-coalescing': [ | |||
'error', | |||
{ | |||
forceSuggestionFixer: false, |
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.
This is the cause of the issue, as this option was removed
ignoreConditionalTests: true, | ||
ignoreMixedLogicalExpressions: true, | ||
ignoreTernaryTests: false, |
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.
This is a new option for this rule, so I thought worth adding here. To me false
makes more sense, but let me know if you think this should be configured as true
, here's more details on how it works.
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.
false
insures consistency and, personally, readability. ??
is much easier to visually parse in PR than comparisons to undefined and/or null.
@@ -4,3 +4,6 @@ | |||
/* eslint-disable @typescript-eslint/strict-boolean-expressions */ | |||
let value: string | undefined; | |||
value || 'fallback'; | |||
|
|||
let foo: string | undefined; |
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.
Added an example of invalid code to demonstrate the new configuration for ignoreTernaryTests
option
Current version of @ridedott/eslint-config has an incorrectly configured rule, which causes CI to fail, trying to install the latest package version in other repositories also fails with an error like:
This PR fixes the configuration for the rule.