Skip to content

Commit

Permalink
fix: remove max-len linting bypasses
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jan 17, 2025
1 parent 8a911ff commit dc31c1b
Show file tree
Hide file tree
Showing 25 changed files with 7 additions and 103 deletions.
1 change: 0 additions & 1 deletion lib/base-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class BaseCommand {
} else if (!this.npm.config.isDefault('expect-result-count')) {
const expected = this.npm.config.get('expect-result-count')
if (expected !== entries) {
/* eslint-disable-next-line max-len */
log.warn(this.name, `Expected ${expected} result${expected === 1 ? '' : 's'}, got ${entries}`)
process.exitCode = 1
}
Expand Down
2 changes: 0 additions & 2 deletions lib/cli/entry.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable max-len */

// Separated out for easier unit testing
module.exports = async (process, validateEngines) => {
// set it here so that regardless of what happens later, we don't
Expand Down
2 changes: 0 additions & 2 deletions lib/cli/validate-engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ const npm = `v${version}`
module.exports = (process, getCli) => {
const node = process.version

/* eslint-disable-next-line max-len */
const unsupportedMessage = `npm ${npm} does not support Node.js ${node}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`

/* eslint-disable-next-line max-len */
const brokenMessage = `ERROR: npm ${npm} is known not to run on Node.js ${node}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`

// coverage ignored because this is only hit in very unsupported node versions
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const localeCompare = require('@isaacs/string-locale-compare')('en')
const { log, output } = require('proc-log')

const searchCachePackage = async (path, parsed, cacheKeys) => {
/* eslint-disable-next-line max-len */
const searchMFH = new RegExp(`^make-fetch-happen:request-cache:.*(?<!/[@a-zA-Z]+)/${parsed.name}/-/(${parsed.name}[^/]+.tgz)$`)
const searchPack = new RegExp(`^make-fetch-happen:request-cache:.*/${parsed.escapedName}$`)
const results = new Set()
Expand Down Expand Up @@ -181,7 +180,6 @@ class Cache extends BaseCommand {
output.standard(`Corrupted content removed: ${stats.badContentCount}`)
}
if (stats.reclaimedCount) {
/* eslint-disable-next-line max-len */
output.standard(`Content garbage-collected: ${stats.reclaimedCount} (${stats.reclaimedSize} bytes)`)
}
if (stats.missingContent) {
Expand Down
1 change: 0 additions & 1 deletion lib/commands/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class Doctor extends BaseCommand {

if (!allOk) {
if (this.npm.silent) {
/* eslint-disable-next-line max-len */
throw new Error('Some problems found. Check logs or disable silent mode for recommendations.')
} else {
throw new Error('Some problems found. See above for recommendations.')
Expand Down
1 change: 0 additions & 1 deletion lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class Install extends ArboristWorkspaceCmd {
if (forced) {
log.warn(
'install',
/* eslint-disable-next-line max-len */
`Forcing global npm install with incompatible version ${npmManifest.version} into node ${process.version}`
)
} else {
Expand Down
1 change: 0 additions & 1 deletion lib/commands/org.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class Org extends BaseCommand {

if (!['owner', 'admin', 'developer'].find(x => x === role)) {
throw new Error(
/* eslint-disable-next-line max-len */
'Third argument `role` must be one of `owner`, `admin`, or `developer`, with `developer` being the default value if omitted.'
)
}
Expand Down
3 changes: 0 additions & 3 deletions lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class Publish extends BaseCommand {
if (err.code !== 'EPRIVATE') {
throw err
}
// eslint-disable-next-line max-len
log.warn('publish', `Skipping workspace ${this.npm.chalk.cyan(name)}, marked as ${this.npm.chalk.bold('private')}`)
}
}
Expand Down Expand Up @@ -161,7 +160,6 @@ class Publish extends BaseCommand {
const latestSemverIsGreater = !!latestVersion && semver.gte(latestVersion, manifest.version)

if (latestSemverIsGreater && isDefaultTag) {
/* eslint-disable-next-line max-len */
throw new Error(`Cannot implicitly apply the "latest" tag because published version ${latestVersion} is higher than the new version ${manifest.version}. You must specify a tag using --tag.`)
}

Expand Down Expand Up @@ -238,7 +236,6 @@ class Publish extends BaseCommand {
const changes = []
const pkg = await pkgJson.fix(spec.fetchSpec, { changes })
if (changes.length && logWarnings) {
/* eslint-disable-next-line max-len */
log.warn('publish', 'npm auto-corrected some errors in your package.json when publishing. Please run "npm pkg fix" to address these errors.')
log.warn('publish', `errors corrected:\n${changes.join('\n')}`)
}
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/sbom.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class SBOM extends BaseCommand {
const packageLockOnly = this.npm.config.get('package-lock-only')

if (!sbomFormat) {
/* eslint-disable-next-line max-len */
throw this.usageError(`Must specify --sbom-format flag with one of: ${SBOM_FORMATS.join(', ')}.`)
}

Expand All @@ -40,7 +39,6 @@ class SBOM extends BaseCommand {
const arb = new Arborist(opts)

const tree = packageLockOnly ? await arb.loadVirtual(opts).catch(() => {
/* eslint-disable-next-line max-len */
throw this.usageError('A package lock or shrinkwrap file is required in package-lock-only mode')
}) : await arb.loadActual(opts)

Expand Down
2 changes: 0 additions & 2 deletions lib/commands/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Token extends BaseCommand {
for (const token of tokens) {
const level = token.readonly ? 'Read only token' : 'Publish token'
const created = String(token.created).slice(0, 10)
/* eslint-disable-next-line max-len */
output.standard(`${chalk.blue(level)} ${token.token}… with id ${chalk.cyan(token.id)} created ${created}`)
if (token.cidr_whitelist) {
output.standard(`with IP whitelist: ${chalk.green(token.cidr_whitelist.join(','))}`)
Expand All @@ -99,7 +98,6 @@ class Token extends BaseCommand {
toRemove.push(matches[0].key)
} else if (matches.length > 1) {
throw new Error(
/* eslint-disable-next-line max-len */
`Token ID "${id}" was ambiguous, a new token may have been created since you last ran \`npm token list\`.`
)
} else {
Expand Down
1 change: 0 additions & 1 deletion lib/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class Version extends BaseCommand {
static workspaces = true
static ignoreImplicitWorkspace = false

/* eslint-disable-next-line max-len */
static usage = ['[<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]']

static async completion (opts) {
Expand Down
1 change: 0 additions & 1 deletion lib/utils/did-you-mean.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const didYouMean = (pkg, scmd) => {
.map(str => [`run ${str}`, `run the "${str}" package script`]),
...Object.keys(bin)
.filter(cmd => isClose(scmd, cmd))
/* eslint-disable-next-line max-len */
.map(str => [`exec ${str}`, `run the "${str}" command from either this or a remote npm package`]),
]

Expand Down
6 changes: 4 additions & 2 deletions lib/utils/format-search-stream.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-len */
const { stripVTControlCharacters: strip } = require('node:util')
const { Minipass } = require('minipass')

Expand Down Expand Up @@ -83,7 +82,10 @@ class TextOutputStream extends Minipass {
constructor (opts) {
super()
// Consider a search for "cowboys" and "boy". If we highlight "boys" first the "cowboys" string will no longer string match because of the ansi highlighting added to "boys". If we highlight "boy" second then the ansi reset at the end will make the highlighting only on "cowboy" with a normal "s". Neither is perfect but at least the first option doesn't do partial highlighting. So, we sort strings smaller to larger
this.#args = opts.args.map(s => s.toLowerCase()).filter(Boolean).sort((a, b) => a.length - b.length)
this.#args = opts.args
.map(s => s.toLowerCase())
.filter(Boolean)
.sort((a, b) => a.length - b.length)
this.#chalk = opts.npm.chalk
this.#exclude = opts.exclude
this.#parseable = opts.parseable
Expand Down
2 changes: 0 additions & 2 deletions lib/utils/reify-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const reifyOutput = (npm, arb) => {
switch (d.action) {
case 'REMOVE':
if (showDiff) {
/* eslint-disable-next-line max-len */
output.standard(`${chalk.blue('remove')} ${d.actual.name} ${d.actual.package.version}`)
}
summary.removed++
Expand All @@ -63,7 +62,6 @@ const reifyOutput = (npm, arb) => {
break
case 'CHANGE':
if (showDiff) {
/* eslint-disable-next-line max-len */
output.standard(`${chalk.cyan('change')} ${d.actual.name} ${d.actual.package.version} => ${d.ideal.package.version}`)
}
summary.changed++
Expand Down
1 change: 0 additions & 1 deletion lib/utils/tar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const logTar = (tarball, { unicode = false, json, key } = {}) => {
log.notice('', `package size: ${formatBytes(tarball.size)}`)
log.notice('', `unpacked size: ${formatBytes(tarball.unpackedSize)}`)
log.notice('', `shasum: ${tarball.shasum}`)
/* eslint-disable-next-line max-len */
log.notice('', `integrity: ${tarball.integrity.toString().slice(0, 20)}[...]${tarball.integrity.toString().slice(80)}`)
if (tarball.bundled.length) {
log.notice('', `bundled deps: ${tarball.bundled.length}`)
Expand Down
10 changes: 0 additions & 10 deletions lib/utils/verify-signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,17 @@ class VerifySignatures {
const verifiedBold = this.npm.chalk.bold('verified')
if (this.verifiedSignatureCount) {
if (this.verifiedSignatureCount === 1) {
/* eslint-disable-next-line max-len */
output.standard(`${this.verifiedSignatureCount} package has a ${verifiedBold} registry signature`)
} else {
/* eslint-disable-next-line max-len */
output.standard(`${this.verifiedSignatureCount} packages have ${verifiedBold} registry signatures`)
}
output.standard('')
}

if (this.verifiedAttestationCount) {
if (this.verifiedAttestationCount === 1) {
/* eslint-disable-next-line max-len */
output.standard(`${this.verifiedAttestationCount} package has a ${verifiedBold} attestation`)
} else {
/* eslint-disable-next-line max-len */
output.standard(`${this.verifiedAttestationCount} packages have ${verifiedBold} attestations`)
}
output.standard('')
Expand All @@ -98,10 +94,8 @@ class VerifySignatures {
if (missing.length) {
const missingClr = this.npm.chalk.redBright('missing')
if (missing.length === 1) {
/* eslint-disable-next-line max-len */
output.standard(`1 package has a ${missingClr} registry signature but the registry is providing signing keys:`)
} else {
/* eslint-disable-next-line max-len */
output.standard(`${missing.length} packages have ${missingClr} registry signatures but the registry is providing signing keys:`)
}
output.standard('')
Expand All @@ -121,7 +115,6 @@ class VerifySignatures {
if (invalidSignatures.length === 1) {
output.standard(`1 package has an ${invalidClr} registry signature:`)
} else {
/* eslint-disable-next-line max-len */
output.standard(`${invalidSignatures.length} packages have ${invalidClr} registry signatures:`)
}
output.standard('')
Expand All @@ -136,7 +129,6 @@ class VerifySignatures {
if (invalidAttestations.length === 1) {
output.standard(`1 package has an ${invalidClr} attestation:`)
} else {
/* eslint-disable-next-line max-len */
output.standard(`${invalidAttestations.length} packages have ${invalidClr} attestations:`)
}
output.standard('')
Expand All @@ -147,10 +139,8 @@ class VerifySignatures {
}

if (invalid.length === 1) {
/* eslint-disable-next-line max-len */
output.standard(`Someone might have tampered with this package since it was published on the registry!`)
} else {
/* eslint-disable-next-line max-len */
output.standard(`Someone might have tampered with these packages since they were published on the registry!`)
}
output.standard('')
Expand Down
6 changes: 3 additions & 3 deletions tap-snapshots/test/lib/commands/install.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ silly logfile done cleaning log files
verbose stack Error: The developer of this package has specified the following through devEngines
verbose stack Invalid engine "runtime"
verbose stack Invalid name "nondescript" does not match "node" for "runtime"
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:182:27)
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:181:27)
verbose stack at MockNpm.#exec ({CWD}/lib/npm.js:251:7)
verbose stack at MockNpm.exec ({CWD}/lib/npm.js:207:9)
error code EBADDEVENGINES
Expand Down Expand Up @@ -199,7 +199,7 @@ warn EBADDEVENGINES }
verbose stack Error: The developer of this package has specified the following through devEngines
verbose stack Invalid engine "runtime"
verbose stack Invalid name "nondescript" does not match "node" for "runtime"
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:182:27)
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:181:27)
verbose stack at MockNpm.#exec ({CWD}/lib/npm.js:251:7)
verbose stack at MockNpm.exec ({CWD}/lib/npm.js:207:9)
error code EBADDEVENGINES
Expand All @@ -225,7 +225,7 @@ silly logfile done cleaning log files
verbose stack Error: The developer of this package has specified the following through devEngines
verbose stack Invalid engine "runtime"
verbose stack Invalid name "nondescript" does not match "node" for "runtime"
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:182:27)
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:181:27)
verbose stack at MockNpm.#exec ({CWD}/lib/npm.js:251:7)
verbose stack at MockNpm.exec ({CWD}/lib/npm.js:207:9)
error code EBADDEVENGINES
Expand Down
1 change: 0 additions & 1 deletion test/lib/cli/exit-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ t.cleanSnapshot = (path) => cleanDate(cleanCwd(path))
mockGlobals(t, {
process: Object.assign(new EventEmitter(), {
// these are process properties that are needed in the running code and tests
// eslint-disable-next-line max-len
...pick(process, 'version', 'execPath', 'stdout', 'stderr', 'stdin', 'cwd', 'chdir', 'env', 'umask'),
pid: 123456,
argv: ['/node', ...process.argv.slice(1)],
Expand Down
1 change: 0 additions & 1 deletion test/lib/cli/validate-engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ t.test('validate engines', async t => {
node: 'v4.5.6',
npm: 'v1.2.3',
engines: '>=0',
/* eslint-disable-next-line max-len */
unsupportedMessage: 'npm v1.2.3 does not support Node.js v4.5.6. This version of npm supports the following node versions: `>=0`. You can find the latest version at https://nodejs.org/.',
})

Expand Down
6 changes: 0 additions & 6 deletions test/lib/commands/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,9 @@ t.test('audit signatures', async t => {
packuments: [{
version: '1.0.0',
dist: {
// eslint-disable-next-line max-len
integrity: 'sha512-e+qfbn/zf1+rCza/BhIA//Awmf0v1pa5HQS8Xk8iXrn9bgytytVLqYD0P7NSqZ6IELTgq+tcDvLPkQjNHyWLNg==',
tarball: 'https://registry.npmjs.org/sigstore/-/sigstore-1.0.0.tgz',
// eslint-disable-next-line max-len
attestations: { url: 'https://registry.npmjs.org/-/npm/v1/attestations/[email protected]', provenance: { predicateType: 'https://slsa.dev/provenance/v0.2' } },
// eslint-disable-next-line max-len
signatures: [{ keyid: 'SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA', sig: 'MEQCIBlpcHT68iWOpx8pJr3WUzD1EqQ7tb0CmY36ebbceR6IAiAVGRaxrFoyh0/5B7H1o4VFhfsHw9F8G+AxOZQq87q+lg==' }],
},
}],
Expand All @@ -844,12 +841,9 @@ t.test('audit signatures', async t => {
packuments: [{
version: '1.0.0',
dist: {
// eslint-disable-next-line max-len
integrity: 'sha512-1dxsQwESDzACJjTdYHQ4wJ1f/of7jALWKfJEHSBWUQB/5UTJUx9SW6GHXp4mZ1KvdBRJCpGjssoPFGi4hvw8/A==',
tarball: 'https://registry.npmjs.org/tuf-js/-/tuf-js-1.0.0.tgz',
// eslint-disable-next-line max-len
attestations: { url: 'https://registry.npmjs.org/-/npm/v1/attestations/[email protected]', provenance: { predicateType: 'https://slsa.dev/provenance/v0.2' } },
// eslint-disable-next-line max-len
signatures: [{ keyid: 'SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA', sig: 'MEYCIQDgGQeY2QLkLuoO9YxOqFZ+a6zYuaZpXhc77kUfdCUXDQIhAJp/vV+9Xg1bfM5YlTvKIH9agUEOu5T76+tQaHY2vZyO' }],
},
}],
Expand Down
14 changes: 0 additions & 14 deletions test/lib/commands/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ t.test('cache add single pkg', async t => {
})
await npm.exec('cache', ['add', pkg])
t.equal(joinedOutput(), '')
// eslint-disable-next-line max-len
t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'))
// eslint-disable-next-line max-len
t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package'))
})

Expand Down Expand Up @@ -113,20 +111,15 @@ t.test('cache add multiple pkgs', async t => {
})
await npm.exec('cache', ['add', pkg, pkg2])
t.equal(joinedOutput(), '')
// eslint-disable-next-line max-len
t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'))
// eslint-disable-next-line max-len
t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package'))
// eslint-disable-next-line max-len
t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package-two/-/test-package-two-1.0.0.tgz'))
// eslint-disable-next-line max-len
t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package-two'))
})

t.test('cache ls', async t => {
const keys = [
'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package',
// eslint-disable-next-line max-len
'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz',
]
const { npm, joinedOutput } = await loadMockNpm(t)
Expand Down Expand Up @@ -204,10 +197,8 @@ t.test('cache ls tagged', async t => {

t.test('cache ls scoped and scoped slash', async t => {
const keys = [
// eslint-disable-next-line max-len
'make-fetch-happen:request-cache:https://registry.npmjs.org/@fritzy/staydown/-/@fritzy/staydown-3.1.1.tgz',
'make-fetch-happen:request-cache:https://registry.npmjs.org/@fritzy%2fstaydown',
// eslint-disable-next-line max-len
'make-fetch-happen:request-cache:https://registry.npmjs.org/@gar/npm-expansion/-/@gar/npm-expansion-2.1.0.tgz',
'make-fetch-happen:request-cache:https://registry.npmjs.org/@gar%2fnpm-expansion',
]
Expand Down Expand Up @@ -248,16 +239,11 @@ t.test('cache ls missing packument version not an object', async t => {
t.test('cache rm', async t => {
const { npm, joinedOutput } = await loadMockNpm(t)
const cache = path.join(npm.cache, '_cacache')
// eslint-disable-next-line max-len
await cacache.put(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package', '{}')
// eslint-disable-next-line max-len
await cacache.put(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz', 'test data')
// eslint-disable-next-line max-len
await npm.exec('cache', ['rm', 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'])
t.matchSnapshot(joinedOutput(), 'logs deleting single entry')
// eslint-disable-next-line max-len
t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package'))
// eslint-disable-next-line max-len
t.rejects(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'))
})

Expand Down
2 changes: 0 additions & 2 deletions test/lib/commands/help-search.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const t = require('tap')
const { load: loadMockNpm } = require('../../fixtures/mock-npm.js')

/* eslint-disable max-len */
const docsFixtures = {
dir1: {
'npm-exec.md': 'the exec command\nhelp has multiple lines of exec help\none of them references exec',
Expand All @@ -19,7 +18,6 @@ const docsFixtures = {
'npm-extra-useless.md': 'exec\nexec\nexec',
},
}
/* eslint-enable max-len */

const execHelpSearch = async (t, exec = [], opts) => {
const { npm, ...rest } = await loadMockNpm(t, {
Expand Down
Loading

0 comments on commit dc31c1b

Please sign in to comment.