Skip to content

Commit 99e233c

Browse files
committed
fix lintfix script, use flat ternaries
1 parent ebd52fd commit 99e233c

15 files changed

+28
-28
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"ArrayExpression": 1,
6363
"ObjectExpression": 1,
6464
"ImportDeclaration": 1,
65-
"flatTernaryExpressions": false,
65+
"flatTernaryExpressions": true,
6666
"ignoreComments": false,
6767
"ignoredNodes": ["TemplateLiteral *"]
6868
}],

lib/config/defaults.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Object.defineProperty(exports, 'defaults', {
158158
globalconfig: path.resolve(globalPrefix, 'etc', 'npmrc'),
159159
'global-style': false,
160160
group: process.platform === 'win32' ? 0
161-
: process.env.SUDO_GID || (process.getgid && process.getgid()),
161+
: process.env.SUDO_GID || (process.getgid && process.getgid()),
162162
'ham-it-up': false,
163163
heading: 'npm',
164164
'if-present': false,

lib/config/flat-options.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
175175
saveType: npm.config.get('save-optional') && npm.config.get('save-peer')
176176
? 'peerOptional'
177177
: npm.config.get('save-optional') ? 'optional'
178-
: npm.config.get('save-dev') ? 'dev'
179-
: npm.config.get('save-peer') ? 'peer'
180-
: npm.config.get('save-prod') ? 'prod'
181-
: null,
178+
: npm.config.get('save-dev') ? 'dev'
179+
: npm.config.get('save-peer') ? 'peer'
180+
: npm.config.get('save-prod') ? 'prod'
181+
: null,
182182
savePrefix: npm.config.get('save-exact') ? ''
183-
: npm.config.get('save-prefix'),
183+
: npm.config.get('save-prefix'),
184184

185185
// configs for npm-registry-fetch
186186
otp: npm.config.get('otp'),

lib/config/set-envs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const envVal = val => Array.isArray(val) ? val.join('\n\n') : val
1616

1717
const sameConfigValue = (def, val) =>
1818
!Array.isArray(val) || !Array.isArray(def) ? def === val
19-
: sameArrayValue(def, val)
19+
: sameArrayValue(def, val)
2020

2121
const sameArrayValue = (def, val) => {
2222
if (def.length !== val.length) {

lib/explore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const explore = async args => {
5151
output(`\nExploring ${cwd}\nType 'exit' or ^D when finished\n`)
5252
}
5353

54-
log.silly('explore', {sh, shellArgs, opts})
54+
log.silly('explore', { sh, shellArgs, opts })
5555

5656
// only noisily fail if non-interactive, but still keep exit code intact
5757
const proc = spawn(sh, shellArgs, opts)

lib/help-search.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ function searchFiles (args, files, cb) {
145145
results = results.sort(function (a, b) {
146146
return a.found.length > b.found.length ? -1
147147
: a.found.length < b.found.length ? 1
148-
: a.totalHits > b.totalHits ? -1
149-
: a.totalHits < b.totalHits ? 1
150-
: a.lines.length > b.lines.length ? -1
151-
: a.lines.length < b.lines.length ? 1
152-
: 0
148+
: a.totalHits > b.totalHits ? -1
149+
: a.totalHits < b.totalHits ? 1
150+
: a.lines.length > b.lines.length ? -1
151+
: a.lines.length < b.lines.length ? 1
152+
: 0
153153
})
154154

155155
cb(null, results)

lib/help.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function pickMan (mans, pref_) {
102102
var bn = b.match(nre)[1]
103103
return an === bn ? (a > b ? -1 : 1)
104104
: pref[an] < pref[bn] ? -1
105-
: 1
105+
: 1
106106
})
107107
return mans[0]
108108
}

lib/outdated.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ async function outdated_ (tree, deps, opts) {
134134

135135
const type = edge.optional ? 'optionalDependencies'
136136
: edge.peer ? 'peerDependencies'
137-
: edge.dev ? 'devDependencies'
138-
: 'dependencies'
137+
: edge.dev ? 'devDependencies'
138+
: 'dependencies'
139139

140140
// deps different from prod not currently
141141
// on disk are not included in the output

lib/repo.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const getRepo = async pkg => {
2626
const r = mani.repository
2727
const rurl = !r ? null
2828
: typeof r === 'string' ? r
29-
: typeof r === 'object' && typeof r.url === 'string' ? r.url
30-
: null
29+
: typeof r === 'object' && typeof r.url === 'string' ? r.url
30+
: null
3131

3232
if (!rurl) {
3333
throw Object.assign(new Error('no repository'), {

lib/utils/escape-arg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ block, creates a new " quoted string with ' in it. So, `foo'bar` becomes
1414
*/
1515

1616
module.exports = str => isWindows ? '"' + normalize(str) + '"'
17-
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, `'"'"'`) + "'"
17+
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, '\'"\'"\'') + "'"
1818
: str

lib/utils/escape-exec-path.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ const winQuote = str => !/ /.test(str) ? str : '"' + str + '"'
1717
const winEsc = str => normalize(str).split(/\\/).map(winQuote).join('\\')
1818

1919
module.exports = str => isWindows ? winEsc(str)
20-
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, `'"'"'`) + "'"
20+
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, '\'"\'"\'') + "'"
2121
: str

lib/utils/hosted-git-info-from-manifest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ module.exports = mani => {
66
const r = mani.repository
77
const rurl = !r ? null
88
: typeof r === 'string' ? r
9-
: typeof r === 'object' && typeof r.url === 'string' ? r.url
10-
: null
9+
: typeof r === 'object' && typeof r.url === 'string' ? r.url
10+
: null
1111

1212
// hgi returns undefined sometimes, but let's always return null here
1313
return (rurl && hostedGitInfo.fromUrl(rurl.replace(/^git\+/, ''))) || null

lib/utils/setup-log.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ module.exports = (config) => {
1919

2020
const enableColorStderr = color === 'always' ? true
2121
: color === false ? false
22-
: stderrTTY
22+
: stderrTTY
2323

2424
const enableColorStdout = color === 'always' ? true
2525
: color === false ? false
26-
: stdoutTTY
26+
: stdoutTTY
2727

2828
if (enableColorStderr) {
2929
log.enableColor()

lib/utils/update-notifier.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ module.exports = (npm) => {
3232
const type = notifier.update.type
3333
const typec = !useColor ? type
3434
: type === 'major' ? chalk.red(type)
35-
: type === 'minor' ? chalk.yellow(type)
36-
: chalk.green(type)
35+
: type === 'minor' ? chalk.yellow(type)
36+
: chalk.green(type)
3737

3838
const changelog = `https://github.com/npm/cli/releases/tag/v${latest}`
3939
notifier.notify({

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
"sudotest": "sudo npm run test --",
289289
"sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --",
290290
"posttest": "npm run lint",
291-
"eslint": "eslint --",
291+
"eslint": "eslint",
292292
"lint": "npm run eslint -- \"lib/**/*.js\"",
293293
"lintfix": "npm run lint -- --fix",
294294
"prelint": "rimraf test/npm_cache*"

0 commit comments

Comments
 (0)