Skip to content

Commit cad9bc7

Browse files
lukekarryswraithgar
authored andcommitted
chore: lint previously ignored files
PR-URL: #3986 Credit: @lukekarrys Close: #3986 Reviewed-by: @wraithgar
1 parent ac2fabb commit cad9bc7

File tree

5 files changed

+19
-24
lines changed

5 files changed

+19
-24
lines changed

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
if (require.main === module) {
1+
if (require.main === module)
22
require('./lib/cli.js')(process)
3-
} else {
3+
else
44
throw new Error('The programmatic API was removed in npm v8.0.0')
5-
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
"sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --",
221221
"posttest": "npm run lint",
222222
"eslint": "eslint",
223-
"lint": "npm run eslint -- test/lib test/bin bin lib scripts docs smoke-tests",
223+
"lint": "npm run eslint -- bin docs lib scripts smoke-tests test ./*.js",
224224
"lintfix": "npm run lint -- --fix",
225225
"prelint": "rimraf test/npm_cache*",
226226
"resetdeps": "bash scripts/resetdeps.sh",

test/fixtures/mock-npm.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const RealMockNpm = (t, otherMocks = {}) => {
2626
}
2727
const Npm = t.mock('../../lib/npm.js', otherMocks)
2828
class MockNpm extends Npm {
29-
constructor() {
29+
constructor () {
3030
super()
3131
for (const level in npmlog.levels) {
3232
npmlog[level] = (...msg) => {
@@ -79,9 +79,8 @@ class MockNpm {
7979
const config = base.config || {}
8080

8181
for (const attr in base) {
82-
if (attr !== 'config') {
82+
if (attr !== 'config')
8383
this[attr] = base[attr]
84-
}
8584
}
8685

8786
this.flatOptions = base.flatOptions || {}
@@ -91,7 +90,7 @@ class MockNpm {
9190
find: (k) => ({...realConfig.defaults, ...config})[k],
9291
get: (k) => ({...realConfig.defaults, ...config})[k],
9392
set: (k, v) => config[k] = v,
94-
list: [{ ...realConfig.defaults, ...config}]
93+
list: [{ ...realConfig.defaults, ...config}],
9594
}
9695
if (!this.log) {
9796
this.log = {
@@ -110,18 +109,18 @@ class MockNpm {
110109
}
111110
}
112111

113-
output(...msg) {
112+
output (...msg) {
114113
if (this.base.output)
115114
return this.base.output(msg)
116115
this._mockOutputs.push(msg)
117116
}
118117
}
119118

120119
const FakeMockNpm = (base = {}) => {
121-
return new MockNpm(base)
120+
return new MockNpm(base)
122121
}
123122

124123
module.exports = {
125124
fake: FakeMockNpm,
126-
real: RealMockNpm
125+
real: RealMockNpm,
127126
}

test/fixtures/sandbox.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ const { promisify } = require('util')
66
const mkdirp = require('mkdirp-infer-owner')
77
const npmlog = require('npmlog')
88
const rimraf = promisify(require('rimraf'))
9-
const t = require('tap')
109

11-
let active = null
1210
const chain = new Map()
1311
const sandboxes = new Map()
1412

13+
// Disable lint errors for assigning to process global
14+
/* global process:writable */
15+
1516
// keep a reference to the real process
1617
const _process = process
1718

18-
const processHook = createHook({
19+
createHook({
1920
init: (asyncId, type, triggerAsyncId, resource) => {
2021
// track parentage of asyncIds
2122
chain.set(asyncId, triggerAsyncId)
2223
},
2324
before: (asyncId) => {
2425
// find the nearest parent id that has a sandbox
2526
let parent = asyncId
26-
while (chain.has(parent) && !sandboxes.has(parent)) {
27+
while (chain.has(parent) && !sandboxes.has(parent))
2728
parent = chain.get(parent)
28-
}
2929

3030
process = sandboxes.has(parent)
3131
? sandboxes.get(parent)
@@ -173,7 +173,7 @@ class Sandbox extends EventEmitter {
173173
if (this[_npm]) {
174174
// replace default config values with placeholders
175175
for (const name of redactedDefaults) {
176-
let value = this[_npm].config.defaults[name]
176+
const value = this[_npm].config.defaults[name]
177177
clean = clean.split(value).join(`{${name.toUpperCase()}}`)
178178
}
179179

@@ -201,21 +201,19 @@ class Sandbox extends EventEmitter {
201201

202202
// test.teardown hook
203203
teardown () {
204-
if (this[_parent]) {
204+
if (this[_parent])
205205
sandboxes.delete(this[_parent])
206-
}
206+
207207
return rimraf(this[_dirs].temp).catch(() => null)
208208
}
209209

210210
// proxy get handler
211211
[_get] (target, prop, receiver) {
212-
if (this[_data].has(prop)) {
212+
if (this[_data].has(prop))
213213
return this[_data].get(prop)
214-
}
215214

216-
if (this[prop] !== undefined) {
215+
if (this[prop] !== undefined)
217216
return Reflect.get(this, prop, this)
218-
}
219217

220218
const actual = Reflect.get(target, prop, receiver)
221219
if (typeof actual === 'function') {

test/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ t.test('loading as main module will load the cli', t => {
2020
t.end()
2121
})
2222
})
23-

0 commit comments

Comments
 (0)