Merge pull request #47 from cj/eslint/no-console

added no-console to eslint
This commit is contained in:
Sébastien Chopin 2016-12-08 18:08:32 +01:00 committed by GitHub
commit ce7e47c7f1
9 changed files with 24 additions and 22 deletions

View File

@ -21,7 +21,9 @@ module.exports = {
// allow async-await
'generator-star-spacing': 0,
// 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...
'no-console': 2
},
globals: {}
}

View File

@ -19,13 +19,13 @@ if (typeof options.rootDir !== 'string') {
}
options.dev = false // Create production build when calling `nuxt build`
console.log('[nuxt] Building...')
console.log('[nuxt] Building...') // eslint-disable-line no-console
const nuxt = new Nuxt(options)
nuxt.build()
.then(() => {
console.log('[nuxt] Building done')
console.log('[nuxt] Building done') // eslint-disable-line no-console
})
.catch((err) => {
console.error(err)
console.error(err) // eslint-disable-line no-console
process.exit(1)
})

View File

@ -19,13 +19,13 @@ if (typeof options.rootDir !== 'string') {
}
options.dev = false // Force production mode (no webpack middlewares called)
console.log('[nuxt] Generating...')
console.log('[nuxt] Generating...') // eslint-disable-line no-console
const nuxt = new Nuxt(options)
nuxt.generate()
.then(() => {
console.log('[nuxt] Generate done')
console.log('[nuxt] Generate done') // eslint-disable-line no-console
})
.catch((err) => {
console.error(err)
console.error(err) // eslint-disable-line no-console
process.exit()
})

View File

@ -39,9 +39,9 @@ const promise = (isProd ? Promise.resolve() : nuxt.build())
promise.then(() => {
app.use(nuxt.render)
app.listen(3000)
console.log('Server is listening on http://localhost:3000')
console.log('Server is listening on http://localhost:3000') // eslint-disable-line no-console
})
.catch((error) => {
console.error(error)
console.error(error) // eslint-disable-line no-console
process.exit(1)
})

View File

@ -282,5 +282,5 @@ Promise.all(resolveComponents)
})
})
.catch((err) => {
console.error('[nuxt.js] Cannot load components', err)
console.error('[nuxt.js] Cannot load components', err) // eslint-disable-line no-console
})

View File

@ -93,9 +93,9 @@ exports.build = function * () {
*/
if (!fs.existsSync(join(this.dir, 'pages'))) {
if (fs.existsSync(join(this.dir, '..', 'pages'))) {
console.error('> No `pages` directory found. Did you mean to run `nuxt` in the parent (`../`) directory?')
console.error('> No `pages` directory found. Did you mean to run `nuxt` in the parent (`../`) directory?') // eslint-disable-line no-console
} else {
console.error('> Couldn\'t find a `pages` directory. Please create one under the project root')
console.error('> Couldn\'t find a `pages` directory. Please create one under the project root') // eslint-disable-line no-console
}
process.exit(1)
}
@ -263,8 +263,8 @@ function webpackWatchAndUpdate () {
this.webpackServerWatcher = serverCompiler.watch({}, (err, stats) => {
if (err) throw err
stats = stats.toJson()
stats.errors.forEach(err => console.error(err))
stats.warnings.forEach(err => console.warn(err))
stats.errors.forEach(err => console.error(err)) // eslint-disable-line no-console
stats.warnings.forEach(err => console.warn(err)) // eslint-disable-line no-console
createRenderer.call(this, mfs.readFileSync(outputPath, 'utf-8'))
})
}
@ -275,7 +275,7 @@ function webpackRunClient () {
const serverCompiler = webpack(clientConfig)
serverCompiler.run((err, stats) => {
if (err) return reject(err)
console.log('[nuxt:build:client]\n', stats.toString({ chunks: false, colors: true }))
console.log('[nuxt:build:client]\n', stats.toString({ chunks: false, colors: true })) // eslint-disable-line no-console
resolve()
})
})
@ -287,7 +287,7 @@ function webpackRunServer () {
const serverCompiler = webpack(serverConfig)
serverCompiler.run((err, stats) => {
if (err) return reject(err)
console.log('[nuxt:build:server]\n', stats.toString({ chunks: false, colors: true }))
console.log('[nuxt:build:server]\n', stats.toString({ chunks: false, colors: true })) // eslint-disable-line no-console
const bundlePath = join(serverConfig.output.path, serverConfig.output.filename)
readFile(bundlePath, 'utf8')
.then((bundle) => {
@ -325,7 +325,7 @@ function watchPages () {
var d = Date.now()
co(generateRoutesAndFiles.bind(this))
.then(() => {
console.log('Time to gen:' + (Date.now() - d) + 'ms')
console.log('Time to gen:' + (Date.now() - d) + 'ms') // eslint-disable-line no-console
})
}, 200)
this.pagesFilesWatcher = chokidar.watch(patterns, options)

View File

@ -72,7 +72,7 @@ module.exports = function () {
if (route.path.includes(':') || route.path.includes('*')) {
const routeParams = this.options.generate.routeParams[route.path]
if (!routeParams) {
console.error(`Could not generate the dynamic route ${route.path}, please add the mapping params in nuxt.config.js (generate.routeParams).`)
console.error(`Could not generate the dynamic route ${route.path}, please add the mapping params in nuxt.config.js (generate.routeParams).`) // eslint-disable-line no-console
return process.exit(1)
}
const toPath = pathToRegexp.compile(route.path)
@ -120,8 +120,8 @@ function resolveRouteParams (routeParams) {
routeParams[routePath] = routeParamsData
})
.catch((e) => {
console.error(`Could not resolve routeParams[${routePath}]`)
console.error(e)
console.error(`Could not resolve routeParams[${routePath}]`) // eslint-disable-line no-console
console.error(e) // eslint-disable-line no-console
process.exit(1)
})
promises.push(promise)

View File

@ -5,7 +5,7 @@ const { getContext } = require('./utils')
exports.render = function (req, res) {
if (!this.renderer && !this.dev) {
console.error('> No build files found, please run `nuxt build` before launching `nuxt start`')
console.error('> No build files found, please run `nuxt build` before launching `nuxt start`') // eslint-disable-line no-console
process.exit(1)
}
if (!this.renderer) {

View File

@ -19,7 +19,7 @@ class Server {
host = host || 'localhost'
port = port || 3000
this.server.listen(port, host, () => {
console.log('Ready on http://%s:%s', host, port)
console.log('Ready on http://%s:%s', host, port) // eslint-disable-line no-console
})
return this
}