Skip to content

Commit

Permalink
fix lintfix script, use flat ternaries
Browse files Browse the repository at this point in the history
PR-URL: #1543
Credit: @isaacs
Close: #1543
Reviewed-by: @ruyadorno
  • Loading branch information
isaacs authored and ruyadorno committed Jul 29, 2020
1 parent 468bbd3 commit f0c4296
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"ArrayExpression": 1,
"ObjectExpression": 1,
"ImportDeclaration": 1,
"flatTernaryExpressions": false,
"flatTernaryExpressions": true,
"ignoreComments": false,
"ignoredNodes": ["TemplateLiteral *"]
}],
Expand Down
2 changes: 1 addition & 1 deletion lib/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Object.defineProperty(exports, 'defaults', {
globalconfig: path.resolve(globalPrefix, 'etc', 'npmrc'),
'global-style': false,
group: process.platform === 'win32' ? 0
: process.env.SUDO_GID || (process.getgid && process.getgid()),
: process.env.SUDO_GID || (process.getgid && process.getgid()),
'ham-it-up': false,
heading: 'npm',
'if-present': false,
Expand Down
10 changes: 5 additions & 5 deletions lib/config/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
saveType: npm.config.get('save-optional') && npm.config.get('save-peer')
? 'peerOptional'
: npm.config.get('save-optional') ? 'optional'
: npm.config.get('save-dev') ? 'dev'
: npm.config.get('save-peer') ? 'peer'
: npm.config.get('save-prod') ? 'prod'
: null,
: npm.config.get('save-dev') ? 'dev'
: npm.config.get('save-peer') ? 'peer'
: npm.config.get('save-prod') ? 'prod'
: null,
savePrefix: npm.config.get('save-exact') ? ''
: npm.config.get('save-prefix'),
: npm.config.get('save-prefix'),

// configs for npm-registry-fetch
otp: npm.config.get('otp'),
Expand Down
2 changes: 1 addition & 1 deletion lib/config/set-envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const envVal = val => Array.isArray(val) ? val.join('\n\n') : val

const sameConfigValue = (def, val) =>
!Array.isArray(val) || !Array.isArray(def) ? def === val
: sameArrayValue(def, val)
: sameArrayValue(def, val)

const sameArrayValue = (def, val) => {
if (def.length !== val.length) {
Expand Down
2 changes: 1 addition & 1 deletion lib/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const explore = async args => {
output(`\nExploring ${cwd}\nType 'exit' or ^D when finished\n`)
}

log.silly('explore', {sh, shellArgs, opts})
log.silly('explore', { sh, shellArgs, opts })

// only noisily fail if non-interactive, but still keep exit code intact
const proc = spawn(sh, shellArgs, opts)
Expand Down
10 changes: 5 additions & 5 deletions lib/help-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ function searchFiles (args, files, cb) {
results = results.sort(function (a, b) {
return a.found.length > b.found.length ? -1
: a.found.length < b.found.length ? 1
: a.totalHits > b.totalHits ? -1
: a.totalHits < b.totalHits ? 1
: a.lines.length > b.lines.length ? -1
: a.lines.length < b.lines.length ? 1
: 0
: a.totalHits > b.totalHits ? -1
: a.totalHits < b.totalHits ? 1
: a.lines.length > b.lines.length ? -1
: a.lines.length < b.lines.length ? 1
: 0
})

cb(null, results)
Expand Down
2 changes: 1 addition & 1 deletion lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function pickMan (mans, pref_) {
var bn = b.match(nre)[1]
return an === bn ? (a > b ? -1 : 1)
: pref[an] < pref[bn] ? -1
: 1
: 1
})
return mans[0]
}
Expand Down
4 changes: 2 additions & 2 deletions lib/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ async function outdated_ (tree, deps, opts) {

const type = edge.optional ? 'optionalDependencies'
: edge.peer ? 'peerDependencies'
: edge.dev ? 'devDependencies'
: 'dependencies'
: edge.dev ? 'devDependencies'
: 'dependencies'

// deps different from prod not currently
// on disk are not included in the output
Expand Down
4 changes: 2 additions & 2 deletions lib/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const getRepo = async pkg => {
const r = mani.repository
const rurl = !r ? null
: typeof r === 'string' ? r
: typeof r === 'object' && typeof r.url === 'string' ? r.url
: null
: typeof r === 'object' && typeof r.url === 'string' ? r.url
: null

if (!rurl) {
throw Object.assign(new Error('no repository'), {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/escape-arg.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ block, creates a new " quoted string with ' in it. So, `foo'bar` becomes
*/

module.exports = str => isWindows ? '"' + normalize(str) + '"'
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, `'"'"'`) + "'"
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, '\'"\'"\'') + "'"
: str
2 changes: 1 addition & 1 deletion lib/utils/escape-exec-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ const winQuote = str => !/ /.test(str) ? str : '"' + str + '"'
const winEsc = str => normalize(str).split(/\\/).map(winQuote).join('\\')

module.exports = str => isWindows ? winEsc(str)
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, `'"'"'`) + "'"
: /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, '\'"\'"\'') + "'"
: str
4 changes: 2 additions & 2 deletions lib/utils/hosted-git-info-from-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module.exports = mani => {
const r = mani.repository
const rurl = !r ? null
: typeof r === 'string' ? r
: typeof r === 'object' && typeof r.url === 'string' ? r.url
: null
: typeof r === 'object' && typeof r.url === 'string' ? r.url
: null

// hgi returns undefined sometimes, but let's always return null here
return (rurl && hostedGitInfo.fromUrl(rurl.replace(/^git\+/, ''))) || null
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/setup-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ module.exports = (config) => {

const enableColorStderr = color === 'always' ? true
: color === false ? false
: stderrTTY
: stderrTTY

const enableColorStdout = color === 'always' ? true
: color === false ? false
: stdoutTTY
: stdoutTTY

if (enableColorStderr) {
log.enableColor()
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/update-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module.exports = (npm) => {
const type = notifier.update.type
const typec = !useColor ? type
: type === 'major' ? chalk.red(type)
: type === 'minor' ? chalk.yellow(type)
: chalk.green(type)
: type === 'minor' ? chalk.yellow(type)
: chalk.green(type)

const changelog = `https://github.com/npm/cli/releases/tag/v${latest}`
notifier.notify({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
"sudotest": "sudo npm run test --",
"sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --",
"posttest": "npm run lint",
"eslint": "eslint --",
"eslint": "eslint",
"lint": "npm run eslint -- \"lib/**/*.js\"",
"lintfix": "npm run lint -- --fix",
"prelint": "rimraf test/npm_cache*"
Expand Down

0 comments on commit f0c4296

Please sign in to comment.