sindresorhus/eslint-plugin-unicorn
Rule proposal: `no-unnecessary-negation`
クローズ
#856 opened on 2020/10/12
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);