sindresorhus/eslint-plugin-unicorn

Rule proposal: Use `Array#includes()` instead of repeated conditional checks

Chiusa

#423 aperta il 19 ott 2019

 (12 commenti) (13 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 1g 16h) (399 PR mergiate in 30 g)

Descrizione

Say that we've to show up help information when both -h and --help flags are fired in.

The Approach

const [, , ...args] = process.argv;
if (args[0] === '-h' || args[0] === '--help') {
  outputHelp();
} 

What Intended

const [, , ...args] = process.argv;
if (['-h', '--help'].includes(args[0])) {
  outputHelp();
}

Guida contributor