sindresorhus/eslint-plugin-unicorn

Rule proposal: `no-unnecessary-negation`

クローズ

#856 opened on 2020/10/12

 (20 件のコメント) (12 件のリアクション) (0 人の担当者)JavaScript (468 件のフォーク)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 個のスター)
PR merge metrics
 (平均マージ 1d 16h) (30d で 399 merged PRs)

説明

Description

This rule would enforce users to simplify negations: !(a === b) -> a !== b. There might be other conditions like this that could be simplified.

Fail

if (!(a > b)) {}
const foo = !(bar === baz);
const foo = !(typeof bar === 'undefined');

Pass

if (a <= b) {}
const foo = bar !== baz;
const foo = typeof bar !== 'undefined';
const foo = !Array.isArray(bar);

コントリビューターガイド