Skip to content

Commit 6624ac3

Browse files
cjihrigMylesBorins
authored andcommitted
tools: update to ESLint 4.12.0
PR-URL: #16948 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 71eb186 commit 6624ac3

File tree

231 files changed

+6170
-19748
lines changed

Some content is hidden

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

231 files changed

+6170
-19748
lines changed

tools/eslint/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ These folks keep the project moving and are resources for help.
116116
* Alberto Rodríguez ([@alberto](https://github.com/alberto))
117117
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo))
118118
* Teddy Katz ([@not-an-aardvark](https://github.com/not-an-aardvark))
119+
* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
119120

120121
### Development Team
121122

@@ -130,7 +131,6 @@ These folks keep the project moving and are resources for help.
130131
* Henry Zhu ([@hzoo](https://github.com/hzoo))
131132
* Marat Dulin ([@mdevils](https://github.com/mdevils))
132133
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox))
133-
* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
134134
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))
135135
* James Henry ([@JamesHenry](https://github.com/JamesHenry))
136136
* Reyad Attiyat ([@soda0289](https://github.com/soda0289))
@@ -225,7 +225,7 @@ In all cases, make sure your plugins' peerDependencies have been installed as we
225225

226226
### Does ESLint support JSX?
227227

228-
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/user-guide/configuring).). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
228+
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/user-guide/configuring)). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
229229

230230
### What about ECMAScript 6 support?
231231

tools/eslint/conf/default-cli-options.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ module.exports = {
1717
ignorePath: null,
1818
cache: false,
1919

20-
// in order to honor the cacheFile option if specified
21-
// this option should not have a default value otherwise
22-
// it will always be used
20+
/*
21+
* in order to honor the cacheFile option if specified
22+
* this option should not have a default value otherwise
23+
* it will always be used
24+
*/
2325
cacheLocation: "",
2426
cacheFile: ".eslintcache",
2527
fix: false,

tools/eslint/conf/environments.js

+128-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,126 @@ const globals = require("globals");
1717
module.exports = {
1818
builtin: globals.es5,
1919
browser: {
20-
globals: globals.browser
20+
21+
/*
22+
* For backward compatibility.
23+
* Remove those on the next major release.
24+
*/
25+
globals: Object.assign(
26+
{
27+
AutocompleteErrorEvent: false,
28+
CDATASection: false,
29+
ClientRect: false,
30+
ClientRectList: false,
31+
CSSAnimation: false,
32+
CSSTransition: false,
33+
CSSUnknownRule: false,
34+
CSSViewportRule: false,
35+
Debug: false,
36+
DocumentTimeline: false,
37+
DOMSettableTokenList: false,
38+
ElementTimeControl: false,
39+
FederatedCredential: false,
40+
FileError: false,
41+
HTMLAppletElement: false,
42+
HTMLBlockquoteElement: false,
43+
HTMLIsIndexElement: false,
44+
HTMLKeygenElement: false,
45+
HTMLLayerElement: false,
46+
IDBEnvironment: false,
47+
InputMethodContext: false,
48+
MediaKeyError: false,
49+
MediaKeyEvent: false,
50+
MediaKeys: false,
51+
opera: false,
52+
PasswordCredential: false,
53+
ReadableByteStream: false,
54+
SharedKeyframeList: false,
55+
showModalDialog: false,
56+
SiteBoundCredential: false,
57+
SVGAltGlyphDefElement: false,
58+
SVGAltGlyphElement: false,
59+
SVGAltGlyphItemElement: false,
60+
SVGAnimateColorElement: false,
61+
SVGAnimatedPathData: false,
62+
SVGAnimatedPoints: false,
63+
SVGColor: false,
64+
SVGColorProfileElement: false,
65+
SVGColorProfileRule: false,
66+
SVGCSSRule: false,
67+
SVGCursorElement: false,
68+
SVGDocument: false,
69+
SVGElementInstance: false,
70+
SVGElementInstanceList: false,
71+
SVGEvent: false,
72+
SVGExternalResourcesRequired: false,
73+
SVGFilterPrimitiveStandardAttributes: false,
74+
SVGFitToViewBox: false,
75+
SVGFontElement: false,
76+
SVGFontFaceElement: false,
77+
SVGFontFaceFormatElement: false,
78+
SVGFontFaceNameElement: false,
79+
SVGFontFaceSrcElement: false,
80+
SVGFontFaceUriElement: false,
81+
SVGGlyphElement: false,
82+
SVGGlyphRefElement: false,
83+
SVGHKernElement: false,
84+
SVGICCColor: false,
85+
SVGLangSpace: false,
86+
SVGLocatable: false,
87+
SVGMissingGlyphElement: false,
88+
SVGPaint: false,
89+
SVGPathSeg: false,
90+
SVGPathSegArcAbs: false,
91+
SVGPathSegArcRel: false,
92+
SVGPathSegClosePath: false,
93+
SVGPathSegCurvetoCubicAbs: false,
94+
SVGPathSegCurvetoCubicRel: false,
95+
SVGPathSegCurvetoCubicSmoothAbs: false,
96+
SVGPathSegCurvetoCubicSmoothRel: false,
97+
SVGPathSegCurvetoQuadraticAbs: false,
98+
SVGPathSegCurvetoQuadraticRel: false,
99+
SVGPathSegCurvetoQuadraticSmoothAbs: false,
100+
SVGPathSegCurvetoQuadraticSmoothRel: false,
101+
SVGPathSegLinetoAbs: false,
102+
SVGPathSegLinetoHorizontalAbs: false,
103+
SVGPathSegLinetoHorizontalRel: false,
104+
SVGPathSegLinetoRel: false,
105+
SVGPathSegLinetoVerticalAbs: false,
106+
SVGPathSegLinetoVerticalRel: false,
107+
SVGPathSegList: false,
108+
SVGPathSegMovetoAbs: false,
109+
SVGPathSegMovetoRel: false,
110+
SVGRenderingIntent: false,
111+
SVGStylable: false,
112+
SVGTests: false,
113+
SVGTransformable: false,
114+
SVGTRefElement: false,
115+
SVGURIReference: false,
116+
SVGViewSpec: false,
117+
SVGVKernElement: false,
118+
SVGZoomAndPan: false,
119+
SVGZoomEvent: false,
120+
TimeEvent: false,
121+
XDomainRequest: false,
122+
XMLHttpRequestProgressEvent: false,
123+
XPathException: false,
124+
XPathNamespace: false,
125+
XPathNSResolver: false
126+
},
127+
globals.browser
128+
)
21129
},
22130
node: {
23-
globals: globals.node,
131+
132+
/*
133+
* For backward compatibility.
134+
* Remove those on the next major release.
135+
*/
136+
globals: Object.assign(
137+
{ arguments: false, GLOBAL: false, root: false },
138+
globals.node
139+
),
24140
parserOptions: {
25141
ecmaFeatures: {
26142
globalReturn: true
@@ -51,7 +167,15 @@ module.exports = {
51167
globals: globals.jasmine
52168
},
53169
jest: {
54-
globals: globals.jest
170+
171+
/*
172+
* For backward compatibility.
173+
* Remove those on the next major release.
174+
*/
175+
globals: Object.assign(
176+
{ check: false, gen: false },
177+
globals.jest
178+
)
55179
},
56180
phantomjs: {
57181
globals: globals.phantomjs
@@ -96,7 +220,7 @@ module.exports = {
96220
globals: globals.webextensions
97221
},
98222
es6: {
99-
globals: globals.es6,
223+
globals: globals.es2015,
100224
parserOptions: {
101225
ecmaVersion: 6
102226
}

tools/eslint/conf/eslint-recommended.js

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module.exports = {
5353
"id-blacklist": "off",
5454
"id-length": "off",
5555
"id-match": "off",
56+
"implicit-arrow-linebreak": "off",
5657
indent: "off",
5758
"indent-legacy": "off",
5859
"init-declarations": "off",

tools/eslint/lib/ast-utils.js

+81-41
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,31 @@ function createGlobalLinebreakMatcher() {
406406
return new RegExp(LINEBREAK_MATCHER.source, "g");
407407
}
408408

409+
/**
410+
* Checks whether or not the tokens of two given nodes are same.
411+
* @param {ASTNode} left - A node 1 to compare.
412+
* @param {ASTNode} right - A node 2 to compare.
413+
* @param {SourceCode} sourceCode - The ESLint source code object.
414+
* @returns {boolean} the source code for the given node.
415+
*/
416+
function equalTokens(left, right, sourceCode) {
417+
const tokensL = sourceCode.getTokens(left);
418+
const tokensR = sourceCode.getTokens(right);
419+
420+
if (tokensL.length !== tokensR.length) {
421+
return false;
422+
}
423+
for (let i = 0; i < tokensL.length; ++i) {
424+
if (tokensL[i].type !== tokensR[i].type ||
425+
tokensL[i].value !== tokensR[i].value
426+
) {
427+
return false;
428+
}
429+
}
430+
431+
return true;
432+
}
433+
409434
//------------------------------------------------------------------------------
410435
// Public Interface
411436
//------------------------------------------------------------------------------
@@ -438,6 +463,7 @@ module.exports = {
438463
isArrayFromMethod,
439464
isParenthesised,
440465
createGlobalLinebreakMatcher,
466+
equalTokens,
441467

442468
isArrowToken,
443469
isClosingBraceToken,
@@ -620,15 +646,17 @@ module.exports = {
620646
node = parent;
621647
break;
622648

623-
// If the upper function is IIFE, checks the destination of the return value.
624-
// e.g.
625-
// obj.foo = (function() {
626-
// // setup...
627-
// return function foo() { ... };
628-
// })();
629-
// obj.foo = (() =>
630-
// function foo() { ... }
631-
// )();
649+
/*
650+
* If the upper function is IIFE, checks the destination of the return value.
651+
* e.g.
652+
* obj.foo = (function() {
653+
* // setup...
654+
* return function foo() { ... };
655+
* })();
656+
* obj.foo = (() =>
657+
* function foo() { ... }
658+
* )();
659+
*/
632660
case "ReturnStatement": {
633661
const func = getUpperFunction(parent);
634662

@@ -645,23 +673,27 @@ module.exports = {
645673
node = parent.parent;
646674
break;
647675

648-
// e.g.
649-
// var obj = { foo() { ... } };
650-
// var obj = { foo: function() { ... } };
651-
// class A { constructor() { ... } }
652-
// class A { foo() { ... } }
653-
// class A { get foo() { ... } }
654-
// class A { set foo() { ... } }
655-
// class A { static foo() { ... } }
676+
/*
677+
* e.g.
678+
* var obj = { foo() { ... } };
679+
* var obj = { foo: function() { ... } };
680+
* class A { constructor() { ... } }
681+
* class A { foo() { ... } }
682+
* class A { get foo() { ... } }
683+
* class A { set foo() { ... } }
684+
* class A { static foo() { ... } }
685+
*/
656686
case "Property":
657687
case "MethodDefinition":
658688
return parent.value !== node;
659689

660-
// e.g.
661-
// obj.foo = function foo() { ... };
662-
// Foo = function() { ... };
663-
// [obj.foo = function foo() { ... }] = a;
664-
// [Foo = function() { ... }] = a;
690+
/*
691+
* e.g.
692+
* obj.foo = function foo() { ... };
693+
* Foo = function() { ... };
694+
* [obj.foo = function foo() { ... }] = a;
695+
* [Foo = function() { ... }] = a;
696+
*/
665697
case "AssignmentExpression":
666698
case "AssignmentPattern":
667699
if (parent.left.type === "MemberExpression") {
@@ -676,8 +708,10 @@ module.exports = {
676708
}
677709
return true;
678710

679-
// e.g.
680-
// var Foo = function() { ... };
711+
/*
712+
* e.g.
713+
* var Foo = function() { ... };
714+
*/
681715
case "VariableDeclarator":
682716
return !(
683717
isAnonymous &&
@@ -686,10 +720,12 @@ module.exports = {
686720
startsWithUpperCase(parent.id.name)
687721
);
688722

689-
// e.g.
690-
// var foo = function foo() { ... }.bind(obj);
691-
// (function foo() { ... }).call(obj);
692-
// (function foo() { ... }).apply(obj, []);
723+
/*
724+
* e.g.
725+
* var foo = function foo() { ... }.bind(obj);
726+
* (function foo() { ... }).call(obj);
727+
* (function foo() { ... }).apply(obj, []);
728+
*/
693729
case "MemberExpression":
694730
return (
695731
parent.object !== node ||
@@ -700,10 +736,12 @@ module.exports = {
700736
isNullOrUndefined(parent.parent.arguments[0])
701737
);
702738

703-
// e.g.
704-
// Reflect.apply(function() {}, obj, []);
705-
// Array.from([], function() {}, obj);
706-
// list.forEach(function() {}, obj);
739+
/*
740+
* e.g.
741+
* Reflect.apply(function() {}, obj, []);
742+
* Array.from([], function() {}, obj);
743+
* list.forEach(function() {}, obj);
744+
*/
707745
case "CallExpression":
708746
if (isReflectApply(parent.callee)) {
709747
return (
@@ -930,8 +968,10 @@ module.exports = {
930968
node.type === "FunctionDeclaration" ||
931969
node.type === "FunctionExpression" ||
932970

933-
// Do not check arrow functions with implicit return.
934-
// `() => "use strict";` returns the string `"use strict"`.
971+
/*
972+
* Do not check arrow functions with implicit return.
973+
* `() => "use strict";` returns the string `"use strict"`.
974+
*/
935975
(node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement")
936976
) {
937977
const statements = node.type === "Program" ? node.body : node.body.body;
@@ -954,7 +994,7 @@ module.exports = {
954994

955995
/**
956996
* Determines whether this node is a decimal integer literal. If a node is a decimal integer literal, a dot added
957-
after the node will be parsed as a decimal point, rather than a property-access dot.
997+
* after the node will be parsed as a decimal point, rather than a property-access dot.
958998
* @param {ASTNode} node - The node to check.
959999
* @returns {boolean} `true` if this node is a decimal integer.
9601000
* @example
@@ -1183,12 +1223,12 @@ module.exports = {
11831223
},
11841224

11851225
/**
1186-
* Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses
1187-
* surrounding the node.
1188-
* @param {SourceCode} sourceCode The source code object
1189-
* @param {ASTNode} node An expression node
1190-
* @returns {string} The text representing the node, with all surrounding parentheses included
1191-
*/
1226+
* Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses
1227+
* surrounding the node.
1228+
* @param {SourceCode} sourceCode The source code object
1229+
* @param {ASTNode} node An expression node
1230+
* @returns {string} The text representing the node, with all surrounding parentheses included
1231+
*/
11921232
getParenthesisedText(sourceCode, node) {
11931233
let leftToken = sourceCode.getFirstToken(node);
11941234
let rightToken = sourceCode.getLastToken(node);

0 commit comments

Comments
 (0)