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 }]
2218 \t\t\t\treturn false
2221 options
: ["tab", { offsetTernaryExpressions
: true }]
2234 * Checking comments:
2235 * https://github.com/eslint/eslint/issues/3845, https://github.com/eslint/eslint/issues/6571
2252 // call the baz function
2255 options
: [2, { SwitchCase
: 1 }]
2265 options
: [2, { SwitchCase
: 1 }]
2275 * Destructuring assignments:
2276 * https://github.com/eslint/eslint/issues/6813
2283 foobar: baz = foobar
2353 // https://github.com/eslint/eslint/issues/7233
2355 var folder = filePath
2359 options
: [2, { MemberExpression
: 2 }]
2363 for (const foo of bar)
2398 // Don't lint the indentation of the first token after a :
2407 // Don't lint the indentation of the first token after a :
2428 // Comments in switch cases
2436 /* multiline comment
2440 options
: [2, { SwitchCase
: 1 }]
2444 // Comments in switch cases
2449 // the comment can also be here
2453 options
: [2, { SwitchCase
: 1 }]
2457 // BinaryExpressions with parens
2467 // BinaryExpressions with parens
2505 var bar = function(baz,
2511 options
: [2, { FunctionExpression
: { parameters
: 3 } }]
2515 return (bar === 1 || bar === 2 &&
2516 (/Function/.test(grandparent.type))) &&
2517 directives(parent).indexOf(node) >= 0;
2523 return (foo === bar || (
2539 (baz === 1 && qux === 1)
2552 return (bar === 1 || bar === 2) &&
2553 (z === 3 || z === 4);
2560 /* comment */ if (foo) {
2568 // Comments at the end of if blocks that have `else` blocks can either refer to the lines above or below them
2572 // Otherwise, if foo is false, do baz.
2573 // baz is very important.
2583 return ((bar === 1 || bar === 2) &&
2584 (z === 3 || z === 4));
2597 options
: [2, { CallExpression
: { arguments
: 1 } }]
2607 options
: ["tab", { CallExpression
: { arguments
: 1 } }]
2615 options
: [4, { CallExpression
: { arguments
: 2 } }]
2625 options
: [2, { CallExpression
: { arguments
: 0 } }]
2634 options
: [2, { CallExpression
: { arguments
: "first" } }]
2642 options
: [2, { CallExpression
: { arguments
: "first" } }]
2652 options
: [2, { CallExpression
: { arguments
: 4 } }]
2665 options
: [4, { CallExpression
: { arguments
: 1 } }]
2668 // https://github.com/eslint/eslint/issues/7484
2671 var foo = function() {
2681 // https://github.com/eslint/eslint/issues/7573
2688 parserOptions
: { ecmaFeatures
: { globalReturn
: true } }
2696 parserOptions
: { ecmaFeatures
: { globalReturn
: true } }
2717 options
: [2, { ArrayExpression
: 0 }]
2726 options
: [2, { ArrayExpression
: 8 }]
2735 options
: [2, { ArrayExpression
: "first" }]
2743 options
: [2, { ArrayExpression
: "first" }]
2754 options
: [4, { ArrayExpression
: 2, ObjectExpression
: "first" }]
2763 options
: [2, { ObjectExpression
: 0 }]
2767 var foo = { foo: 1, bar: 2,
2770 options
: [2, { ObjectExpression
: "first" }]
2780 options
: [4, { ArrayExpression
: 2 }]
2790 options
: [2, { ArrayExpression
: 4 }]
2794 options
: [2, { ArrayExpression
: "first" }]
2798 options
: [2, { ArrayExpression
: 1 }]
2802 options
: [2, { ObjectExpression
: "first" }]
2806 options
: [2, { ObjectExpression
: 1 }]
2816 options
: [2, { ArrayExpression
: "first" }]
2826 options
: [2, { ArrayExpression
: "first" }]
2836 options
: [4, { ArrayExpression
: "first", CallExpression
: { arguments
: "first" } }]
2844 options
: [4, { CallExpression
: { arguments
: "first" }, ArrayExpression
: "first" }]
2847 // https://github.com/eslint/eslint/issues/7732
2850 const lambda = foo => {
2859 options
: [2, { ObjectExpression
: 1 }]
2863 const lambda = foo => {
2872 options
: [2, { ObjectExpression
: "first" }]
2875 // https://github.com/eslint/eslint/issues/7733
2878 var foo = function() {
2893 echo = spawn('cmd.exe',
2897 options
: [2, { ArrayExpression
: "first", CallExpression
: { arguments
: "first" } }]
2903 // Otherwise, if foo is false, do baz.
2904 // baz is very important.
2915 baz && qux // This line is ignored because BinaryExpressions are not checked.
2965 options
: [4, { VariableDeclarator
: 2 }]
2984 options
: [2, { SwitchCase
: 1 }]
3046 // Don't check AssignmentExpression assignments
3059 const template = \`this indentation is not checked
3060 because it
's part of a template literal.\`;
3065 const template = \`the indentation of a \${
3067 } node is checked.\`;
3072 // https://github.com/eslint/eslint/issues/7320
3081 options: [4, { CallExpression: { arguments: 1 } }]
3093 /* comment */ bar();
3120 // https://github.com/eslint/eslint/issues/6007
3159 // https://github.com/eslint/eslint/issues/6670
3173 options: [4, { MemberExpression: 1 }]
3176 // https://github.com/eslint/eslint/issues/7242
3195 // https://github.com/eslint/eslint/issues/7616
3204 options: [4, { CallExpression: { arguments: "first" } }]
3215 var foo = 0, bar = 0, baz = 0;
3222 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3230 options: [4, { flatTernaryExpressions: true }]
3238 options: [4, { flatTernaryExpressions: true }]
3246 options: [4, { flatTernaryExpressions: true }]
3254 options: [4, { flatTernaryExpressions: true }]
3266 options: [4, { flatTernaryExpressions: true }]
3278 options: [4, { flatTernaryExpressions: true }]
3288 options: [4, { flatTernaryExpressions: true }]
3296 options: [4, { flatTernaryExpressions: true }]
3305 options: [4, { flatTernaryExpressions: true }]
3315 options: [4, { flatTernaryExpressions: true }]
3323 options: [4, { flatTernaryExpressions: true }]
3332 options: [4, { flatTernaryExpressions: true }]
3343 options: [4, { flatTernaryExpressions: true }]
3356 options: [4, { flatTernaryExpressions: true }]
3366 options: [4, { flatTernaryExpressions: true }]
3378 options: [4, { flatTernaryExpressions: true }]
3388 options: [4, { flatTernaryExpressions: true }]
3397 options: [4, { flatTernaryExpressions: true }]
3409 options: [4, { flatTernaryExpressions: false }]
3421 options: [4, { flatTernaryExpressions: false }]
3425 options: [2, { ArrayExpression: "first" }]
3429 options: [2, { ArrayExpression: "off" }]
3438 options: [4, { ArrayExpression: "first" }]
3441 code: "[sparse, , array];",
3442 options: [2, { ArrayExpression: "first" }]
3446 foo.bar('baz
', function(err) {
3450 options: [2, { CallExpression: { arguments: "first" } }]
3454 foo.bar(function() {
3460 options: [2, { MemberExpression: 1 }]
3464 foo.bar().baz(function() {
3470 options: [2, { MemberExpression: 1 }]
3481 options: [2, { ObjectExpression: "first" }]
3491 options: [4, { CallExpression: { arguments: "first" } }]
3496 bar ].forEach(function() {
3500 options: [2, { ArrayExpression: "first", MemberExpression: 1 }]
3513 options: [4, { MemberExpression: 1 }]
3523 options: [4, { MemberExpression: 1 }]
3534 ; [1, 2, 3].map(baz)
3546 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3549 code: "import 'foo
'",
3550 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3559 options: [4, { ImportDeclaration: 1 }],
3560 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3570 options: [4, { ImportDeclaration: 1 }],
3571 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3575 import { apple as a,
3576 banana as b } from 'fruits
';
3577 import { cat } from 'animals
';
3579 options: [4, { ImportDeclaration: "first" }],
3580 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3584 import { declaration,
3587 turned } from 'off
';
3589 options: [4, { ImportDeclaration: "off" }],
3590 parserOptions: { ecmaVersion: 6, sourceType: "module" }
3593 // https://github.com/eslint/eslint/issues/8455
3604 ) => b => c => d => {
3652 var x = function foop(bar)
3716 options: [4, { SwitchCase: 1 }]
3731 options: [4, { MemberExpression: 2 }]
3751 options: [4, { MemberExpression: "off" }]
3760 options: [4, { MemberExpression: "off" }]
3769 options: [4, { MemberExpression: "off" }]
3777 options: [4, { MemberExpression: "off" }]
3785 options: [4, { MemberExpression: "off" }]
3794 options: [4, { flatTernaryExpressions: true }]
3803 options: [4, { flatTernaryExpressions: true }]
3810 options: [4, { flatTernaryExpressions: true }]
3819 options: [4, { flatTernaryExpressions: true }]
3959 //----------------------------------------------------------------------
3960 // Ignore Unknown Nodes
3961 //----------------------------------------------------------------------
3970 parser: parser("unknown-nodes/interface")
3983 parser: parser("unknown-nodes/namespace-valid")
3987 abstract class Foo {
4000 parser: parser("unknown-nodes/abstract-class-valid")
4016 parser: parser("unknown-nodes/functions-with-abstract-class-valid")
4034 parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-valid")
4038 type httpMethod = 'GET
'
4042 options: [2, { VariableDeclarator: 0 }],
4043 parser: parser("unknown-nodes/variable-declarator-type-indent-two-spaces")
4047 type httpMethod = 'GET
'
4051 options: [2, { VariableDeclarator: 1 }],
4052 parser: parser("unknown-nodes/variable-declarator-type-no-indent")
4074 // https://github.com/eslint/eslint/issues/8815
4076 async function test() {
4080 } = await doSomethingAsync(
4092 } = yield doSomethingAsync(
4125 //----------------------------------------------------------------------
4127 // https://github.com/eslint/eslint/issues/8425
4128 // Some of the following tests are adapted from the the tests in eslint-plugin-react.
4129 // License: https://github.com/yannickcr/eslint-plugin-react/blob/7ca9841f22d599f447a27ef5b2a97def9229d6c8/LICENSE
4130 //----------------------------------------------------------------------
4132 "<Foo a=\"b\" c=\"d\"/>;",
4139 "var foo = <Bar a=\"b\" c=\"d\"/>;",
4178 "<a href=\"foo\">bar</a>;",
4219 var foo = <a href="bar">
4265 <a href="bar">baz</a>
4283 "var foo = <a href=\"bar\">baz</a>;",
4510 onClick={this.onClick}
4514 onClick={this.onClick}
4610 <App foo={function() {
4619 var x = function() {
4685 <App foo={function() {
4686 \tconsole.log('bar
');
4696 \t\tconsole.log('bar
');
4779 * https://github.com/eslint/eslint/issues/12208
4981 // https://github.com/eslint/eslint/issues/8832
5011 <small>Foo bar
5033 options: [2, { CallExpression: { arguments: "off" } }]
5043 options: [2, { CallExpression: { arguments: "off" } }]
5051 options: [4, { ignoredNodes: ["ConditionalExpression"] }]
5061 options: [4, { ignoredNodes: ["ClassBody"] }]
5071 options: [4, { ignoredNodes: ["ClassBody", "BlockStatement"] }]
5085 options: [4, { ignoredNodes: ["CallExpression > ObjectExpression"] }]
5092 options: [4, { ignoredNodes: ["MemberExpression"] }]
5104 ignoredNodes: ["Program > ExpressionStatement > CallExpression[callee.name='$'] > FunctionExpression > BlockStatement"]
5112 options: [4, { ignoredNodes: ["JSXOpeningElement"] }]
5121 options: [4, { ignoredNodes: ["JSXElement", "JSXOpeningElement"] }]
5131 options: [4, { ignoredNodes: ["ExpressionStatement > CallExpression > FunctionExpression.callee > BlockStatement"] }]
5141 options: [4, { ignoredNodes: ["ConditionalExpression"] }]
5145 var a = 0, b = 0, c = 0;
5153 options: [4, { ignoredNodes: ["ExportDefaultDeclaration > CallExpression > ObjectExpression"] }],
5154 parserOptions: { ecmaVersion: 6, sourceType: "module" }
5162 options: [4, { ignoredNodes: ["ConditionalExpression"] }]
5173 options: [4, { ignoredNodes: ["TemplateLiteral"] }]
5183 options: [4, { ignoredNodes: ["JSXOpeningElement"] }]
5200 options: ["tab", { ignoredNodes: ["VariableDeclarator"] }]
5209 options: ["tab", { ArrayExpression: "first", ignoredNodes: ["CallExpression"] }]
5216 // Intentionally unindented comment
5220 options: [4, { ignoreComments: true }]
5227 /* Intentionally unindented comment */
5231 options: [4, { ignoreComments: true }]
5236 return condition ? // comment
5243 //----------------------------------------------------------------------
5244 // Comment alignment tests
5245 //----------------------------------------------------------------------
5248 // Comment can align with code immediately above even if "incorrect" alignment
5255 // Comment can align with code immediately below even if "incorrect" alignment
5260 // Comment can be in correct alignment even if not aligned with code above/below
5266 // Comment can be in correct alignment even if gaps between (and not aligned with) code above/below
5275 // Comment between nodes
5286 // Comment between nodes
5395 ;[1, 2, 3].forEach(() => {})
5402 ;[1, 2, 3].forEach(() => {})
5409 ;[1, 2, 3].forEach(() => {})
5415 ;[1, 2, 3].forEach(() => {})
5423 [1, 2, 3].forEach(() => {})
5430 [1, 2, 3].forEach(() => {})
5437 [1, 2, 3].forEach(() => {})
5443 [1, 2, 3].forEach(() => {})
5450 [1, 2, 3].forEach(() => {})
5456 [1, 2, 3].forEach(() => {})
5461 ;[1, 2, 3].forEach(() => {})
5465 ;[1, 2, 3].forEach(() => {})
5474 ;[1, 2, 3].forEach(() => {})
5482 ;[1, 2, 3].forEach(() => {})
5489 ;[1, 2, 3].forEach(() => {})
5495 ;[1, 2, 3].forEach(() => {})
5499 // import expressions
5508 parserOptions: { ecmaVersion: 2020 }
5511 // https://github.com/eslint/eslint/issues/12122
5524 parserOptions: { ecmaVersion: 2015 }
5539 parserOptions: { ecmaVersion: 2015 }
5562 parserOptions: { ecmaVersion: 2015 }
5585 parserOptions: { ecmaVersion: 2015 }
5605 parserOptions: { ecmaVersion: 2015 }
5614 bar: tagTwo\`multiline
5622 parserOptions: { ecmaVersion: 2015 }
5626 foo.bar\` template literal \`(() => {
5630 parserOptions: { ecmaVersion: 2015 }
5634 foo.bar.baz\` template literal \`(() => {
5638 parserOptions: { ecmaVersion: 2015 }
5648 parserOptions: { ecmaVersion: 2015 }
5659 parserOptions: { ecmaVersion: 2015 }
5669 parserOptions: { ecmaVersion: 2015 }
5679 parserOptions: { ecmaVersion: 2015 }
5691 parserOptions: { ecmaVersion: 2015 }
5702 parserOptions: { ecmaVersion: 2015 }
5713 options: [4, { MemberExpression: 0 }],
5714 parserOptions: { ecmaVersion: 2015 }
5725 options: [4, { MemberExpression: 2 }],
5726 parserOptions: { ecmaVersion: 2015 }
5730 const foo = async (arg1,
5736 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5740 const foo = async /* some comments */(arg1,
5746 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5758 arg2) => async (arr1,
5764 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5768 const foo = async (arg1,
5778 const foo = async /*comments*/(arg1,
5788 const foo = async (arg1,
5794 options: [2, { FunctionDeclaration: { parameters: 4 }, FunctionExpression: { parameters: 4 } }]
5804 options: [2, { FunctionDeclaration: { parameters: 4 }, FunctionExpression: { parameters: 4 } }]
5808 async function fn(ar1,
5811 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5815 async function /* some comments */ fn(ar1,
5818 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5822 async /* some comments */ function fn(ar1,
5825 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }]
5844 errors: expectedErrors([[3, 2, 0, "Identifier"]])
5848 require('http
').request({hostname: 'localhost
',
5849 port: 80}, function(res) {
5854 require('http
').request({hostname: 'localhost
',
5855 port: 80}, function(res) {
5860 errors: expectedErrors([[2, 2, 18, "Identifier"], [3, 2, 4, "Identifier"], [4, 0, 2, "Punctuator"]])
5864 if (array.some(function(){
5873 if (array.some(function(){
5882 errors: expectedErrors([[4, 2, 0, "Identifier"], [6, 2, 4, "Identifier"]])
5900 errors: expectedErrors("tab", [[3, 1, 2, "Identifier"], [4, 1, 0, "Identifier"]])
5918 errors: expectedErrors([[3, 4, 6, "Identifier"], [4, 4, 1, "Identifier"]])
5922 output: fixedFixture,
5923 options: [2, { SwitchCase: 1, MemberExpression: 1, CallExpression: { arguments: "off" } }],
5924 errors: expectedErrors([
5925 [5, 2, 4, "Keyword"],
5927 [10, 4, 6, "Punctuator"],
5928 [11, 2, 4, "Punctuator"],
5930 [15, 4, 2, "Identifier"],
5931 [16, 2, 4, "Punctuator"],
5932 [23, 2, 4, "Punctuator"],
5933 [29, 2, 4, "Keyword"],
5934 [30, 4, 6, "Identifier"],
5935 [36, 4, 6, "Identifier"],
5936 [38, 2, 4, "Punctuator"],
5937 [39, 4, 2, "Identifier"],
5938 [40, 2, 0, "Punctuator"],
5939 [54, 2, 4, "Punctuator"],
5940 [114, 4, 2, "Keyword"],
5941 [120, 4, 6, "Keyword"],
5942 [124, 4, 2, "Keyword"],
5943 [134, 4, 6, "Keyword"],
5944 [138, 2, 3, "Punctuator"],
5945 [139, 2, 3, "Punctuator"],
5946 [143, 4, 0, "Identifier"],
5947 [144, 6, 2, "Punctuator"],
5948 [145, 6, 2, "Punctuator"],
5949 [151, 4, 6, "Identifier"],
5950 [152, 6, 8, "Punctuator"],
5951 [153, 6, 8, "Punctuator"],
5952 [159, 4, 2, "Identifier"],
5953 [161, 4, 6, "Identifier"],
5954 [175, 2, 0, "Identifier"],
5955 [177, 2, 4, "Identifier"],
5956 [189, 2, 0, "Keyword"],
5957 [192, 6, 18, "Identifier"],
5958 [193, 6, 4, "Identifier"],
5959 [195, 6, 8, "Identifier"],
5960 [228, 5, 4, "Identifier"],
5961 [231, 3, 2, "Punctuator"],
5962 [245, 0, 2, "Punctuator"],
5963 [248, 0, 2, "Punctuator"],
5964 [304, 4, 6, "Identifier"],
5965 [306, 4, 8, "Identifier"],
5966 [307, 2, 4, "Punctuator"],
5967 [308, 2, 4, "Identifier"],
5968 [311, 4, 6, "Identifier"],
5969 [312, 4, 6, "Identifier"],
5970 [313, 4, 6, "Identifier"],
5971 [314, 2, 4, "Punctuator"],
5972 [315, 2, 4, "Identifier"],
5973 [318, 4, 6, "Identifier"],
5974 [319, 4, 6, "Identifier"],
5975 [320, 4, 6, "Identifier"],
5976 [321, 2, 4, "Punctuator"],
5977 [322, 2, 4, "Identifier"],
5978 [326, 2, 1, "Numeric"],
5979 [327, 2, 1, "Numeric"],
5980 [328, 2, 1, "Numeric"],
5981 [329, 2, 1, "Numeric"],
5982 [330, 2, 1, "Numeric"],
5983 [331, 2, 1, "Numeric"],
5984 [332, 2, 1, "Numeric"],
5985 [333, 2, 1, "Numeric"],
5986 [334, 2, 1, "Numeric"],
5987 [335, 2, 1, "Numeric"],
5988 [340, 2, 4, "Identifier"],
5989 [341, 2, 0, "Identifier"],
5990 [344, 2, 4, "Identifier"],
5991 [345, 2, 0, "Identifier"],
5992 [348, 2, 4, "Identifier"],
5993 [349, 2, 0, "Identifier"],
5994 [355, 2, 0, "Identifier"],
5995 [357, 2, 4, "Identifier"],
5996 [361, 4, 6, "Identifier"],
5997 [362, 2, 4, "Punctuator"],
5998 [363, 2, 4, "Identifier"],
5999 [368, 2, 0, "Keyword"],
6000 [370, 2, 4, "Keyword"],
6001 [374, 4, 6, "Keyword"],
6002 [376, 4, 2, "Keyword"],
6003 [383, 2, 0, "Identifier"],
6004 [385, 2, 4, "Identifier"],
6005 [390, 2, 0, "Identifier"],
6006 [392, 2, 4, "Identifier"],
6007 [409, 2, 0, "Identifier"],
6008 [410, 2, 4, "Identifier"],
6009 [416, 2, 0, "Identifier"],
6010 [417, 2, 4, "Identifier"],
6011 [418, 0, 4, "Punctuator"],
6012 [422, 2, 4, "Identifier"],
6013 [423, 2, 0, "Identifier"],
6014 [427, 2, 6, "Identifier"],
6015 [428, 2, 8, "Identifier"],
6016 [429, 2, 4, "Identifier"],
6017 [430, 0, 4, "Punctuator"],
6018 [433, 2, 4, "Identifier"],
6019 [434, 0, 4, "Punctuator"],
6020 [437, 2, 0, "Identifier"],
6021 [438, 0, 4, "Punctuator"],
6022 [442, 2, 4, "Identifier"],
6023 [443, 2, 4, "Identifier"],
6024 [444, 0, 2, "Punctuator"],
6025 [451, 2, 0, "Identifier"],
6026 [453, 2, 4, "Identifier"],
6027 [499, 6, 8, "Punctuator"],
6028 [500, 8, 6, "Identifier"],
6029 [504, 4, 6, "Punctuator"],
6030 [505, 6, 8, "Identifier"],
6031 [506, 4, 8, "Punctuator"]
6061 options: [4, { SwitchCase: 1 }],
6062 errors: expectedErrors([[4, 8, 4, "Keyword"], [7, 8, 4, "Keyword"]])
6080 errors: expectedErrors([[3, 8, 7, "Identifier"], [4, 8, 10, "Identifier"]])
6107 options: [4, { SwitchCase: 1 }],
6108 errors: expectedErrors([9, 8, 4, "Keyword"])
6151 options: [4, { SwitchCase: 1 }],
6152 errors: expectedErrors([[11, 8, 4, "Keyword"], [14, 8, 4, "Keyword"], [17, 8, 4, "Keyword"]])
6178 errors: expectedErrors([
6179 [3, 4, 8, "Identifier"],
6180 [4, 4, 8, "Keyword"],
6181 [5, 0, 4, "Keyword"],
6182 [6, 4, 8, "Keyword"],
6183 [7, 0, 4, "Keyword"],
6184 [8, 4, 8, "Keyword"]
6189 var obj = {foo: 1, bar: 2};
6191 console.log(foo + bar);
6195 var obj = {foo: 1, bar: 2};
6197 console.log(foo + bar);
6200 errors: expectedErrors([3, 4, 0, "Identifier"])
6223 options: [4, { SwitchCase: 1 }],
6224 errors: expectedErrors([
6225 [2, 4, 0, "Keyword"],
6226 [3, 8, 0, "Identifier"],
6227 [4, 8, 0, "Keyword"],
6228 [5, 4, 0, "Keyword"],
6229 [6, 8, 0, "Identifier"],
6230 [7, 8, 0, "Keyword"]
6235 var foo = function(){
6241 var foo = function(){
6246 options: [4, { MemberExpression: 1 }],
6247 errors: expectedErrors(
6248 [3, 8, 10, "Punctuator"]
6264 errors: expectedErrors([3, 8, 4, "Punctuator"])
6268 var foo = function(){
6274 var foo = function(){
6279 options: [4, { MemberExpression: 2 }],
6280 errors: expectedErrors(
6281 [3, 12, 13, "Punctuator"]
6297 options: [4, { MemberExpression: 2 }],
6298 errors: expectedErrors(
6299 [3, 12, 13, "Punctuator"]
6304 TestClass.prototype.method = function () {
6305 return Promise.resolve(3)
6306 .then(function (x) {
6312 TestClass.prototype.method = function () {
6313 return Promise.resolve(3)
6314 .then(function (x) {
6319 options: [2, { MemberExpression: 1 }],
6320 errors: expectedErrors([3, 4, 6, "Punctuator"])
6332 errors: expectedErrors([
6333 [2, 4, 0, "Identifier"]
6359 errors: expectedErrors([
6360 [2, 4, 8, "Identifier"],
6361 [3, 0, 4, "Punctuator"],
6362 [4, 0, 4, "Punctuator"],
6363 [5, 4, 8, "Identifier"],
6364 [6, 0, 4, "Punctuator"],
6365 [7, 0, 4, "Punctuator"],
6366 [8, 4, 8, "Identifier"]
6380 errors: expectedErrors([[2, 4, 0, "Identifier"], [3, 4, 0, "Identifier"]])
6397 errors: expectedErrors([[2, 4, 0, "Keyword"], [3, 4, 0, "Identifier"], [4, 4, 0, "Identifier"], [5, 0, 4, "Punctuator"]])
6409 errors: expectedErrors([
6410 [2, 4, 0, "Identifier"]
6423 errors: expectedErrors([
6424 [2, 4, 0, "Identifier"]
6439 errors: expectedErrors([
6440 [2, 4, 0, "Identifier"]
6453 errors: expectedErrors([
6454 [2, 4, 0, "Identifier"]
6471 errors: expectedErrors([
6472 [2, 2, 6, "Identifier"],
6473 [3, 2, 4, "Identifier"],
6474 [4, 0, 4, "Punctuator"]
6479 var a = function() {
6487 var a = function() {
6495 errors: expectedErrors([
6496 [2, 8, 6, "Identifier"],
6497 [3, 8, 4, "Identifier"],
6498 [4, 8, 10, "Identifier"]
6513 errors: expectedErrors([
6514 [2, 4, 0, "Identifier"],
6515 [3, 4, 0, "Identifier"]
6521 c].forEach((index) => {
6527 c].forEach((index) => {
6532 errors: expectedErrors([
6533 [3, 4, 8, "Identifier"],
6534 [4, 0, 4, "Punctuator"]
6540 c].forEach(function(index){
6546 c].forEach(function(index){
6551 errors: expectedErrors([
6552 [2, 4, 0, "Identifier"],
6553 [3, 4, 2, "Keyword"]
6558 [a, b, c].forEach(function(index){
6563 [a, b, c].forEach(function(index){
6568 errors: expectedErrors([
6569 [2, 4, 2, "Keyword"]
6585 options: [4, { MemberExpression: 1 }],
6586 errors: expectedErrors([[3, 8, 4, "Identifier"], [4, 4, 0, "Punctuator"]])
6602 errors: expectedErrors([
6603 [2, 4, 9, "String"],
6623 errors: expectedErrors([
6624 [2, 4, 9, "String"],
6625 [3, 4, 9, "String"],
6645 errors: expectedErrors([
6646 [2, 4, 9, "String"],
6647 [3, 4, 9, "String"],
6648 [4, 4, 9, "String"],
6668 errors: expectedErrors([
6669 [2, 4, 9, "String"],
6670 [3, 4, 9, "String"],
6671 [4, 4, 9, "String"],
6672 [5, 0, 2, "Punctuator"]
6690 errors: expectedErrors([[3, 4, 8, "Identifier"], [4, 0, 4, "Punctuator"]])
6713 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
6727 errors: expectedErrors([
6728 [2, 2, 0, "Identifier"],
6729 [3, 0, 2, "Identifier"]
6734 function salutation () {
6736 case 0: return console.log('hi
')
6737 case 1: return console.log('hey
')
6742 function salutation () {
6744 case 0: return console.log('hi
')
6745 case 1: return console.log('hey
')
6749 options: [2, { SwitchCase: 1 }],
6750 errors: expectedErrors([
6751 [3, 4, 2, "Keyword"]
6756 var geometry, box, face1, face2, colorT, colorB, sprite, padding, maxWidth,
6760 var geometry, box, face1, face2, colorT, colorB, sprite, padding, maxWidth,
6763 options: [2, { SwitchCase: 1 }],
6764 errors: expectedErrors([
6765 [2, 2, 0, "Identifier"]
6789 options: [4, { SwitchCase: 2 }],
6790 errors: expectedErrors([
6791 [2, 8, 0, "Keyword"],
6792 [3, 12, 0, "Identifier"],
6793 [4, 12, 0, "Keyword"],
6794 [5, 8, 0, "Keyword"],
6795 [6, 12, 0, "Identifier"],
6796 [7, 12, 0, "Keyword"]
6808 options: [2, { VariableDeclarator: 1 }],
6809 errors: expectedErrors([
6810 [2, 2, 0, "Identifier"]
6822 options: [2, { VariableDeclarator: 2 }],
6823 errors: expectedErrors([
6824 [2, 4, 2, "Identifier"]
6836 options: ["tab", { VariableDeclarator: 2 }],
6837 errors: expectedErrors("tab", [
6838 [2, 2, 1, "Identifier"]
6850 options: [2, { VariableDeclarator: 2 }],
6851 errors: expectedErrors([
6852 [2, 4, 2, "Identifier"]
6868 options: [2, { VariableDeclarator: "first" }],
6869 errors: expectedErrors([
6870 [2, 4, 2, "Identifier"],
6871 [4, 6, 2, "Identifier"]
6883 options: [2, { VariableDeclarator: { var: "first" } }],
6884 errors: expectedErrors([
6885 [2, 4, 2, "Identifier"]
6901 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
6902 errors: expectedErrors([
6903 [4, 6, 4, "Identifier"]
6919 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
6920 errors: expectedErrors([
6921 [2, 2, 4, "Identifier"],
6922 [3, 2, 4, "Identifier"]
6938 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
6939 errors: expectedErrors([
6940 [2, 2, 4, "Identifier"],
6941 [3, 2, 4, "Identifier"]
6957 options: [2, { VariableDeclarator: { let: 2 }, SwitchCase: 1 }],
6958 errors: expectedErrors([
6959 [2, 2, 4, "Identifier"],
6960 [3, 2, 4, "Identifier"]
6977 errors: expectedErrors([
6978 [2, 8, 6, "Identifier"],
6979 [3, 4, 2, "Punctuator"]
6988 const c = new Test({
6998 const c = new Test({
7003 options: [2, { VariableDeclarator: { var: 2 } }],
7004 errors: expectedErrors([
7005 [6, 4, 6, "Identifier"],
7006 [7, 2, 4, "Punctuator"],
7007 [8, 2, 4, "Identifier"]
7029 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
7030 errors: expectedErrors([6, 6, 7, "Identifier"])
7047 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
7048 errors: expectedErrors([4, 7, 8, "Identifier"])
7070 errors: expectedErrors([[4, 6, 8, "Identifier"], [5, 4, 6, "Punctuator"]])
7074 var path = require('path
')
7075 , crypto = require('crypto
')
7079 var path = require('path
')
7080 , crypto = require('crypto
')
7084 errors: expectedErrors([
7085 [2, 2, 1, "Punctuator"]
7099 errors: expectedErrors([
7100 [2, 4, 3, "Punctuator"]
7118 options: [4, { VariableDeclarator: 1, SwitchCase: 1 }],
7119 errors: expectedErrors([[2, 4, 2, "Identifier"]])
7136 options: [4, { VariableDeclarator: 1, SwitchCase: 1 }],
7137 errors: expectedErrors([[2, 4, 2, "Identifier"], [4, 4, 2, "Identifier"]])
7156 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
7157 errors: expectedErrors([[3, 6, 4, "Identifier"]])
7181 errors: expectedErrors([[5, 4, 2, "Keyword"]])
7205 errors: expectedErrors([[5, 4, 2, "Keyword"]])
7225 errors: expectedErrors([[4, 4, 2, "Keyword"]])
7242 options: [2, { outerIIFEBody: 0 }],
7243 errors: expectedErrors([[2, 0, 2, "Keyword"], [3, 2, 4, "Keyword"], [4, 0, 2, "Punctuator"]])
7260 options: [4, { outerIIFEBody: 2 }],
7261 errors: expectedErrors([[2, 8, 4, "Keyword"], [3, 12, 8, "Keyword"], [4, 8, 4, "Punctuator"]])
7274 options: [2, { outerIIFEBody: 0 }],
7275 errors: expectedErrors([[2, 2, 0, "Identifier"]])
7279 var ns = function(){
7280 function fooVar(x) {
7286 var ns = function(){
7287 function fooVar(x) {
7292 options: [4, { outerIIFEBody: 2 }],
7293 errors: expectedErrors([[2, 8, 4, "Keyword"], [3, 12, 8, "Keyword"], [4, 8, 4, "Punctuator"]])
7310 options: [2, { outerIIFEBody: 0 }],
7311 errors: expectedErrors([[3, 4, 2, "Keyword"]])
7316 function fooVar(x) {
7323 function fooVar(x) {
7328 options: [2, { outerIIFEBody: 2 }],
7329 errors: expectedErrors([[2, 2, 4, "Keyword"], [3, 4, 6, "Keyword"], [4, 2, 4, "Punctuator"]])
7335 \t\t\t\treturn x + 1;
7346 options: ["tab", { outerIIFEBody: 3 }],
7347 errors: expectedErrors("tab", [[3, 2, 4, "Keyword"]])
7364 options: [4, { outerIIFEBody: "off" }],
7365 errors: expectedErrors([[3, 8, 4, "Keyword"]])
7382 options: [4, { outerIIFEBody: "off" }],
7383 errors: expectedErrors([[3, 4, 0, "Keyword"]])
7400 options: [4, { outerIIFEBody: "off" }],
7401 errors: expectedErrors([[3, 8, 4, "Keyword"]])
7418 options: [4, { outerIIFEBody: "off" }],
7419 errors: expectedErrors([[3, 4, 0, "Keyword"]])
7430 options: [4, { MemberExpression: 1 }],
7431 errors: expectedErrors([[2, 4, 0, "Punctuator"]])
7444 options: [4, { MemberExpression: 1 }],
7445 errors: expectedErrors([[3, 4, 0, "Punctuator"]])
7456 options: [4, { MemberExpression: 1 }],
7457 errors: expectedErrors([[2, 4, 0, "Identifier"]])
7468 options: ["tab", { MemberExpression: 1 }],
7469 errors: expectedErrors("tab", [[2, 1, 2, "Identifier"]])
7482 options: [2, { MemberExpression: 2 }],
7483 errors: expectedErrors([[2, 4, 2, "Punctuator"], [3, 4, 2, "Punctuator"]])
7498 errors: expectedErrors([3, 8, 4, "Punctuator"])
7513 errors: expectedErrors([3, 8, 4, "Identifier"])
7517 // Indentation with multiple else statements: https://github.com/eslint/eslint/issues/6956
7521 else if (baz) foobar();
7522 else if (qux) qux();
7526 else if (baz) foobar();
7527 else if (qux) qux();
7530 errors: expectedErrors([3, 0, 2, "Keyword"])
7535 else if (baz) foobar();
7540 else if (baz) foobar();
7544 errors: expectedErrors([3, 0, 2, "Keyword"])
7558 errors: expectedErrors([[2, 0, 2, "Keyword"], [3, 0, 2, "Keyword"]])
7563 else if (baz) foobar();
7570 else if (baz) foobar();
7576 errors: expectedErrors([[3, 0, 5, "Keyword"], [4, 2, 7, "Identifier"], [5, 0, 5, "Punctuator"]])
7596 errors: expectedErrors([[3, 2, 4, "Identifier"], [4, 0, 5, "Punctuator"], [5, 2, 7, "Identifier"], [6, 0, 5, "Punctuator"]])
7611 options: [2, { FunctionDeclaration: { parameters: 1, body: 2 } }],
7612 errors: expectedErrors([[2, 2, 4, "Identifier"], [3, 4, 6, "Identifier"]])
7616 function foo(aaa, bbb,
7622 function foo(aaa, bbb,
7627 options: [2, { FunctionDeclaration: { parameters: 3, body: 1 } }],
7628 errors: expectedErrors([[2, 6, 2, "Identifier"], [3, 2, 0, "Identifier"]])
7645 options: [4, { FunctionDeclaration: { parameters: 1, body: 3 } }],
7646 errors: expectedErrors([[2, 4, 8, "Identifier"], [3, 4, 2, "Identifier"], [4, 12, 6, "Identifier"]])
7663 options: [2, { FunctionDeclaration: { parameters: "first", body: 1 } }],
7664 errors: expectedErrors([[2, 13, 2, "Identifier"], [3, 13, 19, "Identifier"], [4, 2, 3, "Identifier"]])
7668 function foo(aaa, bbb)
7674 function foo(aaa, bbb)
7679 options: [2, { FunctionDeclaration: { body: 3 } }],
7680 errors: expectedErrors([3, 6, 0, "Identifier"])
7697 options: [2, { FunctionDeclaration: { parameters: "first", body: 2 } }],
7698 errors: expectedErrors([[2, 2, 0, "Identifier"], [3, 2, 4, "Identifier"], [4, 4, 0, "Identifier"]])
7702 var foo = function(aaa,
7710 var foo = function(aaa,
7717 options: [2, { FunctionExpression: { parameters: 2, body: 0 } }],
7718 errors: expectedErrors([[2, 4, 2, "Identifier"], [4, 4, 6, "Identifier"], [5, 0, 2, "Identifier"]])
7722 var foo = function(aaa,
7729 var foo = function(aaa,
7735 options: [2, { FunctionExpression: { parameters: 1, body: 10 } }],
7736 errors: expectedErrors([[2, 2, 3, "Identifier"], [3, 2, 1, "Identifier"], [4, 20, 2, "Identifier"]])
7740 var foo = function(aaa,
7747 var foo = function(aaa,
7753 options: [4, { FunctionExpression: { parameters: "first", body: 1 } }],
7754 errors: expectedErrors([[2, 19, 2, "Identifier"], [3, 19, 24, "Identifier"], [4, 4, 8, "Identifier"]])
7771 options: [2, { FunctionExpression: { parameters: "first", body: 3 } }],
7772 errors: expectedErrors([[2, 2, 0, "Identifier"], [3, 2, 4, "Identifier"], [4, 6, 2, "Identifier"]])
7777 \t\t\tvar baz = qux;
7784 errors: expectedErrors([2, "0 spaces", "3 tabs", "Keyword"])
7802 errors: expectedErrors("tab", [[3, "1 tab", "2 spaces", "Identifier"], [4, "1 tab", "14 spaces", "Identifier"]])
7816 errors: expectedErrors([[3, "0 spaces", "2 tabs", "Punctuator"]])
7833 options: [2, { FunctionDeclaration: { body: 1 } }],
7834 errors: expectedErrors([3, 4, 8, "Identifier"])
7853 options: [2, { FunctionDeclaration: { body: 1, parameters: 2 } }],
7854 errors: expectedErrors([3, 6, 4, "Identifier"])
7859 var bar = function(baz,
7867 var bar = function(baz,
7873 options: [2, { FunctionExpression: { parameters: 3 } }],
7874 errors: expectedErrors([3, 8, 10, "Identifier"])
7879 baz, qux, function() {
7886 baz, qux, function() {
7891 options: [2, { FunctionExpression: { body: 3 }, CallExpression: { arguments: 3 } }],
7892 errors: expectedErrors([3, 12, 8, "Identifier"])
7915 errors: expectedErrors([
7916 [4, 4, 0, "Keyword"],
7917 [6, 4, 0, "Keyword"]
7935 errors: expectedErrors([4, 4, 0, "Keyword"])
7953 errors: expectedErrors([[4, 2, 4, "Punctuator"]])
7971 errors: expectedErrors([[4, 2, 4, "Punctuator"]])
7977 case 1: return function(a){
7978 return fn.call(that, a);
7986 case 1: return function(a){
7987 return fn.call(that, a);
7992 options: [2, { VariableDeclarator: 2, SwitchCase: 1 }],
7993 errors: expectedErrors([[4, 6, 4, "Keyword"]])
8007 errors: expectedErrors([[2, 2, 3, "Keyword"]])
8022 options: [2, { CallExpression: { arguments: 1 } }],
8023 errors: expectedErrors([[2, 2, 0, "Identifier"], [4, 2, 4, "Identifier"]])
8036 options: [2, { CallExpression: { arguments: 2 } }],
8037 errors: expectedErrors([[2, "4 spaces", "1 tab", "Identifier"], [3, "4 spaces", "1 tab", "Identifier"]])
8050 options: ["tab", { CallExpression: { arguments: 1 } }],
8051 errors: expectedErrors("tab", [[2, 1, 2, "Identifier"], [3, 1, 2, "Identifier"]])
8062 options: [2, { CallExpression: { arguments: "first" } }],
8063 errors: expectedErrors([2, 4, 9, "Identifier"])
8076 options: [2, { CallExpression: { arguments: "first" } }],
8077 errors: expectedErrors([[2, 2, 10, "Identifier"], [3, 2, 4, "Identifier"]])
8094 options: [2, { CallExpression: { arguments: 3 } }],
8095 errors: expectedErrors([[2, 6, 2, "Numeric"], [3, 6, 14, "Punctuator"], [4, 6, 8, "Keyword"]])
8098 // https://github.com/eslint/eslint/issues/7573
8110 parserOptions: { ecmaFeatures: { globalReturn: true } },
8111 errors: expectedErrors([3, 0, 4, "Punctuator"])
8124 parserOptions: { ecmaFeatures: { globalReturn: true } },
8125 errors: expectedErrors([3, 0, 4, "Punctuator"])
8128 // https://github.com/eslint/eslint/issues/7604
8140 errors: expectedErrors([2, 4, 8, "Block"])
8155 errors: expectedErrors([2, 4, 8, "Block"])
8168 options: [4, { CallExpression: { arguments: 1 } }],
8169 errors: expectedErrors([2, 4, 0, "Punctuator"])
8183 errors: expectedErrors([2, 4, 0, "Identifier"])
8186 // ternary expressions (https://github.com/eslint/eslint/issues/7420)
8199 errors: expectedErrors([[2, 2, 0, "Punctuator"], [3, 2, 4, "Punctuator"]])
8218 errors: expectedErrors([5, 4, 8, "Identifier"])
8247 options: [2, { offsetTernaryExpressions: true }],
8248 errors: expectedErrors([
8249 [2, 2, 0, "Punctuator"],
8250 [3, 6, 0, "Keyword"],
8251 [4, 4, 0, "Punctuator"],
8252 [5, 2, 0, "Punctuator"],
8253 [6, 4, 0, "Punctuator"],
8254 [7, 8, 0, "Keyword"],
8255 [8, 6, 0, "Punctuator"],
8256 [9, 4, 0, "Punctuator"],
8257 [10, 8, 0, "Keyword"],
8258 [11, 6, 0, "Punctuator"]
8288 options: [2, { offsetTernaryExpressions: false }],
8289 errors: expectedErrors([
8290 [2, 2, 0, "Punctuator"],
8291 [3, 4, 0, "Keyword"],
8292 [4, 2, 0, "Punctuator"],
8293 [5, 2, 0, "Punctuator"],
8294 [6, 4, 0, "Punctuator"],
8295 [7, 6, 0, "Keyword"],
8296 [8, 4, 0, "Punctuator"],
8297 [9, 4, 0, "Punctuator"],
8298 [10, 6, 0, "Keyword"],
8299 [11, 4, 0, "Punctuator"]
8305 * Checking comments:
8306 * https://github.com/eslint/eslint/issues/6571
8325 errors: expectedErrors([[2, 0, 2, "Line"], [3, 0, 4, "Block"], [6, 0, 1, "Line"]])
8328 code: " // comment",
8329 output: "// comment",
8330 errors: expectedErrors([1, 0, 2, "Line"])
8341 errors: expectedErrors([2, 0, 2, "Line"])
8352 errors: expectedErrors([1, 0, 2, "Line"])
8365 errors: expectedErrors([2, 4, 8, "Line"])
8370 * Destructuring assignments:
8371 * https://github.com/eslint/eslint/issues/6813
8378 foobar: baz = foobar
8386 foobar: baz = foobar
8390 errors: expectedErrors([[2, 2, 0, "Identifier"], [4, 2, 4, "Identifier"], [5, 2, 6, "Identifier"], [6, 0, 2, "Punctuator"]])
8408 errors: expectedErrors([[4, 2, 4, "Identifier"], [5, 0, 2, "Punctuator"]])
8423 errors: expectedErrors([[2, 4, 11, "Identifier"], [3, 4, 2, "Identifier"], [4, 0, 10, "Punctuator"]])
8438 errors: expectedErrors([2, 4, 0, "Identifier"])
8453 options: [2, { ArrayExpression: 0 }],
8454 errors: expectedErrors([[2, 0, 2, "Identifier"], [3, 0, 2, "Identifier"]])
8469 options: [2, { ArrayExpression: 8 }],
8470 errors: expectedErrors([[2, 16, 2, "Identifier"], [3, 16, 2, "Identifier"]])
8485 options: [2, { ArrayExpression: "first" }],
8486 errors: expectedErrors([[2, 11, 4, "Identifier"], [3, 11, 4, "Identifier"]])
8499 options: [2, { ArrayExpression: "first" }],
8500 errors: expectedErrors([2, 11, 4, "Identifier"])
8519 options: [4, { ArrayExpression: 2, ObjectExpression: "first" }],
8520 errors: expectedErrors([[3, 10, 12, "Identifier"], [5, 10, 12, "Identifier"]])
8535 options: [2, { ObjectExpression: 0 }],
8536 errors: expectedErrors([[2, 0, 2, "Identifier"], [3, 0, 2, "Identifier"]])
8540 var quux = { foo: 1, bar: 2,
8544 var quux = { foo: 1, bar: 2,
8547 options: [2, { ObjectExpression: "first" }],
8548 errors: expectedErrors([2, 13, 0, "Identifier"])
8565 options: [2, { ArrayExpression: 4 }],
8566 errors: expectedErrors([[2, 2, 4, "Punctuator"], [3, 10, 12, "Identifier"], [4, 2, 4, "Punctuator"]])
8586 errors: expectedErrors([[2, 2, 0, "Identifier"], [4, 2, 4, "Identifier"], [5, 2, 6, "Identifier"], [6, 0, 2, "Punctuator"]])
8603 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8604 errors: expectedErrors([[2, 4, 0, "Identifier"], [3, 4, 2, "Identifier"]])
8619 options: [4, { ImportDeclaration: "first" }],
8620 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8621 errors: expectedErrors([[3, 9, 10, "Identifier"]])
8636 options: [2, { ImportDeclaration: 2 }],
8637 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8638 errors: expectedErrors([[3, 4, 5, "Identifier"]])
8642 var foo = 0, bar = 0, baz = 0;
8650 var foo = 0, bar = 0, baz = 0;
8657 parserOptions: { ecmaVersion: 6, sourceType: "module" },
8658 errors: expectedErrors([[3, 4, 0, "Identifier"], [4, 4, 2, "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 // https://github.com/eslint/eslint/issues/7233
8684 var folder = filePath
8689 var folder = filePath
8693 options: [2, { MemberExpression: 2 }],
8694 errors: expectedErrors([[2, 4, 2, "Punctuator"], [3, 4, 6, "Punctuator"]])
8698 for (const foo of bar)
8702 for (const foo of bar)
8706 errors: expectedErrors([2, 2, 4, "Identifier"])
8718 errors: expectedErrors([2, 2, 4, "Numeric"])
8722 // BinaryExpressions with parens
8734 errors: expectedErrors([2, 4, 8, "Identifier"])
8747 errors: expectedErrors([3, 4, 0, "Punctuator"])
8762 errors: expectedErrors([[3, 8, 4, "Identifier"], [4, 4, 0, "Punctuator"]])
8775 errors: expectedErrors([3, 0, 4, "Punctuator"])
8790 errors: expectedErrors([[3, 12, 16, "Identifier"], [4, 8, 12, "Punctuator"]])
8805 errors: expectedErrors([[3, 4, 8, "Numeric"], [4, 0, 4, "Punctuator"]])
8819 errors: expectedErrors([2, 2, 0, "Identifier"])
8833 errors: expectedErrors([[2, 2, 4, "Template"], [3, 4, 0, "Identifier"]])
8851 errors: expectedErrors([[2, 2, 4, "Template"], [3, 4, 2, "Identifier"], [4, 2, 4, "Template"], [5, 0, 2, "Template"]])
8869 errors: expectedErrors([[2, 2, 0, "Punctuator"], [3, 4, 2, "Identifier"], [4, 2, 0, "Punctuator"]])
8886 errors: expectedErrors([[3, 8, 0, "Identifier"], [4, 8, 2, "Identifier"]])
8891 const template = \`the indentation of
8892 a curly element in a \${
8894 } node is checked.\`;
8899 const template = \`the indentation of
8900 a curly element in a \${
8902 } node is checked.\`;
8905 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Template"]])
8910 const template = \`this time the
8911 closing curly is at the end of the line \${
8913 so the spaces before this line aren't removed
.\`;
8918 const template = \`this time the
8919 closing curly is at the end
of the line
\${
8921 so the spaces before
this line aren
't removed.\`;
8924 errors: expectedErrors([4, 4, 12, "Identifier"])
8929 * https://github.com/eslint/eslint/issues/1801
8930 * Note: This issue also mentioned checking the indentation for the 2 below. However,
8931 * this is intentionally ignored because everyone seems to have a different idea of how
8932 * BinaryExpressions should be indented.
8948 errors: expectedErrors([3, 8, 0, "Numeric"])
8952 // https://github.com/eslint/eslint/issues/3737
8968 errors: expectedErrors([[2, 2, 4, "Keyword"], [3, 4, 6, "Identifier"]])
8972 // https://github.com/eslint/eslint/issues/6670
8999 options: [4, { MemberExpression: 1, CallExpression: { arguments: 1 } }],
9000 errors: expectedErrors([
9001 [3, 8, 4, "Punctuator"],
9002 [4, 12, 15, "String"],
9003 [5, 12, 14, "Punctuator"],
9004 [6, 16, 14, "Numeric"],
9005 [7, 16, 9, "Numeric"],
9006 [8, 16, 35, "Numeric"],
9007 [9, 12, 22, "Punctuator"],
9008 [10, 8, 0, "Punctuator"],
9009 [11, 0, 1, "Punctuator"]
9013 // https://github.com/eslint/eslint/issues/7242
9027 errors: expectedErrors([[2, 4, 6, "Punctuator"], [3, 4, 2, "Punctuator"]])
9042 errors: expectedErrors([[2, 4, 6, "Punctuator"], [3, 4, 2, "Punctuator"]])
9046 echo = spawn('cmd
.exe
',
9051 echo = spawn('cmd
.exe
',
9055 options: [2, { ArrayExpression: "first", CallExpression: { arguments: "first" } }],
9056 errors: expectedErrors([[2, 13, 12, "Punctuator"], [3, 14, 13, "String"]])
9060 // https://github.com/eslint/eslint/issues/7522
9069 errors: expectedErrors([2, 0, 2, "Punctuator"])
9073 // https://github.com/eslint/eslint/issues/7616
9090 options: [4, { CallExpression: { arguments: "first" } }],
9091 errors: expectedErrors([[2, 4, 8, "Identifier"]])
9096 errors: expectedErrors([1, 0, 2, "Keyword"])
9100 var foo = 0, bar = 0, baz = 0;
9108 var foo = 0, bar = 0, baz = 0;
9115 parserOptions: { ecmaVersion: 6, sourceType: "module" },
9116 errors: expectedErrors([[3, 4, 0, "Identifier"], [4, 4, 8, "Identifier"], [5, 4, 2, "Identifier"]])
9129 options: [4, { flatTernaryExpressions: true }],
9130 errors: expectedErrors([3, 4, 0, "Punctuator"])
9143 options: [4, { flatTernaryExpressions: true }],
9144 errors: expectedErrors([3, 4, 0, "Identifier"])
9157 options: [4, { flatTernaryExpressions: true }],
9158 errors: expectedErrors([3, 4, 2, "Punctuator"])
9171 options: [4, { flatTernaryExpressions: true }],
9172 errors: expectedErrors([3, 4, 0, "Identifier"])
9187 options: [4, { flatTernaryExpressions: true }],
9188 errors: expectedErrors([
9189 [3, 4, 8, "Punctuator"],
9190 [4, 4, 12, "Punctuator"]
9206 options: [4, { flatTernaryExpressions: true }],
9207 errors: expectedErrors([
9208 [3, 4, 8, "Identifier"],
9209 [4, 4, 12, "Identifier"]
9227 options: [4, { flatTernaryExpressions: true }],
9228 errors: expectedErrors([
9229 [3, 4, 6, "Identifier"],
9230 [4, 4, 2, "Identifier"]
9246 options: [4, { flatTernaryExpressions: true }],
9247 errors: expectedErrors([
9248 [3, 8, 4, "Punctuator"],
9249 [4, 8, 4, "Punctuator"]
9265 options: [4, { flatTernaryExpressions: false }],
9266 errors: expectedErrors([
9267 [3, 8, 4, "Punctuator"],
9268 [4, 12, 4, "Punctuator"]
9284 options: [4, { flatTernaryExpressions: false }],
9285 errors: expectedErrors([
9286 [3, 8, 4, "Identifier"],
9287 [4, 12, 4, "Identifier"]
9309 options: [4, { flatTernaryExpressions: false }],
9310 errors: expectedErrors([
9311 [4, 8, 4, "Punctuator"],
9312 [5, 8, 4, "Punctuator"],
9313 [6, 12, 4, "Punctuator"],
9314 [7, 12, 4, "Punctuator"]
9336 options: [4, { flatTernaryExpressions: false }],
9337 errors: expectedErrors([
9338 [4, 8, 4, "Identifier"],
9339 [5, 8, 4, "Identifier"],
9340 [6, 12, 4, "Identifier"],
9341 [7, 12, 4, "Identifier"]
9346 foo.bar('baz
', function(err) {
9351 foo.bar('baz
', function(err) {
9355 options: [2, { CallExpression: { arguments: "first" } }],
9356 errors: expectedErrors([2, 2, 10, "Identifier"])
9360 foo.bar(function() {
9367 foo.bar(function() {
9373 options: [2, { MemberExpression: 1 }],
9374 errors: expectedErrors([[4, 2, 4, "Identifier"], [5, 0, 2, "Punctuator"]])
9378 foo.bar().baz(function() {
9385 foo.bar().baz(function() {
9391 options: [2, { MemberExpression: 1 }],
9392 errors: expectedErrors([[4, 2, 4, "Identifier"], [5, 0, 2, "Punctuator"]])
9397 bar ].forEach(function() {
9403 bar ].forEach(function() {
9407 options: [2, { ArrayExpression: "first", MemberExpression: 1 }],
9408 errors: expectedErrors([[3, 2, 4, "Identifier"], [4, 0, 2, "Punctuator"]])
9421 options: [4, { MemberExpression: 1 }],
9422 errors: expectedErrors([3, 0, 4, "Punctuator"])
9437 options: [4, { ObjectExpression: "first" }],
9438 errors: expectedErrors([[2, 4, 0, "Identifier"], [3, 4, 0, "Identifier"]])
9451 options: [2, { CallExpression: { arguments: "first" } }],
9452 errors: expectedErrors([[2, 2, 24, "Identifier"], [3, 2, 24, "Identifier"]])
9458 ; [1, 2, 3].map(baz)
9463 ; [1, 2, 3].map(baz)
9465 errors: expectedErrors([3, 0, 4, "Punctuator"])
9476 errors: expectedErrors([2, 4, 0, "Punctuator"])
9487 parserOptions: { ecmaVersion: 6, sourceType: "module" },
9488 errors: expectedErrors([2, 4, 0, "Identifier"])
9499 parserOptions: { ecmaVersion: 6, sourceType: "module" },
9500 errors: expectedErrors([2, 4, 0, "Identifier"])
9517 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9523 ) => b => c => d => {
9530 ) => b => c => d => {
9534 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9551 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9568 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9585 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9602 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
9615 errors: expectedErrors([[2, 4, 2, "Identifier"], [3, 4, 6, "Identifier"]])
9634 errors: expectedErrors([[4, 8, 12, "String"], [5, 8, 12, "String"], [6, 4, 8, "Punctuator"]])
9653 errors: expectedErrors([[4, 8, 12, "String"], [5, 8, 12, "String"], [6, 4, 8, "Punctuator"]])
9672 errors: expectedErrors([[6, 8, 4, "Punctuator"]])
9689 errors: expectedErrors([[4, 12, 8, "String"]])
9692 //----------------------------------------------------------------------
9693 // Ignore Unknown Nodes
9694 //----------------------------------------------------------------------
9717 parser: parser("unknown-nodes/namespace-invalid"),
9718 errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]])
9722 abstract class Foo {
9736 abstract class Foo {
9749 parser: parser("unknown-nodes/abstract-class-invalid"),
9750 errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]])
9779 parser: parser("unknown-nodes/functions-with-abstract-class-invalid"),
9780 errors: expectedErrors([
9781 [4, 12, 8, "Keyword"],
9782 [5, 16, 8, "Keyword"],
9783 [6, 20, 8, "Identifier"],
9784 [7, 16, 8, "Punctuator"],
9785 [8, 12, 8, "Punctuator"]
9819 parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid"),
9820 errors: expectedErrors([
9821 [3, 8, 4, "Keyword"],
9822 [7, 24, 20, "Identifier"]
9826 //----------------------------------------------------------------------
9828 // Some of the following tests are adapted from the the tests in eslint-plugin-react.
9829 // License: https://github.com/yannickcr/eslint-plugin-react/blob/7ca9841f22d599f447a27ef5b2a97def9229d6c8/LICENSE
9830 //----------------------------------------------------------------------
9843 errors: expectedErrors([2, 4, 2, "Punctuator"])
9857 errors: expectedErrors([2, 2, 4, "Punctuator"])
9871 errors: expectedErrors([2, "1 tab", "4 spaces", "Punctuator"])
9889 errors: expectedErrors([4, 2, 9, "Punctuator"])
9907 errors: expectedErrors([4, 2, 4, "Punctuator"])
9929 errors: expectedErrors([[3, 4, 0, "Punctuator"], [4, 6, 2, "Punctuator"], [5, 4, 0, "Punctuator"]])
9942 errors: expectedErrors([2, 4, 1, "Punctuator"])
9947 {options.map((option, index) => (
9948 <option key={index} value={option.key}>
9956 {options.map((option, index) => (
9957 <option key={index} value={option.key}>
9963 errors: expectedErrors([4, 12, 11, "Punctuator"])
9979 errors: expectedErrors([3, 2, 4, "Punctuator"])
9997 errors: expectedErrors([3, "1 tab", "1 space", "Punctuator"])
10002 * Multiline ternary
10003 * (colon at the end of the first expression)
10015 errors: expectedErrors([3, 4, 0, "Punctuator"])
10020 * Multiline ternary
10021 * (colon on its own line)
10035 errors: expectedErrors([[3, 4, 0, "Punctuator"], [4, 4, 0, "Punctuator"]])
10040 * Multiline ternary
10041 * (colon at the end of the first expression, parenthesized first expression)
10055 errors: expectedErrors([4, 4, 0, "Punctuator"])
10068 errors: expectedErrors([2, 4, 2, "JSXIdentifier"])
10082 errors: expectedErrors([3, 0, 2, "Punctuator"])
10096 errors: expectedErrors([3, 0, 2, "Punctuator"])
10100 const Button = function(props) {
10112 const Button = function(props) {
10124 errors: expectedErrors([6, 4, 36, "Punctuator"])
10128 var x = function() {
10135 var x = function() {
10142 errors: expectedErrors([4, 2, 9, "Punctuator"])
10156 errors: expectedErrors([3, 0, 8, "Punctuator"])
10172 errors: expectedErrors([3, 2, 4, "Punctuator"])
10186 errors: expectedErrors("tab", [3, 0, 1, "Punctuator"])
10200 errors: expectedErrors("tab", [3, 0, 1, "Punctuator"])
10229 errors: expectedErrors([
10230 [3, 8, 4, "Punctuator"],
10231 [4, 8, 4, "Punctuator"],
10232 [9, 8, 4, "JSXIdentifier"],
10233 [10, 8, 4, "JSXIdentifier"]
10251 errors: expectedErrors([4, 8, 4, "JSXText"])
10268 errors: expectedErrors([4, 8, 4, "Punctuator"])
10285 errors: expectedErrors([4, 8, 4, "Punctuator"])
10302 errors: expectedErrors([[4, 4, 8, "Identifier"], [5, 0, 4, "Punctuator"]])
10323 errors: expectedErrors([[5, 4, 8, "Punctuator"], [6, 4, 8, "Punctuator"], [7, 0, 4, "Punctuator"]])
10344 errors: expectedErrors([[3, 8, 4, "Punctuator"], [4, 12, 8, "Numeric"], [5, 8, 4, "Punctuator"]])
10361 errors: expectedErrors([3, 8, 6, "Block"])
10374 errors: expectedErrors([2, 4, 0, "Punctuator"])
10391 errors: expectedErrors([3, 8, 6, "Punctuator"])
10404 errors: expectedErrors([2, 4, 0, "Punctuator"])
10408 <small>Foo bar
10413 <small>Foo bar
10417 errors: expectedErrors([2, 4, 0, "Punctuator"])
10422 * https://github.com/eslint/eslint/issues/12208
10435 errors: expectedErrors([2, 4, 0, "Punctuator"])
10450 errors: expectedErrors([2, 0, 4, "Punctuator"])
10465 errors: expectedErrors([4, 0, 4, "Punctuator"])
10480 errors: expectedErrors([4, 0, 4, "Punctuator"])
10497 errors: expectedErrors([
10498 [2, 0, 4, "Punctuator"],
10499 [5, 0, 4, "Punctuator"]
10517 errors: expectedErrors([
10518 [2, 0, 4, "Punctuator"],
10519 [5, 0, 4, "Punctuator"]
10535 errors: expectedErrors([2, 0, 4, "Punctuator"])
10550 errors: expectedErrors([4, 0, 4, "Punctuator"])
10565 errors: expectedErrors([4, 0, 4, "Punctuator"])
10580 errors: expectedErrors([2, 0, 4, "Punctuator"])
10595 errors: expectedErrors([4, 0, 4, "Punctuator"])
10610 errors: expectedErrors([4, 0, 4, "Punctuator"])
10624 parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation"),
10625 errors: expectedErrors([3, 0, 4, "Punctuator"])
10638 parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation"),
10639 errors: expectedErrors([3, 0, 4, "Punctuator"])
10652 parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation"),
10653 errors: expectedErrors([3, 0, 4, "Punctuator"])
10670 options: [4, { ignoredNodes: ["ClassBody"] }],
10671 errors: expectedErrors([3, 4, 0, "Identifier"])
10699 ignoredNodes: ["ExpressionStatement > CallExpression[callee.name='$'] > FunctionExpression > BlockStatement"]
10701 errors: expectedErrors([7, 4, 0, "Identifier"])
10719 ignoredNodes: ["ExpressionStatement > CallExpression > FunctionExpression.callee > BlockStatement"]
10721 errors: expectedErrors([3, 4, 0, "Identifier"])
10728 // Intentionally unindented comment
10736 // Intentionally unindented comment
10740 options: [4, { ignoreComments: false }],
10741 errors: expectedErrors([4, 4, 0, "Line"])
10748 /* Intentionally unindented comment */
10756 /* Intentionally unindented comment */
10760 options: [4, { ignoreComments: false }],
10761 errors: expectedErrors([4, 4, 0, "Block"])
10767 return condition ? // comment
10776 return condition ? // comment
10782 errors: expectedErrors([4, 12, 8, "Numeric"])
10785 //----------------------------------------------------------------------
10786 // Comment alignment tests
10787 //----------------------------------------------------------------------
10792 // Comment cannot align with code immediately above if there is a whitespace gap
10799 // Comment cannot align with code immediately above if there is a whitespace gap
10803 errors: expectedErrors([3, 4, 0, "Line"])
10810 // Comment cannot align with code immediately below if there is a whitespace gap
10818 // Comment cannot align with code immediately below if there is a whitespace gap
10822 errors: expectedErrors([4, 4, 0, "Line"])
10830 // Comment between nodes
10841 // Comment between nodes
10847 errors: expectedErrors([5, 0, 4, "Line"])
10855 ;(async () => {})()
10862 ;(async () => {})()
10864 errors: expectedErrors([3, 0, 4, "Line"])
10870 ;(async () => {})()
10875 ;(async () => {})()
10877 errors: expectedErrors([2, 0, 4, "Line"])
10894 errors: expectedErrors([3, 4, 0, "Block"])
10900 ;(async () => {})()
10905 ;(async () => {})()
10907 errors: expectedErrors([1, 0, 4, "Line"])
10912 ;(async () => {})()
10916 ;(async () => {})()
10918 errors: expectedErrors([1, 0, 4, "Line"])
10927 ;(async () => {})()
10937 ;(async () => {})()
10941 errors: expectedErrors([4, 4, 8, "Line"])
10948 ;(async () => {})()
10956 ;(async () => {})()
10960 errors: expectedErrors([3, 4, 8, "Line"])
10983 errors: expectedErrors([4, 8, 4, "Block"])
10992 ;[1, 2, 3].forEach(() => {})
11000 ;[1, 2, 3].forEach(() => {})
11002 errors: expectedErrors([4, 0, 4, "Block"])
11009 ;[1, 2, 3].forEach(() => {})
11015 ;[1, 2, 3].forEach(() => {})
11017 errors: expectedErrors([3, 0, 4, "Block"])
11026 [1, 2, 3].forEach(() => {})
11034 [1, 2, 3].forEach(() => {})
11036 errors: expectedErrors([4, 4, 0, "Block"])
11042 ;[1, 2, 3].forEach(() => {})
11047 ;[1, 2, 3].forEach(() => {})
11049 errors: expectedErrors([1, 0, 4, "Block"])
11054 ;[1, 2, 3].forEach(() => {})
11058 ;[1, 2, 3].forEach(() => {})
11060 errors: expectedErrors([1, 0, 4, "Block"])
11070 ;[1, 2, 3].forEach(() => {})
11081 ;[1, 2, 3].forEach(() => {})
11085 errors: expectedErrors([5, 4, 8, "Block"])
11093 ;[1, 2, 3].forEach(() => {})
11102 ;[1, 2, 3].forEach(() => {})
11106 errors: expectedErrors([4, 4, 8, "Block"])
11116 [1, 2, 3].forEach(() => {})
11127 [1, 2, 3].forEach(() => {})
11131 errors: expectedErrors([5, 8, 4, "Block"])
11134 // import expressions
11146 parserOptions: { ecmaVersion: 2020 },
11147 errors: expectedErrors([
11148 [2, 4, 0, "Identifier"],
11149 [3, 0, 4, "Punctuator"]
11153 // https://github.com/eslint/eslint/issues/12122
11159 template\${a} \${b}
11170 template\${a} \${b}
11177 parserOptions: { ecmaVersion: 2015 },
11178 errors: expectedErrors([
11179 [7, 8, 4, "Identifier"]
11189 \${a} \${b}\`(() => {
11200 \${a} \${b}\`(() => {
11205 parserOptions: { ecmaVersion: 2015 },
11206 errors: expectedErrors([
11207 [2, 4, 8, "Identifier"],
11208 [7, 8, 12, "Identifier"],
11209 [8, 4, 8, "Punctuator"]
11215 tagOne\`\${a} \${b}
11234 tagOne\`\${a} \${b}
11251 parserOptions: { ecmaVersion: 2015 },
11252 errors: expectedErrors([
11253 [7, 8, 12, "Identifier"],
11254 [15, 8, 12, "Identifier"],
11255 [16, 4, 0, "Punctuator"]
11265 \${a} \${b}\`(() => {
11284 \${a} \${b}\`(() => {
11297 parserOptions: { ecmaVersion: 2015 },
11298 errors: expectedErrors([
11299 [7, 8, 12, "Identifier"],
11300 [15, 8, 12, "Identifier"],
11301 [16, 4, 0, "Punctuator"]
11306 tagOne\`multiline \${a} \${b}
11322 tagOne\`multiline \${a} \${b}
11337 parserOptions: { ecmaVersion: 2015 },
11338 errors: expectedErrors([
11339 [5, 4, 0, "Identifier"],
11340 [11, 8, 4, "Identifier"]
11346 template \${a} \${b}
11349 bar: tagTwo\`multiline
11359 template \${a} \${b}
11362 bar: tagTwo\`multiline
11370 parserOptions: { ecmaVersion: 2015 },
11371 errors: expectedErrors([
11372 [4, 4, 8, "Identifier"],
11373 [5, 4, 0, "Identifier"],
11374 [9, 8, 0, "Identifier"]
11379 foo.bar\` template literal \`(() => {
11384 foo.bar\` template literal \`(() => {
11388 parserOptions: { ecmaVersion: 2015 },
11389 errors: expectedErrors([
11390 [2, 4, 8, "Identifier"]
11395 foo.bar.baz\` template literal \`(() => {
11400 foo.bar.baz\` template literal \`(() => {
11404 parserOptions: { ecmaVersion: 2015 },
11405 errors: expectedErrors([
11406 [2, 4, 0, "Identifier"],
11407 [3, 0, 4, "Punctuator"]
11425 parserOptions: { ecmaVersion: 2015 },
11426 errors: expectedErrors([
11427 [5, 4, 0, "Punctuator"]
11447 parserOptions: { ecmaVersion: 2015 },
11448 errors: expectedErrors([
11449 [5, 8, 0, "Identifier"]
11469 options: [4, { MemberExpression: 0 }],
11470 parserOptions: { ecmaVersion: 2015 },
11471 errors: expectedErrors([
11472 [2, 0, 4, "Punctuator"],
11473 [5, 4, 0, "Identifier"],
11474 [6, 0, 4, "Punctuator"]
11478 // Optional chaining
11495 parserOptions: { ecmaVersion: 2020 },
11496 errors: expectedErrors([
11497 [2, 4, 0, "Punctuator"],
11498 [3, 4, 0, "Punctuator"],
11499 [4, 4, 0, "Punctuator"],
11500 [5, 8, 0, "Punctuator"]
11523 parserOptions: { ecmaVersion: 2020 },
11524 errors: expectedErrors([
11525 [6, 4, 0, "Punctuator"],
11526 [7, 4, 0, "Punctuator"]
11543 parserOptions: { ecmaVersion: 2020 },
11544 errors: expectedErrors([
11545 [2, 4, 0, "Punctuator"],
11546 [3, 4, 0, "Punctuator"],
11547 [4, 4, 0, "Punctuator"]
11570 parserOptions: { ecmaVersion: 2020 },
11571 errors: expectedErrors([
11572 [6, 4, 0, "Punctuator"],
11573 [7, 4, 0, "Punctuator"]
11578 const foo = async (arg1,
11581 return arg1 + arg2;
11585 const foo = async (arg1,
11588 return arg1 + arg2;
11591 options: [2, { FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" } }],
11592 parserOptions: { ecmaVersion: 2020 },
11593 errors: expectedErrors([
11594 [2, 19, 20, "Identifier"]
11607 errors: expectedErrors([
11608 [2, 0, 1, "Identifier"]