Skip to content

Rule Change: no-constant-binary-expression rule misses BigInt() and Symbol() #20977

Description

@kimtaejin3

What rule do you want to change?

no-constant-binary-expression

What change do you want to make?

Generate more warnings

How do you think the change should be implemented?

A new default behavior

Example code

Boolean(x) === null;       // Flagged
String(x) === null;        // Flagged 
Number(x) === {};          // Flagged 

BigInt(x) === null;        // Passes (Should be flagged)
Symbol(x) === null;        // Passes (Should be flagged)

What does the rule currently do for this code?

the rule currently ignores comparisons involving BigInt() and Symbol(), allowing them to pass without any warnings.

In contrast, it already flags identical comparison patterns for other global primitive wrappers, such as Boolean(x) === null, String(x) === null, and Number(x) === {}.

What will the rule do after it's changed?

After the change, the following comparisons will be flagged:

  • Symbol() === null
  • Symbol("abc") === undefined
  • Symbol() != null
  • BigInt(1) === null
  • BigInt(2) === undefined
  • BigInt(3) != null

Participation

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

AI acknowledgment

  • I did not use AI to generate this issue report.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

Additional comments

No response

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionenhancementThis change enhances an existing feature of ESLintruleRelates to ESLint's core rules

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions