Skip to content

Commit

Permalink
chore(package): update eslint to version 5.1.0 (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
gucong3000 authored Jul 11, 2018
1 parent c8906c2 commit 9db2336
Show file tree
Hide file tree
Showing 17 changed files with 296 additions and 254 deletions.
3 changes: 3 additions & 0 deletions lib/shorturl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,7 @@
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/no-skipped-tests.md#readme": "https://goo.gl/Kr7rCp",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/no-synchronous-tests.md#readme": "https://goo.gl/dY21im",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/no-top-level-hooks.md#readme": "https://goo.gl/tSyM9G",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/prefer-arrow-callback.md#readme": "https://goo.gl/NjT9Rh",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/readme.md#readme": "https://goo.gl/3Frz5M",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/valid-suite-description.md#readme": "https://goo.gl/er9Sbi",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/valid-test-description.md#readme": "https://goo.gl/hTGZCi",
Expand Down Expand Up @@ -1580,6 +1581,7 @@
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/restrict-full-import.md#readme": "https://goo.gl/teMjqo",
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/sinon-no-restricted-features.md#readme": "https://goo.gl/xMjySR",
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/sinon-prefer-meaningful-assertions.md#readme": "https://goo.gl/FS9zRu",
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/strict-component-boundaries.md#readme": "https://goo.gl/XC4sxH",
"https://github.com/silvermine/eslint-plugin-silvermine/blob/head/docs/rules/array-indentation.md#readme": "https://goo.gl/jPRnbi",
"https://github.com/silvermine/eslint-plugin-silvermine/blob/head/docs/rules/call-indentation.md#readme": "https://goo.gl/GjMXnD",
"https://github.com/silvermine/eslint-plugin-silvermine/blob/head/docs/rules/fluent-chaining.md#readme": "https://goo.gl/kvuuDo",
Expand Down Expand Up @@ -2271,6 +2273,7 @@
"https://www.npmjs.com/package/eslint-plugin-flowtype#valid-syntax": "https://goo.gl/cV5CgF",
"https://www.npmjs.com/package/eslint-plugin-gettext#gettextno-variable-string": "https://goo.gl/GV1cwe",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#identical-keys": "https://goo.gl/r49Mkv",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#ignore-keys": "https://goo.gl/jWmYmN",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#sorted-keys": "https://goo.gl/7LMG9s",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#valid-json": "https://goo.gl/6W6Uyi",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#valid-message-syntax": "https://goo.gl/6HQ9ey",
Expand Down
3 changes: 3 additions & 0 deletions lib/shorturl_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,7 @@
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/no-skipped-tests.md#readme": "https://t.cn/Rm5ujrB",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/no-synchronous-tests.md#readme": "https://t.cn/Rm5uTqi",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/no-top-level-hooks.md#readme": "https://t.cn/Rm5uYou",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/prefer-arrow-callback.md#readme": "https://t.cn/RdpfI6C",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/readme.md#readme": "https://t.cn/Rm5ujOD",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/valid-suite-description.md#readme": "https://t.cn/Rm5uj3N",
"https://github.com/lo1tuma/eslint-plugin-mocha/blob/head/docs/rules/valid-test-description.md#readme": "https://t.cn/Rm5ujlg",
Expand Down Expand Up @@ -1580,6 +1581,7 @@
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/restrict-full-import.md#readme": "https://t.cn/Rm5rN4u",
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/sinon-no-restricted-features.md#readme": "https://t.cn/Rm5rN4z",
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/sinon-prefer-meaningful-assertions.md#readme": "https://t.cn/Rm5rNbK",
"https://github.com/shopify/eslint-plugin-shopify/blob/head/docs/rules/strict-component-boundaries.md#readme": "https://t.cn/RrTupGb",
"https://github.com/silvermine/eslint-plugin-silvermine/blob/head/docs/rules/array-indentation.md#readme": "https://t.cn/Rm5D9cm",
"https://github.com/silvermine/eslint-plugin-silvermine/blob/head/docs/rules/call-indentation.md#readme": "https://t.cn/Rm5D9x4",
"https://github.com/silvermine/eslint-plugin-silvermine/blob/head/docs/rules/fluent-chaining.md#readme": "https://t.cn/Rm5D9fc",
Expand Down Expand Up @@ -2271,6 +2273,7 @@
"https://www.npmjs.com/package/eslint-plugin-flowtype#valid-syntax": "https://t.cn/Rm5ECJ2",
"https://www.npmjs.com/package/eslint-plugin-gettext#gettextno-variable-string": "https://t.cn/RmVNbsU",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#identical-keys": "https://t.cn/Rm5Bj32",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#ignore-keys": "https://t.cn/RdPcObJ",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#sorted-keys": "https://t.cn/RugB1EV",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#valid-json": "https://t.cn/Rm5Bj3w",
"https://www.npmjs.com/package/eslint-plugin-i18n-json#valid-message-syntax": "https://t.cn/Rm5Bj3b",
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
"to-time": "^1.0.2"
},
"devDependencies": {
"codecov": "^3.0.2",
"codecov": "^3.0.4",
"csslint": "^1.0.5",
"eclint": "^2.7.0",
"eslint": "^4.19.1",
"eslint": "^5.1.0",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-compat": "^2.4.0",
"eslint-plugin-compat": "^2.5.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
Expand All @@ -43,7 +43,7 @@
"goo.gl": "^0.1.4",
"greenkeeper-lockfile": "^1.15.1",
"gulp-csslint": "^1.0.1",
"gulp-eslint": "^4.0.2",
"gulp-eslint": "^5.0.0",
"gulp-html-postcss": "^7.1.3",
"gulp-htmlhint": "^2.1.1",
"gulp-jscs": "^4.1.0",
Expand All @@ -60,7 +60,7 @@
"npm-run-all": "^4.1.3",
"nyc": "^12.0.2",
"proxyquire": "^2.0.1",
"sinon": "^6.1.0",
"sinon": "^6.1.3",
"strip-ansi": "^4.0.0",
"stylelint": "^9.3.0",
"stylelint-config-standard": "^18.2.0",
Expand Down
31 changes: 17 additions & 14 deletions test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const proxyquire = require('proxyquire');
const stripAnsi = require('strip-ansi');
const eslint = require('gulp-eslint');
const through = require('through2');
const Vinyl = require('vinyl');
const inGFW = require('in-gfw');
const vfs = require('vinyl-fs');
const Vinyl = require('vinyl');
const path = require('path');

require('./sandbox');
Expand All @@ -35,20 +36,22 @@ describe('API', () => {
});
});

