Skip to content

eqeqeq: allow the "== null" / "!= null" idiom (smart option) #3

Description

@O6lvl4

環境

codopsy 2.2.0 / codopsy analyze ./src

症状

x != null(null と undefined を同時に見る定番イディオム)が eqeqeq 警告になります。

最小再現

function f(x: string | null | undefined): boolean {
  return x != null;  // ← null と undefined を同時に判定する意図的な loose equality
}
f.ts:2  warning  eqeqeq  Expected '!==' instead of '!='

参考

ESLint の eqeqeq には "always", { "null": "ignore" }、Biome の noDoubleEquals にも同様の例外があり、== null / != null だけは許すのが主要リンタの既定的な運用です。リテラル null との比較のときだけ警告を抑止するオプション(または既定でそう)を提案します。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions