Skip to content

Commit fb2f449

Browse files
TrottMylesBorins
authored andcommitted
tools: update ESLint to current version
We have been stalled on ESLint 3.8.0 for some time. Current ESLint is 3.13.0. We have been unable to upgrade because of more aggressive reporting on some rules, including indentation. ESLint configuration options and bugfixes are now such that we can reasonably upgrade. PR-URL: #10561 Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent b4cf8c4 commit fb2f449

File tree

731 files changed

+21015
-11069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

731 files changed

+21015
-11069
lines changed

.eslintrc.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ rules:
8383
computed-property-spacing: 2
8484
eol-last: 2
8585
func-call-spacing: 2
86-
indent: [2, 2, {SwitchCase: 1, MemberExpression: 1}]
86+
func-name-matching: 2
87+
indent: [2, 2, {ArrayExpression: first,
88+
CallExpression: {arguments: first},
89+
MemberExpression: 1,
90+
ObjectExpression: first,
91+
SwitchCase: 1}]
8792
key-spacing: [2, {mode: minimum}]
8893
keyword-spacing: 2
8994
linebreak-style: [2, unix]

benchmark/common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function runBenchmarks() {
5858
if (!test)
5959
return;
6060

61-
if (test.match(/^[\._]/))
61+
if (test.match(/^[._]/))
6262
return process.nextTick(runBenchmarks);
6363

6464
if (outputFormat == 'default')
@@ -86,7 +86,7 @@ function Benchmark(fn, options) {
8686
this.fn = fn;
8787
this.options = options;
8888
this.config = parseOpts(options);
89-
this._name = require.main.filename.split(/benchmark[\/\\]/).pop();
89+
this._name = require.main.filename.split(/benchmark[/\\]/).pop();
9090
this._start = [0, 0];
9191
this._started = false;
9292

@@ -101,7 +101,7 @@ function Benchmark(fn, options) {
101101
Benchmark.prototype.http = function(p, args, cb) {
102102
hasWrk();
103103
var self = this;
104-
var regexp = /Requests\/sec:[ \t]+([0-9\.]+)/;
104+
var regexp = /Requests\/sec:[ \t]+([0-9.]+)/;
105105
var url = 'http://127.0.0.1:' + exports.PORT + p;
106106

107107
args = args.concat(url);

lib/fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ try {
7474
printDeprecation('fs: re-evaluating native module sources is not ' +
7575
'supported. If you are using the graceful-fs module, ' +
7676
'please update it to a more recent version.',
77-
false);
77+
false);
7878
}
7979

8080
function throwOptionsError(options) {

lib/internal/process.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ function setupConfig(_source) {
141141
Intl.hasOwnProperty('v8BreakIterator') &&
142142
!process.icu_data_dir) {
143143
const des = Object.getOwnPropertyDescriptor(Intl, 'v8BreakIterator');
144+
// eslint-disable-next-line func-name-matching
144145
des.value = function v8BreakIterator() {
145146
throw new Error('v8BreakIterator: full ICU data not installed. ' +
146147
'See https://github.com/nodejs/node/wiki/Intl');

lib/readline.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,17 +1102,20 @@ function codePointAt(str, index) {
11021102
}
11031103
return code;
11041104
}
1105-
exports.codePointAt = internalUtil.deprecate(codePointAt,
1106-
'readline.codePointAt is deprecated. ' +
1107-
'Use String.prototype.codePointAt instead.');
1105+
exports.codePointAt = internalUtil.deprecate(
1106+
codePointAt,
1107+
'readline.codePointAt is deprecated. ' +
1108+
'Use String.prototype.codePointAt instead.');
11081109

11091110

1110-
exports.getStringWidth = internalUtil.deprecate(getStringWidth,
1111-
'getStringWidth is deprecated and will be removed.');
1111+
exports.getStringWidth = internalUtil.deprecate(
1112+
getStringWidth,
1113+
'getStringWidth is deprecated and will be removed.');
11121114

11131115

1114-
exports.isFullWidthCodePoint = internalUtil.deprecate(isFullWidthCodePoint,
1115-
'isFullWidthCodePoint is deprecated and will be removed.');
1116+
exports.isFullWidthCodePoint = internalUtil.deprecate(
1117+
isFullWidthCodePoint,
1118+
'isFullWidthCodePoint is deprecated and will be removed.');
11161119

11171120

11181121
exports.stripVTControlCharacters = internalUtil.deprecate(

lib/url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const portPattern = /:[0-9]*$/;
4141
const hostPattern = /^\/\/[^@/]+@[^@/]+/;
4242

4343
// Special case for a simple path URL
44-
const simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;
44+
const simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/;
4545

4646
const hostnameMaxLen = 255;
4747
// protocols that can allow "unsafe" and "unwise" chars.

test/parallel/test-child-process-exec-timeout.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ cp.exec(cmd, {
3939

4040
// Test the case where a timeout is set, but not expired.
4141
cp.exec(cmd, { timeout: Math.pow(2, 30) },
42-
common.mustCall((err, stdout, stderr) => {
43-
assert.ifError(err);
44-
assert.strictEqual(stdout.trim(), 'child stdout');
45-
assert.strictEqual(stderr.trim(), 'child stderr');
46-
})
42+
common.mustCall((err, stdout, stderr) => {
43+
assert.ifError(err);
44+
assert.strictEqual(stdout.trim(), 'child stdout');
45+
assert.strictEqual(stderr.trim(), 'child stderr');
46+
})
4747
);

tools/doc/html.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function loadGtoc(cb) {
9191
function toID(filename) {
9292
return filename
9393
.replace('.html', '')
94-
.replace(/[^\w\-]/g, '-')
94+
.replace(/[^\w-]/g, '-')
9595
.replace(/-+/g, '-');
9696
}
9797

@@ -309,7 +309,7 @@ function linkJsTypeDocs(text) {
309309
// Handle types, for example the source Markdown might say
310310
// "This argument should be a {Number} or {String}"
311311
for (i = 0; i < parts.length; i += 2) {
312-
typeMatches = parts[i].match(/\{([^\}]+)\}/g);
312+
typeMatches = parts[i].match(/\{([^}]+)\}/g);
313313
if (typeMatches) {
314314
typeMatches.forEach(function(typeMatch) {
315315
parts[i] = parts[i].replace(typeMatch, typeParser.toLink(typeMatch));

tools/doc/json.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function doJSON(input, filename, cb) {
3131
// <!-- type = module -->
3232
// This is for cases where the markdown semantic structure is lacking.
3333
if (type === 'paragraph' || type === 'html') {
34-
var metaExpr = /<!--([^=]+)=([^\-]+)-->\n*/g;
34+
var metaExpr = /<!--([^=]+)=([^-]+)-->\n*/g;
3535
text = text.replace(metaExpr, function(_0, k, v) {
3636
current[k.trim()] = v.trim();
3737
return '';
@@ -371,7 +371,7 @@ function parseListItem(item) {
371371
item.name = 'return';
372372
text = text.replace(retExpr, '');
373373
} else {
374-
var nameExpr = /^['`"]?([^'`": \{]+)['`"]?\s*:?\s*/;
374+
var nameExpr = /^['`"]?([^'`": {]+)['`"]?\s*:?\s*/;
375375
var name = text.match(nameExpr);
376376
if (name) {
377377
item.name = name[1];
@@ -388,7 +388,7 @@ function parseListItem(item) {
388388
}
389389

390390
text = text.trim();
391-
var typeExpr = /^\{([^\}]+)\}/;
391+
var typeExpr = /^\{([^}]+)\}/;
392392
var type = text.match(typeExpr);
393393
if (type) {
394394
item.type = type[1];
@@ -546,12 +546,12 @@ function deepCopy_(src) {
546546
var eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i;
547547
var classExpr = /^Class:\s*([^ ]+).*?$/i;
548548
var propExpr = /^(?:property:?\s*)?[^.]+\.([^ .()]+)\s*?$/i;
549-
var braceExpr = /^(?:property:?\s*)?[^.\[]+(\[[^\]]+\])\s*?$/i;
549+
var braceExpr = /^(?:property:?\s*)?[^.[]+(\[[^\]]+\])\s*?$/i;
550550
var classMethExpr =
551551
/^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*?$/i;
552552
var methExpr =
553553
/^(?:method:?\s*)?(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*?$/i;
554-
var newExpr = /^new ([A-Z][a-zA-Z]+)\([^\)]*\)\s*?$/;
554+
var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*?$/;
555555
var paramExpr = /\((.*)\);?$/;
556556

557557
function newSection(tok) {

tools/eslint/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ESLint
2-
Copyright jQuery Foundation and other contributors, https://jquery.org/
2+
Copyright JS Foundation and other contributors, https://js.foundation
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal

tools/eslint/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[Rules](http://eslint.org/docs/rules/) |
1414
[Contributing](http://eslint.org/docs/developer-guide/contributing) |
1515
[Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) |
16-
[Code of Conduct](https://jquery.org/conduct/) |
16+
[Code of Conduct](https://js.foundation/conduct/) |
1717
[Twitter](https://twitter.com/geteslint) |
1818
[Mailing List](https://groups.google.com/group/eslint) |
1919
[Chat Room](https://gitter.im/eslint/eslint)
@@ -210,10 +210,7 @@ ESLint has full support for ECMAScript 6. By default, this support is off. You c
210210

211211
ESLint doesn't natively support experimental ECMAScript language features. You can use [babel-eslint](https://github.com/babel/babel-eslint) to use any option available in Babel.
212212

213-
Once a language feature has been adopted into the ECMAScript standard, we will accept
214-
issues and pull requests related to the new feature, subject to our [contributing
215-
guidelines](http://eslint.org/docs/developer-guide/contributing). Until then, please use
216-
the appropriate parser and plugin(s) for your experimental feature.
213+
Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](http://eslint.org/docs/developer-guide/contributing). Until then, please use the appropriate parser and plugin(s) for your experimental feature.
217214

218215
### Where to ask for help?
219216

tools/eslint/bin/eslint.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @author Nicholas C. Zakas
66
*/
77

8-
/* eslint no-console:off, no-process-exit:off */
8+
/* eslint no-console:off */
99

1010
"use strict";
1111

@@ -36,7 +36,7 @@ const concat = require("concat-stream"),
3636
// Execution
3737
//------------------------------------------------------------------------------
3838

39-
process.on("uncaughtException", function(err) {
39+
process.once("uncaughtException", err => {
4040

4141
// lazy load
4242
const lodash = require("lodash");
@@ -51,17 +51,17 @@ process.on("uncaughtException", function(err) {
5151
console.log(err.stack);
5252
}
5353

54-
process.exit(1);
54+
process.exitCode = 1;
5555
});
5656

5757
if (useStdIn) {
58-
process.stdin.pipe(concat({ encoding: "string" }, function(text) {
58+
process.stdin.pipe(concat({ encoding: "string" }, text => {
5959
process.exitCode = cli.execute(process.argv, text);
6060
}));
6161
} else if (init) {
6262
const configInit = require("../lib/config/config-initializer");
6363

64-
configInit.initializeConfig(function(err) {
64+
configInit.initializeConfig(err => {
6565
if (err) {
6666
process.exitCode = 1;
6767
console.error(err.message);

tools/eslint/conf/eslint.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"rules": {
55
"no-alert": "off",
66
"no-array-constructor": "off",
7+
"no-await-in-loop": "off",
78
"no-bitwise": "off",
89
"no-caller": "off",
910
"no-case-declarations": "error",
@@ -41,7 +42,7 @@
4142
"no-fallthrough": "error",
4243
"no-floating-decimal": "off",
4344
"no-func-assign": "error",
44-
"no-global-assign": "off",
45+
"no-global-assign": "error",
4546
"no-implicit-coercion": "off",
4647
"no-implicit-globals": "off",
4748
"no-implied-eval": "off",
@@ -63,9 +64,9 @@
6364
"no-multi-spaces": "off",
6465
"no-multi-str": "off",
6566
"no-multiple-empty-lines": "off",
66-
"no-native-reassign": "error",
67+
"no-native-reassign": "off",
6768
"no-negated-condition": "off",
68-
"no-negated-in-lhs": "error",
69+
"no-negated-in-lhs": "off",
6970
"no-nested-ternary": "off",
7071
"no-new": "off",
7172
"no-new-func": "off",
@@ -91,6 +92,7 @@
9192
"no-restricted-properties": "off",
9293
"no-restricted-syntax": "off",
9394
"no-return-assign": "off",
95+
"no-return-await": "off",
9496
"no-script-url": "off",
9597
"no-self-assign": "error",
9698
"no-self-compare": "off",
@@ -115,7 +117,7 @@
115117
"no-unneeded-ternary": "off",
116118
"no-unreachable": "error",
117119
"no-unsafe-finally": "error",
118-
"no-unsafe-negation": "off",
120+
"no-unsafe-negation": "error",
119121
"no-unused-expressions": "off",
120122
"no-unused-labels": "error",
121123
"no-unused-vars": "error",
@@ -126,6 +128,7 @@
126128
"no-useless-constructor": "off",
127129
"no-useless-escape": "off",
128130
"no-useless-rename": "off",
131+
"no-useless-return": "off",
129132
"no-void": "off",
130133
"no-var": "off",
131134
"no-warning-comments": "off",
@@ -141,6 +144,7 @@
141144
"brace-style": "off",
142145
"callback-return": "off",
143146
"camelcase": "off",
147+
"capitalized-comments": "off",
144148
"class-methods-use-this": "off",
145149
"comma-dangle": "off",
146150
"comma-spacing": "off",
@@ -200,6 +204,7 @@
200204
"padded-blocks": "off",
201205
"prefer-arrow-callback": "off",
202206
"prefer-const": "off",
207+
"prefer-destructuring": "off",
203208
"prefer-numeric-literals": "off",
204209
"prefer-reflect": "off",
205210
"prefer-rest-params": "off",
@@ -208,6 +213,7 @@
208213
"quote-props": "off",
209214
"quotes": "off",
210215
"radix": "off",
216+
"require-await": "off",
211217
"require-jsdoc": "off",
212218
"require-yield": "error",
213219
"rest-spread-spacing": "off",

0 commit comments

Comments
 (0)