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

Enhancement: [prefer-nullish-coalescing] Allow ignorePrimitives option to be true #7180

Closed
4 tasks done
JoshuaKGoldberg opened this issue Jul 10, 2023 · 3 comments · Fixed by #7331
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Jul 10, 2023

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/prefer-nullish-coalescing

Description

In #6487, @omril1 added a new ignorePrimitives option. Which is great! It lets us configure individually whether bigints, booleans, numbers, and/or strings, are ignored by the rule.

As a convenience, it'd be nice to allow the option to be set as just the shorthand true - to set all of them as true.

"@typescript-eslint/prefer-nullish-coalescing": ["error", {
  ignorePrimitives: true,
}]

Fail

n/a (no change)

Pass

n/a (no change)

Additional Info

The label here is slightly inaccurate - it's not a new rule option, it's an augmentation to an existing option.

@JoshuaKGoldberg JoshuaKGoldberg added good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin enhancement: plugin rule option New rule option for an existing eslint-plugin rule accepting prs Go ahead, send a pull request that resolves this issue labels Jul 10, 2023
@omril1
Copy link
Contributor

omril1 commented Jul 10, 2023

@JoshuaKGoldberg Doc link should to prefer-nullish-coalescing.
Edit: And the example.

@benneq

This comment was marked as outdated.

@bradzacher
Copy link
Member

@benneq there is already an option for your case - please read the rule docs.
https://typescript-eslint.io/rules/prefer-nullish-coalescing/#ignoreprimitives

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
4 participants