From 6968fcbdde48a50148d7251b87422644182a18e9 Mon Sep 17 00:00:00 2001 From: Eli Perelman Date: Fri, 17 Mar 2017 08:07:30 -0500 Subject: [PATCH] Fixing linting to run for all packages --- package.json | 2 +- packages/neutrino-preset-jest/src/index.js | 10 ++-- packages/neutrino-preset-mocha/src/index.js | 4 +- packages/neutrino-preset-mocha/src/mocha.js | 4 +- packages/neutrino/src/neutrino.js | 52 +++++++++++---------- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 9ec6311..b7294ce 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", "repository": "mozilla-neutrino/neutrino-dev", "scripts": { - "lint": "eslint packages/**/*.js", + "lint": "eslint packages/*/*.js packages/*/src/**/*.js", "bootstrap": "oao bootstrap", "changelog": "changelog mozilla-neutrino/neutrino-dev all --markdown > CHANGELOG.md", "deps:add": "oao add", diff --git a/packages/neutrino-preset-jest/src/index.js b/packages/neutrino-preset-jest/src/index.js index bf4fbd4..45f1a72 100644 --- a/packages/neutrino-preset-jest/src/index.js +++ b/packages/neutrino-preset-jest/src/index.js @@ -12,7 +12,7 @@ function normalizeJestOptions(jestOptions, config, args) { Object .keys(aliases) - .map(key => options.moduleNameMapper[key] = join('', aliases[key])); + .map(key => Object.assign(options.moduleNameMapper, { [key]: join('', aliases[key]) })); options.moduleFileExtensions = [...new Set([ ...options.moduleFileExtensions, @@ -33,12 +33,12 @@ function normalizeJestOptions(jestOptions, config, args) { return options; } -module.exports = neutrino => { - neutrino.on('test', args => { +module.exports = (neutrino) => { + neutrino.on('test', (args) => { const jestOptions = merge({ bail: true, transform: { - "\\.(js|jsx)$": require.resolve('./transformer') + '\\.(js|jsx)$': require.resolve('./transformer') }, roots: [neutrino.options.tests], testRegex: '(_test|_spec|\\.test|\\.spec)\\.jsx?$', @@ -75,7 +75,7 @@ module.exports = neutrino => { const dir = options.rootDir || neutrino.options.root; writeFileSync(configFile, `${JSON.stringify(options, null, 2)}\n`); - runCLI(cliOptions, dir, result => result.numFailedTests || result.numFailedTestSuites ? reject() : resolve()); + runCLI(cliOptions, dir, result => (result.numFailedTests || result.numFailedTestSuites ? reject() : resolve())); }); }); }; diff --git a/packages/neutrino-preset-mocha/src/index.js b/packages/neutrino-preset-mocha/src/index.js index 8db4953..7978411 100644 --- a/packages/neutrino-preset-mocha/src/index.js +++ b/packages/neutrino-preset-mocha/src/index.js @@ -2,7 +2,7 @@ const mocha = require('./mocha'); const merge = require('deepmerge'); const loaderMerge = require('neutrino-middleware-loader-merge'); -module.exports = neutrino => { +module.exports = (neutrino) => { neutrino.on('test', ({ files }) => { neutrino.use(loaderMerge('compile', 'babel'), { env: { @@ -16,6 +16,6 @@ module.exports = neutrino => { merge({ reporter: 'spec', ui: 'tdd', bail: true }, neutrino.options.mocha || {}), neutrino.config.module.rule('compile').use('babel').get('options'), files - ) + ); }); }; diff --git a/packages/neutrino-preset-mocha/src/mocha.js b/packages/neutrino-preset-mocha/src/mocha.js index b615ada..8dfd029 100644 --- a/packages/neutrino-preset-mocha/src/mocha.js +++ b/packages/neutrino-preset-mocha/src/mocha.js @@ -3,13 +3,13 @@ const toParam = require('change-case').paramCase; let proc; -module.exports = (mochaOpts = {}, babelOpts = {}, files = []) => new Promise(resolve => { +module.exports = (mochaOpts = {}, babelOpts = {}, files = []) => new Promise((resolve) => { if (proc) { proc.kill(); } if (files.length) { - mochaOpts.recursive = true; + Object.assign(mochaOpts, { recursive: true }); } process.env.NEUTRINO_BABEL_CONFIG = JSON.stringify(babelOpts); diff --git a/packages/neutrino/src/neutrino.js b/packages/neutrino/src/neutrino.js index 1f24936..75d510e 100644 --- a/packages/neutrino/src/neutrino.js +++ b/packages/neutrino/src/neutrino.js @@ -6,7 +6,7 @@ const Config = require('webpack-chain'); const ora = require('ora'); const merge = require('deepmerge'); -const normalizePath = (path, root) => isAbsolute(path) ? path : join(root, path); +const normalizePath = (path, root) => (isAbsolute(path) ? path : join(root, path)); class Neutrino extends EventEmitter { constructor(options = {}) { @@ -16,7 +16,7 @@ class Neutrino extends EventEmitter { const source = normalizePath(options.source || 'src', root); const output = normalizePath(options.output || 'build', root); const tests = normalizePath(options.tests || 'test', root); - const node_modules = normalizePath(options.node_modules || 'node_modules', root); + const node_modules = normalizePath(options.node_modules || 'node_modules', root); // eslint-disable-line camelcase const entry = normalizePath(options.entry || 'index.js', source); this.config = new Config(); @@ -27,6 +27,7 @@ class Neutrino extends EventEmitter { preset(this, options); } + /* eslint-disable no-console */ handleErrors(err, stats) { if (err) { console.error(err.stack || err); @@ -47,6 +48,7 @@ class Neutrino extends EventEmitter { return false; } + /* eslint-enable no-console */ getWebpackOptions() { return this.config.toConfig(); @@ -85,7 +87,7 @@ class Neutrino extends EventEmitter { } devServer() { - return new Promise(resolve => { + return new Promise((resolve) => { const starting = ora('Starting development server').start(); const config = this.getWebpackOptions(); const protocol = config.devServer.https ? 'https' : 'http'; @@ -111,7 +113,7 @@ class Neutrino extends EventEmitter { } watcher() { - return new Promise(resolve => { + return new Promise((resolve) => { const building = ora('Waiting for initial build to finish').start(); const config = this.getWebpackOptions(); const compiler = webpack(config); @@ -125,26 +127,28 @@ class Neutrino extends EventEmitter { } builder() { - return new Promise((resolve, reject) => { - const config = this.getWebpackOptions(); - const compiler = webpack(config); - - compiler.run((err, stats) => { - const failed = this.handleErrors(err, stats); - - if (failed) { - return reject(); - } - - console.log(stats.toString({ - colors: true, - chunks: false, - children: false - })); - - resolve(); - }); - }); + return new Promise((resolve, reject) => { + const config = this.getWebpackOptions(); + const compiler = webpack(config); + + // eslint-disable-next-line consistent-return + compiler.run((err, stats) => { + const failed = this.handleErrors(err, stats); + + if (failed) { + return reject(); + } + + // eslint-disable-next-line no-console + console.log(stats.toString({ + colors: true, + chunks: false, + children: false + })); + + resolve(); + }); + }); } }