it('short-doc-url (out GFW)', () => {
const shortDocUrl = proxyquire('../lib/short-doc-url', {
'./locale': 'en_US',
'in-gfw': () => Promise.resolve(false),
});
return shortDocUrl([{
doc: 'http://163.com',
}]).then(errors => {
if (!errors[0].docShort) {
return;
}
assert.ok(/^https?:\/\/goo\.gl\//.test(errors[0].docShort));
if (!inGFW.sync()) {
it('short-doc-url (out GFW)', () => {
const shortDocUrl = proxyquire('../lib/short-doc-url', {
'./locale': 'en_US',
'in-gfw': () => Promise.resolve(false),
});
return shortDocUrl([{
doc: 'http://163.com',
}]).then(errors => {
if (!errors[0].docShort) {
return;
}
assert.ok(/^https?:\/\/goo\.gl\//.test(errors[0].docShort));
});
});
});
}

it('short-doc-url error', () => {
return shortDocUrl([{
Expand Down
32 changes: 17 additions & 15 deletions test/csslint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const sandbox = require('./sandbox');

describe('CSSLint', function () {
this.timeout(10000);
it('console reporter', done => {
return vfs.src('test/fixtures/csslint/invalid.css', {
it('console reporter', () => {
const stream = vfs.src('test/fixtures/csslint/invalid.css', {
base: process.cwd(),
removeBOM: false,
})
Expand All @@ -18,19 +18,19 @@ describe('CSSLint', function () {
.pipe(reporter({
output: true,
blame: false,
})).on('error', ex => {
assert.equal(ex.plugin, 'gulp-reporter');
assert.equal(ex.message, 'Lint failed for: test/fixtures/csslint/invalid.css');
const log = sandbox.getLog();
assert.ok(log.indexOf('test/fixtures/csslint/invalid.css') >= 0);
assert.ok(log.indexOf('(CSSLint order-alphabetical') >= 0);
assert.ok(log.indexOf('(CSSLint duplicate-properties') >= 0);
done();
});
}));
return sandbox.gotError(stream).then(error => {
assert.equal(error.plugin, 'gulp-reporter');
assert.equal(error.message, 'Lint failed for: test/fixtures/csslint/invalid.css');
const log = sandbox.getLog();
assert.ok(log.indexOf('test/fixtures/csslint/invalid.css') >= 0);
assert.ok(log.indexOf('(CSSLint order-alphabetical') >= 0);
assert.ok(log.indexOf('(CSSLint duplicate-properties') >= 0);
});
});

it('browser reporter', done => {
return vfs.src('test/fixtures/csslint/invalid.css', {
it('browser reporter', () => {
const stream = vfs.src('test/fixtures/csslint/invalid.css', {
base: process.cwd(),
removeBOM: false,
})
Expand All @@ -40,12 +40,14 @@ describe('CSSLint', function () {
output: false,
fail: false,
author: null,
})).on('data', file => {
}));
return sandbox.thenable(stream).then(files => {
files.forEach(file => {
const contents = file.contents.toString();
assert.ok(/\W+test\W+fixtures\W+csslint\W+invalid\.css\b/i.test(contents));
assert.ok(/\d+:\d+/.test(contents));
assert.ok(/\bCSSLint order-alphabetical\b/.test(contents));
done();
});
});
});
});
49 changes: 24 additions & 25 deletions test/eclint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,46 @@ const reporter = require('../');
const sandbox = require('./sandbox');

describe('ECLint', () => {
it('console reporter', done => {
return vfs.src('test/fixtures/eclint/invalid.js', {
it('console reporter', () => {
const stream = vfs.src('test/fixtures/eclint/invalid.js', {
base: process.cwd(),
removeBOM: false,
})
.pipe(eclint.check())
.pipe(reporter({
output: true,
author: null,
})).on('error', ex => {
assert.equal(ex.plugin, 'gulp-reporter');
assert.equal(ex.message, 'Lint failed for: test/fixtures/eclint/invalid.js');
}));
return sandbox.gotError(stream).then(error => {
assert.equal(error.plugin, 'gulp-reporter');
assert.equal(error.message, 'Lint failed for: test/fixtures/eclint/invalid.js');

const log = sandbox.getLog();
assert.ok(log.indexOf('(EditorConfig charset http') >= 0);
assert.ok(log.indexOf('(EditorConfig indent_style http') >= 0);
assert.ok(/\bdone\(\)/.test(log));
assert.ok(/@/.test(log));

done();
});
const log = sandbox.getLog();
assert.ok(log.indexOf('(EditorConfig charset http') >= 0);
assert.ok(log.indexOf('(EditorConfig indent_style http') >= 0);
assert.ok(/\bdone\(\)/.test(log));
assert.ok(/@/.test(log));
});
});
it('console reporter without blame', done => {
return vfs.src('test/fixtures/eclint/invalid.js', {
it('console reporter without blame', () => {
const stream = vfs.src('test/fixtures/eclint/invalid.js', {
base: process.cwd(),
removeBOM: false,
})
.pipe(eclint.check())
.pipe(reporter({
output: true,
blame: false,
})).on('error', ex => {
assert.equal(ex.plugin, 'gulp-reporter');
assert.equal(ex.message, 'Lint failed for: test/fixtures/eclint/invalid.js');
}));
return sandbox.gotError(stream).then(error => {
assert.equal(error.plugin, 'gulp-reporter');
assert.equal(error.message, 'Lint failed for: test/fixtures/eclint/invalid.js');

const log = sandbox.getLog();
assert.ok(log.indexOf('(EditorConfig charset http') >= 0);
assert.ok(log.indexOf('(EditorConfig indent_style http') >= 0);
assert.equal(/\bdone\(\)/.test(log), false);
assert.equal(/@/.test(log), false);
done();
});
const log = sandbox.getLog();
assert.ok(log.indexOf('(EditorConfig charset http') >= 0);
assert.ok(log.indexOf('(EditorConfig indent_style http') >= 0);
assert.equal(/\bdone\(\)/.test(log), false);
assert.equal(/@/.test(log), false);
});
});
});
47 changes: 27 additions & 20 deletions test/eslint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ describe('ESLint', () => {
assert.ok(/\n\s+at\s+https?:\/\/(?:\w+\.)?eslint.org\/docs\/rules\/strict$/m.test(error));
})
.on('error', ex => {
assert.equal(ex.plugin, 'gulp-reporter');
done();
try {
assert.equal(ex.plugin, 'gulp-reporter');
done();
} catch (ex) {
done(ex);
}
});
});

Expand All @@ -114,9 +118,13 @@ describe('ESLint', () => {
}
})
.on('error', ex => {
assert.equal(ex.plugin, 'gulp-reporter');
assert.ok(files.length >= 2);
done();
try {
assert.equal(ex.plugin, 'gulp-reporter');
assert.ok(files.length >= 2);
done();
} catch (ex) {
done(ex);
}
});
});

Expand All @@ -132,29 +140,28 @@ describe('ESLint', () => {
.on('error', done);
});

it('not commit file', done => {
it('not commit file', () => {
const message = [];
const stream = eslint({
const srcStream = eslint({
fix: true,
});
stream.pipe(reporter({
const stream = srcStream.pipe(reporter({
fail: false,
output: msg => {
message.push(stripAnsi(msg));
},
}))
.on('finish', () => {
assert.ok(/^\s*0+…?\s+\(Not Committed Yet\s+<not.committed.yet>\s+\d+-\d+-\d+ \d+:\d+:\d+\)$/m.test(message[0]));
done();
})
.on('error', done);

stream.write(new Vinyl({
base: process.cwd(),
path: __filename,
contents: Buffer.from('"use strict";\nalert(console > 1);'),
}));
stream.end();

process.nextTick(() => {
srcStream.end(new Vinyl({
base: process.cwd(),
path: __filename,
contents: Buffer.from('"use strict";\nalert(console > 1);'),
}));
});
return sandbox.thenable(stream).then(() => {
assert.ok(/^\s*0+…?\s+\(Not Committed Yet\s+<not.committed.yet>\s+\d+-\d+-\d+ \d+:\d+:\d+\)$/m.test(message[0]));
});
});

it('warn', done => {
Expand Down
52 changes: 24 additions & 28 deletions test/htmlhint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,35 @@ const sandbox = require('./sandbox');
describe('HTMLHint', () => {
require('../lib/locale');

it('console reporter', (done) => {
return vfs.src('test/fixtures/htmlhint/invalid.html', {
it('console reporter', () => {
const stream = vfs.src('test/fixtures/htmlhint/invalid.html', {
base: process.cwd(),
})
.pipe(htmlhint())
.pipe(reporter({
output: true,
blame: false,
})).on('error', ex => {
assert.equal(ex.plugin, 'gulp-reporter');
assert.equal(ex.message, 'Lint failed for: test/fixtures/htmlhint/invalid.html');
let log = sandbox.getLog().match(/^.*$/igm);
try {
assert.ok(log);
assert.ok(/^test\/fixtures\/htmlhint\/invalid.html$/.test(log.shift()));
log = log.map(log => log.match(/^\s*(\d+):(\d+)\s+\S+\s+(.+?)\s+\(HTMLHint\s+(.+?)\s+(https?.+?)\)$/i));
assert.equal(log[0][1], '01');
assert.equal(log[0][2], '01');
assert.equal(log[1][1], '08');
assert.equal(log[1][2], '01');
assert.equal(log[0][4], 'doctype-first');
assert.equal(log[1][4], 'tag-pair');
if (locale === 'zh_CN') {
assert.equal(log[0][3], 'doctype必须首先声明。');
assert.equal(log[1][3], '标签必须匹配,缺失:[ </h1> ],在第7行匹配开始标签[ <h1> ]失败');
} else {
assert.equal(log[0][3], 'Doctype must be declared first.');
assert.equal(log[1][3], 'Tag must be paired, missing: [ </h1> ], start tag match failed [ <h1> ] on line 7.');
}
done();
} catch (ex) {
done(ex);
}
});
}));
return sandbox.gotError(stream).then(error => {
assert.equal(error.plugin, 'gulp-reporter');
assert.equal(error.message, 'Lint failed for: test/fixtures/htmlhint/invalid.html');
let log = sandbox.getLog().match(/^.*$/igm);
assert.ok(log);
assert.ok(/^test\/fixtures\/htmlhint\/invalid.html$/.test(log.shift()));
log = log.map(log => log.match(/^\s*(\d+):(\d+)\s+\S+\s+(.+?)\s+\(HTMLHint\s+(.+?)\s+(https?.+?)\)$/i));
assert.equal(log[0][1], '01');
assert.equal(log[0][2], '01');
assert.equal(log[1][1], '08');
assert.equal(log[1][2], '01');
assert.equal(log[0][4], 'doctype-first');
assert.equal(log[1][4], 'tag-pair');
if (locale === 'zh_CN') {
assert.equal(log[0][3], 'doctype必须首先声明。');
assert.equal(log[1][3], '标签必须匹配,缺失:[ </h1> ],在第7行匹配开始标签[ <h1> ]失败');
} else {
assert.equal(log[0][3], 'Doctype must be declared first.');
assert.equal(log[1][3], 'Tag must be paired, missing: [ </h1> ], start tag match failed [ <h1> ] on line 7.');
}
});
});
});
Loading

0 comments on commit 9db2336

Please sign in to comment.