Skip to content

Base rule extension: [no-constant-binary-condition] Remove the parts of the rule that TypeScript also reports on #9973

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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

My proposal is suitable for this project

  • My proposal specifically checks TypeScript syntax, or it proposes a check that requires type information to be accurate.
  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the base rule

https://eslint.org/docs/latest/rules/no-constant-binary-expression

Description

Coming over from https://devblogs.microsoft.com/typescript/announcing-typescript-5-6/#disallowed-nullish-and-truthy-checks1 -> #9653: TypeScript now includes a "Disallowed Nullish and Truthy Checks" feature. The blog post says:

Similar results can be achieved by enabling the ESLint no-constant-binary-expression rule, and you can see some of the results they achieved in their blog post; but the new checks TypeScript performs does not have perfect overlap with the ESLint rule, and we also believe there is a lot of value in having these checks built into TypeScript itself.

Shall we write an extension rule that only reports on what TypeScript doesn't?

Fail

if (true || inDebuggingOrDevelopmentEnvironment()) {
    // ...
}

Pass

if (true && inDebuggingOrDevelopmentEnvironment()) {
    // ...
}

Additional Info

💖

Metadata

Metadata

Labels

accepting prsGo ahead, send a pull request that resolves this issueenhancement: new base rule extensionNew base rule extension required to handle a TS specific caselocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions