chore: update code to meet new curly-all rule (#4505)

[skip ci]
This commit is contained in:
Jonas Galvez 2018-12-09 20:00:48 -02:00 committed by Pooya Parsa
parent 1162f2ddc1
commit 655f11cefd
7 changed files with 36 additions and 12 deletions

View File

@ -100,7 +100,9 @@ export default class Builder {
normalizePlugins() { normalizePlugins() {
return uniqBy( return uniqBy(
this.options.plugins.map((p) => { this.options.plugins.map((p) => {
if (typeof p === 'string') p = { src: p } if (typeof p === 'string') {
p = { src: p }
}
const pluginBaseName = path.basename(p.src, path.extname(p.src)).replace( const pluginBaseName = path.basename(p.src, path.extname(p.src)).replace(
/[^a-zA-Z?\d\s:]/g, /[^a-zA-Z?\d\s:]/g,
'' ''
@ -551,7 +553,9 @@ export default class Builder {
this.watchers.restart = chokidar this.watchers.restart = chokidar
.watch(nuxtRestartWatch, this.options.watchers.chokidar) .watch(nuxtRestartWatch, this.options.watchers.chokidar)
.on('all', (event, _path) => { .on('all', (event, _path) => {
if (['add', 'change', 'unlink'].includes(event) === false) return if (['add', 'change', 'unlink'].includes(event) === false) {
return
}
this.nuxt.callHook('watch:fileChanged', this, _path) // Legacy this.nuxt.callHook('watch:fileChanged', this, _path) // Legacy
this.nuxt.callHook('watch:restart', { event, path: _path }) this.nuxt.callHook('watch:restart', { event, path: _path })
}) })
@ -564,7 +568,9 @@ export default class Builder {
} }
async close() { async close() {
if (this.__closed) return if (this.__closed) {
return
}
this.__closed = true this.__closed = true
// Unwatch // Unwatch

View File

@ -142,8 +142,12 @@ export default class NuxtCommand {
const opts = foldLines(`Options:`, startSpaces) + '\n\n' + _opts const opts = foldLines(`Options:`, startSpaces) + '\n\n' + _opts
let helpText = colorize(`${usage}\n\n`) let helpText = colorize(`${usage}\n\n`)
if (this.cmd.description) helpText += colorize(`${description}\n\n`) if (this.cmd.description) {
if (options.length) helpText += colorize(`${opts}\n\n`) helpText += colorize(`${description}\n\n`)
}
if (options.length) {
helpText += colorize(`${opts}\n\n`)
}
return helpText return helpText
} }

View File

@ -137,7 +137,9 @@ export default class Generator {
const { fallback } = this.options.generate const { fallback } = this.options.generate
// Disable SPA fallback if value isn't a non-empty string // Disable SPA fallback if value isn't a non-empty string
if (typeof fallback !== 'string' || !fallback) return if (typeof fallback !== 'string' || !fallback) {
return
}
const fallbackPath = path.join(this.distPath, fallback) const fallbackPath = path.join(this.distPath, fallback)

View File

@ -178,7 +178,9 @@ export default class Server {
try { try {
handler = this.nuxt.resolver.requireModule(middleware.handler || middleware) handler = this.nuxt.resolver.requireModule(middleware.handler || middleware)
} catch (err) { } catch (err) {
if (!this.options.dev) throw err[0] if (!this.options.dev) {
throw err[0]
}
// Only warn missing file in development // Only warn missing file in development
consola.warn(err[0]) consola.warn(err[0])
} }
@ -231,7 +233,9 @@ export default class Server {
} }
async close() { async close() {
if (this.__closed) return if (this.__closed) {
return
}
this.__closed = true this.__closed = true
for (const listener of this.listeners) { for (const listener of this.listeners) {

View File

@ -33,7 +33,9 @@ export default class VueRenderer {
} }
get assetsMapping() { get assetsMapping() {
if (this._assetsMapping) return this._assetsMapping if (this._assetsMapping) {
return this._assetsMapping
}
const legacyAssets = this.context.resources.clientManifest.assetsMapping const legacyAssets = this.context.resources.clientManifest.assetsMapping
const modernAssets = invert(this.context.resources.modernManifest.assetsMapping) const modernAssets = invert(this.context.resources.modernManifest.assetsMapping)
@ -449,7 +451,9 @@ export default class VueRenderer {
} }
close() { close() {
if (this.__closed) return if (this.__closed) {
return
}
this.__closed = true this.__closed = true
for (const key in this.renderer) { for (const key in this.renderer) {

View File

@ -232,7 +232,9 @@ export class WebpackBundler {
} }
async close() { async close() {
if (this.__closed) return if (this.__closed) {
return
}
this.__closed = true this.__closed = true
// Unwatch // Unwatch

View File

@ -115,7 +115,9 @@ export default class PostcssConfig {
.map((p) => { .map((p) => {
const plugin = require(p) const plugin = require(p)
const opts = plugins[p] const opts = plugins[p]
if (opts === false) return // Disabled if (opts === false) {
return // Disabled
}
const instance = plugin(opts) const instance = plugin(opts)
return instance return instance
}) })