8000 fix: correctly configure @typescript-eslint/prefer-nullish-coalescing by aaneitchik · Pull Request #1594 · ridedott/eslint-config · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 2 commits into from
Nov 11, 2022

Conversation

aaneitchik
Copy link
Contributor
@aaneitchik aaneitchik commented Nov 10, 2022

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:

.eslintrc.yaml » ./index.js » ./rules/typescript.js:
    	Configuration for rule "@typescript-eslint/prefer-nullish-coalescing" is invalid:
    	Value {"forceSuggestionFixer":false,"ignoreConditionalTests":true,"ignoreMixedLogicalExpressions":true} should NOT have additional properties.

This PR fixes the configuration for the rule.

@@ -250,9 +250,9 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
{
forceSuggestionFixer: false,
Copy link
Contributor Author

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,
Copy link
Contributor Author

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.

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;
Copy link
Contributor Author

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

@aaneitchik aaneitchik marked this pull request as ready for review November 10, 2022 10:49
@aaneitchik aaneitchik requested a review from a team November 10, 2022 10:49
@aaneitchik aaneitchik self-assigned this Nov 10, 2022
@vadim-c-noveo vadim-c-noveo merged commit d6af389 into master Nov 11, 2022
@vadim-c-noveo vadim-c-noveo deleted the fix/prefer-nullish-coalescing branch November 11, 2022 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0