Skip to content

Commit

Permalink
fix(linting): no-unused-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Apr 30, 2024
1 parent 2fba4b7 commit d679ce8
Show file tree
Hide file tree
Showing 31 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion bin/npx-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion docs/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })))
})
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/dedupe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')}`,
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/find-dupes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', [])
}
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/help-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Outdated extends ArboristWorkspaceCmd {
this.edges.add(edge)
}

getWorkspacesEdges (node) {
getWorkspacesEdges () {
if (this.npm.global) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class Profile extends BaseCommand {
}
}

async disable2fa (args) {
async disable2fa () {
const conf = { ...this.npm.flatOptions }
const info = await npmProfile.get(conf)

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions lib/commands/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`)
}
Expand Down Expand Up @@ -185,7 +185,7 @@ class RunScript extends BaseCommand {
return allScripts
}

async runWorkspaces (args, filters) {
async runWorkspaces (args) {
const res = []
await this.setWorkspaces()

Expand All @@ -205,7 +205,7 @@ class RunScript extends BaseCommand {
}
}

async listWorkspaces (args, filters) {
async listWorkspaces (args) {
await this.setWorkspaces()

if (this.npm.silent) {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/whoami.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/explain-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
}
Expand Down
2 changes: 1 addition & 1 deletion mock-registry/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/lib/cli/exit-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
2 changes: 1 addition & 1 deletion test/lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
Expand Down
28 changes: 14 additions & 14 deletions test/lib/commands/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
},
}
Expand Down Expand Up @@ -587,7 +587,7 @@ t.test('enable-2fa', async t => {
async get () {
return userProfile
},
async set (newProfile, conf) {
async set (newProfile) {
t.match(
newProfile,
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -747,7 +747,7 @@ t.test('enable-2fa', async t => {
},
}
},
async set (newProfile, conf) {
async set () {
return {
...userProfile,
tfa: 'http://foo?secret=1234',
Expand All @@ -759,7 +759,7 @@ t.test('enable-2fa', async t => {
async password () {
return 'password1234'
},
async otp (label) {
async otp () {
return '123456'
},
}
Expand All @@ -786,7 +786,7 @@ t.test('enable-2fa', async t => {
async get () {
return userProfile
},
async set (newProfile, conf) {
async set () {
return {
...userProfile,
tfa: null,
Expand All @@ -809,7 +809,7 @@ t.test('enable-2fa', async t => {
config: { otp: '123456' },
})

npm.config.getCredentialsByURI = reg => {
npm.config.getCredentialsByURI = () => {
return { token: 'token' }
}

Expand All @@ -830,7 +830,7 @@ t.test('enable-2fa', async t => {
tfa: undefined,
}
},
async set (newProfile, conf) {
async set () {
return {
...userProfile,
tfa: null,
Expand All @@ -852,7 +852,7 @@ t.test('enable-2fa', async t => {
readUserInfo,
})

npm.config.getCredentialsByURI = reg => {
npm.config.getCredentialsByURI = () => {
return { token: 'token' }
}

Expand All @@ -873,7 +873,7 @@ t.test('enable-2fa', async t => {
tfa: undefined,
}
},
async set (newProfile, conf) {
async set () {
return {
...userProfile,
tfa: null,
Expand All @@ -895,7 +895,7 @@ t.test('enable-2fa', async t => {
readUserInfo,
})

npm.config.getCredentialsByURI = reg => {
npm.config.getCredentialsByURI = () => {
return { token: 'token' }
}

Expand Down Expand Up @@ -933,7 +933,7 @@ t.test('disable-2fa', async t => {
async get () {
return userProfile
},
async set (newProfile, conf) {
async set (newProfile) {
t.same(
newProfile,
{
Expand Down Expand Up @@ -1014,7 +1014,7 @@ t.test('disable-2fa', async t => {
async get () {
return userProfile
},
async set (newProfile, conf) {
async set (newProfile) {
t.same(
newProfile,
{
Expand All @@ -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')
},
}
Expand Down
Loading

0 comments on commit d679ce8

Please sign in to comment.