Skip to content

Commit 3e03624

Browse files
authored
update eslint config (gucong3000#22)
1 parent 1345a4c commit 3e03624

File tree

10 files changed

+38
-29
lines changed

10 files changed

+38
-29
lines changed

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
"node": true
66
},
77
"extends": [
8-
"eslint:recommended"
8+
"standard"
99
],
1010
"root": true,
1111
"rules": {
12+
"prefer-arrow-callback": [
13+
"error"
14+
],
1215
"arrow-spacing": [
1316
"error",
1417
{
@@ -46,6 +49,9 @@
4649
{
4750
}
4851
],
52+
"no-tabs": [
53+
"off"
54+
],
4955
"quotes": [
5056
"error",
5157
"single",

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22
const config = require('./lib/config')(process.argv);
33
Object.keys(config).forEach(key => {
44
process.env['npm_config_' + key] = config[key];

lib/cli.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env node
22

3-
'use strict';
43
const npmrc = require('./npmrc');
54
const env = require('./env');
65
const path = require('path');

lib/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
'use strict';
2-
function getConf(argv) {
1+
2+
function getConf (argv) {
33
const npmrc = {
44
registry: 'http://registry.npm.taobao.org',
55
disturl: 'http://npm.taobao.org/dist',
@@ -12,7 +12,7 @@ function getConf(argv) {
1212
profiler_binary_host_mirror: '{mirrors}node-inspector/',
1313
python_mirror: '{mirrors}python',
1414
sass_binary_site: '{mirrors}node-sass',
15-
sqlite3_binary_site: '{mirrors}sqlite3',
15+
sqlite3_binary_site: '{mirrors}sqlite3'
1616
};
1717

1818
argv.forEach(arg => {

lib/env.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
'use strict';
1+
22
const path = require('path');
33
const os = require('os');
44
const exec = (require('util').promisify || require('util.promisify'))(require('child_process').execFile);
55
const fs = require('fs-extra');
66

77
const MIRRORS = {
8-
iojs:[
8+
iojs: [
99
'IOJS_ORG_MIRROR',
1010
'NODIST_IOJS_MIRROR',
1111
'NVM_IOJS_ORG_MIRROR',
1212
'NVMW_IOJS_ORG_MIRROR'
1313
],
14-
node:[
14+
node: [
1515
'NODEJS_ORG_MIRROR',
1616
'NODIST_NODE_MIRROR',
1717
'NVM_NODEJS_ORG_MIRROR',
@@ -22,7 +22,7 @@ const MIRRORS = {
2222
]
2323
};
2424

25-
function getMirrors(tmp) {
25+
function getMirrors (tmp) {
2626
return Array.prototype.concat.apply(
2727
[],
2828
Object.keys(MIRRORS).map(project => {
@@ -35,7 +35,7 @@ function getMirrors(tmp) {
3535
);
3636
}
3737

38-
function envForWin() {
38+
function envForWin () {
3939
const cmdTmpSetx = (key, url) => ['SETX', key, url];
4040
const cmdTmpReg = (key, url) => ['REG', 'ADD', 'HKCU\\Environment', '/v', key, '/d', url, '/f'];
4141

@@ -45,8 +45,7 @@ function envForWin() {
4545
).then(getMirrors).then(cmds => Promise.all(cmds.map(cmdArgs => exec(cmdArgs[0], cmdArgs.slice(1)))));
4646
}
4747

48-
function envInProfile() {
49-
48+
function envInProfile () {
5049
// 环境变量信息转换为shell脚本
5150
let sh = getMirrors((key, url) => `export ${key}=${url}`);
5251

lib/install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22
const npmrc = require('./npmrc');
33
const env = require('./env');
44

lib/npmrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
'use strict';
1+
22
const fs = require('fs-extra');
33
const config = require('./config');
44

5-
function setConf(argv, configFile) {
5+
function setConf (argv, configFile) {
66
const npmrc = config(argv);
77

88
// 读取npmrc文件
@@ -30,7 +30,7 @@ function setConf(argv, configFile) {
3030
// 将文件中没有的配置项,追加到其末尾
3131
Object.keys(npmrc).forEach(key => {
3232
if (npmrc[key]) {
33-
config.push( key + '=' + npmrc[key]);
33+
config.push(key + '=' + npmrc[key]);
3434
}
3535
});
3636

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
"description": "Mirrors in China about node.js",
1313
"devDependencies": {
1414
"eslint": "^4.13.1",
15+
"eslint-config-standard": "^11.0.0-beta.0",
16+
"eslint-plugin-import": "^2.8.0",
17+
"eslint-plugin-node": "^5.2.1",
18+
"eslint-plugin-promise": "^3.6.0",
19+
"eslint-plugin-standard": "^3.0.1",
1520
"mocha": "^4.0.1"
1621
},
1722
"homepage": "https://github.com/gucong3000/mirror-config-china#readme",
@@ -31,7 +36,7 @@
3136
"scripts": {
3237
"preinstall": "node -e \"require('util').promisify.call\" || npm i util.promisify",
3338
"install": "node lib/install",
34-
"pretest": "eslint lib/**/*.js *.js",
39+
"pretest": "eslint lib test *.js",
3540
"test": "mocha"
3641
},
3742
"version": "2.2.0"
File renamed without changes.

test/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
'use strict';
1+
22
const assert = require('assert');
33
const util = require('util');
44
if (!util.promisify) {
55
util.promisify = require('util.promisify');
66
}
77
const exec = util.promisify(require('child_process').execFile);
88

9-
describe('environment variables', function() {
9+
describe('environment variables', () => {
1010
before(() => {
11-
if (process.platform == 'win32') {
11+
if (process.platform === 'win32') {
1212
return exec('REG', ['QUERY', 'HKCU\\Environment']).then(regs => {
1313
regs.stdout.replace(/^\s*(\w+)\s+REG_\w+\s*(.+)$/gm, (s, key, value) => {
1414
process.env[key] = value;
@@ -17,31 +17,31 @@ describe('environment variables', function() {
1717
}
1818
});
1919

20-
it('NODEJS_ORG_MIRROR', function() {
20+
it('NODEJS_ORG_MIRROR', () => {
2121
assert.equal(process.env.NODEJS_ORG_MIRROR, 'https://npm.taobao.org/mirrors/node');
2222
});
2323

24-
it('NVM_NODEJS_ORG_MIRROR', function() {
24+
it('NVM_NODEJS_ORG_MIRROR', () => {
2525
assert.equal(process.env.NVM_NODEJS_ORG_MIRROR, 'https://npm.taobao.org/mirrors/node');
2626
});
2727

28-
it('IOJS_ORG_MIRROR', function() {
28+
it('IOJS_ORG_MIRROR', () => {
2929
assert.equal(process.env.IOJS_ORG_MIRROR, 'https://npm.taobao.org/mirrors/iojs');
3030
});
3131

32-
it('NVM_IOJS_ORG_MIRROR', function() {
32+
it('NVM_IOJS_ORG_MIRROR', () => {
3333
assert.equal(process.env.NVM_IOJS_ORG_MIRROR, 'https://npm.taobao.org/mirrors/iojs');
3434
});
3535
});
3636

37-
describe('npm config', function() {
38-
it('electron', function() {
37+
describe('npm config', () => {
38+
it('electron', () => {
3939
assert.equal(process.env.npm_config_electron_mirror, 'https://npm.taobao.org/mirrors/electron/');
4040
});
41-
it('git4win_mirror', function() {
41+
it('git4win_mirror', () => {
4242
assert.equal(process.env.npm_config_git4win_mirror, 'https://npm.taobao.org/mirrors/git-for-windows');
4343
});
44-
it('python_mirror', function() {
44+
it('python_mirror', () => {
4545
assert.equal(process.env.npm_config_python_mirror, 'https://npm.taobao.org/mirrors/python');
4646
});
4747
});

0 commit comments

Comments
 (0)