From d679ce80fd9b761b2323777ec5cd84ebc5c164fe Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 30 Apr 2024 09:37:09 -0700 Subject: [PATCH] fix(linting): no-unused-vars --- bin/npx-cli.js | 2 +- docs/lib/index.js | 2 +- lib/commands/adduser.js | 2 +- lib/commands/ci.js | 2 +- lib/commands/completion.js | 4 ++-- lib/commands/dedupe.js | 2 +- lib/commands/diff.js | 4 ++-- lib/commands/doctor.js | 2 +- lib/commands/find-dupes.js | 2 +- lib/commands/help-search.js | 4 ++-- lib/commands/login.js | 2 +- lib/commands/logout.js | 2 +- lib/commands/outdated.js | 2 +- lib/commands/ping.js | 2 +- lib/commands/prefix.js | 2 +- lib/commands/profile.js | 2 +- lib/commands/publish.js | 2 +- lib/commands/run-script.js | 6 +++--- lib/commands/token.js | 2 +- lib/commands/whoami.js | 2 +- lib/utils/auth.js | 2 +- lib/utils/explain-dep.js | 2 +- mock-registry/lib/index.js | 2 +- test/lib/cli/exit-handler.js | 2 +- test/lib/commands/ci.js | 2 +- test/lib/commands/profile.js | 28 ++++++++++++++-------------- test/lib/commands/version.js | 2 +- test/lib/docs.js | 2 +- test/lib/utils/log-file.js | 2 +- test/lib/utils/otplease.js | 4 ++-- test/lib/utils/web-auth.js | 4 ++-- 31 files changed, 51 insertions(+), 51 deletions(-) diff --git a/bin/npx-cli.js b/bin/npx-cli.js index 17d96fb26267c..e2e1b87906abe 100755 --- a/bin/npx-cli.js +++ b/bin/npx-cli.js @@ -26,7 +26,7 @@ const removed = new Set([ const { definitions, shorthands } = require('@npmcli/config/lib/definitions') const npmSwitches = Object.entries(definitions) - .filter(([key, { type }]) => type === Boolean || + .filter(([, { type }]) => type === Boolean || (Array.isArray(type) && type.includes(Boolean))) .map(([key]) => key) diff --git a/docs/lib/index.js b/docs/lib/index.js index 5d4ae7af3457b..5f8501ead27b8 100644 --- a/docs/lib/index.js +++ b/docs/lib/index.js @@ -119,7 +119,7 @@ const replaceConfig = (src, { path }) => { } const allConfig = Object.entries(definitions).sort(sort) - .map(([_, def]) => def.describe()) + .map(([, def]) => def.describe()) .join('\n\n') return src.replace(replacer, allConfig) diff --git a/lib/commands/adduser.js b/lib/commands/adduser.js index 5299ebaca41aa..cf64e7a7e7438 100644 --- a/lib/commands/adduser.js +++ b/lib/commands/adduser.js @@ -12,7 +12,7 @@ class AddUser extends BaseCommand { 'auth-type', ] - async exec (args) { + async exec () { const scope = this.npm.config.get('scope') let registry = this.npm.config.get('registry') diff --git a/lib/commands/ci.js b/lib/commands/ci.js index a8b4a845126f5..7e79d7208c9c4 100644 --- a/lib/commands/ci.js +++ b/lib/commands/ci.js @@ -81,7 +81,7 @@ class CI extends ArboristWorkspaceCmd { await time.start('npm-ci:rm', async () => { const path = `${where}/node_modules` // get the list of entries so we can skip the glob for performance - const entries = await fs.readdir(path, null).catch(er => []) + const entries = await fs.readdir(path, null).catch(() => []) return Promise.all(entries.map(f => fs.rm(`${path}/${f}`, { force: true, recursive: true }))) }) diff --git a/lib/commands/completion.js b/lib/commands/completion.js index a4cf1d77c5e3a..9b147d2f5bdac 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -248,7 +248,7 @@ const configCompl = opts => { // expand with the valid values of various config values. // not yet implemented. -const configValueCompl = opts => [] +const configValueCompl = () => [] // check if the thing is a flag or not. const isFlag = word => { @@ -265,7 +265,7 @@ const isFlag = word => { // complete against the npm commands // if they all resolve to the same thing, just return the thing it already is -const cmdCompl = (opts, npm) => { +const cmdCompl = (opts) => { const allCommands = commands.concat(Object.keys(aliases)) const matches = allCommands.filter(c => c.startsWith(opts.partialWord)) if (!matches.length) { diff --git a/lib/commands/dedupe.js b/lib/commands/dedupe.js index f9785fd66bb49..e07bcd31e894b 100644 --- a/lib/commands/dedupe.js +++ b/lib/commands/dedupe.js @@ -21,7 +21,7 @@ class Dedupe extends ArboristWorkspaceCmd { ...super.params, ] - async exec (args) { + async exec () { if (this.npm.global) { const er = new Error('`npm dedupe` does not work in global mode.') er.code = 'EDEDUPEGLOBAL' diff --git a/lib/commands/diff.js b/lib/commands/diff.js index 6b5adf633acd7..ca8b1237b40c5 100644 --- a/lib/commands/diff.js +++ b/lib/commands/diff.js @@ -78,7 +78,7 @@ class Diff extends BaseCommand { // get the package name from the packument at `path` // throws if no packument is present OR if it does not have `name` attribute - async packageName (path) { + async packageName () { let name try { const { content: pkg } = await pkgJson.normalize(this.prefix) @@ -103,7 +103,7 @@ class Diff extends BaseCommand { // no arguments, defaults to comparing cwd // to its latest published registry version if (!a) { - const pkgName = await this.packageName(this.prefix) + const pkgName = await this.packageName() return [ `${pkgName}@${this.npm.config.get('tag')}`, `file:${this.prefix.replace(/#/g, '%23')}`, diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index e46c97a94bc90..c29dd7e0ecb17 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -254,7 +254,7 @@ class Doctor extends BaseCommand { } if (st.isDirectory()) { - const entries = await readdir(f).catch(er => { + const entries = await readdir(f).catch(() => { ok = false log.warn('doctor', 'checkFilesPermission', 'error reading directory ' + f) return [] diff --git a/lib/commands/find-dupes.js b/lib/commands/find-dupes.js index 0945089c74b7c..735ac7c4a7ed0 100644 --- a/lib/commands/find-dupes.js +++ b/lib/commands/find-dupes.js @@ -19,7 +19,7 @@ class FindDupes extends ArboristWorkspaceCmd { ...super.params, ] - async exec (args) { + async exec () { this.npm.config.set('dry-run', true) return this.npm.exec('dedupe', []) } diff --git a/lib/commands/help-search.js b/lib/commands/help-search.js index 67d381dd94565..72dd03ac7406e 100644 --- a/lib/commands/help-search.js +++ b/lib/commands/help-search.js @@ -22,7 +22,7 @@ class HelpSearch extends BaseCommand { // preserve glob@8 behavior files = files.sort((a, b) => a.localeCompare(b, 'en')) const data = await this.readFiles(files) - const results = await this.searchFiles(args, data, files) + const results = await this.searchFiles(args, data) const formatted = this.formatResults(args, results) if (!formatted.trim()) { output.standard(`No matches in help for: ${args.join(' ')}\n`) @@ -40,7 +40,7 @@ class HelpSearch extends BaseCommand { return res } - async searchFiles (args, data, files) { + async searchFiles (args, data) { const results = [] for (const [file, content] of Object.entries(data)) { const lowerCase = content.toLowerCase() diff --git a/lib/commands/login.js b/lib/commands/login.js index fa82ecaa2c207..630abf9ac8e04 100644 --- a/lib/commands/login.js +++ b/lib/commands/login.js @@ -12,7 +12,7 @@ class Login extends BaseCommand { 'auth-type', ] - async exec (args) { + async exec () { const scope = this.npm.config.get('scope') let registry = this.npm.config.get('registry') diff --git a/lib/commands/logout.js b/lib/commands/logout.js index 39b4b176bf966..dc5a0dfda0e98 100644 --- a/lib/commands/logout.js +++ b/lib/commands/logout.js @@ -11,7 +11,7 @@ class Logout extends BaseCommand { 'scope', ] - async exec (args) { + async exec () { const registry = this.npm.config.get('registry') const scope = this.npm.config.get('scope') const regRef = scope ? `${scope}:registry` : 'registry' diff --git a/lib/commands/outdated.js b/lib/commands/outdated.js index ceef86be950c5..2249808110bbb 100644 --- a/lib/commands/outdated.js +++ b/lib/commands/outdated.js @@ -160,7 +160,7 @@ class Outdated extends ArboristWorkspaceCmd { this.edges.add(edge) } - getWorkspacesEdges (node) { + getWorkspacesEdges () { if (this.npm.global) { return } diff --git a/lib/commands/ping.js b/lib/commands/ping.js index 8ade46ac8f82a..0d057862baa8f 100644 --- a/lib/commands/ping.js +++ b/lib/commands/ping.js @@ -8,7 +8,7 @@ class Ping extends BaseCommand { static params = ['registry'] static name = 'ping' - async exec (args) { + async exec () { const cleanRegistry = redact(this.npm.config.get('registry')) log.notice('PING', cleanRegistry) const start = Date.now() diff --git a/lib/commands/prefix.js b/lib/commands/prefix.js index d1f56cb190bd7..da8702cf91caa 100644 --- a/lib/commands/prefix.js +++ b/lib/commands/prefix.js @@ -7,7 +7,7 @@ class Prefix extends BaseCommand { static params = ['global'] static usage = ['[-g]'] - async exec (args) { + async exec () { return output.standard(this.npm.prefix) } } diff --git a/lib/commands/profile.js b/lib/commands/profile.js index 66bb3d118e6b7..8eae6278549f5 100644 --- a/lib/commands/profile.js +++ b/lib/commands/profile.js @@ -357,7 +357,7 @@ class Profile extends BaseCommand { } } - async disable2fa (args) { + async disable2fa () { const conf = { ...this.npm.flatOptions } const info = await npmProfile.get(conf) diff --git a/lib/commands/publish.js b/lib/commands/publish.js index fba7b7a120953..6bb2dcc6614bb 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -149,7 +149,7 @@ class Publish extends BaseCommand { return pkgContents } - async execWorkspaces (args) { + async execWorkspaces () { // Suppresses JSON output in publish() so we can handle it here this.suppressOutput = true diff --git a/lib/commands/run-script.js b/lib/commands/run-script.js index 0bf517f77efb4..dd00c98fc8b6e 100644 --- a/lib/commands/run-script.js +++ b/lib/commands/run-script.js @@ -24,7 +24,7 @@ class RunScript extends BaseCommand { const argv = opts.conf.argv.remain if (argv.length === 2) { const { content: { scripts = {} } } = await pkgJson.normalize(npm.localPrefix) - .catch(er => ({ content: {} })) + .catch(() => ({ content: {} })) if (opts.isFish) { return Object.keys(scripts).map(s => `${s}\t${scripts[s].slice(0, 30)}`) } @@ -185,7 +185,7 @@ class RunScript extends BaseCommand { return allScripts } - async runWorkspaces (args, filters) { + async runWorkspaces (args) { const res = [] await this.setWorkspaces() @@ -205,7 +205,7 @@ class RunScript extends BaseCommand { } } - async listWorkspaces (args, filters) { + async listWorkspaces (args) { await this.setWorkspaces() if (this.npm.silent) { diff --git a/lib/commands/token.js b/lib/commands/token.js index aa9bd0fce24f8..24ca21a8e29ce 100644 --- a/lib/commands/token.js +++ b/lib/commands/token.js @@ -125,7 +125,7 @@ class Token extends BaseCommand { } } - async create (args) { + async create () { const json = this.npm.config.get('json') const parseable = this.npm.config.get('parseable') const cidr = this.npm.config.get('cidr') diff --git a/lib/commands/whoami.js b/lib/commands/whoami.js index df749e9db7e91..507adb276c731 100644 --- a/lib/commands/whoami.js +++ b/lib/commands/whoami.js @@ -7,7 +7,7 @@ class Whoami extends BaseCommand { static name = 'whoami' static params = ['registry'] - async exec (args) { + async exec () { const username = await getIdentity(this.npm, { ...this.npm.flatOptions }) output.standard( this.npm.config.get('json') ? JSON.stringify(username) : username diff --git a/lib/utils/auth.js b/lib/utils/auth.js index c38d7cc78e2ce..04ca455ceb526 100644 --- a/lib/utils/auth.js +++ b/lib/utils/auth.js @@ -36,7 +36,7 @@ const adduser = async (npm, { creds, ...opts }) => { // password, it's effectively a login, and if that account has otp you'll // be prompted for it. res = await otplease(npm, opts, (reqOpts) => - profile.adduserCouch(username, email, password, opts) + profile.adduserCouch(username, email, password, reqOpts) ) } diff --git a/lib/utils/explain-dep.js b/lib/utils/explain-dep.js index efe0ceece0882..4e9e93454e8a2 100644 --- a/lib/utils/explain-dep.js +++ b/lib/utils/explain-dep.js @@ -44,7 +44,7 @@ const explainLinksIn = ({ linksIn }, depth, chalk) => { return str.split('\n').join('\n ') } -const explainDependents = ({ name, dependents }, depth, chalk) => { +const explainDependents = ({ dependents }, depth, chalk) => { if (!dependents || !dependents.length || depth <= 0) { return '' } diff --git a/mock-registry/lib/index.js b/mock-registry/lib/index.js index d98cb055a1713..558cb25e2674e 100644 --- a/mock-registry/lib/index.js +++ b/mock-registry/lib/index.js @@ -225,7 +225,7 @@ class MockRegistry { }) } - webadduser ({ username, password, token = 'npm_default-test-token' }) { + webadduser ({ token = 'npm_default-test-token' }) { const doneUrl = new URL('/npm-cli-test/done', this.origin).href const loginUrl = new URL('/npm-cli-test/login', this.origin).href this.nock = this.nock diff --git a/test/lib/cli/exit-handler.js b/test/lib/cli/exit-handler.js index fd6754b30096e..7b465643504c7 100644 --- a/test/lib/cli/exit-handler.js +++ b/test/lib/cli/exit-handler.js @@ -388,7 +388,7 @@ t.test('log files fail to write', async (t) => { '{LIB}/utils/log-file.js': tmock(t, '{LIB}/utils/log-file.js', { 'fs-minipass': { ...fsMiniPass, - WriteStreamSync: (file, ...rest) => { + WriteStreamSync: (file) => { if (file.includes('LOGS_DIR')) { throw new Error('err') } diff --git a/test/lib/commands/ci.js b/test/lib/commands/ci.js index 6ab9662fc8be5..c4b855932a9ed 100644 --- a/test/lib/commands/ci.js +++ b/test/lib/commands/ci.js @@ -142,7 +142,7 @@ t.test('--no-audit and --ignore-scripts', async t => { 'package-lock.json': JSON.stringify(packageLock), }, }) - require('nock').emitter.on('no match', req => { + require('nock').emitter.on('no match', () => { t.fail('Should not audit') }) const manifest = registry.manifest({ name: 'abbrev' }) diff --git a/test/lib/commands/profile.js b/test/lib/commands/profile.js index 4cf0908aae816..8bbffd1675d07 100644 --- a/test/lib/commands/profile.js +++ b/test/lib/commands/profile.js @@ -540,7 +540,7 @@ t.test('enable-2fa', async t => { t.test('from basic username/password auth', async t => { const npmProfile = { - async createToken (pass) { + async createToken () { return {} }, } @@ -587,7 +587,7 @@ t.test('enable-2fa', async t => { async get () { return userProfile }, - async set (newProfile, conf) { + async set (newProfile) { t.match( newProfile, { @@ -659,7 +659,7 @@ t.test('enable-2fa', async t => { }, } }, - async set (newProfile, conf) { + async set (newProfile) { setCount++ // when profile response shows that 2fa is pending the @@ -747,7 +747,7 @@ t.test('enable-2fa', async t => { }, } }, - async set (newProfile, conf) { + async set () { return { ...userProfile, tfa: 'http://foo?secret=1234', @@ -759,7 +759,7 @@ t.test('enable-2fa', async t => { async password () { return 'password1234' }, - async otp (label) { + async otp () { return '123456' }, } @@ -786,7 +786,7 @@ t.test('enable-2fa', async t => { async get () { return userProfile }, - async set (newProfile, conf) { + async set () { return { ...userProfile, tfa: null, @@ -809,7 +809,7 @@ t.test('enable-2fa', async t => { config: { otp: '123456' }, }) - npm.config.getCredentialsByURI = reg => { + npm.config.getCredentialsByURI = () => { return { token: 'token' } } @@ -830,7 +830,7 @@ t.test('enable-2fa', async t => { tfa: undefined, } }, - async set (newProfile, conf) { + async set () { return { ...userProfile, tfa: null, @@ -852,7 +852,7 @@ t.test('enable-2fa', async t => { readUserInfo, }) - npm.config.getCredentialsByURI = reg => { + npm.config.getCredentialsByURI = () => { return { token: 'token' } } @@ -873,7 +873,7 @@ t.test('enable-2fa', async t => { tfa: undefined, } }, - async set (newProfile, conf) { + async set () { return { ...userProfile, tfa: null, @@ -895,7 +895,7 @@ t.test('enable-2fa', async t => { readUserInfo, }) - npm.config.getCredentialsByURI = reg => { + npm.config.getCredentialsByURI = () => { return { token: 'token' } } @@ -933,7 +933,7 @@ t.test('disable-2fa', async t => { async get () { return userProfile }, - async set (newProfile, conf) { + async set (newProfile) { t.same( newProfile, { @@ -1014,7 +1014,7 @@ t.test('disable-2fa', async t => { async get () { return userProfile }, - async set (newProfile, conf) { + async set (newProfile) { t.same( newProfile, { @@ -1032,7 +1032,7 @@ t.test('disable-2fa', async t => { async password () { return 'password1234' }, - async otp (label) { + async otp () { throw new Error('should not ask for otp') }, } diff --git a/test/lib/commands/version.js b/test/lib/commands/version.js index 755caae444310..1f02f368f67bc 100644 --- a/test/lib/commands/version.js +++ b/test/lib/commands/version.js @@ -339,7 +339,7 @@ t.test('empty versions', async t => { }, }, mocks: { - libnpmversion: (arg, opts) => { + libnpmversion: () => { return '2.0.0' }, }, diff --git a/test/lib/docs.js b/test/lib/docs.js index e074d556bb360..67afd1b54d91e 100644 --- a/test/lib/docs.js +++ b/test/lib/docs.js @@ -22,7 +22,7 @@ t.test('shorthands', async t => { t.test('config', async t => { const keys = Object.keys(definitions) - const flat = Object.entries(definitions).filter(([_, d]) => d.flatten).map(([k]) => k) + const flat = Object.entries(definitions).filter(([, d]) => d.flatten).map(([k]) => k) const notFlat = keys.filter(k => !flat.includes(k)) t.matchSnapshot(keys, 'all keys') t.matchSnapshot(flat, 'keys that are flattened') diff --git a/test/lib/utils/log-file.js b/test/lib/utils/log-file.js index a4cf8a256a634..8e07da8671b6a 100644 --- a/test/lib/utils/log-file.js +++ b/test/lib/utils/log-file.js @@ -167,7 +167,7 @@ t.test('initial stream error', async t => { mocks: { 'fs-minipass': { WriteStreamSync: class { - constructor (...args) { + constructor () { throw new Error('no stream') } }, diff --git a/test/lib/utils/otplease.js b/test/lib/utils/otplease.js index d788c39da842c..6dc3ee0f0b069 100644 --- a/test/lib/utils/otplease.js +++ b/test/lib/utils/otplease.js @@ -119,7 +119,7 @@ t.test('prompts for otp for 401', async (t) => { }) t.test('does not prompt for non-otp errors', async (t) => { - const fn = async (opts) => { + const fn = async () => { throw new Error('nope') } @@ -132,7 +132,7 @@ t.test('does not prompt for non-otp errors', async (t) => { }) t.test('does not prompt if stdin or stdout is not a tty', async (t) => { - const fn = async (opts) => { + const fn = async () => { throw Object.assign(new Error('nope'), { code: 'EOTP' }) } diff --git a/test/lib/utils/web-auth.js b/test/lib/utils/web-auth.js index a4e8f4bbc755d..ec8c1d17e9fa1 100644 --- a/test/lib/utils/web-auth.js +++ b/test/lib/utils/web-auth.js @@ -21,8 +21,8 @@ t.test('returns token on success', async (t) => { t.test('closes opener when auth check finishes', async (t) => { const opener = (_url, emitter) => { - return new Promise((resolve, reject) => { - // the only way to finish this promise is to emit aboter on the emitter + return new Promise((resolve) => { + // the only way to finish this promise is to emit abort on the emitter emitter.addListener('abort', () => { resolve() })