mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
lint: Update linting rule on space-before-paren
This commit is contained in:
parent
69fa6fc637
commit
83815de91b
@ -22,7 +22,14 @@ module.exports = {
|
||||
// allow debugger during development
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
||||
// do not allow console.logs etc...
|
||||
'no-console': 2
|
||||
'no-console': 2,
|
||||
'space-before-function-paren': [
|
||||
2,
|
||||
{
|
||||
anonymous: 'always',
|
||||
named: 'never'
|
||||
}
|
||||
],
|
||||
},
|
||||
globals: {}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import { isUrl, urlJoin } from 'utils'
|
||||
| webpack config files
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
export default function webpackBaseConfig (name) {
|
||||
export default function webpackBaseConfig(name) {
|
||||
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
||||
|
||||
const config = {
|
||||
@ -113,7 +113,7 @@ export default function webpackBaseConfig (name) {
|
||||
|
||||
// Workaround for hiding Warnings about plugins without a default export (#1179)
|
||||
config.plugins.push({
|
||||
apply (compiler) {
|
||||
apply(compiler) {
|
||||
compiler.plugin('done', stats => {
|
||||
stats.compilation.warnings = stats.compilation.warnings.filter(warn => {
|
||||
if (warn.name === 'ModuleDependencyWarning' && warn.message.includes(`export 'default'`) && warn.message.includes('plugin')) {
|
||||
|
@ -24,7 +24,7 @@ debug.color = 2 // Force green color
|
||||
| In production, will generate public/dist/style.css
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
export default function webpackClientConfig () {
|
||||
export default function webpackClientConfig() {
|
||||
let config = base.call(this, 'client')
|
||||
|
||||
// App entry
|
||||
@ -48,7 +48,7 @@ export default function webpackClientConfig () {
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'common',
|
||||
filename: this.options.build.filenames.vendor,
|
||||
minChunks (module, count) {
|
||||
minChunks(module, count) {
|
||||
// In the dev we use on-demand-entries.
|
||||
// So, it makes no sense to use commonChunks based on the minChunks count.
|
||||
// Instead, we move all the code in node_modules into each of the pages.
|
||||
@ -222,7 +222,7 @@ export default function webpackClientConfig () {
|
||||
if (typeof this.options.build.extend === 'function') {
|
||||
const isDev = this.options.dev
|
||||
const extendedConfig = this.options.build.extend.call(this, config, {
|
||||
get dev () {
|
||||
get dev() {
|
||||
console.warn('dev has been deprecated in build.extend(), please use isDev') // eslint-disable-line no-console
|
||||
return isDev
|
||||
},
|
||||
|
@ -8,7 +8,7 @@ import ClientConfig from './client.config'
|
||||
| https://github.com/webpack/webpack/tree/master/examples/dll
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
export default function webpackDllConfig (_refConfig) {
|
||||
export default function webpackDllConfig(_refConfig) {
|
||||
const refConfig = _refConfig || new ClientConfig()
|
||||
|
||||
const name = refConfig.name + '-dll'
|
||||
|
@ -11,7 +11,7 @@ import base from './base.config.js'
|
||||
| Webpack Server Config
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
export default function webpackServerConfig () {
|
||||
export default function webpackServerConfig() {
|
||||
let config = base.call(this, 'server')
|
||||
|
||||
// env object defined in nuxt.config.js
|
||||
@ -78,7 +78,7 @@ export default function webpackServerConfig () {
|
||||
if (typeof this.options.build.extend === 'function') {
|
||||
const isDev = this.options.dev
|
||||
const extendedConfig = this.options.build.extend.call(this, config, {
|
||||
get dev () {
|
||||
get dev() {
|
||||
console.warn('dev has been deprecated in build.extend(), please use isDev') // eslint-disable-line no-console
|
||||
return isDev
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ExtractTextPlugin from 'extract-text-webpack-plugin'
|
||||
import { join } from 'path'
|
||||
|
||||
export default function styleLoader (ext, loaders = [], isVueLoader = false) {
|
||||
export default function styleLoader(ext, loaders = [], isVueLoader = false) {
|
||||
// Normalize loaders
|
||||
loaders = (Array.isArray(loaders) ? loaders : [loaders]).map(loader => {
|
||||
if (typeof loader === 'string') {
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { resolve, relative, sep } from 'path'
|
||||
import _ from 'lodash'
|
||||
|
||||
export function encodeHtml (str) {
|
||||
export function encodeHtml(str) {
|
||||
return str.replace(/</g, '<').replace(/>/g, '>')
|
||||
}
|
||||
|
||||
export function getContext (req, res) {
|
||||
export function getContext(req, res) {
|
||||
return { req, res }
|
||||
}
|
||||
|
||||
export function setAnsiColors (ansiHTML) {
|
||||
export function setAnsiColors(ansiHTML) {
|
||||
ansiHTML.setColors({
|
||||
reset: ['efefef', 'a6004c'],
|
||||
darkgrey: '5a012b',
|
||||
@ -22,21 +22,21 @@ export function setAnsiColors (ansiHTML) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function waitFor (ms) {
|
||||
export async function waitFor(ms) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(resolve, (ms || 0))
|
||||
})
|
||||
}
|
||||
|
||||
export function urlJoin () {
|
||||
export function urlJoin() {
|
||||
return [].slice.call(arguments).join('/').replace(/\/+/g, '/').replace(':/', '://')
|
||||
}
|
||||
|
||||
export function isUrl (url) {
|
||||
export function isUrl(url) {
|
||||
return (url.indexOf('http') === 0 || url.indexOf('//') === 0)
|
||||
}
|
||||
|
||||
export function promisifyRoute (fn) {
|
||||
export function promisifyRoute(fn) {
|
||||
// If routes is an array
|
||||
if (Array.isArray(fn)) {
|
||||
return Promise.resolve(fn)
|
||||
@ -59,15 +59,15 @@ export function promisifyRoute (fn) {
|
||||
return promise
|
||||
}
|
||||
|
||||
export function sequence (tasks, fn) {
|
||||
export function sequence(tasks, fn) {
|
||||
return tasks.reduce((promise, task) => promise.then(() => fn(task)), Promise.resolve())
|
||||
}
|
||||
|
||||
export function parallel (tasks, fn) {
|
||||
export function parallel(tasks, fn) {
|
||||
return Promise.all(tasks.map(task => fn(task)))
|
||||
}
|
||||
|
||||
export function chainFn (base, fn) {
|
||||
export function chainFn(base, fn) {
|
||||
/* istanbul ignore if */
|
||||
if (!(fn instanceof Function)) {
|
||||
return
|
||||
@ -90,13 +90,13 @@ export function chainFn (base, fn) {
|
||||
}
|
||||
}
|
||||
|
||||
export function isPureObject (o) {
|
||||
export function isPureObject(o) {
|
||||
return !Array.isArray(o) && typeof o === 'object'
|
||||
}
|
||||
|
||||
export const isWindows = /^win/.test(process.platform)
|
||||
|
||||
export function wp (p = '') {
|
||||
export function wp(p = '') {
|
||||
/* istanbul ignore if */
|
||||
if (isWindows) {
|
||||
return p.replace(/\\/g, '\\\\')
|
||||
@ -104,7 +104,7 @@ export function wp (p = '') {
|
||||
return p
|
||||
}
|
||||
|
||||
export function wChunk (p = '') {
|
||||
export function wChunk(p = '') {
|
||||
/* istanbul ignore if */
|
||||
if (isWindows) {
|
||||
return p.replace(/\//g, '\\\\')
|
||||
@ -116,7 +116,7 @@ const reqSep = /\//g
|
||||
const sysSep = _.escapeRegExp(sep)
|
||||
const normalize = string => string.replace(reqSep, sysSep)
|
||||
|
||||
export function r () {
|
||||
export function r() {
|
||||
let args = Array.prototype.slice.apply(arguments)
|
||||
let lastArg = _.last(args)
|
||||
|
||||
@ -127,7 +127,7 @@ export function r () {
|
||||
return wp(resolve(...args.map(normalize)))
|
||||
}
|
||||
|
||||
export function relativeTo () {
|
||||
export function relativeTo() {
|
||||
let args = Array.prototype.slice.apply(arguments)
|
||||
let dir = args.shift()
|
||||
|
||||
@ -147,7 +147,7 @@ export function relativeTo () {
|
||||
return wp(rp)
|
||||
}
|
||||
|
||||
export function flatRoutes (router, path = '', routes = []) {
|
||||
export function flatRoutes(router, path = '', routes = []) {
|
||||
router.forEach((r) => {
|
||||
if (!r.path.includes(':') && !r.path.includes('*')) {
|
||||
/* istanbul ignore if */
|
||||
@ -161,7 +161,7 @@ export function flatRoutes (router, path = '', routes = []) {
|
||||
return routes
|
||||
}
|
||||
|
||||
export function cleanChildrenRoutes (routes, isChild = false) {
|
||||
export function cleanChildrenRoutes(routes, isChild = false) {
|
||||
let start = -1
|
||||
let routesIndex = []
|
||||
routes.forEach((route) => {
|
||||
@ -207,7 +207,7 @@ export function cleanChildrenRoutes (routes, isChild = false) {
|
||||
return routes
|
||||
}
|
||||
|
||||
export function createRoutes (files, srcDir) {
|
||||
export function createRoutes(files, srcDir) {
|
||||
let routes = []
|
||||
files.forEach((file) => {
|
||||
let keys = file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/{2,}/g, '/').split('/').slice(1)
|
||||
|
@ -5,7 +5,7 @@ import VueServerRenderer from 'vue-server-renderer'
|
||||
import LRU from 'lru-cache'
|
||||
|
||||
export default class MetaRenderer {
|
||||
constructor (nuxt, renderer) {
|
||||
constructor(nuxt, renderer) {
|
||||
this.nuxt = nuxt
|
||||
this.renderer = renderer
|
||||
this.options = nuxt.options
|
||||
@ -22,7 +22,7 @@ export default class MetaRenderer {
|
||||
})
|
||||
}
|
||||
|
||||
getMeta (url) {
|
||||
getMeta(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const vm = new Vue({
|
||||
render: (h) => h(), // Render empty html tag
|
||||
@ -35,7 +35,7 @@ export default class MetaRenderer {
|
||||
})
|
||||
}
|
||||
|
||||
async render ({ url = '/' }) {
|
||||
async render({ url = '/' }) {
|
||||
let meta = this.cache.get(url)
|
||||
|
||||
if (meta) {
|
||||
|
@ -22,7 +22,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
dev: false,
|
||||
head: {
|
||||
titleTemplate (titleChunk) {
|
||||
titleTemplate(titleChunk) {
|
||||
return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js'
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ test('Fail with routes() which throw an error', async t => {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
dev: false,
|
||||
generate: {
|
||||
async routes () {
|
||||
async routes() {
|
||||
throw new Error('Not today!')
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
dev: false,
|
||||
head: {
|
||||
titleTemplate (titleChunk) {
|
||||
titleTemplate(titleChunk) {
|
||||
return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js'
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user