Skip to content

Enhancement: [prefer-nullish-coalescing] recognize "||=" #5229

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

Closed
4 tasks done
jakebailey opened this issue Jun 22, 2022 · 3 comments · Fixed by #5234
Closed
4 tasks done

Enhancement: [prefer-nullish-coalescing] recognize "||=" #5229

jakebailey opened this issue Jun 22, 2022 · 3 comments · Fixed by #5234
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 package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@jakebailey
Copy link
Collaborator

jakebailey commented Jun 22, 2022

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 cases where an assignment is made to a nullish variable via ||=, it'd be nice if ??= was suggested instead.

Fail

let foo: Map<string, string> | undefined;

foo ||= new Map();

foo = foo || new Map(); // These are already handled in prefer-nullish-coalescing.
(foo || new Map()).get("key");

Pass

let foo: Map<string, string> | undefined;

foo ??= new Map();

foo = foo ?? new Map(); // These are already handled in prefer-nullish-coalescing.
(foo ?? new Map()).get("key");

Additional Info

No response

@jakebailey jakebailey added enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jun 22, 2022
@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Jun 22, 2022
@glen-84
Copy link
Contributor

glen-84 commented Aug 13, 2023

@JoshuaKGoldberg Should this be closed?

@Josh-Cena
Copy link
Member

Right, fixed by #5234

@JoshuaKGoldberg
Copy link
Member

Heh, thanks - so many PRs targeting v6 that didn't close their issue...

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2023
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 package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
5 participants