diff --git a/.eslintrc.js b/.eslintrc.js index 86cc480173f..ff213cf5f97 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,7 +17,22 @@ module.exports = { "eslint-plugin/prefer-placeholders": "error", "eslint-plugin/report-message-format": ["error", "[^a-z].*\\.$"], "eslint-plugin/require-meta-type": "error", - "eslint-plugin/test-case-property-ordering": "error", + "eslint-plugin/test-case-property-ordering": [ + "error", + + // https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/79 + [ + "filename", + "code", + "output", + "options", + "parser", + "parserOptions", + "globals", + "env", + "errors" + ] + ], "eslint-plugin/test-case-shorthand-strings": "error", "internal-rules/multiline-comment-style": "error" }, diff --git a/tests/lib/rules/array-bracket-spacing.js b/tests/lib/rules/array-bracket-spacing.js index da3dadd6ec5..efb72ca5f52 100644 --- a/tests/lib/rules/array-bracket-spacing.js +++ b/tests/lib/rules/array-bracket-spacing.js @@ -174,8 +174,8 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var obj = {'foo': [1, 2]}", options: ["never"] }, // destructuring with type annotation - { code: "([ a, b ]: Array) => {}", options: ["always"], parserOptions: { ecmaVersion: 6 }, parser: parser("flow-destructuring-1") }, - { code: "([a, b]: Array< any >) => {}", options: ["never"], parserOptions: { ecmaVersion: 6 }, parser: parser("flow-destructuring-2") } + { code: "([ a, b ]: Array) => {}", options: ["always"], parser: parser("flow-destructuring-1"), parserOptions: { ecmaVersion: 6 } }, + { code: "([a, b]: Array< any >) => {}", options: ["never"], parser: parser("flow-destructuring-2"), parserOptions: { ecmaVersion: 6 } } ], invalid: [ @@ -830,6 +830,7 @@ ruleTester.run("array-bracket-spacing", rule, { code: "([ a, b ]: Array) => {}", output: "([a, b]: Array) => {}", options: ["never"], + parser: parser("flow-destructuring-1"), parserOptions: { ecmaVersion: 6 }, @@ -852,13 +853,13 @@ ruleTester.run("array-bracket-spacing", rule, { line: 1, column: 9 } - ], - parser: parser("flow-destructuring-1") + ] }, { code: "([a, b]: Array< any >) => {}", output: "([ a, b ]: Array< any >) => {}", options: ["always"], + parser: parser("flow-destructuring-2"), parserOptions: { ecmaVersion: 6 }, @@ -881,8 +882,7 @@ ruleTester.run("array-bracket-spacing", rule, { line: 1, column: 7 } - ], - parser: parser("flow-destructuring-2") + ] } ] }); diff --git a/tests/lib/rules/comma-dangle.js b/tests/lib/rules/comma-dangle.js index 8797dbdcf19..1f1fc33cf09 100644 --- a/tests/lib/rules/comma-dangle.js +++ b/tests/lib/rules/comma-dangle.js @@ -1410,29 +1410,29 @@ let d = 0;export {d,}; code: "function foo({a}: {a: string,}) {}", output: "function foo({a,}: {a: string,}) {}", options: ["always"], - errors: [{ messageId: "missing" }], - parser: parser("object-pattern-1") + parser: parser("object-pattern-1"), + errors: [{ messageId: "missing" }] }, { code: "function foo({a,}: {a: string}) {}", output: "function foo({a}: {a: string}) {}", options: ["never"], - errors: [{ messageId: "unexpected" }], - parser: parser("object-pattern-2") + parser: parser("object-pattern-2"), + errors: [{ messageId: "unexpected" }] }, { code: "function foo(a): {b: boolean,} {}", output: "function foo(a,): {b: boolean,} {}", options: [{ functions: "always" }], - errors: [{ messageId: "missing" }], - parser: parser("return-type-1") + parser: parser("return-type-1"), + errors: [{ messageId: "missing" }] }, { code: "function foo(a,): {b: boolean} {}", output: "function foo(a): {b: boolean} {}", options: [{ functions: "never" }], - errors: [{ messageId: "unexpected" }], - parser: parser("return-type-2") + parser: parser("return-type-2"), + errors: [{ messageId: "unexpected" }] } ] }); diff --git a/tests/lib/rules/indent.js b/tests/lib/rules/indent.js index 45abc654d0e..7d5210b45ca 100644 --- a/tests/lib/rules/indent.js +++ b/tests/lib/rules/indent.js @@ -8686,8 +8686,8 @@ ruleTester.run("indent", rule, { } } `, - errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]]), - parser: parser("unknown-nodes/namespace-invalid") + parser: parser("unknown-nodes/namespace-invalid"), + errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]]) }, { code: unIndent` @@ -8718,8 +8718,8 @@ ruleTester.run("indent", rule, { } } `, - errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]]), - parser: parser("unknown-nodes/abstract-class-invalid") + parser: parser("unknown-nodes/abstract-class-invalid"), + errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]]) }, { code: unIndent` @@ -8748,14 +8748,14 @@ ruleTester.run("indent", rule, { } } `, + parser: parser("unknown-nodes/functions-with-abstract-class-invalid"), errors: expectedErrors([ [4, 12, 8, "Keyword"], [5, 16, 8, "Keyword"], [6, 20, 8, "Identifier"], [7, 16, 8, "Punctuator"], [8, 12, 8, "Punctuator"] - ]), - parser: parser("unknown-nodes/functions-with-abstract-class-invalid") + ]) }, { code: unIndent` @@ -8788,11 +8788,11 @@ ruleTester.run("indent", rule, { } } `, + parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid"), errors: expectedErrors([ [3, 8, 4, "Keyword"], [7, 24, 20, "Identifier"] - ]), - parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid") + ]) }, //---------------------------------------------------------------------- @@ -9369,8 +9369,8 @@ ruleTester.run("indent", rule, { foo }: bar) => baz `, - errors: expectedErrors([3, 0, 4, "Punctuator"]), - parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation") + parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation"), + errors: expectedErrors([3, 0, 4, "Punctuator"]) }, { code: unIndent` @@ -9383,8 +9383,8 @@ ruleTester.run("indent", rule, { foo ]: bar) => baz `, - errors: expectedErrors([3, 0, 4, "Punctuator"]), - parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation") + parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation"), + errors: expectedErrors([3, 0, 4, "Punctuator"]) }, { code: unIndent` @@ -9397,8 +9397,8 @@ ruleTester.run("indent", rule, { foo }: {}) => baz `, - errors: expectedErrors([3, 0, 4, "Punctuator"]), - parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation") + parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation"), + errors: expectedErrors([3, 0, 4, "Punctuator"]) }, { code: unIndent` diff --git a/tests/lib/rules/keyword-spacing.js b/tests/lib/rules/keyword-spacing.js index 5e6a0d83730..a2b7d2f8ac6 100644 --- a/tests/lib/rules/keyword-spacing.js +++ b/tests/lib/rules/keyword-spacing.js @@ -3135,8 +3135,8 @@ ruleTester.run("keyword-spacing", rule, { { code: "class Foo { @desc({set a(value) {}, get a() {}, async c() {}}) async[foo]() {} }", output: "class Foo { @desc({set a(value) {}, get a() {}, async c() {}}) async [foo]() {} }", - errors: expectedAfter("async"), - parser: parser("typescript-parsers/decorator-with-keywords-class-method") + parser: parser("typescript-parsers/decorator-with-keywords-class-method"), + errors: expectedAfter("async") } ] }); diff --git a/tests/lib/rules/no-console.js b/tests/lib/rules/no-console.js index 76a39227e5c..5241acc251b 100644 --- a/tests/lib/rules/no-console.js +++ b/tests/lib/rules/no-console.js @@ -58,6 +58,6 @@ ruleTester.run("no-console", rule, { { code: "console.warn(foo)", options: [{ allow: ["info", "log"] }], errors: [{ messageId: "unexpected", type: "MemberExpression" }] }, // In case that implicit global variable of 'console' exists - { code: "console.log(foo)", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { node: true } } + { code: "console.log(foo)", env: { node: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] } ] }); diff --git a/tests/lib/rules/no-eval.js b/tests/lib/rules/no-eval.js index d31c726b946..5421bbcc875 100644 --- a/tests/lib/rules/no-eval.js +++ b/tests/lib/rules/no-eval.js @@ -72,17 +72,17 @@ ruleTester.run("no-eval", rule, { // Indirect eval { code: "(0, eval)('foo')", errors: [{ messageId: "unexpected", type: "Identifier" }] }, - { code: "(0, window.eval)('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { browser: true } }, - { code: "(0, window['eval'])('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { browser: true } }, + { code: "(0, window.eval)('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] }, + { code: "(0, window['eval'])('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] }, { code: "var EVAL = eval; EVAL('foo')", errors: [{ messageId: "unexpected", type: "Identifier" }] }, { code: "var EVAL = this.eval; EVAL('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }] }, { code: "(function(exe){ exe('foo') })(eval);", errors: [{ messageId: "unexpected", type: "Identifier" }] }, - { code: "window.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } }, - { code: "window.window.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } }, - { code: "window.window['eval']('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } }, - { code: "global.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } }, - { code: "global.global.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } }, - { code: "global.global[`eval`]('foo')", parserOptions: { ecmaVersion: 6 }, errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } }, + { code: "window.eval('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] }, + { code: "window.window.eval('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] }, + { code: "window.window['eval']('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] }, + { code: "global.eval('foo')", env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] }, + { code: "global.global.eval('foo')", env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] }, + { code: "global.global[`eval`]('foo')", parserOptions: { ecmaVersion: 6 }, env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] }, { code: "this.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }] }, { code: "function foo() { this.eval('foo') }", errors: [{ messageId: "unexpected", type: "CallExpression" }] } ] diff --git a/tests/lib/rules/no-global-assign.js b/tests/lib/rules/no-global-assign.js index 3cd7926373e..051752db016 100644 --- a/tests/lib/rules/no-global-assign.js +++ b/tests/lib/rules/no-global-assign.js @@ -42,18 +42,18 @@ ruleTester.run("no-global-assign", rule, { }, { code: "top = 0;", - errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }] }, { code: "require = 0;", - errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }], - env: { node: true } + env: { node: true }, + errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }] }, // Notifications of readonly are moved from no-undef: https://github.com/eslint/eslint/issues/4504 { code: "/*global b:false*/ function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, - { code: "function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }], globals: { b: false } }, + { code: "function f() { b = 1; }", globals: { b: false }, errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, { code: "/*global b:false*/ function f() { b++; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, { code: "/*global b*/ b = 1;", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, { code: "Array = 1;", errors: [{ message: "Read-only global 'Array' should not be modified.", type: "Identifier" }] } diff --git a/tests/lib/rules/no-magic-numbers.js b/tests/lib/rules/no-magic-numbers.js index 34b1e2f6ae2..beb0282dbbd 100644 --- a/tests/lib/rules/no-magic-numbers.js +++ b/tests/lib/rules/no-magic-numbers.js @@ -83,8 +83,8 @@ ruleTester.run("no-magic-numbers", rule, { options: [{ enforceConst: true }], - errors: [{ messageId: "useConst" }], - env: { es6: true } + env: { es6: true }, + errors: [{ messageId: "useConst" }] }, { code: "var foo = 0 + 1;", @@ -189,6 +189,7 @@ ruleTester.run("no-magic-numbers", rule, { "function invokeInTen(func) {\n" + "setTimeout(func, 10);\n" + "}\n", + env: { es6: true }, errors: [ { messageId: "noMagic", data: { raw: "10" }, line: 7 }, { messageId: "noMagic", data: { raw: "10" }, line: 7 }, @@ -196,8 +197,7 @@ ruleTester.run("no-magic-numbers", rule, { { messageId: "noMagic", data: { raw: "1000" }, line: 15 }, { messageId: "noMagic", data: { raw: "0" }, line: 19 }, { messageId: "noMagic", data: { raw: "10" }, line: 22 } - ], - env: { es6: true } + ] }, { code: "var data = ['foo', 'bar', 'baz']; var third = data[3];", diff --git a/tests/lib/rules/no-mixed-spaces-and-tabs.js b/tests/lib/rules/no-mixed-spaces-and-tabs.js index f427a6f1c2d..8badf704a16 100644 --- a/tests/lib/rules/no-mixed-spaces-and-tabs.js +++ b/tests/lib/rules/no-mixed-spaces-and-tabs.js @@ -136,6 +136,7 @@ ruleTester.run("no-mixed-spaces-and-tabs", rule, { { code: "`foo${\n \t 5 }bar`;", options: ["smart-tabs"], + env: { es6: true }, errors: [ { message: "Mixed spaces and tabs.", @@ -143,11 +144,11 @@ ruleTester.run("no-mixed-spaces-and-tabs", rule, { line: 2, column: 2 } - ], - env: { es6: true } + ] }, { code: "`foo${\n\t 5 }bar`;", + env: { es6: true }, errors: [ { message: "Mixed spaces and tabs.", @@ -155,8 +156,7 @@ ruleTester.run("no-mixed-spaces-and-tabs", rule, { line: 2, column: 2 } - ], - env: { es6: true } + ] } ] }); diff --git a/tests/lib/rules/no-native-reassign.js b/tests/lib/rules/no-native-reassign.js index ce6f4756f8f..eaf763bb74b 100644 --- a/tests/lib/rules/no-native-reassign.js +++ b/tests/lib/rules/no-native-reassign.js @@ -43,18 +43,18 @@ ruleTester.run("no-native-reassign", rule, { }, { code: "top = 0;", - errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }] }, { code: "require = 0;", - errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }], - env: { node: true } + env: { node: true }, + errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }] }, // Notifications of readonly are moved from no-undef: https://github.com/eslint/eslint/issues/4504 { code: "/*global b:false*/ function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, - { code: "function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }], globals: { b: false } }, + { code: "function f() { b = 1; }", globals: { b: false }, errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, { code: "/*global b:false*/ function f() { b++; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, { code: "/*global b*/ b = 1;", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] }, { code: "Array = 1;", errors: [{ message: "Read-only global 'Array' should not be modified.", type: "Identifier" }] } diff --git a/tests/lib/rules/no-redeclare.js b/tests/lib/rules/no-redeclare.js index 2cd0f8ef57d..23a45f02185 100644 --- a/tests/lib/rules/no-redeclare.js +++ b/tests/lib/rules/no-redeclare.js @@ -62,8 +62,8 @@ ruleTester.run("no-redeclare", rule, { { code: "var top = 0;", options: [{ builtinGlobals: true }], - errors: [{ message: "'top' is already defined.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "'top' is already defined.", type: "Identifier" }] }, { code: "var a; var {a = 0, b: Object = 0} = {};", diff --git a/tests/lib/rules/no-restricted-globals.js b/tests/lib/rules/no-restricted-globals.js index 8d4a6994179..0e09be16984 100644 --- a/tests/lib/rules/no-restricted-globals.js +++ b/tests/lib/rules/no-restricted-globals.js @@ -70,20 +70,20 @@ ruleTester.run("no-restricted-globals", rule, { { code: "function fn() { foo; }", options: ["foo"], - errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }], - globals: { foo: false } + globals: { foo: false }, + errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }] }, { code: "event", options: ["foo", "event"], - errors: [{ message: "Unexpected use of 'event'.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "Unexpected use of 'event'.", type: "Identifier" }] }, { code: "foo", options: ["foo"], - errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }], - globals: { foo: false } + globals: { foo: false }, + errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }] }, { code: "foo()", @@ -108,20 +108,20 @@ ruleTester.run("no-restricted-globals", rule, { { code: "function fn() { foo; }", options: [{ name: "foo" }], - errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }], - globals: { foo: false } + globals: { foo: false }, + errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }] }, { code: "event", options: ["foo", { name: "event" }], - errors: [{ message: "Unexpected use of 'event'.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "Unexpected use of 'event'.", type: "Identifier" }] }, { code: "foo", options: [{ name: "foo" }], - errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }], - globals: { foo: false } + globals: { foo: false }, + errors: [{ message: "Unexpected use of 'foo'.", type: "Identifier" }] }, { code: "foo()", @@ -146,20 +146,20 @@ ruleTester.run("no-restricted-globals", rule, { { code: "function fn() { foo; }", options: [{ name: "foo", message: "Use bar instead." }], - errors: [{ message: "Unexpected use of 'foo'. Use bar instead.", type: "Identifier" }], - globals: { foo: false } + globals: { foo: false }, + errors: [{ message: "Unexpected use of 'foo'. Use bar instead.", type: "Identifier" }] }, { code: "event", options: ["foo", { name: "event", message: "Use local event parameter." }], - errors: [{ message: "Unexpected use of 'event'. Use local event parameter.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "Unexpected use of 'event'. Use local event parameter.", type: "Identifier" }] }, { code: "foo", options: [{ name: "foo", message: "Use bar instead." }], - errors: [{ message: "Unexpected use of 'foo'. Use bar instead.", type: "Identifier" }], - globals: { foo: false } + globals: { foo: false }, + errors: [{ message: "Unexpected use of 'foo'. Use bar instead.", type: "Identifier" }] }, { code: "foo()", diff --git a/tests/lib/rules/no-sequences.js b/tests/lib/rules/no-sequences.js index 1ab5ed42e70..a32400b2f1a 100644 --- a/tests/lib/rules/no-sequences.js +++ b/tests/lib/rules/no-sequences.js @@ -61,6 +61,6 @@ ruleTester.run("no-sequences", rule, { { code: "switch (doSomething(), val) {}", errors: errors(22) }, { code: "while (doSomething(), !!test);", errors: errors(21) }, { code: "with (doSomething(), val) {}", errors: errors(20) }, - { code: "a => (doSomething(), a)", errors: errors(20), env: { es6: true } } + { code: "a => (doSomething(), a)", env: { es6: true }, errors: errors(20) } ] }); diff --git a/tests/lib/rules/no-shadow.js b/tests/lib/rules/no-shadow.js index 071eadd1530..18ce5b16197 100644 --- a/tests/lib/rules/no-shadow.js +++ b/tests/lib/rules/no-shadow.js @@ -299,8 +299,8 @@ ruleTester.run("no-shadow", rule, { { code: "function foo() { var top = 0; }", options: [{ builtinGlobals: true }], - errors: [{ message: "'top' is already declared in the upper scope.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "'top' is already declared in the upper scope.", type: "Identifier" }] }, { code: "var Object = 0;", @@ -312,8 +312,8 @@ ruleTester.run("no-shadow", rule, { code: "var top = 0;", options: [{ builtinGlobals: true }], parserOptions: { sourceType: "module" }, - errors: [{ message: "'top' is already declared in the upper scope.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "'top' is already declared in the upper scope.", type: "Identifier" }] }, { code: "var Object = 0;", @@ -325,8 +325,8 @@ ruleTester.run("no-shadow", rule, { code: "var top = 0;", options: [{ builtinGlobals: true }], parserOptions: { ecmaFeatures: { globalReturn: true } }, - errors: [{ message: "'top' is already declared in the upper scope.", type: "Identifier" }], - env: { browser: true } + env: { browser: true }, + errors: [{ message: "'top' is already declared in the upper scope.", type: "Identifier" }] }, { code: "function foo(cb) { (function (cb) { cb(42); })(cb); }", diff --git a/tests/lib/rules/no-unused-vars.js b/tests/lib/rules/no-unused-vars.js index 9b6733cacc3..3012dec6368 100644 --- a/tests/lib/rules/no-unused-vars.js +++ b/tests/lib/rules/no-unused-vars.js @@ -477,10 +477,10 @@ ruleTester.run("no-unused-vars", rule, { // surrogate pair. { code: "/*global 𠮷𩸽, 𠮷*/\n\\u{20BB7}\\u{29E3D};", + env: { es6: true }, errors: [ { line: 1, column: 16, message: "'𠮷' is defined but never used." } - ], - env: { es6: true } + ] }, // https://github.com/eslint/eslint/issues/4047 diff --git a/tests/lib/rules/object-curly-newline.js b/tests/lib/rules/object-curly-newline.js index 072ca1611b3..8cf75265a5e 100644 --- a/tests/lib/rules/object-curly-newline.js +++ b/tests/lib/rules/object-curly-newline.js @@ -670,11 +670,11 @@ ruleTester.run("object-curly-newline", rule, { "} : MyType) {}" ].join("\n"), options: ["always"], + parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-singleline"), errors: [ { line: 1, column: 14, message: "Expected a line break after this opening brace." }, { line: 1, column: 21, message: "Expected a line break before this closing brace." } - ], - parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-singleline") + ] }, { code: "function foo({ a, b } : { a : string, b : string }) {}", @@ -684,11 +684,11 @@ ruleTester.run("object-curly-newline", rule, { "} : { a : string, b : string }) {}" ].join("\n"), options: ["always"], + parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-singleline-type-literal"), errors: [ { line: 1, column: 14, message: "Expected a line break after this opening brace." }, { line: 1, column: 21, message: "Expected a line break before this closing brace." } - ], - parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-singleline-type-literal") + ] }, // "never" ------------------------------------------------------------ @@ -784,11 +784,11 @@ ruleTester.run("object-curly-newline", rule, { " b} : MyType) {}" ].join("\n"), options: ["never"], + parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-multiline"), errors: [ { line: 1, column: 14, message: "Unexpected line break after this opening brace." }, { line: 4, column: 1, message: "Unexpected line break before this closing brace." } - ], - parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-multiline") + ] }, { code: [ @@ -802,11 +802,11 @@ ruleTester.run("object-curly-newline", rule, { " b} : { a : string, b : string }) {}" ].join("\n"), options: ["never"], + parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-multiline-type-literal"), errors: [ { line: 1, column: 14, message: "Unexpected line break after this opening brace." }, { line: 4, column: 1, message: "Unexpected line break before this closing brace." } - ], - parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-newline/flow-stub-parser-multiline-type-literal") + ] }, // "multiline" --------------------------------------------------------- diff --git a/tests/lib/rules/object-curly-spacing.js b/tests/lib/rules/object-curly-spacing.js index c016b731b16..3595ff6b523 100644 --- a/tests/lib/rules/object-curly-spacing.js +++ b/tests/lib/rules/object-curly-spacing.js @@ -768,13 +768,13 @@ ruleTester.run("object-curly-spacing", rule, { code: "function foo ({a, b }: Props) {\n}", output: "function foo ({a, b}: Props) {\n}", options: ["never"], + parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-spacing/flow-stub-parser-never-invalid"), errors: [ { message: "There should be no space before '}'.", type: "ObjectPattern" } - ], - parser: resolvePath(__dirname, "../../fixtures/parsers/object-curly-spacing/flow-stub-parser-never-invalid") + ] } ] }); diff --git a/tests/lib/rules/prefer-const.js b/tests/lib/rules/prefer-const.js index 699feb6cfb2..66eec8c539f 100644 --- a/tests/lib/rules/prefer-const.js +++ b/tests/lib/rules/prefer-const.js @@ -383,8 +383,8 @@ ruleTester.run("prefer-const", rule, { code: "let { name, ...otherStuff } = obj; otherStuff = {};", output: null, options: [{ destructuring: "any" }], - errors: [{ messageId: "useConst", data: { name: "name" }, type: "Identifier", column: 7 }], - parser: fixtureParser("babel-eslint5/destructuring-object-spread") + parser: fixtureParser("babel-eslint5/destructuring-object-spread"), + errors: [{ messageId: "useConst", data: { name: "name" }, type: "Identifier", column: 7 }] }, // Warnings are located at declaration if there are reading references before assignments. diff --git a/tests/lib/rules/quote-props.js b/tests/lib/rules/quote-props.js index 6291960d351..fa8037b7c32 100644 --- a/tests/lib/rules/quote-props.js +++ b/tests/lib/rules/quote-props.js @@ -148,18 +148,18 @@ ruleTester.run("quote-props", rule, { code: "({ 'a': 0, [x]: 0 })", output: "({ a: 0, [x]: 0 })", options: ["consistent-as-needed"], + env: { es6: true }, errors: [ { message: "Properties shouldn't be quoted as all quotes are redundant.", type: "Property" } - ], - env: { es6: true } + ] }, { code: "({ 'a': 0, x })", output: "({ a: 0, x })", options: ["consistent-as-needed"], + env: { es6: true }, errors: [{ message: "Properties shouldn't be quoted as all quotes are redundant.", type: "Property" - }], - env: { es6: true } + }] }, { code: "({ 'true': 0, 'null': 0 })", output: "({ true: 0, null: 0 })", diff --git a/tests/lib/rules/require-unicode-regexp.js b/tests/lib/rules/require-unicode-regexp.js index a261c86e3b2..b6ac758d17d 100644 --- a/tests/lib/rules/require-unicode-regexp.js +++ b/tests/lib/rules/require-unicode-regexp.js @@ -78,13 +78,13 @@ ruleTester.run("require-unicode-regexp", rule, { }, { code: "new window.RegExp('foo')", - errors: [{ messageId: "requireUFlag" }], - env: { browser: true } + env: { browser: true }, + errors: [{ messageId: "requireUFlag" }] }, { code: "new global.RegExp('foo')", - errors: [{ messageId: "requireUFlag" }], - env: { node: true } + env: { node: true }, + errors: [{ messageId: "requireUFlag" }] } ] }); diff --git a/tests/lib/rules/space-infix-ops.js b/tests/lib/rules/space-infix-ops.js index 76939f7fe5b..8932997e25a 100644 --- a/tests/lib/rules/space-infix-ops.js +++ b/tests/lib/rules/space-infix-ops.js @@ -41,13 +41,13 @@ ruleTester.run("space-infix-ops", rule, { { code: "a |0", options: [{ int32Hint: true }] }, // Type Annotations - { code: "function foo(a: number = 0) { }", parserOptions: { ecmaVersion: 6 }, parser: parser("type-annotations/function-parameter-type-annotation") }, - { code: "function foo(): Bar { }", parserOptions: { ecmaVersion: 6 }, parser: parser("type-annotations/function-return-type-annotation") }, - { code: "var foo: Bar = '';", parserOptions: { ecmaVersion: 6 }, parser: parser("type-annotations/variable-declaration-init-type-annotation") }, - { code: "const foo = function(a: number = 0): Bar { };", parserOptions: { ecmaVersion: 6 }, parser: parser("type-annotations/function-expression-type-annotation") }, + { code: "function foo(a: number = 0) { }", parser: parser("type-annotations/function-parameter-type-annotation"), parserOptions: { ecmaVersion: 6 } }, + { code: "function foo(): Bar { }", parser: parser("type-annotations/function-return-type-annotation"), parserOptions: { ecmaVersion: 6 } }, + { code: "var foo: Bar = '';", parser: parser("type-annotations/variable-declaration-init-type-annotation"), parserOptions: { ecmaVersion: 6 } }, + { code: "const foo = function(a: number = 0): Bar { };", parser: parser("type-annotations/function-expression-type-annotation"), parserOptions: { ecmaVersion: 6 } }, // TypeScript Type Aliases - { code: "type Foo = T;", parserOptions: { ecmaVersion: 6 }, parser: parser("typescript-parsers/type-alias") } + { code: "type Foo = T;", parser: parser("typescript-parsers/type-alias"), parserOptions: { ecmaVersion: 6 } } ], invalid: [ { @@ -368,25 +368,25 @@ ruleTester.run("space-infix-ops", rule, { { code: "var a: Foo= b;", output: "var a: Foo = b;", + parser: parser("type-annotations/variable-declaration-init-type-annotation-no-space"), errors: [{ message: "Operator '=' must be spaced.", type: "VariableDeclarator", line: 1, column: 11 - }], - parser: parser("type-annotations/variable-declaration-init-type-annotation-no-space") + }] }, { code: "function foo(a: number=0): Foo { }", output: "function foo(a: number = 0): Foo { }", + parser: parser("type-annotations/function-declaration-type-annotation-no-space"), parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Operator '=' must be spaced.", line: 1, column: 23, nodeType: "AssignmentPattern" - }], - parser: parser("type-annotations/function-declaration-type-annotation-no-space") + }] } ] });