Skip to content

Commit 78da60f

Browse files
Ivan12273wraithgar
authored andcommitted
chore(linting): add bin and clean up lib/ls.js
This adds linting checking to our bin directory, fixes the linting errors that generated, and cleans up lib/ls.js to remove unused variables. PR-URL: #3454 Credit: @Ivan12273 Close: #3454 Reviewed-by: @darcyclarke
1 parent 53f81af commit 78da60f

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

bin/npx-cli.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ process.argv.splice(2, 0, 'exec')
1010
const removedSwitches = new Set([
1111
'always-spawn',
1212
'ignore-existing',
13-
'shell-auto-fallback'
13+
'shell-auto-fallback',
1414
])
1515

1616
const removedOpts = new Set([
1717
'npm',
1818
'node-arg',
19-
'n'
19+
'n',
2020
])
2121

2222
const removed = new Set([
2323
...removedSwitches,
24-
...removedOpts
24+
...removedOpts,
2525
])
2626

2727
const { definitions, shorthands } = require('../lib/utils/config/index.js')
@@ -40,7 +40,7 @@ const switches = new Set([
4040
'version',
4141
'v',
4242
'help',
43-
'h'
43+
'h',
4444
])
4545

4646
// things that do take a value
@@ -55,7 +55,7 @@ const opts = new Set([
5555
'shell',
5656
'npm',
5757
'node-arg',
58-
'n'
58+
'n',
5959
])
6060

6161
// break out of loop when we find a positional argument or --
@@ -65,9 +65,9 @@ let i
6565
let sawRemovedFlags = false
6666
for (i = 3; i < process.argv.length; i++) {
6767
const arg = process.argv[i]
68-
if (arg === '--') {
68+
if (arg === '--')
6969
break
70-
} else if (/^-/.test(arg)) {
70+
else if (/^-/.test(arg)) {
7171
const [key, ...v] = arg.replace(/^-+/, '').split('=')
7272

7373
switch (key) {
@@ -87,9 +87,8 @@ for (i = 3; i < process.argv.length; i++) {
8787
// resolve shorthands and run again
8888
if (shorthands[key] && !removed.has(key)) {
8989
const a = [...shorthands[key]]
90-
if (v.length) {
90+
if (v.length)
9191
a.push(v.join('='))
92-
}
9392
process.argv.splice(i, 1, ...a)
9493
i--
9594
continue
@@ -110,9 +109,8 @@ for (i = 3; i < process.argv.length; i++) {
110109
if (removed.has(key)) {
111110
// also remove the value for the cut key.
112111
process.argv.splice(i + 1, 1)
113-
} else {
112+
} else
114113
i++
115-
}
116114
}
117115
} else {
118116
// found a positional arg, put -- in front of it, and we're done
@@ -121,8 +119,7 @@ for (i = 3; i < process.argv.length; i++) {
121119
}
122120
}
123121

124-
if (sawRemovedFlags) {
122+
if (sawRemovedFlags)
125123
console.error('See `npm help exec` for more information')
126-
}
127124

128125
cli(process)

lib/ls.js

-4
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,9 @@ class LS extends ArboristWorkspaceCmd {
145145
dev,
146146
development,
147147
link,
148-
node,
149148
prod,
150149
production,
151150
only,
152-
tree,
153151
}))
154152
.map(mapEdgesToNodes({ seenPaths }))
155153
.concat(appendExtraneousChildren({ node, seenPaths }))
@@ -392,11 +390,9 @@ const filterByEdgesTypes = ({
392390
dev,
393391
development,
394392
link,
395-
node,
396393
prod,
397394
production,
398395
only,
399-
tree,
400396
}) => {
401397
// filter deps by type, allows for: `npm ls --dev`, `npm ls --prod`,
402398
// `npm ls --link`, `npm ls --only=dev`, etc

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
"sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --",
213213
"posttest": "npm run lint",
214214
"eslint": "eslint",
215-
"lint": "npm run eslint -- test/lib test/bin lib scripts docs smoke-tests",
215+
"lint": "npm run eslint -- test/lib test/bin bin lib scripts docs smoke-tests",
216216
"lintfix": "npm run lint -- --fix",
217217
"prelint": "rimraf test/npm_cache*",
218218
"resetdeps": "bash scripts/resetdeps.sh",

0 commit comments

Comments
 (0)