Rule proposal: Simplifying booleanish checks

Author: abrahamguoCreated Sep 9, 2026Updated Sep 14, 2026
Labelspackage: eslint-pluginenhancement: new plugin ruleevaluating community engagement

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.
  • My proposal is not a "formatting rule"; meaning it does not just enforce how code is formatted (whitespace, brace placement, etc).
  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

I have a local ESLint rule that flags and simplifies all of the following things, and has been useful for me. I'm curious whether you guys would be interested in accepting any parts of this as one, or multiple, rules!

  1. <string/number/bigint> == <literal falsy of that primitive>
  2. <nonprimitive | nullish> == null/undefined
  3. <literalUnion> == <single falsy, or single truthy of literal union>
  4. === when using == would not cause any coercion
  5. <array>.length == 0
  6. !! in the return value of a find/filter/etc.

Fail Cases

typescript
declare const str: string;
declare const num: number;
declare const arr: { complete: boolean; valid: boolean }[] | null;
declare const type: 'major' | 'minor' | undefined;

str == '';
num != 0;
type != undefined;
str === 'Alice';

if (arr != null) {
  arr.length > 0 ? 'filled' : 'empty';
  arr.find(x => x.complete && !!x.valid);
}

Pass Cases

typescript
declare const str: string;
declare const num: number;
declare const arr: { complete: boolean; valid: boolean }[] | null;
declare const type: 'major' | 'minor' | undefined;

!str; // 1
!!num; // 1
!!type; // 3
str == 'Alice'; // 4

if (!!arr /* 2 */) {
  !!arr.length ? 'filled' : 'empty'; // 5
  arr.find(x => x.complete && x.valid); // 6
}

Additional Info

No response

Source: typescript-eslint/typescript-eslint