style: lint

This commit is contained in:
Daniel Roe 2020-07-31 07:52:44 +01:00
parent 38e72f86c2
commit c1188eebd5
5 changed files with 26 additions and 26 deletions

View File

@ -8,6 +8,7 @@ import hash from 'hash-sum'
import pify from 'pify'
import upath from 'upath'
import semver from 'semver'
import type { RouteLocationRaw } from 'vue-router'
import debounce from 'lodash/debounce'
import omit from 'lodash/omit'
@ -36,7 +37,6 @@ import {
import Ignore from './ignore'
import BuildContext from './context/build'
import TemplateContext from './context/template'
import { RouteLocationRaw } from 'vue-router'
const glob = pify(Glob)
export default class Builder {

View File

@ -17,7 +17,7 @@ export default class TemplateContext {
nuxtOptions: options,
features: options.features,
extensions: options.extensions
.map(ext => ext.replace(/^\./, ''))
.map((ext: string) => ext.replace(/^\./, ''))
.join('|'),
messages: options.messages,
splitChunks: options.build.splitChunks,
@ -57,7 +57,7 @@ export default class TemplateContext {
}
}
get templateOptions() {
get templateOptions () {
return {
imports: {
serialize,

View File

@ -44,7 +44,7 @@ export default class NuxtCommand extends Hookable {
cmd: Command & { options: Command['options'] }
constructor(cmd: Command = { name: '', usage: '', description: '' }, argv = process.argv.slice(2), hooks: Hooks = {}) {
constructor (cmd: Command = { name: '', usage: '', description: '' }, argv = process.argv.slice(2), hooks: Hooks = {}) {
super(consola)
this.addHooks(hooks)
@ -57,18 +57,18 @@ export default class NuxtCommand extends Hookable {
this._parsedArgv = null // Lazy evaluate
}
static run(cmd: Command, argv: NodeJS.Process['argv'], hooks: Hooks) {
static run (cmd: Command, argv: NodeJS.Process['argv'], hooks: Hooks) {
return NuxtCommand.from(cmd, argv, hooks).run()
}
static from(cmd: Command, argv: NodeJS.Process['argv'], hooks: Hooks) {
static from (cmd: Command, argv: NodeJS.Process['argv'], hooks: Hooks) {
if (cmd instanceof NuxtCommand) {
return cmd
}
return new NuxtCommand(cmd, argv, hooks)
}
async run() {
async run () {
await this.callHook('run:before', {
argv: this._argv,
cmd: this.cmd,
@ -117,15 +117,15 @@ export default class NuxtCommand extends Hookable {
}
}
showVersion() {
showVersion () {
process.stdout.write(`${name} v${version}\n`)
}
showHelp() {
showHelp () {
process.stdout.write(this._getHelp())
}
get argv() {
get argv () {
if (!this._parsedArgv) {
const minimistOptions = this._getMinimistOptions()
this._parsedArgv = minimist(this._argv, minimistOptions)
@ -133,7 +133,7 @@ export default class NuxtCommand extends Hookable {
return this._parsedArgv
}
async getNuxtConfig(extraOptions: ExtraOptions = {}) {
async getNuxtConfig (extraOptions: ExtraOptions = {}) {
// Flag to indicate nuxt is running with CLI (not programmatic)
extraOptions._cli = true
@ -154,7 +154,7 @@ export default class NuxtCommand extends Hookable {
return options
}
async getNuxt(options) {
async getNuxt (options) {
const nuxt = new Nuxt(options)
await nuxt.ready()
@ -162,16 +162,16 @@ export default class NuxtCommand extends Hookable {
return nuxt
}
async getBuilder(nuxt: Nuxt) {
async getBuilder (nuxt: Nuxt) {
return new Builder(nuxt)
}
async getGenerator(nuxt) {
async getGenerator (nuxt) {
const builder = await this.getBuilder(nuxt)
return new Generator(nuxt, builder)
}
async setLock(lockRelease) {
async setLock (lockRelease) {
if (lockRelease) {
if (this._lockRelease) {
consola.warn(`A previous unreleased lock was found, this shouldn't happen and is probably an error in 'nuxt ${this.cmd.name}' command. The lock will be removed but be aware of potential strange results`)
@ -184,14 +184,14 @@ export default class NuxtCommand extends Hookable {
}
}
async releaseLock() {
async releaseLock () {
if (this._lockRelease) {
await this._lockRelease()
this._lockRelease = undefined
}
}
isUserSuppliedArg(option: string) {
isUserSuppliedArg (option: string) {
return this._argv.includes(`--${option}`) || this._argv.includes(`--no-${option}`)
}
@ -199,7 +199,7 @@ export default class NuxtCommand extends Hookable {
return option.default instanceof Function ? option.default(this.cmd) : option.default
}
_getMinimistOptions() {
_getMinimistOptions () {
const minimistOptions = {
alias: {},
boolean: [],
@ -224,7 +224,7 @@ export default class NuxtCommand extends Hookable {
return minimistOptions
}
_getHelp() {
_getHelp () {
const options = []
let maxOptionLength = 0

View File

@ -17,7 +17,7 @@ export default {
alias: 'a',
type: 'boolean',
description: 'Launch webpack-bundle-analyzer to optimize your bundles',
prepare (cmd: NuxtCommand, options, argv: ParsedArgs) {
prepare (_cmd: NuxtCommand, options, argv: ParsedArgs) {
// Analyze option
options.build = options.build || {}
if (argv.analyze && typeof options.build.analyze !== 'object') {
@ -29,7 +29,7 @@ export default {
type: 'boolean',
default: false,
description: 'Enable Vue devtools',
prepare (cmd: NuxtCommand, options, argv: ParsedArgs) {
prepare (_cmd: NuxtCommand, options, argv: ParsedArgs) {
options.vue = options.vue || {}
options.vue.config = options.vue.config || {}
if (argv.devtools) {
@ -46,7 +46,7 @@ export default {
alias: 'q',
type: 'boolean',
description: 'Disable output except for errors',
prepare (cmd: NuxtCommand, options, argv: ParsedArgs) {
prepare (_cmd: NuxtCommand, options, argv: ParsedArgs) {
// Silence output when using --quiet
options.build = options.build || {}
if (argv.quiet) {
@ -58,7 +58,7 @@ export default {
type: 'boolean',
default: false,
description: 'Bundle all server dependencies (useful for nuxt-start)',
prepare (cmd: NuxtCommand, options, argv: ParsedArgs) {
prepare (_cmd: NuxtCommand, options, argv: ParsedArgs) {
if (argv.standalone) {
options.build.standalone = true
}

View File

@ -50,7 +50,7 @@ export default {
return nuxt
},
async _listenDev (cmd: NuxtCommand, argv) {
async _listenDev (cmd: NuxtCommand, argv: ParsedArgs) {
const config = await cmd.getNuxtConfig({ dev: true, _build: true })
const nuxt = await cmd.getNuxt(config)
@ -78,7 +78,7 @@ export default {
return nuxt
},
async _buildDev (cmd: NuxtCommand, argv: ParsedArgs, nuxt: Nuxt) {
async _buildDev (cmd: NuxtCommand, _argv: ParsedArgs, nuxt: Nuxt) {
// Create builder instance
const builder = await cmd.getBuilder(nuxt)
@ -97,7 +97,7 @@ export default {
return nuxt
},
logChanged ({ event, path }) {
logChanged ({ event, path }: { event: keyof typeof eventsMapping, path: string }) {
const { icon, color, action } = eventsMapping[event] || eventsMapping.change
consola.log({