2 * @fileoverview This option sets a specific tab width for your code
3 * @author Dmitriy Shekhovtsov
4 * @author Gyandeep Singh
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/indent"),
13 { RuleTester
} = require("../../../lib/rule-tester");
14 const fs
= require("fs");
15 const path
= require("path");
17 //------------------------------------------------------------------------------
19 //------------------------------------------------------------------------------
21 const fixture
= fs
.readFileSync(path
.join(__dirname
, "../../fixtures/rules/indent/indent-invalid-fixture-1.js"), "utf8");
22 const fixedFixture
= fs
.readFileSync(path
.join(__dirname
, "../../fixtures/rules/indent/indent-valid-fixture-1.js"), "utf8");
23 const parser
= require("../../fixtures/fixture-parser");
24 const { unIndent
} = require("../../_utils");
28 * Create error message object for failure cases with a single 'found' indentation type
29 * @param {string} providedIndentType indent type of string or tab
30 * @param {Array} providedErrors error info
31 * @returns {Object} returns the error messages collection
34 function expectedErrors(providedIndentType
, providedErrors
) {
38 if (Array
.isArray(providedIndentType
)) {
39 errors
= Array
.isArray(providedIndentType
[0]) ? providedIndentType
: [providedIndentType
];
42 errors
= Array
.isArray(providedErrors
[0]) ? providedErrors
: [providedErrors
];
43 indentType
= providedIndentType
;
46 return errors
.map(err
=> ({
47 messageId
: "wrongIndentation",
49 expected
: typeof err
[1] === "string" && typeof err
[2] === "string"
51 : `${err[1]} ${indentType}${err[1] === 1 ? "" : "s"}`,
59 const ruleTester
= new RuleTester({ parserOptions
: { ecmaVersion
: 8, ecmaFeatures
: { jsx
: true } } });
61 ruleTester
.run("indent", rule
, {
66 'getAppVersion', 'test23', function(responseData) {
67 window.ah.mobileAppVersion = responseData;
76 'getAppVersion', 'test23', function(responseData) {
77 window.ah.mobileAppVersion = responseData;
87 function responseCallback(responseData) {
88 window.ah.mobileAppVersion = responseData;
99 function responseCallback(responseData) {
100 window.ah.mobileAppVersion = responseData;
107 function doStuff(keys) {
122 console.log('example');
130 let foo = somethingList
194 code
: "var x = 0 && 1;",
198 code
: "var x = 0 && { a: 1, b: 2 };",
212 require('http').request({hostname: 'localhost',
213 port: 80}, function(res) {
222 return client.signUp(email, PASSWORD, { preVerified: true })
223 .then(function (result) {
227 return FunctionalHelpers.clearBrowserState(self, {
238 it('should... some lengthy test description that is forced to be' +
239 'wrapped into two lines since the line length limit is set', () => {
240 expect(true).toBe(true);
248 return client.signUp(email, PASSWORD, { preVerified: true })
249 .then(function (result) {
263 // https://github.com/eslint/eslint/issues/11802
265 import foo from "foo"
270 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
275 return client.signUp(email, PASSWORD, { preVerified: true })
276 .then(function (result) {
286 options
: [4, { MemberExpression
: 0 }]
291 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
295 var Command = function() {
299 files.concat(fileList)
302 options
: [2, { VariableDeclarator
: { var: 2, let: 2, const: 3 } }]
306 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
314 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
322 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
326 function test(data) {
330 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
334 var test = function(data) {
338 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
342 arr.forEach(function(data) {
343 otherdata.forEach(function(zero) {
347 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
355 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
362 ['deflate', 'inflate'],
363 ['deflateRaw', 'inflateRaw'],
364 ].forEach(function(method) {
368 options
: [2, { SwitchCase
: 1, VariableDeclarator
: 2 }]
382 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
393 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
406 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
438 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
452 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
463 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
472 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
486 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
499 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
511 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
541 var foo = { a: 1 }, bar = {
546 var foo = { a: 1 }, bar = {
565 options
: [2, { VariableDeclarator
: 1 }]
573 options
: [2, { VariableDeclarator
: 1 }]
582 options
: [2, { VariableDeclarator
: 1 }]
593 options
: [2, { VariableDeclarator
: 1 }]
602 options
: [2, { VariableDeclarator
: 1 }]
611 options
: [2, { VariableDeclarator
: "first" }]
616 bar = bar // <-- no semicolon here
618 b = 'b' // <-- no semicolon here
620 options
: [2, { VariableDeclarator
: "first" }]
629 options
: [2, { VariableDeclarator
: { var: 2 } }]
638 options
: [2, { VariableDeclarator
: { var: 2 } }]
645 options
: [2, { VariableDeclarator
: { var: "first" } }]
650 bar = 'bar' // <-- no semicolon here
652 options
: [2, { VariableDeclarator
: { var: "first" } }]
660 options
: [2, { VariableDeclarator
: "first" }]
667 options
: [4, { VariableDeclarator
: "first" }]
675 options
: [2, { VariableDeclarator
: "first" }]
685 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
695 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
706 options
: [2, { VariableDeclarator
: 1, SwitchCase
: 1 }]
717 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
727 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
736 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
747 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
773 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
782 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
786 function hi(){ var a = 1;
790 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
794 for(;length > index; index++)if(NO_HOLES || index in self){
798 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
804 case 1: return function(a){
805 return fn.call(that, a);
810 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
817 options
: [2, { VariableDeclarator
: 0 }]
824 options
: [4, { VariableDeclarator
: 1 }]
831 options
: ["tab", { VariableDeclarator
: 1 }]
838 options
: [2, { VariableDeclarator
: 1 }]
845 options
: [2, { VariableDeclarator
: 2 }]
852 options
: [2, { VariableDeclarator
: 2 }]
859 options
: [2, { VariableDeclarator
: 2 }]
863 var geometry, box, face1, face2, colorT, colorB, sprite, padding, maxWidth,
866 options
: [2, { SwitchCase
: 1 }]
869 code
: "var geometry, box, face1, face2, colorT, colorB, sprite, padding, maxWidth;",
870 options
: [2, { SwitchCase
: 1 }]
889 code
: "while (1 < 2) console.log('hi');",
896 c].forEach((index) => {
905 c].forEach(function(index){
913 [a, b, c].forEach((index) => {
921 [a, b, c].forEach(function(index){
934 options
: [4, { MemberExpression
: 1 }]
954 options
: [4, { SwitchCase
: 1 }]
974 options
: [4, { SwitchCase
: 2 }]
1066 options
: [4, { SwitchCase
: 1 }]
1069 var obj = {foo: 1, bar: 2};
1071 console.log(foo + bar);
1076 (1 + 2 + 3); // no error on this line
1079 "switch(value){ default: a(); break; }",
1082 import {addons} from 'react/addons'
1083 import React from 'react'
1086 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
1096 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
1100 var foo = 0, bar = 0; baz = 0;
1107 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
1126 code
: "while (1 < 2) console.log('hi')",
1131 function salutation () {
1133 case 0: return console.log('hi')
1134 case 1: return console.log('hey')
1138 options
: [2, { SwitchCase
: 1 }]
1148 options
: [2, { VariableDeclarator
: 2 }]
1159 const items2 = Items(
1165 options
: [2, { VariableDeclarator
: 3 }]
1177 options
: [2, { VariableDeclarator
: { const: 3, let: 2 } }]
1203 options
: [2, { VariableDeclarator
: { var: 2, const: 3 }, SwitchCase
: 1 }]
1211 environment: 'node',
1243 var path = require('path')
1244 , crypto = require('crypto')
1256 export function create (some,
1258 return Object.create({
1264 options
: [2, { FunctionDeclaration
: { parameters
: "first" } }],
1265 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
1269 export function create (id, xfilter, rawType,
1270 width=defaultWidth, height=defaultHeight,
1271 footerHeight=defaultFooterHeight,
1272 padding=defaultPadding) {
1273 // ... function body, indented two spaces
1276 options
: [2, { FunctionDeclaration
: { parameters
: "first" } }],
1277 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
1284 .then(function (ok) {
1312 options
: [2, { VariableDeclarator
: { var: 2, let: 2, const: 3 } }]
1323 if (YO) console.log(TE)
1325 options
: [2, { VariableDeclarator
: { var: 2, let: 2, const: 3 } }]
1373 options
: [2, { MemberExpression
: 0 }]
1376 const someOtherFunction = argument => {
1377 console.log(argument);
1379 someOtherValue = 'someOtherValue';
1386 ].sort().should.deepEqual([
1402 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
1415 options
: [2, { VariableDeclarator
: 2, SwitchCase
: 1 }]
1425 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
1435 options
: [4, { VariableDeclarator
: 1, SwitchCase
: 1 }]
1472 options
: [4, { VariableDeclarator
: 0, SwitchCase
: 1 }]
1483 options
: [4, { VariableDeclarator
: 0, SwitchCase
: 1 }]
1504 const func = function (opts) {
1505 return Promise.resolve()
1509 ].forEach(command => { doSomething(); });
1513 options
: [4, { MemberExpression
: 0 }]
1517 const func = function (opts) {
1518 return Promise.resolve()
1522 ].forEach(command => { doSomething(); });
1530 var haveFun = function () {
1545 var haveFun = function () {
1617 fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => {
1621 options
: [2, { outerIIFEBody
: 0 }]
1631 options
: [2, { outerIIFEBody
: 0 }]
1641 options
: [4, { outerIIFEBody
: 2 }]
1651 options
: [2, { outerIIFEBody
: 0 }]
1661 options
: [2, { outerIIFEBody
: 0 }]
1671 options
: [2, { outerIIFEBody
: 0 }]
1676 \t\t\tfunction foo(x) {
1677 \t\t\t\treturn x + 1;
1681 options
: ["tab", { outerIIFEBody
: 3 }]
1685 var out = function(){
1686 function fooVar(x) {
1691 options
: [2, { outerIIFEBody
: 0 }]
1695 var ns = function(){
1696 function fooVar(x) {
1701 options
: [2, { outerIIFEBody
: 0 }]
1706 function fooVar(x) {
1711 options
: [2, { outerIIFEBody
: 0 }]
1715 var ns = (function(){
1716 function fooVar(x) {
1721 options
: [2, { outerIIFEBody
: 0 }]
1725 var ns = (function(){
1726 function fooVar(x) {
1731 options
: [4, { outerIIFEBody
: 2 }]
1741 options
: [2, { outerIIFEBody
: 0 }]
1753 options
: [2, { outerIIFEBody
: 20 }]
1763 options
: [2, { outerIIFEBody
: 0 }]
1770 options
: ["tab", { outerIIFEBody
: 0 }]
1780 options
: [2, { outerIIFEBody
: 0 }]
1788 options
: [2, { outerIIFEBody
: 0 }]
1796 options
: [4, { outerIIFEBody
: "off" }]
1804 options
: [4, { outerIIFEBody
: "off" }]
1814 options
: [4, { outerIIFEBody
: "off" }]
1824 options
: [4, { outerIIFEBody
: "off" }]
1831 options
: [4, { outerIIFEBody
: "off" }]
1834 code
: "Buffer.length",
1835 options
: [4, { MemberExpression
: 1 }]
1843 options
: [4, { MemberExpression
: 1 }]
1850 options
: [4, { MemberExpression
: 1 }]
1858 options
: [4, { MemberExpression
: 1 }]
1866 options
: ["tab", { MemberExpression
: 1 }]
1874 options
: [2, { MemberExpression
: 2 }]
1936 options
: [4, { MemberExpression
: "off" }]
1943 options
: [4, { MemberExpression
: 1 }]
1976 options
: [2, { FunctionDeclaration
: { parameters
: 1, body
: 2 } }]
1980 function foo(aaa, bbb,
1985 options
: [2, { FunctionDeclaration
: { parameters
: 3, body
: 1 } }]
1995 options
: [4, { FunctionDeclaration
: { parameters
: 1, body
: 3 } }]
2005 options
: [2, { FunctionDeclaration
: { parameters
: "first", body
: 1 } }]
2009 function foo(aaa, bbb)
2014 options
: [2, { FunctionDeclaration
: { body
: 3 } }]
2024 options
: [2, { FunctionDeclaration
: { parameters
: "first", body
: 2 } }]
2028 var foo = function(aaa,
2035 options
: [2, { FunctionExpression
: { parameters
: 2, body
: 0 } }]
2039 var foo = function(aaa,
2045 options
: [2, { FunctionExpression
: { parameters
: 1, body
: 10 } }]
2049 var foo = function(aaa,
2055 options
: [4, { FunctionExpression
: { parameters
: "first", body
: 1 } }]
2065 options
: [2, { FunctionExpression
: { parameters
: "first", body
: 3 } }]
2070 baz, qux, function() {
2075 options
: [2, { FunctionExpression
: { body
: 3 }, CallExpression
: { arguments
: 3 } }]
2082 \t \t\t\t \t\t\t \t \tqux();
2095 options
: [2, { FunctionDeclaration
: { body
: 1 } }]
2114 options
: [2, { FunctionDeclaration
: { body
: 1, parameters
: 2 } }]
2125 // ternary expressions (https://github.com/eslint/eslint/issues/7420)
2173 options
: [2, { offsetTernaryExpressions
: false }]
2189 options
: [2, { offsetTernaryExpressions
: true }]
2205 options
: [4, { offsetTernaryExpressions
: true }]
2211 ? Promise.resolve(1)
2212 : Promise.resolve(2)
2213 : Promise.resolve(3)
2215 options
: [2, { offsetTernaryExpressions
: true }]
2220 ? Promise.resolve(1)
2222 ? Promise.resolve(2)
2223 : Promise.resolve(3)
2225 options
: [2, { offsetTernaryExpressions
: true }]
2238 \t\t\t\treturn false
2241 options
: ["tab", { offsetTernaryExpressions
: true }]
2254 * Checking comments:
2255 * https://github.com/eslint/eslint/issues/3845, https://github.com/eslint/eslint/issues/6571
2272 // call the baz function
2275 options
: [2, { SwitchCase
: 1 }]
2285 options
: [2, { SwitchCase
: 1 }]
2295 * Destructuring assignments:
2296 * https://github.com/eslint/eslint/issues/6813
2303 foobar: baz = foobar
2373 // https://github.com/eslint/eslint/issues/7233
2375 var folder = filePath
2379 options
: [2, { MemberExpression
: 2 }]
2383 for (const foo of bar)
2418 // Don't lint the indentation of the first token after a :
2427 // Don't lint the indentation of the first token after a :
2448 // Comments in switch cases
2456 /* multiline comment
2460 options
: [2, { SwitchCase
: 1 }]
2464 // Comments in switch cases
2469 // the comment can also be here
2473 options
: [2, { SwitchCase
: 1 }]
2477 // BinaryExpressions with parens
2487 // BinaryExpressions with parens
2525 var bar = function(baz,
2531 options
: [2, { FunctionExpression
: { parameters
: 3 } }]
2535 return (bar === 1 || bar === 2 &&
2536 (/Function/.test(grandparent.type))) &&
2537 directives(parent).indexOf(node) >= 0;
2543 return (foo === bar || (
2559 (baz === 1 && qux === 1)
2572 return (bar === 1 || bar === 2) &&
2573 (z === 3 || z === 4);
2580 /* comment */ if (foo) {
2588 // Comments at the end of if blocks that have `else` blocks can either refer to the lines above or below them
2592 // Otherwise, if foo is false, do baz.
2593 // baz is very important.
2603 return ((bar === 1 || bar === 2) &&
2604 (z === 3 || z === 4));
2617 options
: [2, { CallExpression
: { arguments
: 1 } }]
2627 options
: ["tab", { CallExpression
: { arguments
: 1 } }]
2635 options
: [4, { CallExpression
: { arguments
: 2 } }]
2645 options
: [2, { CallExpression
: { arguments
: 0 } }]
2654 options
: [2, { CallExpression
: { arguments
: "first" } }]
2662 options
: [2, { CallExpression
: { arguments
: "first" } }]
2672 options
: [2, { CallExpression
: { arguments
: 4 } }]
2685 options
: [4, { CallExpression
: { arguments
: 1 } }]
2688 // https://github.com/eslint/eslint/issues/7484
2691 var foo = function() {
2701 // https://github.com/eslint/eslint/issues/7573
2708 parserOptions
: { ecmaFeatures
: { globalReturn
: true } }
2716 parserOptions
: { ecmaFeatures
: { globalReturn
: true } }
2737 options
: [2, { ArrayExpression
: 0 }]
2746 options
: [2, { ArrayExpression
: 8 }]
2755 options
: [2, { ArrayExpression
: "first" }]
2763 options
: [2, { ArrayExpression
: "first" }]
2774 options
: [4, { ArrayExpression
: 2, ObjectExpression
: "first" }]
2783 options
: [2, { ObjectExpression
: 0 }]
2787 var foo = { foo: 1, bar: 2,
2790 options
: [2, { ObjectExpression
: "first" }]
2800 options
: [4, { ArrayExpression
: 2 }]
2810 options
: [2, { ArrayExpression
: 4 }]
2814 options
: [2, { ArrayExpression
: "first" }]
2818 options
: [2, { ArrayExpression
: 1 }]
2822 options
: [2, { ObjectExpression
: "first" }]
2826 options
: [2, { ObjectExpression
: 1 }]
2836 options
: [2, { ArrayExpression
: "first" }]
2846 options
: [2, { ArrayExpression
: "first" }]
2856 options
: [4, { ArrayExpression
: "first", CallExpression
: { arguments
: "first" } }]
2864 options
: [4, { CallExpression
: { arguments
: "first" }, ArrayExpression
: "first" }]
2867 // https://github.com/eslint/eslint/issues/7732
2870 const lambda = foo => {
2879 options
: [2, { ObjectExpression
: 1 }]
2883 const lambda = foo => {
2892 options
: [2, { ObjectExpression
: "first" }]
2895 // https://github.com/eslint/eslint/issues/7733
2898 var foo = function() {
2913 echo = spawn('cmd.exe',
2917 options
: [2, { ArrayExpression
: "first", CallExpression
: { arguments
: "first" } }]
2923 // Otherwise, if foo is false, do baz.
2924 // baz is very important.
2935 baz && qux // This line is ignored because BinaryExpressions are not checked.
2985 options
: [4, { VariableDeclarator
: 2 }]
3004 options
: [2, { SwitchCase
: 1 }]
3066 // Don't check AssignmentExpression assignments
3079 const template = \`this indentation is not checked
3080 because it
's part of a template literal.\`;
3085 const template = \`the indentation of a \${
3087 } node is checked.\`;
3092 // https://github.com/eslint/eslint/issues/7320
3101 options: [4, { CallExpression: { arguments: 1 } }]
3113 /* comment */ bar();
3140 // https://github.com/eslint/eslint/issues/6007
3179 // https://github.com/eslint/eslint/issues/6670
3193 options: [4, { MemberExpression: 1 }]
3196 // https://github.com/eslint/eslint/issues/7242
3215 // https://github.com/eslint/eslint/issues/7616
3224 options: [4, { CallExpression: { arguments: "first" } }]
3235 var foo = 0, bar = 0, baz = 0;
3242 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3250 options: [4, { flatTernaryExpressions: true }]
3258 options: [4, { flatTernaryExpressions: true }]
3266 options: [4, { flatTernaryExpressions: true }]
3274 options: [4, { flatTernaryExpressions: true }]
3286 options: [4, { flatTernaryExpressions: true }]
3298 options: [4, { flatTernaryExpressions: true }]
3308 options: [4, { flatTernaryExpressions: true }]
3316 options: [4, { flatTernaryExpressions: true }]
3325 options: [4, { flatTernaryExpressions: true }]
3335 options: [4, { flatTernaryExpressions: true }]
3343 options: [4, { flatTernaryExpressions: true }]
3352 options: [4, { flatTernaryExpressions: true }]
3363 options: [4, { flatTernaryExpressions: true }]
3376 options: [4, { flatTernaryExpressions: true }]
3386 options: [4, { flatTernaryExpressions: true }]
3398 options: [4, { flatTernaryExpressions: true }]
3408 options: [4, { flatTernaryExpressions: true }]
3417 options: [4, { flatTernaryExpressions: true }]
3429 options: [4, { flatTernaryExpressions: false }]
3441 options: [4, { flatTernaryExpressions: false }]
3445 options: [2, { ArrayExpression: "first" }]
3449 options: [2, { ArrayExpression: "off" }]
3458 options: [4, { ArrayExpression: "first" }]
3461 code: "[sparse, , array];",
3462 options: [2, { ArrayExpression: "first" }]
3466 foo.bar('baz
', function(err) {
3470 options: [2, { CallExpression: { arguments: "first" } }]
3474 foo.bar(function() {
3480 options: [2, { MemberExpression: 1 }]
3484 foo.bar().baz(function() {
3490 options: [2, { MemberExpression: 1 }]
3501 options: [2, { ObjectExpression: "first" }]
3511 options: [4, { CallExpression: { arguments: "first" } }]
3516 bar ].forEach(function() {
3520 options: [2, { ArrayExpression: "first", MemberExpression: 1 }]
3533 options: [4, { MemberExpression: 1 }]
3543 options: [4, { MemberExpression: 1 }]
3554 ; [1, 2, 3].map(baz)
3566 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3569 code: "import 'foo
'",
3570 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3579 options: [4, { ImportDeclaration: 1 }],
3580 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3590 options: [4, { ImportDeclaration: 1 }],
3591 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3595 import { apple as a,
3596 banana as b } from 'fruits
';
3597 import { cat } from 'animals
';
3599 options: [4, { ImportDeclaration: "first" }],
3600 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3604 import { declaration,
3607 turned } from 'off
';
3609 options: [4, { ImportDeclaration: "off" }],
3610 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3613 // https://github.com/eslint/eslint/issues/8455
3624 ) => b => c => d => {
3672 var x = function foop(bar)
3736 options: [4, { SwitchCase: 1 }]
3751 options: [4, { MemberExpression: 2 }]
3771 options: [4, { MemberExpression: "off" }]
3780 options: [4, { MemberExpression: "off" }]
3789 options: [4, { MemberExpression: "off" }]
3797 options: [4, { MemberExpression: "off" }]
3805 options: [4, { MemberExpression: "off" }]
3814 options: [4, { flatTernaryExpressions: true }]
3823 options: [4, { flatTernaryExpressions: true }]
3830 options: [4, { flatTernaryExpressions: true }]
3839 options: [4, { flatTernaryExpressions: true }]
3979 //----------------------------------------------------------------------
3980 // Ignore Unknown Nodes
3981 //----------------------------------------------------------------------
3990 parser: parser("unknown-nodes/interface")
4003 parser: parser("unknown-nodes/namespace-valid")
4007 abstract class Foo {
4020 parser: parser("unknown-nodes/abstract-class-valid")
4036 parser: parser("unknown-nodes/functions-with-abstract-class-valid")
4054 parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-valid")
4058 type httpMethod = 'GET
'
4062 options: [2, { VariableDeclarator: 0 }],
4063 parser: parser("unknown-nodes/variable-declarator-type-indent-two-spaces")
4067 type httpMethod = 'GET
'
4071 options: [2, { VariableDeclarator: 1 }],
4072 parser: parser("unknown-nodes/variable-declarator-type-no-indent")
4094 // https://github.com/eslint/eslint/issues/8815
4096 async function test() {
4100 } = await doSomethingAsync(
4112 } = yield doSomethingAsync(
4145 //----------------------------------------------------------------------
4147 // https://github.com/eslint/eslint/issues/8425
4148 // Some of the following tests are adapted from the tests in eslint-plugin-react.
4149 // License: https://github.com/yannickcr/eslint-plugin-react/blob/7ca9841f22d599f447a27ef5b2a97def9229d6c8/LICENSE
4150 //----------------------------------------------------------------------
4152 "<Foo a=\"b\" c=\"d\"/>;",
4159 "var foo = <Bar a=\"b\" c=\"d\"/>;",
4198 "<a href=\"foo\">bar</a>;",
4239 var foo = <a href="bar">
4285 <a href="bar">baz</a>
4303 "var foo = <a href=\"bar\">baz</a>;",
4530 onClick={this.onClick}
4534 onClick={this.onClick}
4630 <App foo={function() {
4639 var x = function() {
4705 <App foo={function() {
4706 \tconsole.log('bar
');
4716 \t\tconsole.log('bar
');
4799 * https://github.com/eslint/eslint/issues/12208
5001 // https://github.com/eslint/eslint/issues/8832
5031 <small>Foo bar
5053 options: [2, { CallExpression: { arguments: "off" } }]
5063 options: [2, { CallExpression: { arguments: "off" } }]
5071 options: [4, { ignoredNodes: ["ConditionalExpression"] }]
5081 options: [4, { ignoredNodes: ["ClassBody"] }]
5091 options: [4, { ignoredNodes: ["ClassBody", "BlockStatement"] }]
5105 options: [4, { ignoredNodes: ["CallExpression > ObjectExpression"] }]
5112 options: [4, { ignoredNodes: ["MemberExpression"] }]
5124 ignoredNodes: ["Program > ExpressionStatement > CallExpression[callee.name='$'] > FunctionExpression > BlockStatement"]
5132 options: [4, { ignoredNodes: ["JSXOpeningElement"] }]
5141 options: [4, { ignoredNodes: ["JSXElement", "JSXOpeningElement"] }]
5151 options: [4, { ignoredNodes: ["ExpressionStatement > CallExpression > FunctionExpression.callee > BlockStatement"] }]
5161 options: [4, { ignoredNodes: ["ConditionalExpression"] }]
5165 var a = 0, b = 0, c = 0;
5173 options: [4, { ignoredNodes: ["ExportDefaultDeclaration > CallExpression > ObjectExpression"] }],
5174 parserOptions: { ecmaVersion: 6, sourceType: "module" }
5182 options: [4, { ignoredNodes: ["ConditionalExpression"] }]
5193 options: [4, { ignoredNodes: ["TemplateLiteral"] }]
5203 options: [4, { ignoredNodes: ["JSXOpeningElement"] }]
5220 options: ["tab", { ignoredNodes: ["VariableDeclarator"] }]
5229 options: ["tab", { ArrayExpression: "first", ignoredNodes: ["CallExpression"] }]
5236 // Intentionally unindented comment
5240 options: [4, { ignoreComments: true }]
5247 /* Intentionally unindented comment */
5251 options: [4, { ignoreComments: true }]
5256 return condition ? // comment
5263 //----------------------------------------------------------------------
5264 // Comment alignment tests
5265 //----------------------------------------------------------------------
5268 // Comment can align with code immediately above even if "incorrect" alignment
5275 // Comment can align with code immediately below even if "incorrect" alignment
5280 // Comment can be in correct alignment even if not aligned with code above/below
5286 // Comment can be in correct alignment even if gaps between (and not aligned with) code above/below
5295 // Comment between nodes
5306 // Comment between nodes
5415 ;[1, 2, 3].forEach(() => {})
5422 ;[1, 2, 3].forEach(() => {})
5429 ;[1, 2, 3].forEach(() => {})
5435 ;[1, 2, 3].forEach(() => {})
5443 [1, 2, 3].forEach(() => {})
5450 [1, 2, 3].forEach(() => {})
5457 [1, 2, 3].forEach(() => {})
5463 [1, 2, 3].forEach(() => {})
5470 [1, 2, 3].forEach(() => {})
5476 [1, 2, 3].forEach(() => {})
5481 ;[1, 2, 3].forEach(() => {})
5485 ;[1, 2, 3].forEach(() => {})
5494 ;[1, 2, 3].forEach(() => {})
5502 ;[1, 2, 3].forEach(() => {})
5509 ;[1, 2, 3].forEach(() => {})
5515 ;[1, 2, 3].forEach(() => {})
5519 // import expressions
5528 parserOptions: { ecmaVersion: 2020 }
5531 // https://github.com/eslint/eslint/issues/12122
5544 parserOptions: { ecmaVersion: 2015 }
5559 parserOptions: { ecmaVersion: 2015 }
5582 parserOptions: { ecmaVersion: 2015 }
5605 parserOptions: { ecmaVersion: 2015 }
5625 parserOptions: { ecmaVersion: 2015 }
5634 bar: tagTwo\`multiline
5642 parserOptions: { ecmaVersion: 2015 }
5646 foo.bar\` template literal \`(() => {
5650 parserOptions: { ecmaVersion: 2015 }
5654 foo.bar.baz\` template literal \`(() => {
5658 parserOptions: { ecmaVersion: 2015 }
5668 parserOptions: { ecmaVersion: 2015 }
5679 parserOptions: { ecmaVersion: 2015 }
5689 parserOptions: { ecmaVersion: 2015 }
5699 parserOptions: { ecmaVersion: 2015 }
5711 parserOptions: { ecmaVersion: 2015 }
5722 parserOptions: { ecmaVersion: 2015 }
5733 options: [4, { MemberExpression: 0 }],
5734 parserOptions: { ecmaVersion: 2015 }
5745 options: [4, { MemberExpression: 2 }],
5746 parserOptions: { ecmaVersion: 2015 }
5750 const foo = async (arg1,
5756 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5760 const foo = async /* some comments */(arg1,
5766 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5778 arg2) => async (arr1,
5784 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5788 const foo = async (arg1,
5798 const foo = async /*comments*/(arg1,
5808 const foo = async (arg1,
5814 options: [2, { FunctionDeclaration: { parameters: 4 }, FunctionExpression: { parameters: 4 } }]
5824 options: [2, { FunctionDeclaration: { parameters: 4 }, FunctionExpression: { parameters: 4 } }]
5828 async function fn(ar1,
5831 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5835 async function /* some comments */ fn(ar1,
5838 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5842 async /* some comments */ function fn(ar1,
5845 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5864 errors: expectedErrors([[3, 2, 0, "Identifier"]])
5868 require('http
').request({hostname: 'localhost
',
5869 port: 80}, function(res) {
5874 require('http
').request({hostname: 'localhost
',
5875 port: 80}, function(res) {
5880 errors: expectedErrors([[2, 2, 18, "Identifier"], [3, 2, 4, "Identifier"], [4, 0, 2, "Punctuator"]])
5884 if (array.some(function(){
5893 if (array.some(function(){
5902 errors: expectedErrors([[4, 2, 0, "Identifier"], [6, 2, 4, "Identifier"]])
5920 errors: expectedErrors("tab", [[3, 1, 2, "Identifier"], [4, 1, 0, "Identifier"]])
5938 errors: expectedErrors([[3, 4, 6, "Identifier"], [4, 4, 1, "Identifier"]])
5942 output: fixedFixture,
5943 options: [2, { SwitchCase: 1, MemberExpression: 1, CallExpression: { arguments: "off" } }],
5944 errors: expectedErrors([
5945 [5, 2, 4, "Keyword"],
5947 [10, 4, 6, "Punctuator"],
5948 [11, 2, 4, "Punctuator"],
5950 [15, 4, 2, "Identifier"],
5951 [16, 2, 4, "Punctuator"],
5952 [23, 2, 4, "Punctuator"],
5953 [29, 2, 4, "Keyword"],
5954 [30, 4, 6, "Identifier"],
5955 [36, 4, 6, "Identifier"],
5956 [38, 2, 4, "Punctuator"],
5957 [39, 4, 2, "Identifier"],
5958 [40, 2, 0, "Punctuator"],
5959 [54, 2, 4, "Punctuator"],
5960 [114, 4, 2, "Keyword"],
5961 [120, 4, 6, "Keyword"],
5962 [124, 4, 2, "Keyword"],
5963 [134, 4, 6, "Keyword"],
5964 [138, 2, 3, "Punctuator"],
5965 [139, 2, 3, "Punctuator"],
5966 [143, 4, 0, "Identifier"],
5967 [144, 6, 2, "Punctuator"],
5968 [145, 6, 2, "Punctuator"],
5969 [151, 4, 6, "Identifier"],
5970 [152, 6, 8, "Punctuator"],
5971 [153, 6, 8, "Punctuator"],
5972 [159, 4, 2, "Identifier"],
5973 [161, 4, 6, "Identifier"],
5974 [175, 2, 0, "Identifier"],
5975 [177, 2, 4, "Identifier"],
5976 [189, 2, 0, "Keyword"],
5977 [192, 6, 18, "Identifier"],
5978 [193, 6, 4, "Identifier"],
5979 [195, 6, 8, "Identifier"],
5980 [228, 5, 4, "Identifier"],
5981 [231, 3, 2, "Punctuator"],
5982 [245, 0, 2, "Punctuator"],
5983 [248, 0, 2, "Punctuator"],
5984 [304, 4, 6, "Identifier"],
5985 [306, 4, 8, "Identifier"],
5986 [307, 2, 4, "Punctuator"],
5987 [308, 2, 4, "Identifier"],
5988 [311, 4, 6, "Identifier"],
5989 [312, 4, 6, "Identifier"],
5990 [313, 4, 6, "Identifier"],
5991 [314, 2, 4, "Punctuator"],
5992 [315, 2, 4, "Identifier"],
5993 [318, 4, 6, "Identifier"],
5994 [319, 4, 6, "Identifier"],
5995 [320, 4, 6, "Identifier"],
5996 [321, 2, 4, "Punctuator"],
5997 [322, 2, 4, "Identifier"],
5998 [326, 2, 1, "Numeric"],
5999 [327, 2, 1, "Numeric"],
6000 [328, 2, 1, "Numeric"],
6001 [329, 2, 1, "Numeric"],
6002 [330, 2, 1, "Numeric"],
6003 [331, 2, 1, "Numeric"],
6004 [332, 2, 1, "Numeric"],
6005 [333, 2, 1, "Numeric"],
6006 [334, 2, 1, "Numeric"],
6007 [335, 2, 1, "Numeric"],
6008 [340, 2, 4, "Identifier"],
6009 [341, 2, 0, "Identifier"],
6010 [344, 2, 4, "Identifier"],
6011 [345, 2, 0, "Identifier"],
6012 [348, 2, 4, "Identifier"],
6013 [349, 2, 0, "Identifier"],
6014 [355, 2, 0, "Identifier"],
6015 [357, 2, 4, "Identifier"],
6016 [361, 4, 6, "Identifier"],
6017 [362, 2, 4, "Punctuator"],
6018 [363, 2, 4, "Identifier"],
6019 [368, 2, 0, "Keyword"],
6020 [370, 2, 4, "Keyword"],
6021 [374, 4, 6, "Keyword"],
6022 [376, 4, 2, "Keyword"],
6023 [383, 2, 0, "Identifier"],
6024 [385, 2, 4, "Identifier"],
6025 [390, 2, 0, "Identifier"],
6026 [392, 2, 4, "Identifier"],
6027 [409, 2, 0, "Identifier"],
6028 [410, 2, 4, "Identifier"],
6029 [416, 2, 0, "Identifier"],
6030 [417, 2, 4, "Identifier"],
6031 [418, 0, 4, "Punctuator"],
6032 [422, 2, 4, "Identifier"],
6033 [423, 2, 0, "Identifier"],
6034 [427, 2, 6, "Identifier"],
6035 [428, 2, 8, "Identifier"],
6036 [429, 2, 4, "Identifier"],
6037 [430, 0, 4, "Punctuator"],
6038 [433, 2, 4, "Identifier"],
6039 [434, 0, 4, "Punctuator"],
6040 [437, 2, 0, "Identifier"],
6041 [438, 0, 4, "Punctuator"],
6042 [442, 2, 4, "Identifier"],
6043 [443, 2, 4, "Identifier"],
6044 [444, 0, 2, "Punctuator"],
6045 [451, 2, 0, "Identifier"],
6046 [453, 2, 4, "Identifier"],
6047 [499, 6, 8, "Punctuator"],
6048 [500, 8, 6, "Identifier"],
6049 [504, 4, 6, "Punctuator"],
6050 [505, 6, 8, "Identifier"],
6051 [506, 4, 8, "Punctuator"]
6081 options: [4, { SwitchCase: 1 }],
6082 errors: expectedErrors([[4, 8, 4, "Keyword"], [7, 8, 4, "Keyword"]])
6100 errors: expectedErrors([[3, 8, 7, "Identifier"], [4, 8, 10, "Identifier"]])
6127 options: [4, { SwitchCase: 1 }],
6128 errors: expectedErrors([9, 8, 4, "Keyword"])
6171 options: [4, { SwitchCase: 1 }],
6172 errors: expectedErrors([[11, 8, 4, "Keyword"], [14, 8, 4, "Keyword"], [17, 8, 4, "Keyword"]])
6198 errors: expectedErrors([
6199 [3, 4, 8, "Identifier"],
6200 [4, 4, 8, "Keyword"],
6201 [5, 0, 4, "Keyword"],
6202 [6, 4, 8, "Keyword"],
6203 [7, 0, 4, "Keyword"],
6204 [8, 4, 8, "Keyword"]
6209 var obj = {foo: 1, bar: 2};
6211 console.log(foo + bar);
6215 var obj = {foo: 1, bar: 2};
6217 console.log(foo + bar);
6220 errors: expectedErrors([3, 4, 0, "Identifier"])
6243 options: [4, { SwitchCase: 1 }],
6244 errors: expectedErrors([
6245 [2, 4, 0, "Keyword"],
6246 [3, 8, 0, "Identifier"],
6247 [4, 8, 0, "Keyword"],
6248 [5, 4, 0, "Keyword"],
6249 [6, 8, 0, "Identifier"],
6250 [7, 8, 0, "Keyword"]
6255 var foo = function(){
6261 var foo = function(){
6266 options: [4, { MemberExpression: 1 }],
6267 errors: expectedErrors(
6268 [3, 8, 10, "Punctuator"]
6284 errors: expectedErrors([3, 8, 4, "Punctuator"])
6288 var foo = function(){
6294 var foo = function(){
6299 options: [4, { MemberExpression: 2 }],
6300 errors: expectedErrors(
6301 [3, 12, 13, "Punctuator"]
6317 options: [4, { MemberExpression: 2 }],
6318 errors: expectedErrors(
6319 [3, 12, 13, "Punctuator"]
6324 TestClass.prototype.method = function () {
6325 return Promise.resolve(3)
6326 .then(function (x) {
6332 TestClass.prototype.method = function () {
6333 return Promise.resolve(3)
6334 .then(function (x) {
6339 options: [2, { MemberExpression: 1 }],
6340 errors: expectedErrors([3, 4, 6, "Punctuator"])
6352 errors: expectedErrors([
6353 [2, 4, 0, "Identifier"]
6379 errors: expectedErrors([
6380 [2, 4, 8, "Identifier"],
6381 [3, 0, 4, "Punctuator"],
6382 [4, 0, 4, "Punctuator"],
6383 [5, 4, 8, "Identifier"],
6384 [6, 0, 4, "Punctuator"],
6385 [7, 0, 4, "Punctuator"],
6386 [8, 4, 8, "Identifier"]
6400 errors: expectedErrors([[2, 4, 0, "Identifier"], [3, 4, 0, "Identifier"]])
6417 errors: expectedErrors([[2, 4, 0, "Keyword"], [3, 4, 0, "Identifier"], [4, 4, 0, "Identifier"], [5, 0, 4, "Punctuator"]])
6429 errors: expectedErrors([
6430 [2, 4, 0, "Identifier"]
6443 errors: expectedErrors([
6444 [2, 4, 0, "Identifier"]
6459 errors: expectedErrors([
6460 [2, 4, 0, "Identifier"]
6473 errors: expectedErrors([
6474 [2, 4, 0, "Identifier"]
6491 errors: expectedErrors([
6492 [2, 2, 6, "Identifier"],
6493 [3, 2, 4, "Identifier"],
6494 [4, 0, 4, "Punctuator"]
6499 var a = function() {
6507 var a = function() {
6515 errors: expectedErrors([
6516 [2, 8, 6, "Identifier"],
6517 [3, 8, 4, "Identifier"],
6518 [4, 8, 10, "Identifier"]
6533 errors: expectedErrors([
6534 [2, 4, 0, "Identifier"],
6535 [3, 4, 0, "Identifier"]
6541 c].forEach((index) => {
6547 c].forEach((index) => {
6552 errors: expectedErrors([
6553 [3, 4, 8, "Identifier"],
6554 [4, 0, 4, "Punctuator"]
6560 c].forEach(function(index){
6566 c].forEach(function(index){
6571 errors: expectedErrors([
6572 [2, 4, 0, "Identifier"],
6573 [3, 4, 2, "Keyword"]
6578 [a, b, c].forEach(function(index){
6583 [a, b, c].forEach(function(index){
6588 errors: expectedErrors([
6589 [2, 4, 2, "Keyword"]
6605 options: [4, { MemberExpression: 1 }],
6606 errors: expectedErrors([[3, 8, 4, "Identifier"], [4, 4, 0, "Punctuator"]])
6622 errors: expectedErrors([
6623 [2, 4, 9, "String"],
6643 errors: expectedErrors([
6644 [2, 4, 9, "String"],
6645 [3, 4, 9, "String"],
6665 errors: expectedErrors([
6666 [2, 4, 9, "String"],
6667 [3, 4, 9, "String"],
6668 [4, 4, 9, "String"],
6688 errors: expectedErrors([
6689 [2, 4, 9, "String"],
6690 [3, 4, 9, "String"],
6691 [4, 4, 9, "String"],
6692 [5, 0, 2, "Punctuator"]
6710 errors: expectedErrors([[3, 4, 8, "Identifier"], [4, 0, 4, "Punctuator"]])
6733 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
6747 errors: expectedErrors([
6748 [2, 2, 0, "Identifier"],
6749 [3, 0, 2, "Identifier"]
6754 function salutation () {
6756 case 0: return console.log('hi
')
6757 case 1: return console.log('hey
')
6762 function salutation () {
6764 case 0: return console.log('hi
')
6765 case 1: return console.log('hey
')
6769 options: [2, { SwitchCase: 1 }],
6770 errors: expectedErrors([
6771 [3, 4, 2, "Keyword"]
6776 var geometry, box, face1, face2, colorT, colorB, sprite, padding, maxWidth,
6780 var geometry, box, face1, face2, colorT, colorB, sprite, padding, maxWidth,
6783 options: [2, { SwitchCase: 1 }],
6784 errors: expectedErrors([
6785 [2, 2, 0, "Identifier"]
6809 options: [4, { SwitchCase: 2 }],
6810 errors: expectedErrors([
6811 [2, 8, 0, "Keyword"],
6812 [3, 12, 0, "Identifier"],
6813 [4, 12, 0, "Keyword"],
6814 [5, 8, 0, "Keyword"],
6815 [6, 12, 0, "Identifier"],
6816 [7, 12, 0, "Keyword"]
6828 options: [2, { VariableDeclarator: 1 }],
6829 errors: expectedErrors([
6830 [2, 2, 0, "Identifier"]
6842 options: [2, { VariableDeclarator: 2 }],
6843 errors: expectedErrors([
6844 [2, 4, 2, "Identifier"]
6856 options: ["tab", { VariableDeclarator: 2 }],
6857 errors: expectedErrors("tab", [
6858 [2, 2, 1, "Identifier"]
6870 options: [2, { VariableDeclarator: 2 }],
6871 errors: expectedErrors([
6872 [2, 4, 2, "Identifier"]
6888 options: [2, { VariableDeclarator: "first" }],
6889 errors: expectedErrors([
6890 [2, 4, 2, "Identifier"],
6891 [4, 6, 2, "Identifier"]
6903 options: [2, { VariableDeclarator: { var: "first" } }],
6904 errors: expectedErrors([
6905 [2, 4, 2, "Identifier"]
6921 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
6922 errors: expectedErrors([
6923 [4, 6, 4, "Identifier"]
6939 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
6940 errors: expectedErrors([
6941 [2, 2, 4, "Identifier"],
6942 [3, 2, 4, "Identifier"]
6958 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
6959 errors: expectedErrors([
6960 [2, 2, 4, "Identifier"],
6961 [3, 2, 4, "Identifier"]
6977 options: [2, { VariableDeclarator: { let: 2 }, SwitchCase: 1 }],
6978 errors: expectedErrors([
6979 [2, 2, 4, "Identifier"],
6980 [3, 2, 4, "Identifier"]
6997 errors: expectedErrors([
6998 [2, 8, 6, "Identifier"],
6999 [3, 4, 2, "Punctuator"]
7008 const c = new Test({
7018 const c = new Test({
7023 options: [2, { VariableDeclarator: { var: 2 } }],
7024 errors: expectedErrors([
7025 [6, 4, 6, "Identifier"],
7026 [7, 2, 4, "Punctuator"],
7027 [8, 2, 4, "Identifier"]
7049 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
7050 errors: expectedErrors([6, 6, 7, "Identifier"])
7067 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
7068 errors: expectedErrors([4, 7, 8, "Identifier"])
7090 errors: expectedErrors([[4, 6, 8, "Identifier"], [5, 4, 6, "Punctuator"]])
7094 var path = require('path
')
7095 , crypto = require('crypto
')
7099 var path = require('path
')
7100 , crypto = require('crypto
')
7104 errors: expectedErrors([
7105 [2, 2, 1, "Punctuator"]
7119 errors: expectedErrors([
7120 [2, 4, 3, "Punctuator"]
7138 options: [4, { VariableDeclarator: 1, SwitchCase: 1 }],
7139 errors: expectedErrors([[2, 4, 2, "Identifier"]])
7156 options: [4, { VariableDeclarator: 1, SwitchCase: 1 }],
7157 errors: expectedErrors([[2, 4, 2, "Identifier"], [4, 4, 2, "Identifier"]])
7176 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
7177 errors: expectedErrors([[3, 6, 4, "Identifier"]])
7201 errors: expectedErrors([[5, 4, 2, "Keyword"]])
7225 errors: expectedErrors([[5, 4, 2, "Keyword"]])
7245 errors: expectedErrors([[4, 4, 2, "Keyword"]])
7262 options: [2, { outerIIFEBody: 0 }],
7263 errors: expectedErrors([[2, 0, 2, "Keyword"], [3, 2, 4, "Keyword"], [4, 0, 2, "Punctuator"]])
7280 options: [4, { outerIIFEBody: 2 }],
7281 errors: expectedErrors([[2, 8, 4, "Keyword"], [3, 12, 8, "Keyword"], [4, 8, 4, "Punctuator"]])
7294 options: [2, { outerIIFEBody: 0 }],
7295 errors: expectedErrors([[2, 2, 0, "Identifier"]])
7299 var ns = function(){
7300 function fooVar(x) {
7306 var ns = function(){
7307 function fooVar(x) {
7312 options: [4, { outerIIFEBody: 2 }],
7313 errors: expectedErrors([[2, 8, 4, "Keyword"], [3, 12, 8, "Keyword"], [4, 8, 4, "Punctuator"]])
7330 options: [2, { outerIIFEBody: 0 }],
7331 errors: expectedErrors([[3, 4, 2, "Keyword"]])
7336 function fooVar(x) {
7343 function fooVar(x) {
7348 options: [2, { outerIIFEBody: 2 }],
7349 errors: expectedErrors([[2, 2, 4, "Keyword"], [3, 4, 6, "Keyword"], [4, 2, 4, "Punctuator"]])
7355 \t\t\t\treturn x + 1;
7366 options: ["tab", { outerIIFEBody: 3 }],
7367 errors: expectedErrors("tab", [[3, 2, 4, "Keyword"]])
7384 options: [4, { outerIIFEBody: "off" }],
7385 errors: expectedErrors([[3, 8, 4, "Keyword"]])
7402 options: [4, { outerIIFEBody: "off" }],
7403 errors: expectedErrors([[3, 4, 0, "Keyword"]])
7420 options: [4, { outerIIFEBody: "off" }],
7421 errors: expectedErrors([[3, 8, 4, "Keyword"]])
7438 options: [4, { outerIIFEBody: "off" }],
7439 errors: expectedErrors([[3, 4, 0, "Keyword"]])
7450 options: [4, { MemberExpression: 1 }],
7451 errors: expectedErrors([[2, 4, 0, "Punctuator"]])
7464 options: [4, { MemberExpression: 1 }],
7465 errors: expectedErrors([[3, 4, 0, "Punctuator"]])
7476 options: [4, { MemberExpression: 1 }],
7477 errors: expectedErrors([[2, 4, 0, "Identifier"]])
7488 options: ["tab", { MemberExpression: 1 }],
7489 errors: expectedErrors("tab", [[2, 1, 2, "Identifier"]])
7502 options: [2, { MemberExpression: 2 }],
7503 errors: expectedErrors([[2, 4, 2, "Punctuator"], [3, 4, 2, "Punctuator"]])
7518 errors: expectedErrors([3, 8, 4, "Punctuator"])
7533 errors: expectedErrors([3, 8, 4, "Identifier"])
7537 // Indentation with multiple else statements: https://github.com/eslint/eslint/issues/6956
7541 else if (baz) foobar();
7542 else if (qux) qux();
7546 else if (baz) foobar();
7547 else if (qux) qux();
7550 errors: expectedErrors([3, 0, 2, "Keyword"])
7555 else if (baz) foobar();
7560 else if (baz) foobar();
7564 errors: expectedErrors([3, 0, 2, "Keyword"])
7578 errors: expectedErrors([[2, 0, 2, "Keyword"], [3, 0, 2, "Keyword"]])
7583 else if (baz) foobar();
7590 else if (baz) foobar();
7596 errors: expectedErrors([[3, 0, 5, "Keyword"], [4, 2, 7, "Identifier"], [5, 0, 5, "Punctuator"]])
7616 errors: expectedErrors([[3, 2, 4, "Identifier"], [4, 0, 5, "Punctuator"], [5, 2, 7, "Identifier"], [6, 0, 5, "Punctuator"]])
7631 options: [2, { FunctionDeclaration: { parameters: 1, body: 2 } }],
7632 errors: expectedErrors([[2, 2, 4, "Identifier"], [3, 4, 6, "Identifier"]])
7636 function foo(aaa, bbb,
7642 function foo(aaa, bbb,
7647 options: [2, { FunctionDeclaration: { parameters: 3, body: 1 } }],
7648 errors: expectedErrors([[2, 6, 2, "Identifier"], [3, 2, 0, "Identifier"]])
7665 options: [4, { FunctionDeclaration: { parameters: 1, body: 3 } }],
7666 errors: expectedErrors([[2, 4, 8, "Identifier"], [3, 4, 2, "Identifier"], [4, 12, 6, "Identifier"]])
7683 options: [2, { FunctionDeclaration: { parameters: "first", body: 1 } }],
7684 errors: expectedErrors([[2, 13, 2, "Identifier"], [3, 13, 19, "Identifier"], [4, 2, 3, "Identifier"]])
7688 function foo(aaa, bbb)
7694 function foo(aaa, bbb)
7699 options: [2, { FunctionDeclaration: { body: 3 } }],
7700 errors: expectedErrors([3, 6, 0, "Identifier"])
7717 options: [2, { FunctionDeclaration: { parameters: "first", body: 2 } }],
7718 errors: expectedErrors([[2, 2, 0, "Identifier"], [3, 2, 4, "Identifier"], [4, 4, 0, "Identifier"]])
7722 var foo = function(aaa,
7730 var foo = function(aaa,
7737 options: [2, { FunctionExpression: { parameters: 2, body: 0 } }],
7738 errors: expectedErrors([[2, 4, 2, "Identifier"], [4, 4, 6, "Identifier"], [5, 0, 2, "Identifier"]])
7742 var foo = function(aaa,
7749 var foo = function(aaa,
7755 options: [2, { FunctionExpression: { parameters: 1, body: 10 } }],
7756 errors: expectedErrors([[2, 2, 3, "Identifier"], [3, 2, 1, "Identifier"], [4, 20, 2, "Identifier"]])
7760 var foo = function(aaa,
7767 var foo = function(aaa,
7773 options: [4, { FunctionExpression: { parameters: "first", body: 1 } }],
7774 errors: expectedErrors([[2, 19, 2, "Identifier"], [3, 19, 24, "Identifier"], [4, 4, 8, "Identifier"]])
7791 options: [2, { FunctionExpression: { parameters: "first", body: 3 } }],
7792 errors: expectedErrors([[2, 2, 0, "Identifier"], [3, 2, 4, "Identifier"], [4, 6, 2, "Identifier"]])
7797 \t\t\tvar baz = qux;
7804 errors: expectedErrors([2, "0 spaces", "3 tabs", "Keyword"])
7822 errors: expectedErrors("tab", [[3, "1 tab", "2 spaces", "Identifier"], [4, "1 tab", "14 spaces", "Identifier"]])
7836 errors: expectedErrors([[3, "0 spaces", "2 tabs", "Punctuator"]])
7853 options: [2, { FunctionDeclaration: { body: 1 } }],
7854 errors: expectedErrors([3, 4, 8, "Identifier"])
7873 options: [2, { FunctionDeclaration: { body: 1, parameters: 2 } }],
7874 errors: expectedErrors([3, 6, 4, "Identifier"])
7879 var bar = function(baz,
7887 var bar = function(baz,
7893 options: [2, { FunctionExpression: { parameters: 3 } }],
7894 errors: expectedErrors([3, 8, 10, "Identifier"])
7899 baz, qux, function() {
7906 baz, qux, function() {
7911 options: [2, { FunctionExpression: { body: 3 }, CallExpression: { arguments: 3 } }],
7912 errors: expectedErrors([3, 12, 8, "Identifier"])
7935 errors: expectedErrors([
7936 [4, 4, 0, "Keyword"],
7937 [6, 4, 0, "Keyword"]
7955 errors: expectedErrors([4, 4, 0, "Keyword"])
7973 errors: expectedErrors([[4, 2, 4, "Punctuator"]])
7991 errors: expectedErrors([[4, 2, 4, "Punctuator"]])
7997 case 1: return function(a){
7998 return fn.call(that, a);
8006 case 1: return function(a){
8007 return fn.call(that, a);
8012 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
8013 errors: expectedErrors([[4, 6, 4, "Keyword"]])
8027 errors: expectedErrors([[2, 2, 3, "Keyword"]])
8042 options: [2, { CallExpression: { arguments: 1 } }],
8043 errors: expectedErrors([[2, 2, 0, "Identifier"], [4, 2, 4, "Identifier"]])
8056 options: [2, { CallExpression: { arguments: 2 } }],
8057 errors: expectedErrors([[2, "4 spaces", "1 tab", "Identifier"], [3, "4 spaces", "1 tab", "Identifier"]])
8070 options: ["tab", { CallExpression: { arguments: 1 } }],
8071 errors: expectedErrors("tab", [[2, 1, 2, "Identifier"], [3, 1, 2, "Identifier"]])
8082 options: [2, { CallExpression: { arguments: "first" } }],
8083 errors: expectedErrors([2, 4, 9, "Identifier"])
8096 options: [2, { CallExpression: { arguments: "first" } }],
8097 errors: expectedErrors([[2, 2, 10, "Identifier"], [3, 2, 4, "Identifier"]])
8114 options: [2, { CallExpression: { arguments: 3 } }],
8115 errors: expectedErrors([[2, 6, 2, "Numeric"], [3, 6, 14, "Punctuator"], [4, 6, 8, "Keyword"]])
8118 // https://github.com/eslint/eslint/issues/7573
8130 parserOptions: { ecmaFeatures: { globalReturn: true } },
8131 errors: expectedErrors([3, 0, 4, "Punctuator"])
8144 parserOptions: { ecmaFeatures: { globalReturn: true } },
8145 errors: expectedErrors([3, 0, 4, "Punctuator"])
8148 // https://github.com/eslint/eslint/issues/7604
8160 errors: expectedErrors([2, 4, 8, "Block"])
8175 errors: expectedErrors([2, 4, 8, "Block"])
8188 options: [4, { CallExpression: { arguments: 1 } }],
8189 errors: expectedErrors([2, 4, 0, "Punctuator"])
8203 errors: expectedErrors([2, 4, 0, "Identifier"])
8206 // ternary expressions (https://github.com/eslint/eslint/issues/7420)
8219 errors: expectedErrors([[2, 2, 0, "Punctuator"], [3, 2, 4, "Punctuator"]])
8238 errors: expectedErrors([5, 4, 8, "Identifier"])
8267 options: [2, { offsetTernaryExpressions: true }],
8268 errors: expectedErrors([
8269 [2, 2, 0, "Punctuator"],
8270 [3, 6, 0, "Keyword"],
8271 [4, 4, 0, "Punctuator"],
8272 [5, 2, 0, "Punctuator"],
8273 [6, 4, 0, "Punctuator"],
8274 [7, 8, 0, "Keyword"],
8275 [8, 6, 0, "Punctuator"],
8276 [9, 4, 0, "Punctuator"],
8277 [10, 8, 0, "Keyword"],
8278 [11, 6, 0, "Punctuator"]
8308 options: [2, { offsetTernaryExpressions: false }],
8309 errors: expectedErrors([
8310 [2, 2, 0, "Punctuator"],
8311 [3, 4, 0, "Keyword"],
8312 [4, 2, 0, "Punctuator"],
8313 [5, 2, 0, "Punctuator"],
8314 [6, 4, 0, "Punctuator"],
8315 [7, 6, 0, "Keyword"],
8316 [8, 4, 0, "Punctuator"],
8317 [9, 4, 0, "Punctuator"],
8318 [10, 6, 0, "Keyword"],
8319 [11, 4, 0, "Punctuator"]
8325 * Checking comments:
8326 * https://github.com/eslint/eslint/issues/6571
8345 errors: expectedErrors([[2, 0, 2, "Line"], [3, 0, 4, "Block"], [6, 0, 1, "Line"]])
8348 code: " // comment",
8349 output: "// comment",
8350 errors: expectedErrors([1, 0, 2, "Line"])
8361 errors: expectedErrors([2, 0, 2, "Line"])
8372 errors: expectedErrors([1, 0, 2, "Line"])
8385 errors: expectedErrors([2, 4, 8, "Line"])
8390 * Destructuring assignments:
8391 * https://github.com/eslint/eslint/issues/6813
8398 foobar: baz = foobar
8406 foobar: baz = foobar
8410 errors: expectedErrors([[2, 2, 0, "Identifier"], [4, 2, 4, "Identifier"], [5, 2, 6, "Identifier"], [6, 0, 2, "Punctuator"]])
8428 errors: expectedErrors([[4, 2, 4, "Identifier"], [5, 0, 2, "Punctuator"]])
8443 errors: expectedErrors([[2, 4, 11, "Identifier"], [3, 4, 2, "Identifier"], [4, 0, 10, "Punctuator"]])
8458 errors: expectedErrors([2, 4, 0, "Identifier"])
8473 options: [2, { ArrayExpression: 0 }],
8474 errors: expectedErrors([[2, 0, 2, "Identifier"], [3, 0, 2, "Identifier"]])
8489 options: [2, { ArrayExpression: 8 }],
8490 errors: expectedErrors([[2, 16, 2, "Identifier"], [3, 16, 2, "Identifier"]])
8505 options: [2, { ArrayExpression: "first" }],
8506 errors: expectedErrors([[2, 11, 4, "Identifier"], [3, 11, 4, "Identifier"]])
8519 options: [2, { ArrayExpression: "first" }],
8520 errors: expectedErrors([2, 11, 4, "Identifier"])
8539 options: [4, { ArrayExpression: 2, ObjectExpression: "first" }],
8540 errors: expectedErrors([[3, 10, 12, "Identifier"], [5, 10, 12, "Identifier"]])
8555 options: [2, { ObjectExpression: 0 }],
8556 errors: expectedErrors([[2, 0, 2, "Identifier"], [3, 0, 2, "Identifier"]])
8560 var quux = { foo: 1, bar: 2,
8564 var quux = { foo: 1, bar: 2,
8567 options: [2, { ObjectExpression: "first" }],
8568 errors: expectedErrors([2, 13, 0, "Identifier"])
8585 options: [2, { ArrayExpression: 4 }],
8586 errors: expectedErrors([[2, 2, 4, "Punctuator"], [3, 10, 12, "Identifier"], [4, 2, 4, "Punctuator"]])
8606 errors: expectedErrors([[2, 2, 0, "Identifier"], [4, 2, 4, "Identifier"], [5, 2, 6, "Identifier"], [6, 0, 2, "Punctuator"]])
8623 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8624 errors: expectedErrors([[2, 4, 0, "Identifier"], [3, 4, 2, "Identifier"]])
8639 options: [4, { ImportDeclaration: "first" }],
8640 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8641 errors: expectedErrors([[3, 9, 10, "Identifier"]])
8656 options: [2, { ImportDeclaration: 2 }],
8657 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8658 errors: expectedErrors([[3, 4, 5, "Identifier"]])
8662 var foo = 0, bar = 0, baz = 0;
8670 var foo = 0, bar = 0, baz = 0;
8677 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8678 errors: expectedErrors([[3, 4, 0, "Identifier"], [4, 4, 2, "Identifier"]])
8682 var foo = 0, bar = 0, baz = 0;
8690 var foo = 0, bar = 0, baz = 0;
8697 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8698 errors: expectedErrors([[3, 4, 0, "Identifier"], [4, 4, 2, "Identifier"]])
8702 // https://github.com/eslint/eslint/issues/7233
8704 var folder = filePath
8709 var folder = filePath
8713 options: [2, { MemberExpression: 2 }],
8714 errors: expectedErrors([[2, 4, 2, "Punctuator"], [3, 4, 6, "Punctuator"]])
8718 for (const foo of bar)
8722 for (const foo of bar)
8726 errors: expectedErrors([2, 2, 4, "Identifier"])
8738 errors: expectedErrors([2, 2, 4, "Numeric"])
8742 // BinaryExpressions with parens
8754 errors: expectedErrors([2, 4, 8, "Identifier"])
8767 errors: expectedErrors([3, 4, 0, "Punctuator"])
8782 errors: expectedErrors([[3, 8, 4, "Identifier"], [4, 4, 0, "Punctuator"]])
8795 errors: expectedErrors([3, 0, 4, "Punctuator"])
8810 errors: expectedErrors([[3, 12, 16, "Identifier"], [4, 8, 12, "Punctuator"]])
8825 errors: expectedErrors([[3, 4, 8, "Numeric"], [4, 0, 4, "Punctuator"]])
8839 errors: expectedErrors([2, 2, 0, "Identifier"])
8853 errors: expectedErrors([[2, 2, 4, "Template"], [3, 4, 0, "Identifier"]])
8871 errors: expectedErrors([[2, 2, 4, "Template"], [3, 4, 2, "Identifier"], [4, 2, 4, "Template"], [5, 0, 2, "Template"]])
8889 errors: expectedErrors([[2, 2, 0, "Punctuator"], [3, 4, 2, "Identifier"], [4, 2, 0, "Punctuator"]])
8906 errors: expectedErrors([[3, 8, 0, "Identifier"], [4, 8, 2, "Identifier"]])
8911 const template = \`the indentation of
8912 a curly element in a \${
8914 } node is checked.\`;
8919 const template = \`the indentation of
8920 a curly element in a \${
8922 } node is checked.\`;
8925 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Template"]])
8930 const template = \`this time the
8931 closing curly is at the end of the line \${
8933 so the spaces before this line aren't removed
.\`;
8938 const template = \`this time the
8939 closing curly is at the end
of the line
\${
8941 so the spaces before
this line aren
't removed.\`;
8944 errors: expectedErrors([4, 4, 12, "Identifier"])
8949 * https://github.com/eslint/eslint/issues/1801
8950 * Note: This issue also mentioned checking the indentation for the 2 below. However,
8951 * this is intentionally ignored because everyone seems to have a different idea of how
8952 * BinaryExpressions should be indented.
8968 errors: expectedErrors([3, 8, 0, "Numeric"])
8972 // https://github.com/eslint/eslint/issues/3737
8988 errors: expectedErrors([[2, 2, 4, "Keyword"], [3, 4, 6, "Identifier"]])
8992 // https://github.com/eslint/eslint/issues/6670
9019 options: [4, { MemberExpression: 1, CallExpression: { arguments: 1 } }],
9020 errors: expectedErrors([
9021 [3, 8, 4, "Punctuator"],
9022 [4, 12, 15, "String"],
9023 [5, 12, 14, "Punctuator"],
9024 [6, 16, 14, "Numeric"],
9025 [7, 16, 9, "Numeric"],
9026 [8, 16, 35, "Numeric"],
9027 [9, 12, 22, "Punctuator"],
9028 [10, 8, 0, "Punctuator"],
9029 [11, 0, 1, "Punctuator"]
9033 // https://github.com/eslint/eslint/issues/7242
9047 errors: expectedErrors([[2, 4, 6, "Punctuator"], [3, 4, 2, "Punctuator"]])
9062 errors: expectedErrors([[2, 4, 6, "Punctuator"], [3, 4, 2, "Punctuator"]])
9066 echo = spawn('cmd
.exe
',
9071 echo = spawn('cmd
.exe
',
9075 options: [2, { ArrayExpression: "first", CallExpression: { arguments: "first" } }],
9076 errors: expectedErrors([[2, 13, 12, "Punctuator"], [3, 14, 13, "String"]])
9080 // https://github.com/eslint/eslint/issues/7522
9089 errors: expectedErrors([2, 0, 2, "Punctuator"])
9093 // https://github.com/eslint/eslint/issues/7616
9110 options: [4, { CallExpression: { arguments: "first" } }],
9111 errors: expectedErrors([[2, 4, 8, "Identifier"]])
9116 errors: expectedErrors([1, 0, 2, "Keyword"])
9120 var foo = 0, bar = 0, baz = 0;
9128 var foo = 0, bar = 0, baz = 0;
9135 parserOptions: { ecmaVersion: 6, sourceType: "module" },
9136 errors: expectedErrors([[3, 4, 0, "Identifier"], [4, 4, 8, "Identifier"], [5, 4, 2, "Identifier"]])
9149 options: [4, { flatTernaryExpressions: true }],
9150 errors: expectedErrors([3, 4, 0, "Punctuator"])
9163 options: [4, { flatTernaryExpressions: true }],
9164 errors: expectedErrors([3, 4, 0, "Identifier"])
9177 options: [4, { flatTernaryExpressions: true }],
9178 errors: expectedErrors([3, 4, 2, "Punctuator"])
9191 options: [4, { flatTernaryExpressions: true }],
9192 errors: expectedErrors([3, 4, 0, "Identifier"])
9207 options: [4, { flatTernaryExpressions: true }],
9208 errors: expectedErrors([
9209 [3, 4, 8, "Punctuator"],
9210 [4, 4, 12, "Punctuator"]
9226 options: [4, { flatTernaryExpressions: true }],
9227 errors: expectedErrors([
9228 [3, 4, 8, "Identifier"],
9229 [4, 4, 12, "Identifier"]
9247 options: [4, { flatTernaryExpressions: true }],
9248 errors: expectedErrors([
9249 [3, 4, 6, "Identifier"],
9250 [4, 4, 2, "Identifier"]
9266 options: [4, { flatTernaryExpressions: true }],
9267 errors: expectedErrors([
9268 [3, 8, 4, "Punctuator"],
9269 [4, 8, 4, "Punctuator"]
9285 options: [4, { flatTernaryExpressions: false }],
9286 errors: expectedErrors([
9287 [3, 8, 4, "Punctuator"],
9288 [4, 12, 4, "Punctuator"]
9304 options: [4, { flatTernaryExpressions: false }],
9305 errors: expectedErrors([
9306 [3, 8, 4, "Identifier"],
9307 [4, 12, 4, "Identifier"]
9329 options: [4, { flatTernaryExpressions: false }],
9330 errors: expectedErrors([
9331 [4, 8, 4, "Punctuator"],
9332 [5, 8, 4, "Punctuator"],
9333 [6, 12, 4, "Punctuator"],
9334 [7, 12, 4, "Punctuator"]
9356 options: [4, { flatTernaryExpressions: false }],
9357 errors: expectedErrors([
9358 [4, 8, 4, "Identifier"],
9359 [5, 8, 4, "Identifier"],
9360 [6, 12, 4, "Identifier"],
9361 [7, 12, 4, "Identifier"]
9366 foo.bar('baz
', function(err) {
9371 foo.bar('baz
', function(err) {
9375 options: [2, { CallExpression: { arguments: "first" } }],
9376 errors: expectedErrors([2, 2, 10, "Identifier"])
9380 foo.bar(function() {
9387 foo.bar(function() {
9393 options: [2, { MemberExpression: 1 }],
9394 errors: expectedErrors([[4, 2, 4, "Identifier"], [5, 0, 2, "Punctuator"]])
9398 foo.bar().baz(function() {
9405 foo.bar().baz(function() {
9411 options: [2, { MemberExpression: 1 }],
9412 errors: expectedErrors([[4, 2, 4, "Identifier"], [5, 0, 2, "Punctuator"]])
9417 bar ].forEach(function() {
9423 bar ].forEach(function() {
9427 options: [2, { ArrayExpression: "first", MemberExpression: 1 }],
9428 errors: expectedErrors([[3, 2, 4, "Identifier"], [4, 0, 2, "Punctuator"]])
9441 options: [4, { MemberExpression: 1 }],
9442 errors: expectedErrors([3, 0, 4, "Punctuator"])
9457 options: [4, { ObjectExpression: "first" }],
9458 errors: expectedErrors([[2, 4, 0, "Identifier"], [3, 4, 0, "Identifier"]])
9471 options: [2, { CallExpression: { arguments: "first" } }],
9472 errors: expectedErrors([[2, 2, 24, "Identifier"], [3, 2, 24, "Identifier"]])
9478 ; [1, 2, 3].map(baz)
9483 ; [1, 2, 3].map(baz)
9485 errors: expectedErrors([3, 0, 4, "Punctuator"])
9496 errors: expectedErrors([2, 4, 0, "Punctuator"])
9507 parserOptions: { ecmaVersion: 6, sourceType: "module" },
9508 errors: expectedErrors([2, 4, 0, "Identifier"])
9519 parserOptions: { ecmaVersion: 6, sourceType: "module" },
9520 errors: expectedErrors([2, 4, 0, "Identifier"])
9537 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9543 ) => b => c => d => {
9550 ) => b => c => d => {
9554 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9571 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9588 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9605 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9622 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9635 errors: expectedErrors([[2, 4, 2, "Identifier"], [3, 4, 6, "Identifier"]])
9654 errors: expectedErrors([[4, 8, 12, "String"], [5, 8, 12, "String"], [6, 4, 8, "Punctuator"]])
9673 errors: expectedErrors([[4, 8, 12, "String"], [5, 8, 12, "String"], [6, 4, 8, "Punctuator"]])
9692 errors: expectedErrors([[6, 8, 4, "Punctuator"]])
9709 errors: expectedErrors([[4, 12, 8, "String"]])
9712 //----------------------------------------------------------------------
9713 // Ignore Unknown Nodes
9714 //----------------------------------------------------------------------
9737 parser: parser("unknown-nodes/namespace-invalid"),
9738 errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]])
9742 abstract class Foo {
9756 abstract class Foo {
9769 parser: parser("unknown-nodes/abstract-class-invalid"),
9770 errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]])
9799 parser: parser("unknown-nodes/functions-with-abstract-class-invalid"),
9800 errors: expectedErrors([
9801 [4, 12, 8, "Keyword"],
9802 [5, 16, 8, "Keyword"],
9803 [6, 20, 8, "Identifier"],
9804 [7, 16, 8, "Punctuator"],
9805 [8, 12, 8, "Punctuator"]
9839 parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid"),
9840 errors: expectedErrors([
9841 [3, 8, 4, "Keyword"],
9842 [7, 24, 20, "Identifier"]
9846 //----------------------------------------------------------------------
9848 // Some of the following tests are adapted from the tests in eslint-plugin-react.
9849 // License: https://github.com/yannickcr/eslint-plugin-react/blob/7ca9841f22d599f447a27ef5b2a97def9229d6c8/LICENSE
9850 //----------------------------------------------------------------------
9863 errors: expectedErrors([2, 4, 2, "Punctuator"])
9877 errors: expectedErrors([2, 2, 4, "Punctuator"])
9891 errors: expectedErrors([2, "1 tab", "4 spaces", "Punctuator"])
9909 errors: expectedErrors([4, 2, 9, "Punctuator"])
9927 errors: expectedErrors([4, 2, 4, "Punctuator"])
9949 errors: expectedErrors([[3, 4, 0, "Punctuator"], [4, 6, 2, "Punctuator"], [5, 4, 0, "Punctuator"]])
9962 errors: expectedErrors([2, 4, 1, "Punctuator"])
9967 {options.map((option, index) => (
9968 <option key={index} value={option.key}>
9976 {options.map((option, index) => (
9977 <option key={index} value={option.key}>
9983 errors: expectedErrors([4, 12, 11, "Punctuator"])
9999 errors: expectedErrors([3, 2, 4, "Punctuator"])
10017 errors: expectedErrors([3, "1 tab", "1 space", "Punctuator"])
10022 * Multiline ternary
10023 * (colon at the end of the first expression)
10035 errors: expectedErrors([3, 4, 0, "Punctuator"])
10040 * Multiline ternary
10041 * (colon on its own line)
10055 errors: expectedErrors([[3, 4, 0, "Punctuator"], [4, 4, 0, "Punctuator"]])
10060 * Multiline ternary
10061 * (colon at the end of the first expression, parenthesized first expression)
10075 errors: expectedErrors([4, 4, 0, "Punctuator"])
10088 errors: expectedErrors([2, 4, 2, "JSXIdentifier"])
10102 errors: expectedErrors([3, 0, 2, "Punctuator"])
10116 errors: expectedErrors([3, 0, 2, "Punctuator"])
10120 const Button = function(props) {
10132 const Button = function(props) {
10144 errors: expectedErrors([6, 4, 36, "Punctuator"])
10148 var x = function() {
10155 var x = function() {
10162 errors: expectedErrors([4, 2, 9, "Punctuator"])
10176 errors: expectedErrors([3, 0, 8, "Punctuator"])
10192 errors: expectedErrors([3, 2, 4, "Punctuator"])
10206 errors: expectedErrors("tab", [3, 0, 1, "Punctuator"])
10220 errors: expectedErrors("tab", [3, 0, 1, "Punctuator"])
10249 errors: expectedErrors([
10250 [3, 8, 4, "Punctuator"],
10251 [4, 8, 4, "Punctuator"],
10252 [9, 8, 4, "JSXIdentifier"],
10253 [10, 8, 4, "JSXIdentifier"]
10271 errors: expectedErrors([4, 8, 4, "JSXText"])
10288 errors: expectedErrors([4, 8, 4, "Punctuator"])
10305 errors: expectedErrors([4, 8, 4, "Punctuator"])
10322 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
10343 errors: expectedErrors([[5, 4, 8, "Punctuator"], [6, 4, 8, "Punctuator"], [7, 0, 4, "Punctuator"]])
10364 errors: expectedErrors([[3, 8, 4, "Punctuator"], [4, 12, 8, "Numeric"], [5, 8, 4, "Punctuator"]])
10381 errors: expectedErrors([3, 8, 6, "Block"])
10394 errors: expectedErrors([2, 4, 0, "Punctuator"])
10411 errors: expectedErrors([3, 8, 6, "Punctuator"])
10424 errors: expectedErrors([2, 4, 0, "Punctuator"])
10428 <small>Foo bar
10433 <small>Foo bar
10437 errors: expectedErrors([2, 4, 0, "Punctuator"])
10442 * https://github.com/eslint/eslint/issues/12208
10455 errors: expectedErrors([2, 4, 0, "Punctuator"])
10470 errors: expectedErrors([2, 0, 4, "Punctuator"])
10485 errors: expectedErrors([4, 0, 4, "Punctuator"])
10500 errors: expectedErrors([4, 0, 4, "Punctuator"])
10517 errors: expectedErrors([
10518 [2, 0, 4, "Punctuator"],
10519 [5, 0, 4, "Punctuator"]
10537 errors: expectedErrors([
10538 [2, 0, 4, "Punctuator"],
10539 [5, 0, 4, "Punctuator"]
10555 errors: expectedErrors([2, 0, 4, "Punctuator"])
10570 errors: expectedErrors([4, 0, 4, "Punctuator"])
10585 errors: expectedErrors([4, 0, 4, "Punctuator"])
10600 errors: expectedErrors([2, 0, 4, "Punctuator"])
10615 errors: expectedErrors([4, 0, 4, "Punctuator"])
10630 errors: expectedErrors([4, 0, 4, "Punctuator"])
10644 parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation"),
10645 errors: expectedErrors([3, 0, 4, "Punctuator"])
10658 parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation"),
10659 errors: expectedErrors([3, 0, 4, "Punctuator"])
10672 parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation"),
10673 errors: expectedErrors([3, 0, 4, "Punctuator"])
10690 options: [4, { ignoredNodes: ["ClassBody"] }],
10691 errors: expectedErrors([3, 4, 0, "Identifier"])
10719 ignoredNodes: ["ExpressionStatement > CallExpression[callee.name='$'] > FunctionExpression > BlockStatement"]
10721 errors: expectedErrors([7, 4, 0, "Identifier"])
10739 ignoredNodes: ["ExpressionStatement > CallExpression > FunctionExpression.callee > BlockStatement"]
10741 errors: expectedErrors([3, 4, 0, "Identifier"])
10748 // Intentionally unindented comment
10756 // Intentionally unindented comment
10760 options: [4, { ignoreComments: false }],
10761 errors: expectedErrors([4, 4, 0, "Line"])
10768 /* Intentionally unindented comment */
10776 /* Intentionally unindented comment */
10780 options: [4, { ignoreComments: false }],
10781 errors: expectedErrors([4, 4, 0, "Block"])
10787 return condition ? // comment
10796 return condition ? // comment
10802 errors: expectedErrors([4, 12, 8, "Numeric"])
10805 //----------------------------------------------------------------------
10806 // Comment alignment tests
10807 //----------------------------------------------------------------------
10812 // Comment cannot align with code immediately above if there is a whitespace gap
10819 // Comment cannot align with code immediately above if there is a whitespace gap
10823 errors: expectedErrors([3, 4, 0, "Line"])
10830 // Comment cannot align with code immediately below if there is a whitespace gap
10838 // Comment cannot align with code immediately below if there is a whitespace gap
10842 errors: expectedErrors([4, 4, 0, "Line"])
10850 // Comment between nodes
10861 // Comment between nodes
10867 errors: expectedErrors([5, 0, 4, "Line"])
10875 ;(async () => {})()
10882 ;(async () => {})()
10884 errors: expectedErrors([3, 0, 4, "Line"])
10890 ;(async () => {})()
10895 ;(async () => {})()
10897 errors: expectedErrors([2, 0, 4, "Line"])
10914 errors: expectedErrors([3, 4, 0, "Block"])
10920 ;(async () => {})()
10925 ;(async () => {})()
10927 errors: expectedErrors([1, 0, 4, "Line"])
10932 ;(async () => {})()
10936 ;(async () => {})()
10938 errors: expectedErrors([1, 0, 4, "Line"])
10947 ;(async () => {})()
10957 ;(async () => {})()
10961 errors: expectedErrors([4, 4, 8, "Line"])
10968 ;(async () => {})()
10976 ;(async () => {})()
10980 errors: expectedErrors([3, 4, 8, "Line"])
11003 errors: expectedErrors([4, 8, 4, "Block"])
11012 ;[1, 2, 3].forEach(() => {})
11020 ;[1, 2, 3].forEach(() => {})
11022 errors: expectedErrors([4, 0, 4, "Block"])
11029 ;[1, 2, 3].forEach(() => {})
11035 ;[1, 2, 3].forEach(() => {})
11037 errors: expectedErrors([3, 0, 4, "Block"])
11046 [1, 2, 3].forEach(() => {})
11054 [1, 2, 3].forEach(() => {})
11056 errors: expectedErrors([4, 4, 0, "Block"])
11062 ;[1, 2, 3].forEach(() => {})
11067 ;[1, 2, 3].forEach(() => {})
11069 errors: expectedErrors([1, 0, 4, "Block"])
11074 ;[1, 2, 3].forEach(() => {})
11078 ;[1, 2, 3].forEach(() => {})
11080 errors: expectedErrors([1, 0, 4, "Block"])
11090 ;[1, 2, 3].forEach(() => {})
11101 ;[1, 2, 3].forEach(() => {})
11105 errors: expectedErrors([5, 4, 8, "Block"])
11113 ;[1, 2, 3].forEach(() => {})
11122 ;[1, 2, 3].forEach(() => {})
11126 errors: expectedErrors([4, 4, 8, "Block"])
11136 [1, 2, 3].forEach(() => {})
11147 [1, 2, 3].forEach(() => {})
11151 errors: expectedErrors([5, 8, 4, "Block"])
11154 // import expressions
11166 parserOptions: { ecmaVersion: 2020 },
11167 errors: expectedErrors([
11168 [2, 4, 0, "Identifier"],
11169 [3, 0, 4, "Punctuator"]
11173 // https://github.com/eslint/eslint/issues/12122
11179 template\${a} \${b}
11190 template\${a} \${b}
11197 parserOptions: { ecmaVersion: 2015 },
11198 errors: expectedErrors([
11199 [7, 8, 4, "Identifier"]
11209 \${a} \${b}\`(() => {
11220 \${a} \${b}\`(() => {
11225 parserOptions: { ecmaVersion: 2015 },
11226 errors: expectedErrors([
11227 [2, 4, 8, "Identifier"],
11228 [7, 8, 12, "Identifier"],
11229 [8, 4, 8, "Punctuator"]
11235 tagOne\`\${a} \${b}
11254 tagOne\`\${a} \${b}
11271 parserOptions: { ecmaVersion: 2015 },
11272 errors: expectedErrors([
11273 [7, 8, 12, "Identifier"],
11274 [15, 8, 12, "Identifier"],
11275 [16, 4, 0, "Punctuator"]
11285 \${a} \${b}\`(() => {
11304 \${a} \${b}\`(() => {
11317 parserOptions: { ecmaVersion: 2015 },
11318 errors: expectedErrors([
11319 [7, 8, 12, "Identifier"],
11320 [15, 8, 12, "Identifier"],
11321 [16, 4, 0, "Punctuator"]
11326 tagOne\`multiline \${a} \${b}
11342 tagOne\`multiline \${a} \${b}
11357 parserOptions: { ecmaVersion: 2015 },
11358 errors: expectedErrors([
11359 [5, 4, 0, "Identifier"],
11360 [11, 8, 4, "Identifier"]
11366 template \${a} \${b}
11369 bar: tagTwo\`multiline
11379 template \${a} \${b}
11382 bar: tagTwo\`multiline
11390 parserOptions: { ecmaVersion: 2015 },
11391 errors: expectedErrors([
11392 [4, 4, 8, "Identifier"],
11393 [5, 4, 0, "Identifier"],
11394 [9, 8, 0, "Identifier"]
11399 foo.bar\` template literal \`(() => {
11404 foo.bar\` template literal \`(() => {
11408 parserOptions: { ecmaVersion: 2015 },
11409 errors: expectedErrors([
11410 [2, 4, 8, "Identifier"]
11415 foo.bar.baz\` template literal \`(() => {
11420 foo.bar.baz\` template literal \`(() => {
11424 parserOptions: { ecmaVersion: 2015 },
11425 errors: expectedErrors([
11426 [2, 4, 0, "Identifier"],
11427 [3, 0, 4, "Punctuator"]
11445 parserOptions: { ecmaVersion: 2015 },
11446 errors: expectedErrors([
11447 [5, 4, 0, "Punctuator"]
11467 parserOptions: { ecmaVersion: 2015 },
11468 errors: expectedErrors([
11469 [5, 8, 0, "Identifier"]
11489 options: [4, { MemberExpression: 0 }],
11490 parserOptions: { ecmaVersion: 2015 },
11491 errors: expectedErrors([
11492 [2, 0, 4, "Punctuator"],
11493 [5, 4, 0, "Identifier"],
11494 [6, 0, 4, "Punctuator"]
11498 // Optional chaining
11515 parserOptions: { ecmaVersion: 2020 },
11516 errors: expectedErrors([
11517 [2, 4, 0, "Punctuator"],
11518 [3, 4, 0, "Punctuator"],
11519 [4, 4, 0, "Punctuator"],
11520 [5, 8, 0, "Punctuator"]
11543 parserOptions: { ecmaVersion: 2020 },
11544 errors: expectedErrors([
11545 [6, 4, 0, "Punctuator"],
11546 [7, 4, 0, "Punctuator"]
11563 parserOptions: { ecmaVersion: 2020 },
11564 errors: expectedErrors([
11565 [2, 4, 0, "Punctuator"],
11566 [3, 4, 0, "Punctuator"],
11567 [4, 4, 0, "Punctuator"]
11590 parserOptions: { ecmaVersion: 2020 },
11591 errors: expectedErrors([
11592 [6, 4, 0, "Punctuator"],
11593 [7, 4, 0, "Punctuator"]
11598 const foo = async (arg1,
11601 return arg1 + arg2;
11605 const foo = async (arg1,
11608 return arg1 + arg2;
11611 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }],
11612 parserOptions: { ecmaVersion: 2020 },
11613 errors: expectedErrors([
11614 [2, 19, 20, "Identifier"]
11627 errors: expectedErrors([
11628 [2, 0, 1, "Identifier"]