sindresorhus/eslint-plugin-unicorn
Rule proposal: `no-unnecessary-negation`
Chiusa
#856 aperta il 12 ott 2020
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 1g 16h) (399 PR mergiate in 30 g)
Descrizione
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);