Browse Source

Merge pull request #120 from eliperelman/fixing-linting

Fixing linting to run for all packages
v6-dev
Eli Perelman 8 years ago
committed by GitHub
parent
commit
04e96b2f3f
  1. 2
      package.json
  2. 10
      packages/neutrino-preset-jest/src/index.js
  3. 4
      packages/neutrino-preset-mocha/src/index.js
  4. 4
      packages/neutrino-preset-mocha/src/mocha.js
  5. 12
      packages/neutrino/src/neutrino.js

2
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",

10
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('<rootDir>', aliases[key]));
.map(key => Object.assign(options.moduleNameMapper, { [key]: join('<rootDir>', 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()));
});
});
};

4
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
)
);
});
};

4
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);

12
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);
@ -129,6 +131,7 @@ class Neutrino extends EventEmitter {
const config = this.getWebpackOptions();
const compiler = webpack(config);
// eslint-disable-next-line consistent-return
compiler.run((err, stats) => {
const failed = this.handleErrors(err, stats);
@ -136,6 +139,7 @@ class Neutrino extends EventEmitter {
return reject();
}
// eslint-disable-next-line no-console
console.log(stats.toString({
colors: true,
chunks: false,

Loading…
Cancel
Save