diff --git a/.gitignore b/.gitignore index 57490e6..c2d453d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,10 +6,12 @@ npm-debug.log* /test/**/dist /examples/**/dist /examples/**/node_modules +package-lock.json # tnpm cache directory /test/**/.cache # IDE .idea +.vscode diff --git a/src/dev.js b/src/dev.js index 902ec2f..58aacc9 100644 --- a/src/dev.js +++ b/src/dev.js @@ -29,7 +29,7 @@ export default function runDev(opts = {}) { let returnedWatchConfig = null; try { const configObj = getConfig({ cwd }); - config = configObj.config; + ({ config } = configObj); returnedWatchConfig = configObj.watch; debug(`user config: ${JSON.stringify(config)}`); } catch (e) { diff --git a/src/roadhog.js b/src/roadhog.js index 20525e5..13fe900 100644 --- a/src/roadhog.js +++ b/src/roadhog.js @@ -1,3 +1,5 @@ +/* eslint-disable global-require */ + import chalk from 'chalk'; import { fork } from 'child_process'; @@ -19,7 +21,8 @@ if (major * 10 + minor * 1 < 65) { // Notify update when process exits const updater = require('update-notifier'); const pkg = require('../package.json'); -updater({ pkg: pkg }).notify({ defer: true }); + +updater({ pkg }).notify({ defer: true }); const scriptAlias = { server: 'dev', @@ -27,16 +30,17 @@ const scriptAlias = { const aliasedScript = scriptAlias[script] || script; switch (aliasedScript) { case '-v': - case '--version': + case '--version': { const pkg = require('../package.json'); console.log(pkg.version); if (!(pkg._from && pkg._resolved)) { console.log(chalk.cyan('@local')); } break; + } case 'build': case 'dev': - case 'test': + case 'test': { require('atool-monitor').emit(); const proc = fork( require.resolve(`../lib/scripts/${aliasedScript}`), @@ -52,6 +56,7 @@ switch (aliasedScript) { proc.kill(); }); break; + } default: console.log(`Unknown script ${chalk.cyan(script)}.`); break; diff --git a/src/scripts/build.js b/src/scripts/build.js index 537a6ed..3b5f773 100644 --- a/src/scripts/build.js +++ b/src/scripts/build.js @@ -2,10 +2,10 @@ import chalk from 'chalk'; import yargs from 'yargs'; import build from '../build'; -const argv = yargs.option('watch', { +const { argv } = yargs.option('watch', { alias: 'w', default: false, -}).argv; +}); build({ cwd: process.cwd(), diff --git a/src/utils/getEntry.js b/src/utils/getEntry.js index 29672bc..1b3e5da 100644 --- a/src/utils/getEntry.js +++ b/src/utils/getEntry.js @@ -38,19 +38,17 @@ export default function(opts = {}) { if (isBuild) { return entryObj; } else { - return Object.keys(entryObj).reduce( - (memo, key) => - !Array.isArray(entryObj[key]) - ? { - ...memo, - [key]: [webpackHotDevClientPath, entryObj[key]], - } - : { - ...memo, - [key]: entryObj[key], - }, - {}, - ); + return Object.keys(entryObj).reduce((memo, key) => { + return !Array.isArray(entryObj[key]) + ? { + ...memo, + [key]: [webpackHotDevClientPath, entryObj[key]], + } + : { + ...memo, + [key]: entryObj[key], + }; + }, {}); } } diff --git a/src/utils/mock.js b/src/utils/mock.js index e7fe4e3..2591b1b 100644 --- a/src/utils/mock.js +++ b/src/utils/mock.js @@ -25,6 +25,8 @@ function getConfig() { delete require.cache[file]; } }); + /* eslint-disable global-require */ + /* eslint-disable import/no-dynamic-require */ return require(configFile); } else { return {}; @@ -51,6 +53,7 @@ function createProxy(method, path, target) { let matchPath = req.originalUrl; const matches = matchPath.match(path); if (matches.length > 1) { + /* eslint-disable prefer-destructuring */ matchPath = matches[1]; } return winPath(join(url.parse(target).path, matchPath));