Skip to content

Commit

Permalink
lint: Update linting rule on space-before-paren
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Oct 30, 2017
1 parent 69fa6fc commit 83815de
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 34 deletions.
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
}
4 changes: 2 additions & 2 deletions lib/builder/webpack/base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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')) {
Expand Down
6 changes: 3 additions & 3 deletions lib/builder/webpack/client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion lib/builder/webpack/dll.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions lib/builder/webpack/server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion lib/builder/webpack/style-loader.js
Original file line number Diff line number Diff line change
@@ -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') {
Expand Down
36 changes: 18 additions & 18 deletions lib/common/utils.js
Original file line number Diff line number Diff line change
@@ -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, '&lt;').replace(/>/g, '&gt;')
}

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',
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -90,21 +90,21 @@ 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, '\\\\')
}
return p
}

export function wChunk (p = '') {
export function wChunk(p = '') {
/* istanbul ignore if */
if (isWindows) {
return p.replace(/\//g, '\\\\')
Expand All @@ -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)

Expand All @@ -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()

Expand All @@ -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 */
Expand All @@ -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) => {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lib/core/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -35,7 +35,7 @@ export default class MetaRenderer {
})
}

async render ({ url = '/' }) {
async render({ url = '/' }) {
let meta = this.cache.get(url)

if (meta) {
Expand Down
2 changes: 1 addition & 1 deletion test/basic.dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/basic.fail.generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!')
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Expand Down

0 comments on commit 83815de

Please sign in to comment.