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