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

Rule Change: (valid-typeof) undefined should be banned #15591

Closed
1 task done
Zzzen opened this issue Feb 9, 2022 · 2 comments · Fixed by #15635
Closed
1 task done

Rule Change: (valid-typeof) undefined should be banned #15591

Zzzen opened this issue Feb 9, 2022 · 2 comments · Fixed by #15635
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects

Comments

@Zzzen
Copy link
Contributor

Zzzen commented Feb 9, 2022

What rule do you want to change?

valid-typeof

What change to do you want to make?

Generate more warnings

How do you think the change should be implemented?

A new default behavior

Example code

typeof foo === null
typeof foo === undefined

What does the rule currently do for this code?

only null is reported

What will the rule do after it's changed?

both null and undefined should be reported

Participation

  • I am willing to submit a pull request to implement this change.

Additional comments

No response

@Zzzen Zzzen added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules labels Feb 9, 2022
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Feb 9, 2022
@Zzzen Zzzen changed the title Rule Change: (fill in) Rule Change: (valid-typeof) undefined should be banned Feb 9, 2022
@mdjermanovic mdjermanovic moved this from Needs Triage to Triaging in Triage Feb 9, 2022
@mdjermanovic mdjermanovic self-assigned this Feb 9, 2022
@mdjermanovic
Copy link
Member

This was partially discussed in #14074.

I think it makes sense to report global undefined regardless of requireStringLiteralsoption. It's a small change in the functionality of this rule that would catch probably the most common mistakes with typeof.

I'll champion this.

(As a future enhancement and a much bigger change in the functionality, this rule could use getStaticValue. That would catch global undefined since it evaluates to the undefined value, and more).

@mdjermanovic mdjermanovic moved this from Triaging to Feedback Needed in Triage Feb 9, 2022
@nzakas
Copy link
Member

nzakas commented Feb 24, 2022

This change makes sense.

@nzakas nzakas moved this from Feedback Needed to Ready to Implement in Triage Feb 24, 2022
@nzakas nzakas added the accepted There is consensus among the team that this change meets the criteria for inclusion label Feb 24, 2022
Triage automation moved this from Ready to Implement to Complete Mar 5, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Sep 2, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
Archived in project
Triage
Complete
Development

Successfully merging a pull request may close this issue.

3 participants