diff options
author | Gar <gar+gh@danger.computer> | 2021-11-04 20:21:00 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-11-05 00:45:18 +0300 |
commit | 225645420cf3d13bc0b0d591f7f7bf21a9c24e47 (patch) | |
tree | 107797bef3206793cda93d7dad97f3ab54ef3cd8 /bin | |
parent | de45f90eebbf51205748ed3f09fbeab6cc000b3e (diff) |
chore: update to latest eslint and linting rules
This brings us in line with the rest of the linting rules we are wanting
to use on the npm cli repos.
There were several hundred over-length lines and instead of editing them
all by hand I piped the failing file through `prettier` and back through
`eslint` just to save some time and energy. This means there may be
some quirks in the linting those files have, but we can fix those if we
see them and they bother us.
Other than that there were about 50 lines that are legitimately
over-length, all are now explicitly overridden. Many are tests that
could be snapshots.
PR-URL: https://github.com/npm/cli/pull/3995
Credit: @wraithgar
Close: #3995
Reviewed-by: @lukekarrys
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/npx-cli.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/bin/npx-cli.js b/bin/npx-cli.js index 7a3fb3983..cb05e1cb7 100755 --- a/bin/npx-cli.js +++ b/bin/npx-cli.js @@ -26,7 +26,7 @@ const removed = new Set([ const { definitions, shorthands } = require('../lib/utils/config/index.js') const npmSwitches = Object.entries(definitions) - .filter(([key, {type}]) => type === Boolean || + .filter(([key, { type }]) => type === Boolean || (Array.isArray(type) && type.includes(Boolean))) .map(([key]) => key) @@ -65,9 +65,9 @@ let i let sawRemovedFlags = false for (i = 3; i < process.argv.length; i++) { const arg = process.argv[i] - if (arg === '--') + if (arg === '--') { break - else if (/^-/.test(arg)) { + } else if (/^-/.test(arg)) { const [key, ...v] = arg.replace(/^-+/, '').split('=') switch (key) { @@ -87,8 +87,9 @@ for (i = 3; i < process.argv.length; i++) { // resolve shorthands and run again if (shorthands[key] && !removed.has(key)) { const a = [...shorthands[key]] - if (v.length) + if (v.length) { a.push(v.join('=')) + } process.argv.splice(i, 1, ...a) i-- continue @@ -109,8 +110,9 @@ for (i = 3; i < process.argv.length; i++) { if (removed.has(key)) { // also remove the value for the cut key. process.argv.splice(i + 1, 1) - } else + } else { i++ + } } } else { // found a positional arg, put -- in front of it, and we're done @@ -119,7 +121,8 @@ for (i = 3; i < process.argv.length; i++) { } } -if (sawRemovedFlags) +if (sawRemovedFlags) { console.error('See `npm help exec` for more information') +} cli(process) |