From c4823f27a85b2c1fb72c31d50acbdd87ef4b341f Mon Sep 17 00:00:00 2001 From: cj Date: Thu, 8 Dec 2016 09:41:20 -0600 Subject: [PATCH] added no-console to eslint --- .eslintrc.js | 4 +++- bin/nuxt-build | 6 +++--- bin/nuxt-generate | 6 +++--- examples/auth-routes/server.js | 4 ++-- lib/app/client.js | 2 +- lib/build/index.js | 14 +++++++------- lib/generate.js | 6 +++--- lib/render.js | 2 +- lib/server.js | 2 +- 9 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 53a5ff72a2..fc4bf8aeb8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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: {} } diff --git a/bin/nuxt-build b/bin/nuxt-build index c32dc0221d..5ccd3e895f 100755 --- a/bin/nuxt-build +++ b/bin/nuxt-build @@ -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) }) diff --git a/bin/nuxt-generate b/bin/nuxt-generate index 5d0272cd77..f8fce471ee 100755 --- a/bin/nuxt-generate +++ b/bin/nuxt-generate @@ -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() }) diff --git a/examples/auth-routes/server.js b/examples/auth-routes/server.js index 0f8c352f05..164caf224b 100644 --- a/examples/auth-routes/server.js +++ b/examples/auth-routes/server.js @@ -37,9 +37,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) }) diff --git a/lib/app/client.js b/lib/app/client.js index 5e5522cb2d..5430cf00a2 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -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 }) diff --git a/lib/build/index.js b/lib/build/index.js index 4fa69d3c7b..e213fdc282 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -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) diff --git a/lib/generate.js b/lib/generate.js index 7d00286663..a8e20e10e4 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -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) @@ -119,8 +119,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) diff --git a/lib/render.js b/lib/render.js index 4e9cc52989..f88fb77e76 100644 --- a/lib/render.js +++ b/lib/render.js @@ -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) { diff --git a/lib/server.js b/lib/server.js index 7dc8d7ef69..4d61bf6feb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -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 }