From d868d666d2c72faf5f117beffb9f54087745a9ca Mon Sep 17 00:00:00 2001 From: Edu93Jer Date: Tue, 15 Dec 2020 19:12:40 -0600 Subject: [PATCH] fix : Fix lines that were bigger than 80 characters --- lib/deprecate.js | 3 ++- lib/doctor.js | 7 +++++-- lib/init.js | 5 ++++- lib/npm.js | 3 ++- lib/outdated.js | 8 ++++++-- lib/profile.js | 4 +++- lib/repo.js | 3 ++- lib/token.js | 14 ++++++++++---- lib/unpublish.js | 3 ++- lib/utils/error-message.js | 3 ++- lib/utils/file-exists.js | 3 ++- lib/utils/metrics.js | 6 ++++-- lib/utils/reify-output.js | 3 ++- lib/view.js | 13 ++++++++++--- test/lib/help-search.js | 4 +++- test/lib/utils/reify-output.js | 3 ++- 16 files changed, 61 insertions(+), 24 deletions(-) diff --git a/lib/deprecate.js b/lib/deprecate.js index fbaad54b7fde3..1a46148e8405e 100644 --- a/lib/deprecate.js +++ b/lib/deprecate.js @@ -25,7 +25,8 @@ const completion = (opts, cb) => { return libaccess.lsPackages(username, npm.flatOptions).then((packages) => { return Object.keys(packages) .filter((name) => packages[name] === 'write' && - (opts.conf.argv.remain.length === 0 || name.startsWith(opts.conf.argv.remain[0])) + (opts.conf.argv.remain.length === 0 || + name.startsWith(opts.conf.argv.remain[0])) ) }) }).then((list) => cb(null, list), (err) => cb(err)) diff --git a/lib/doctor.js b/lib/doctor.js index 0b29936bb4d1f..f30b33dbd5b41 100644 --- a/lib/doctor.js +++ b/lib/doctor.js @@ -59,7 +59,8 @@ const getLatestNodejsVersion = async () => { if (lts && semver.gt(version, maxLTS)) maxLTS = version - if (semver.satisfies(version, currentRange) && semver.gt(version, maxCurrent)) + if (semver.satisfies(version, currentRange) && + semver.gt(version, maxCurrent)) maxCurrent = version } const recommended = semver.gt(maxCurrent, maxLTS) ? maxCurrent : maxLTS @@ -175,7 +176,9 @@ const verifyCachedFiles = async () => { tracker.info('verifyCachedFiles', 'Verifying the npm cache') try { const stats = await cacache.verify(npm.flatOptions.cache) - const { badContentCount, reclaimedCount, missingContent, reclaimedSize } = stats + const { + badContentCount, reclaimedCount, missingContent, reclaimedSize, + } = stats if (badContentCount || reclaimedCount || missingContent) { if (badContentCount) tracker.warn('verifyCachedFiles', `Corrupted content removed: ${badContentCount}`) diff --git a/lib/init.js b/lib/init.js index 6e4213c28ff6f..f1aa700bb5a9d 100644 --- a/lib/init.js +++ b/lib/init.js @@ -42,7 +42,10 @@ const init = async args => { } npm.config.set('package', []) return new Promise((res, rej) => { - npm.commands.exec([packageName, ...args.slice(1)], er => er ? rej(er) : res()) + npm.commands.exec( + [packageName, ...args.slice(1)], + er => er ? rej(er) : res() + ) }) } diff --git a/lib/npm.js b/lib/npm.js index 4430b80539d03..876432e5bdf38 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -13,7 +13,8 @@ require('graceful-fs').gracefulify(require('fs')) const procLogListener = require('./utils/proc-log-listener.js') -const hasOwnProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key) +const hasOwnProperty = (obj, key) => + Object.prototype.hasOwnProperty.call(obj, key) // the first time `npm.commands.xyz` is loaded, it gets added // to the cmds object, so we don't have to load it again. diff --git a/lib/outdated.js b/lib/outdated.js index f0ec7a72f40ee..c0d9909073da8 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -234,7 +234,9 @@ function makePretty (dep, opts) { // :::: function makeParseable (list, opts) { return list.map(dep => { - const { name, current, wanted, latest, path, dependent, type, homepage } = dep + const { + name, current, wanted, latest, path, dependent, type, homepage, + } = dep const out = [ path, name + '@' + wanted, @@ -252,7 +254,9 @@ function makeParseable (list, opts) { function makeJSON (list, opts) { const out = {} list.forEach(dep => { - const { name, current, wanted, latest, path, type, dependent, homepage } = dep + const { + name, current, wanted, latest, path, type, dependent, homepage, + } = dep out[name] = { current, wanted, diff --git a/lib/profile.js b/lib/profile.js index 50d7ddd7d22e6..5230f019fe7a4 100644 --- a/lib/profile.js +++ b/lib/profile.js @@ -127,7 +127,9 @@ function get (args) { }) } else { const table = new Table() - Object.keys(cleaned).forEach((k) => table.push({ [ansistyles.bright(k)]: cleaned[k] })) + Object.keys(cleaned).forEach((k) => + table.push({ [ansistyles.bright(k)]: cleaned[k] }) + ) output(table.toString()) } } diff --git a/lib/repo.js b/lib/repo.js index 7bd3bd154f739..2dc3bcb1b846f 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -36,7 +36,8 @@ const getRepo = async pkg => { } const info = hostedFromMani(mani) - const url = info ? info.browse(mani.repository.directory) : unknownHostedUrl(rurl) + const url = info ? + info.browse(mani.repository.directory) : unknownHostedUrl(rurl) if (!url) { throw Object.assign(new Error('no repository: could not get url'), { diff --git a/lib/token.js b/lib/token.js index 8809e4412f857..fe7ea5da3b7b1 100644 --- a/lib/token.js +++ b/lib/token.js @@ -77,7 +77,9 @@ function generateTokenIds (tokens, minLength) { tokens.forEach((token) => { token.id = token.key for (let ii = minLength; ii < token.key.length; ++ii) { - if (!tokens.some((ot) => ot !== token && ot.key.slice(0, ii) === token.key.slice(0, ii))) { + if (!tokens.some((ot) => + ot !== token && ot.key.slice(0, ii) === token.key.slice(0, ii) + )) { token.id = token.key.slice(0, ii) break } @@ -136,7 +138,8 @@ function list (args) { return } generateTokenIds(tokens, 6) - const idWidth = tokens.reduce((acc, token) => Math.max(acc, token.id.length), 0) + const idWidth = tokens.reduce((acc, token) => + Math.max(acc, token.id.length), 0) const table = new Table({ head: ['id', 'token', 'created', 'readonly', 'CIDR whitelist'], colWidths: [Math.max(idWidth, 2) + 2, 9, 12, 10], @@ -170,7 +173,8 @@ function rm (args) { else if (matches.length > 1) throw new Error(`Token ID "${id}" was ambiguous, a new token may have been created since you last ran \`npm token list\`.`) else { - const tokenMatches = tokens.filter((token) => id.indexOf(token.token) === 0) + const tokenMatches = tokens.filter((token) => + id.indexOf(token.token) === 0) if (tokenMatches.length === 0) throw new Error(`Unknown token id or value "${id}".`) @@ -212,7 +216,9 @@ function create (args) { Object.keys(result).forEach((k) => output(k + '\t' + result[k])) else { const table = new Table() - Object.keys(result).forEach((k) => table.push({ [ansistyles.bright(k)]: String(result[k]) })) + Object.keys(result).forEach((k) => + table.push({ [ansistyles.bright(k)]: String(result[k]) }) + ) output(table.toString()) } }) diff --git a/lib/unpublish.js b/lib/unpublish.js index 1d7601b60cd84..9b4892a7cbe19 100644 --- a/lib/unpublish.js +++ b/lib/unpublish.js @@ -94,7 +94,8 @@ async function unpublish (args) { const { name, version, publishConfig } = manifest const pkgJsonSpec = npa.resolve(name, version) - res = await otplease(opts, opts => libunpub(pkgJsonSpec, { ...opts, publishConfig })) + res = await otplease(opts, opts => + libunpub(pkgJsonSpec, { ...opts, publishConfig })) pkgName = name pkgVersion = version ? `@${version}` : '' } else { diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index 695b497ab64b7..917990fc86661 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -193,7 +193,8 @@ module.exports = (er) => { else { detail.push(['404', 'This package name is not valid, because', '']) - const errorsArray = (valResult.errors || []).concat(valResult.warnings || []) + const errorsArray = (valResult.errors || []) + .concat(valResult.warnings || []) errorsArray.forEach(function (item, idx) { detail.push(['404', ' ' + (idx + 1) + '. ' + item]) }) diff --git a/lib/utils/file-exists.js b/lib/utils/file-exists.js index 3149c0ae52fd8..c8a7ccfe9fa3b 100644 --- a/lib/utils/file-exists.js +++ b/lib/utils/file-exists.js @@ -3,6 +3,7 @@ const util = require('util') const stat = util.promisify(fs.stat) -const fileExists = (file) => stat(file).then((stat) => stat.isFile()).catch(() => false) +const fileExists = (file) => + stat(file).then((stat) => stat.isFile()).catch(() => false) module.exports = fileExists diff --git a/lib/utils/metrics.js b/lib/utils/metrics.js index 432f8dc703477..faa2c209d020a 100644 --- a/lib/utils/metrics.js +++ b/lib/utils/metrics.js @@ -15,7 +15,8 @@ let inMetrics = false function startMetrics () { if (inMetrics) return - // loaded on demand to avoid any recursive deps when `./metrics-launch` requires us. + // loaded on demand to avoid any recursive deps when + // `./metrics-launch` requires us. var metricsLaunch = require('./metrics-launch.js') npm.metricsProcess = metricsLaunch() } @@ -30,7 +31,8 @@ function stopMetrics () { function saveMetrics (itWorked) { if (inMetrics) return - // If the metrics reporter hasn't managed to PUT yet then kill it so that it doesn't + // If the metrics reporter hasn't managed to PUT yet + // then kill it so that it doesn't // step on our updating the anonymous-cli-metrics json stopMetrics() var metricsFile = path.join(npm.config.get('cache'), 'anonymous-cli-metrics.json') diff --git a/lib/utils/reify-output.js b/lib/utils/reify-output.js index ed573348796c1..06d28d7ab5315 100644 --- a/lib/utils/reify-output.js +++ b/lib/utils/reify-output.js @@ -1,7 +1,8 @@ // pass in an arborist object, and it'll output the data about what // was done, what was audited, etc. // -// added 351 packages, removed 132 packages, and audited 13388 packages in 19.157s +// added 351 packages, removed 132 packages, +// and audited 13388 packages in 19.157s // // 1 package is looking for funding // run `npm fund` for details diff --git a/lib/view.js b/lib/view.js index 42ba4b1c1b68e..4f98e88775646 100644 --- a/lib/view.js +++ b/lib/view.js @@ -196,7 +196,8 @@ const prettyView = async (packument, manifest, opts) => { name: color.yellow(manifest._npmUser.name), email: color.cyan(manifest._npmUser.email), }), - modified: packument.time ? color.yellow(relativeDate(packument.time[packument.version])) : undefined, + modified: packument.time ? + color.yellow(relativeDate(packument.time[packument.version])) : undefined, maintainers: (packument.maintainers || []).map((u) => unparsePerson({ name: color.yellow(u.name), email: color.cyan(u.email), @@ -387,8 +388,14 @@ async function printData (data, name, opts) { if (includeVersions || includeFields || typeof d !== 'string') { if (opts.json) msgJson[msgJson.length - 1][f] = d - else - d = inspect(d, { showHidden: false, depth: 5, colors: npm.color, maxArrayLength: null }) + else { + d = inspect(d, { + showHidden: false, + depth: 5, + colors: npm.color, + maxArrayLength: null, + }) + } } else if (typeof d === 'string' && opts.json) d = JSON.stringify(d) diff --git a/test/lib/help-search.js b/test/lib/help-search.js index 5ecf5db0614ac..ce32503ca594b 100644 --- a/test/lib/help-search.js +++ b/test/lib/help-search.js @@ -40,7 +40,9 @@ const globDir = { 'npm-more-useless.md': 'exec exec', 'npm-extra-useless.md': 'exec\nexec\nexec', } -const glob = (p, cb) => cb(null, Object.keys(globDir).map((file) => join(globRoot, file))) +const glob = (p, cb) => + cb(null, Object.keys(globDir).map((file) => + join(globRoot, file))) const helpSearch = requireInject('../../lib/help-search.js', { '../../lib/npm.js': npm, diff --git a/test/lib/utils/reify-output.js b/test/lib/utils/reify-output.js index f7fd96ee87d98..268effe8de1ad 100644 --- a/test/lib/utils/reify-output.js +++ b/test/lib/utils/reify-output.js @@ -245,7 +245,8 @@ t.test('packages changed message', t => { settings.json = json npmock.command = command const mock = { - actualTree: { inventory: { size: audited, has: () => true }, children: [] }, + actualTree: { inventory: { size: audited, has: () => true }, + children: [] }, auditReport: audited ? { toJSON: () => mock.auditReport, vulnerabilities: {},