| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,6 +116,7 @@ These folks keep the project moving and are resources for help. | |||
| 116 | 116 | * Alberto Rodríguez ([@alberto](https://github.com/alberto)) | |
| 117 | 117 | * Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo)) | |
| 118 | 118 | * Teddy Katz ([@not-an-aardvark](https://github.com/not-an-aardvark)) | |
| 119 | + * Kevin Partington ([@platinumazure](https://github.com/platinumazure)) | ||
| 119 | 120 | ||
| 120 | 121 | ### Development Team | |
| 121 | 122 | ||
@@ -130,7 +131,6 @@ These folks keep the project moving and are resources for help. | |||
| 130 | 131 | * Henry Zhu ([@hzoo](https://github.com/hzoo)) | |
| 131 | 132 | * Marat Dulin ([@mdevils](https://github.com/mdevils)) | |
| 132 | 133 | * Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox)) | |
| 133 | - * Kevin Partington ([@platinumazure](https://github.com/platinumazure)) | ||
| 134 | 134 | * Vitor Balocco ([@vitorbal](https://github.com/vitorbal)) | |
| 135 | 135 | * James Henry ([@JamesHenry](https://github.com/JamesHenry)) | |
| 136 | 136 | * Reyad Attiyat ([@soda0289](https://github.com/soda0289)) | |
@@ -225,7 +225,7 @@ In all cases, make sure your plugins' peerDependencies have been installed as we | |||
| 225 | 225 | ||
| 226 | 226 | ### Does ESLint support JSX? | |
| 227 | 227 | ||
| 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. | ||
| 229 | 229 | ||
| 230 | 230 | ### What about ECMAScript 6 support? | |
| 231 | 231 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,9 +17,11 @@ module.exports = { | |||
| 17 | 17 | ignorePath: null, | |
| 18 | 18 | cache: false, | |
| 19 | 19 | ||
| 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 | + */ | ||
| 23 | 25 | cacheLocation: "", | |
| 24 | 26 | cacheFile: ".eslintcache", | |
| 25 | 27 | fix: false, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,10 +17,126 @@ const globals = require("globals"); | |||
| 17 | 17 | module.exports = { | |
| 18 | 18 | builtin: globals.es5, | |
| 19 | 19 | 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 | + ) | ||
| 21 | 129 | }, | |
| 22 | 130 | 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 | + ), | ||
| 24 | 140 | parserOptions: { | |
| 25 | 141 | ecmaFeatures: { | |
| 26 | 142 | globalReturn: true | |
@@ -51,7 +167,15 @@ module.exports = { | |||
| 51 | 167 | globals: globals.jasmine | |
| 52 | 168 | }, | |
| 53 | 169 | 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 | + ) | ||
| 55 | 179 | }, | |
| 56 | 180 | phantomjs: { | |
| 57 | 181 | globals: globals.phantomjs | |
@@ -96,7 +220,7 @@ module.exports = { | |||
| 96 | 220 | globals: globals.webextensions | |
| 97 | 221 | }, | |
| 98 | 222 | es6: { | |
| 99 | - globals: globals.es6, | ||
| 223 | + globals: globals.es2015, | ||
| 100 | 224 | parserOptions: { | |
| 101 | 225 | ecmaVersion: 6 | |
| 102 | 226 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,6 +53,7 @@ module.exports = { | |||
| 53 | 53 | "id-blacklist": "off", | |
| 54 | 54 | "id-length": "off", | |
| 55 | 55 | "id-match": "off", | |
| 56 | + "implicit-arrow-linebreak": "off", | ||
| 56 | 57 | indent: "off", | |
| 57 | 58 | "indent-legacy": "off", | |
| 58 | 59 | "init-declarations": "off", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -406,6 +406,31 @@ function createGlobalLinebreakMatcher() { | |||
| 406 | 406 | return new RegExp(LINEBREAK_MATCHER.source, "g"); | |
| 407 | 407 | } | |
| 408 | 408 | ||
| 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 | + | ||
| 409 | 434 | //------------------------------------------------------------------------------ | |
| 410 | 435 | // Public Interface | |
| 411 | 436 | //------------------------------------------------------------------------------ | |
@@ -438,6 +463,7 @@ module.exports = { | |||
| 438 | 463 | isArrayFromMethod, | |
| 439 | 464 | isParenthesised, | |
| 440 | 465 | createGlobalLinebreakMatcher, | |
| 466 | + equalTokens, | ||
| 441 | 467 | ||
| 442 | 468 | isArrowToken, | |
| 443 | 469 | isClosingBraceToken, | |
@@ -620,15 +646,17 @@ module.exports = { | |||
| 620 | 646 | node = parent; | |
| 621 | 647 | break; | |
| 622 | 648 | ||
| 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 | + */ | ||
| 632 | 660 | case "ReturnStatement": { | |
| 633 | 661 | const func = getUpperFunction(parent); | |
| 634 | 662 | ||
@@ -645,23 +673,27 @@ module.exports = { | |||
| 645 | 673 | node = parent.parent; | |
| 646 | 674 | break; | |
| 647 | 675 | ||
| 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 | + */ | ||
| 656 | 686 | case "Property": | |
| 657 | 687 | case "MethodDefinition": | |
| 658 | 688 | return parent.value !== node; | |
| 659 | 689 | ||
| 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 | + */ | ||
| 665 | 697 | case "AssignmentExpression": | |
| 666 | 698 | case "AssignmentPattern": | |
| 667 | 699 | if (parent.left.type === "MemberExpression") { | |
@@ -676,8 +708,10 @@ module.exports = { | |||
| 676 | 708 | } | |
| 677 | 709 | return true; | |
| 678 | 710 | ||
| 679 | - // e.g. | ||
| 680 | - // var Foo = function() { ... }; | ||
| 711 | + /* | ||
| 712 | + * e.g. | ||
| 713 | + * var Foo = function() { ... }; | ||
| 714 | + */ | ||
| 681 | 715 | case "VariableDeclarator": | |
| 682 | 716 | return !( | |
| 683 | 717 | isAnonymous && | |
@@ -686,10 +720,12 @@ module.exports = { | |||
| 686 | 720 | startsWithUpperCase(parent.id.name) | |
| 687 | 721 | ); | |
| 688 | 722 | ||
| 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 | + */ | ||
| 693 | 729 | case "MemberExpression": | |
| 694 | 730 | return ( | |
| 695 | 731 | parent.object !== node || | |
@@ -700,10 +736,12 @@ module.exports = { | |||
| 700 | 736 | isNullOrUndefined(parent.parent.arguments[0]) | |
| 701 | 737 | ); | |
| 702 | 738 | ||
| 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 | + */ | ||
| 707 | 745 | case "CallExpression": | |
| 708 | 746 | if (isReflectApply(parent.callee)) { | |
| 709 | 747 | return ( | |
@@ -930,8 +968,10 @@ module.exports = { | |||
| 930 | 968 | node.type === "FunctionDeclaration" || | |
| 931 | 969 | node.type === "FunctionExpression" || | |
| 932 | 970 | ||
| 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 | + */ | ||
| 935 | 975 | (node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement") | |
| 936 | 976 | ) { | |
| 937 | 977 | const statements = node.type === "Program" ? node.body : node.body.body; | |
@@ -954,7 +994,7 @@ module.exports = { | |||
| 954 | 994 | ||
| 955 | 995 | /** | |
| 956 | 996 | * 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. | ||
| 958 | 998 | * @param {ASTNode} node - The node to check. | |
| 959 | 999 | * @returns {boolean} `true` if this node is a decimal integer. | |
| 960 | 1000 | * @example | |
@@ -1183,12 +1223,12 @@ module.exports = { | |||
| 1183 | 1223 | }, | |
| 1184 | 1224 | ||
| 1185 | 1225 | /** | |
| 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 | + */ | ||
| 1192 | 1232 | getParenthesisedText(sourceCode, node) { | |
| 1193 | 1233 | let leftToken = sourceCode.getFirstToken(node); | |
| 1194 | 1234 | let rightToken = sourceCode.getLastToken(node); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments