mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
chore: fix all eslint error and warnings
This commit is contained in:
parent
052364c689
commit
c63091b68d
@ -1,5 +1,5 @@
|
||||
// Add polyfill imports to the first file encountered.
|
||||
module.exports = ({ types }) => {
|
||||
module.exports = ({ _types }) => {
|
||||
let entryFile
|
||||
return {
|
||||
name: 'inject-polyfills',
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { createWatcher } from './watch'
|
||||
|
||||
export interface NuxtRoute {
|
||||
path: ''
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { join } from 'path'
|
||||
import fsExtra from 'fs-extra'
|
||||
import consola from 'consola'
|
||||
import { BundleBuilder } from 'src/webpack'
|
||||
import { Nuxt } from '../core'
|
||||
import { compileTemplates, scanTemplates, NuxtTemplate } from './template'
|
||||
@ -40,7 +41,7 @@ function watch (builder: Builder) {
|
||||
const nuxtAppWatcher = createWatcher(nuxt.options.appDir)
|
||||
// nuxtAppWatcher.debug()
|
||||
nuxtAppWatcher.watchAll(async () => {
|
||||
console.log('Re-generate templates')
|
||||
consola.log('Re-generate templates')
|
||||
await compileTemplates(builder.templates, nuxt.options.buildDir)
|
||||
})
|
||||
|
||||
@ -56,7 +57,7 @@ function watch (builder: Builder) {
|
||||
await generate(builder)
|
||||
})
|
||||
appWatcher.watch('pages/', async () => {
|
||||
console.log('Re-generate routes')
|
||||
consola.log('Re-generate routes')
|
||||
await compileTemplates(builder.templates, nuxt.options.buildDir)
|
||||
})
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs-extra'
|
||||
import ignore from 'ignore'
|
||||
import { NormalizedConfiguration } from 'src/config'
|
||||
|
||||
type IgnoreInstance = ReturnType<typeof ignore>
|
||||
type IgnoreOptions = Parameters<typeof ignore>[0]
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { join, relative, dirname } from 'path'
|
||||
import fsExtra from 'fs-extra'
|
||||
import globby from 'globby'
|
||||
import consola from 'consola'
|
||||
import lodashTemplate from 'lodash/template'
|
||||
|
||||
interface NuxtTemplate {
|
||||
export interface NuxtTemplate {
|
||||
src: string // Absolute path to source file
|
||||
path: string // Relative path of destination
|
||||
data?: any
|
||||
@ -13,12 +14,12 @@ async function compileTemplate ({ src, path, data }: NuxtTemplate, destDir: stri
|
||||
const srcContents = await fsExtra.readFile(src, 'utf-8')
|
||||
const compiledSrc = lodashTemplate(srcContents, {})(data)
|
||||
const dest = join(destDir, path)
|
||||
console.log('Compile template', dest)
|
||||
consola.log('Compile template', dest)
|
||||
await fsExtra.mkdirp(dirname(dest))
|
||||
await fsExtra.writeFile(dest, compiledSrc)
|
||||
}
|
||||
|
||||
export async function compileTemplates (templates: NuxtTemplate[], destDir: string) {
|
||||
export function compileTemplates (templates: NuxtTemplate[], destDir: string) {
|
||||
return Promise.all(templates.map(t => compileTemplate(t, destDir)))
|
||||
}
|
||||
|
||||
@ -32,7 +33,7 @@ export async function scanTemplates (dir: string, data?: Object) {
|
||||
}))
|
||||
}
|
||||
|
||||
export async function watchTemplate (template: NuxtTemplate, watcher: any, cb: Function) {
|
||||
export function watchTemplate (template: NuxtTemplate, _watcher: any, _cb: Function) {
|
||||
template.data = new Proxy(template.data, {
|
||||
// TODO: deep watch option changes
|
||||
})
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { relative } from 'path'
|
||||
import chokidar, { WatchOptions } from 'chokidar'
|
||||
import consola from 'consola'
|
||||
|
||||
export function createWatcher (dir: string|string[], options?: WatchOptions) {
|
||||
export function createWatcher (dir: string, options?: WatchOptions) {
|
||||
const watcher = chokidar.watch(dir, {
|
||||
ignored: [],
|
||||
ignoreInitial: true,
|
||||
@ -9,7 +10,7 @@ export function createWatcher (dir: string|string[], options?: WatchOptions) {
|
||||
})
|
||||
|
||||
const watchAll = (cb: Function, filter?: Function) => {
|
||||
watcher.on('raw', (event, path: string, details) => {
|
||||
watcher.on('raw', (event, path: string, _details) => {
|
||||
if (options.ignored.find(ignore => path.match(ignore))) {
|
||||
return // 🖕 chokidar ignored option
|
||||
}
|
||||
@ -24,9 +25,9 @@ export function createWatcher (dir: string|string[], options?: WatchOptions) {
|
||||
const watch = (pattern: string| RegExp, cb: Function) => watchAll(cb, e => e.path.match(pattern))
|
||||
|
||||
const debug = (tag: string = '[Watcher]') => {
|
||||
console.log(tag, 'Watching ', dir)
|
||||
consola.log(tag, 'Watching ', dir)
|
||||
watchAll((e) => {
|
||||
console.log(tag, e.event, e.path)
|
||||
consola.log(tag, e.event, e.path)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ export default class NuxtCommand extends Hookable {
|
||||
return nuxt
|
||||
}
|
||||
|
||||
async getBuilder (nuxt: Nuxt) {
|
||||
getBuilder (nuxt: Nuxt) {
|
||||
return new Builder(nuxt)
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ export default {
|
||||
if (options.target === TARGETS.server) {
|
||||
throw new Error('You cannot use `nuxt serve` with ' + TARGETS.server + ' target, please use `nuxt start`')
|
||||
}
|
||||
const distStat = await fs.stat(options.generate.dir).catch(err => null) // eslint-disable-line handle-callback-err
|
||||
const distStat = await fs.stat(options.generate.dir).catch(_err => null) // eslint-disable-line handle-callback-err
|
||||
if (!distStat || !distStat.isDirectory()) {
|
||||
throw new Error('Output directory `' + basename(options.generate.dir) + '/` does not exists, please run `nuxt export` before `nuxt serve`.')
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default {
|
||||
alias: 'm',
|
||||
type: 'string',
|
||||
description: 'Build/Start app for modern browsers, e.g. server, client and false',
|
||||
prepare (cmd, options, argv) {
|
||||
prepare (_cmd, options, argv) {
|
||||
if (argv.modern !== undefined) {
|
||||
options.modern = normalizeArg(argv.modern)
|
||||
}
|
||||
@ -32,7 +32,7 @@ export default {
|
||||
alias: 't',
|
||||
type: 'string',
|
||||
description: 'Build/start app for a different target, e.g. server, serverless and static',
|
||||
prepare (cmd, options, argv) {
|
||||
prepare (_cmd, options, argv) {
|
||||
if (argv.target) {
|
||||
options.target = argv.target
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ interface CommonConfiguration {
|
||||
_modules: NuxtModule[]
|
||||
_nuxtConfigFile?: string
|
||||
alias: Record<string, string>
|
||||
appDir: string,
|
||||
buildDir: string
|
||||
buildModules: NuxtModule[]
|
||||
createRequire?: (module: NodeJS.Module) => NodeJS.Require
|
||||
|
@ -73,7 +73,7 @@ interface RenderOptions {
|
||||
export default (): RenderOptions => ({
|
||||
bundleRenderer: {
|
||||
shouldPrefetch: () => false,
|
||||
shouldPreload: (fileWithoutQuery, asType) => ['script', 'style'].includes(asType),
|
||||
shouldPreload: (_fileWithoutQuery, asType) => ['script', 'style'].includes(asType),
|
||||
runInNewContext: undefined
|
||||
},
|
||||
crossorigin: undefined,
|
||||
|
@ -4,8 +4,11 @@ export interface ServerProcessEnv extends NodeJS.ProcessEnv {
|
||||
HOST?: string
|
||||
PORT?: string
|
||||
UNIX_SOCKET?: string
|
||||
// eslint-disable-next-line camelcase
|
||||
npm_package_config_nuxt_port?: string
|
||||
// eslint-disable-next-line camelcase
|
||||
npm_package_config_nuxt_host?: string
|
||||
// eslint-disable-next-line camelcase
|
||||
npm_package_config_unix_socket?: string
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ interface InputConfiguration {
|
||||
layoutTransition?: string | DefaultConfiguration['layoutTransition']
|
||||
loading?: true | false | DefaultConfiguration['loading']
|
||||
manifest?: {
|
||||
// eslint-disable-next-line camelcase
|
||||
theme_color?: string
|
||||
}
|
||||
pageTransition?: string | DefaultConfiguration['pageTransition']
|
||||
|
@ -14,7 +14,11 @@ import ModuleContainer from './module'
|
||||
import Resolver from './resolver'
|
||||
|
||||
declare global {
|
||||
var __NUXT_DEV__: boolean
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
__NUXT_DEV__: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default class Nuxt extends Hookable {
|
||||
|
@ -49,7 +49,7 @@ function cleanChildrenRoutes (routes: NuxtRouteConfig[], isChild = false, routeN
|
||||
routes.forEach((route) => {
|
||||
route.path = isChild ? route.path.replace('/', '') : route.path
|
||||
if (route.path.includes('?')) {
|
||||
const names = typeof route.name === 'string' && route.name.split(routeNameSplitter) || []
|
||||
const names = typeof route.name === 'string' ? route.name.split(routeNameSplitter) : []
|
||||
const paths = route.path.split('/')
|
||||
if (!isChild) {
|
||||
paths.shift()
|
||||
|
@ -22,6 +22,7 @@ export const timeout = function timeout <T> (
|
||||
) {
|
||||
let timerId: NodeJS.Timeout
|
||||
const warpPromise = promiseFinally(fn, () => clearTimeout(timerId))
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const timerPromise = new Promise((resolve, reject) => {
|
||||
timerId = setTimeout(() => reject(new Error(msg)), ms)
|
||||
})
|
||||
|
@ -136,7 +136,7 @@ export default function nodeExternals (options) {
|
||||
: readDir(modulesDir).filter(isNotBinary)
|
||||
|
||||
// return an externals function
|
||||
return function ({ context, request }, callback) {
|
||||
return function ({ context: _context, request }, callback) {
|
||||
const moduleName = getModuleName(request, includeAbsolutePaths)
|
||||
if (
|
||||
contains(nodeModules, moduleName) &&
|
||||
|
Loading…
Reference in New Issue
Block a user