Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

按照eslint规则,消除所有eslint error #607

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion src/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 8 additions & 3 deletions src/roadhog.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable global-require */

import chalk from 'chalk';
import { fork } from 'child_process';

Expand All @@ -19,24 +21,26 @@ 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',
};
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}`),
Expand All @@ -52,6 +56,7 @@ switch (aliasedScript) {
proc.kill();
});
break;
}
default:
console.log(`Unknown script ${chalk.cyan(script)}.`);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
24 changes: 11 additions & 13 deletions src/utils/getEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
};
}, {});
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand All @@ -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));
Expand Down