Skip to content

Commit 1f715a2

Browse files
mysticateanot-an-aardvark
authored andcommitted
Chore: make test-case-property-ordering reasonable (#11511)
1 parent f354770 commit 1f715a2

22 files changed

+131
-116
lines changed

.eslintrc.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,22 @@ module.exports = {
1717
"eslint-plugin/prefer-placeholders": "error",
1818
"eslint-plugin/report-message-format": ["error", "[^a-z].*\\.$"],
1919
"eslint-plugin/require-meta-type": "error",
20-
"eslint-plugin/test-case-property-ordering": "error",
20+
"eslint-plugin/test-case-property-ordering": [
21+
"error",
22+
23+
// https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/79
24+
[
25+
"filename",
26+
"code",
27+
"output",
28+
"options",
29+
"parser",
30+
"parserOptions",
31+
"globals",
32+
"env",
33+
"errors"
34+
]
35+
],
2136
"eslint-plugin/test-case-shorthand-strings": "error",
2237
"internal-rules/multiline-comment-style": "error"
2338
},

tests/lib/rules/array-bracket-spacing.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ ruleTester.run("array-bracket-spacing", rule, {
174174
{ code: "var obj = {'foo': [1, 2]}", options: ["never"] },
175175

176176
// destructuring with type annotation
177-
{ code: "([ a, b ]: Array<any>) => {}", options: ["always"], parserOptions: { ecmaVersion: 6 }, parser: parser("flow-destructuring-1") },
178-
{ code: "([a, b]: Array< any >) => {}", options: ["never"], parserOptions: { ecmaVersion: 6 }, parser: parser("flow-destructuring-2") }
177+
{ code: "([ a, b ]: Array<any>) => {}", options: ["always"], parser: parser("flow-destructuring-1"), parserOptions: { ecmaVersion: 6 } },
178+
{ code: "([a, b]: Array< any >) => {}", options: ["never"], parser: parser("flow-destructuring-2"), parserOptions: { ecmaVersion: 6 } }
179179
],
180180

181181
invalid: [
@@ -830,6 +830,7 @@ ruleTester.run("array-bracket-spacing", rule, {
830830
code: "([ a, b ]: Array<any>) => {}",
831831
output: "([a, b]: Array<any>) => {}",
832832
options: ["never"],
833+
parser: parser("flow-destructuring-1"),
833834
parserOptions: {
834835
ecmaVersion: 6
835836
},
@@ -852,13 +853,13 @@ ruleTester.run("array-bracket-spacing", rule, {
852853
line: 1,
853854
column: 9
854855
}
855-
],
856-
parser: parser("flow-destructuring-1")
856+
]
857857
},
858858
{
859859
code: "([a, b]: Array< any >) => {}",
860860
output: "([ a, b ]: Array< any >) => {}",
861861
options: ["always"],
862+
parser: parser("flow-destructuring-2"),
862863
parserOptions: {
863864
ecmaVersion: 6
864865
},
@@ -881,8 +882,7 @@ ruleTester.run("array-bracket-spacing", rule, {
881882
line: 1,
882883
column: 7
883884
}
884-
],
885-
parser: parser("flow-destructuring-2")
885+
]
886886
}
887887
]
888888
});

tests/lib/rules/comma-dangle.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,29 +1410,29 @@ let d = 0;export {d,};
14101410
code: "function foo({a}: {a: string,}) {}",
14111411
output: "function foo({a,}: {a: string,}) {}",
14121412
options: ["always"],
1413-
errors: [{ messageId: "missing" }],
1414-
parser: parser("object-pattern-1")
1413+
parser: parser("object-pattern-1"),
1414+
errors: [{ messageId: "missing" }]
14151415
},
14161416
{
14171417
code: "function foo({a,}: {a: string}) {}",
14181418
output: "function foo({a}: {a: string}) {}",
14191419
options: ["never"],
1420-
errors: [{ messageId: "unexpected" }],
1421-
parser: parser("object-pattern-2")
1420+
parser: parser("object-pattern-2"),
1421+
errors: [{ messageId: "unexpected" }]
14221422
},
14231423
{
14241424
code: "function foo(a): {b: boolean,} {}",
14251425
output: "function foo(a,): {b: boolean,} {}",
14261426
options: [{ functions: "always" }],
1427-
errors: [{ messageId: "missing" }],
1428-
parser: parser("return-type-1")
1427+
parser: parser("return-type-1"),
1428+
errors: [{ messageId: "missing" }]
14291429
},
14301430
{
14311431
code: "function foo(a,): {b: boolean} {}",
14321432
output: "function foo(a): {b: boolean} {}",
14331433
options: [{ functions: "never" }],
1434-
errors: [{ messageId: "unexpected" }],
1435-
parser: parser("return-type-2")
1434+
parser: parser("return-type-2"),
1435+
errors: [{ messageId: "unexpected" }]
14361436
}
14371437
]
14381438
});

tests/lib/rules/indent.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8686,8 +8686,8 @@ ruleTester.run("indent", rule, {
86868686
}
86878687
}
86888688
`,
8689-
errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]]),
8690-
parser: parser("unknown-nodes/namespace-invalid")
8689+
parser: parser("unknown-nodes/namespace-invalid"),
8690+
errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]])
86918691
},
86928692
{
86938693
code: unIndent`
@@ -8718,8 +8718,8 @@ ruleTester.run("indent", rule, {
87188718
}
87198719
}
87208720
`,
8721-
errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]]),
8722-
parser: parser("unknown-nodes/abstract-class-invalid")
8721+
parser: parser("unknown-nodes/abstract-class-invalid"),
8722+
errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]])
87238723
},
87248724
{
87258725
code: unIndent`
@@ -8748,14 +8748,14 @@ ruleTester.run("indent", rule, {
87488748
}
87498749
}
87508750
`,
8751+
parser: parser("unknown-nodes/functions-with-abstract-class-invalid"),
87518752
errors: expectedErrors([
87528753
[4, 12, 8, "Keyword"],
87538754
[5, 16, 8, "Keyword"],
87548755
[6, 20, 8, "Identifier"],
87558756
[7, 16, 8, "Punctuator"],
87568757
[8, 12, 8, "Punctuator"]
8757-
]),
8758-
parser: parser("unknown-nodes/functions-with-abstract-class-invalid")
8758+
])
87598759
},
87608760
{
87618761
code: unIndent`
@@ -8788,11 +8788,11 @@ ruleTester.run("indent", rule, {
87888788
}
87898789
}
87908790
`,
8791+
parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid"),
87918792
errors: expectedErrors([
87928793
[3, 8, 4, "Keyword"],
87938794
[7, 24, 20, "Identifier"]
8794-
]),
8795-
parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid")
8795+
])
87968796
},
87978797

87988798
//----------------------------------------------------------------------
@@ -9369,8 +9369,8 @@ ruleTester.run("indent", rule, {
93699369
foo
93709370
}: bar) => baz
93719371
`,
9372-
errors: expectedErrors([3, 0, 4, "Punctuator"]),
9373-
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation")
9372+
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation"),
9373+
errors: expectedErrors([3, 0, 4, "Punctuator"])
93749374
},
93759375
{
93769376
code: unIndent`
@@ -9383,8 +9383,8 @@ ruleTester.run("indent", rule, {
93839383
foo
93849384
]: bar) => baz
93859385
`,
9386-
errors: expectedErrors([3, 0, 4, "Punctuator"]),
9387-
parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation")
9386+
parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation"),
9387+
errors: expectedErrors([3, 0, 4, "Punctuator"])
93889388
},
93899389
{
93909390
code: unIndent`
@@ -9397,8 +9397,8 @@ ruleTester.run("indent", rule, {
93979397
foo
93989398
}: {}) => baz
93999399
`,
9400-
errors: expectedErrors([3, 0, 4, "Punctuator"]),
9401-
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation")
9400+
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation"),
9401+
errors: expectedErrors([3, 0, 4, "Punctuator"])
94029402
},
94039403
{
94049404
code: unIndent`

tests/lib/rules/keyword-spacing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,8 +3135,8 @@ ruleTester.run("keyword-spacing", rule, {
31353135
{
31363136
code: "class Foo { @desc({set a(value) {}, get a() {}, async c() {}}) async[foo]() {} }",
31373137
output: "class Foo { @desc({set a(value) {}, get a() {}, async c() {}}) async [foo]() {} }",
3138-
errors: expectedAfter("async"),
3139-
parser: parser("typescript-parsers/decorator-with-keywords-class-method")
3138+
parser: parser("typescript-parsers/decorator-with-keywords-class-method"),
3139+
errors: expectedAfter("async")
31403140
}
31413141
]
31423142
});

tests/lib/rules/no-console.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ ruleTester.run("no-console", rule, {
5858
{ code: "console.warn(foo)", options: [{ allow: ["info", "log"] }], errors: [{ messageId: "unexpected", type: "MemberExpression" }] },
5959

6060
// In case that implicit global variable of 'console' exists
61-
{ code: "console.log(foo)", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { node: true } }
61+
{ code: "console.log(foo)", env: { node: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] }
6262
]
6363
});

tests/lib/rules/no-eval.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ ruleTester.run("no-eval", rule, {
7272

7373
// Indirect eval
7474
{ code: "(0, eval)('foo')", errors: [{ messageId: "unexpected", type: "Identifier" }] },
75-
{ code: "(0, window.eval)('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { browser: true } },
76-
{ code: "(0, window['eval'])('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { browser: true } },
75+
{ code: "(0, window.eval)('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] },
76+
{ code: "(0, window['eval'])('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] },
7777
{ code: "var EVAL = eval; EVAL('foo')", errors: [{ messageId: "unexpected", type: "Identifier" }] },
7878
{ code: "var EVAL = this.eval; EVAL('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }] },
7979
{ code: "(function(exe){ exe('foo') })(eval);", errors: [{ messageId: "unexpected", type: "Identifier" }] },
80-
{ code: "window.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } },
81-
{ code: "window.window.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } },
82-
{ code: "window.window['eval']('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } },
83-
{ code: "global.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } },
84-
{ code: "global.global.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } },
85-
{ code: "global.global[`eval`]('foo')", parserOptions: { ecmaVersion: 6 }, errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } },
80+
{ code: "window.eval('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
81+
{ code: "window.window.eval('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
82+
{ code: "window.window['eval']('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
83+
{ code: "global.eval('foo')", env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
84+
{ code: "global.global.eval('foo')", env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
85+
{ code: "global.global[`eval`]('foo')", parserOptions: { ecmaVersion: 6 }, env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
8686
{ code: "this.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }] },
8787
{ code: "function foo() { this.eval('foo') }", errors: [{ messageId: "unexpected", type: "CallExpression" }] }
8888
]

tests/lib/rules/no-global-assign.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ ruleTester.run("no-global-assign", rule, {
4242
},
4343
{
4444
code: "top = 0;",
45-
errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }],
46-
env: { browser: true }
45+
env: { browser: true },
46+
errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }]
4747
},
4848
{
4949
code: "require = 0;",
50-
errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }],
51-
env: { node: true }
50+
env: { node: true },
51+
errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }]
5252
},
5353

5454
// Notifications of readonly are moved from no-undef: https://github.com/eslint/eslint/issues/4504
5555
{ code: "/*global b:false*/ function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
56-
{ code: "function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }], globals: { b: false } },
56+
{ code: "function f() { b = 1; }", globals: { b: false }, errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
5757
{ code: "/*global b:false*/ function f() { b++; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
5858
{ code: "/*global b*/ b = 1;", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
5959
{ code: "Array = 1;", errors: [{ message: "Read-only global 'Array' should not be modified.", type: "Identifier" }] }

tests/lib/rules/no-magic-numbers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ ruleTester.run("no-magic-numbers", rule, {
8383
options: [{
8484
enforceConst: true
8585
}],
86-
errors: [{ messageId: "useConst" }],
87-
env: { es6: true }
86+
env: { es6: true },
87+
errors: [{ messageId: "useConst" }]
8888
},
8989
{
9090
code: "var foo = 0 + 1;",
@@ -189,15 +189,15 @@ ruleTester.run("no-magic-numbers", rule, {
189189
"function invokeInTen(func) {\n" +
190190
"setTimeout(func, 10);\n" +
191191
"}\n",
192+
env: { es6: true },
192193
errors: [
193194
{ messageId: "noMagic", data: { raw: "10" }, line: 7 },
194195
{ messageId: "noMagic", data: { raw: "10" }, line: 7 },
195196
{ messageId: "noMagic", data: { raw: "24" }, line: 11 },
196197
{ messageId: "noMagic", data: { raw: "1000" }, line: 15 },
197198
{ messageId: "noMagic", data: { raw: "0" }, line: 19 },
198199
{ messageId: "noMagic", data: { raw: "10" }, line: 22 }
199-
],
200-
env: { es6: true }
200+
]
201201
},
202202
{
203203
code: "var data = ['foo', 'bar', 'baz']; var third = data[3];",

tests/lib/rules/no-mixed-spaces-and-tabs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,27 @@ ruleTester.run("no-mixed-spaces-and-tabs", rule, {
136136
{
137137
code: "`foo${\n \t 5 }bar`;",
138138
options: ["smart-tabs"],
139+
env: { es6: true },
139140
errors: [
140141
{
141142
message: "Mixed spaces and tabs.",
142143
type: "Program",
143144
line: 2,
144145
column: 2
145146
}
146-
],
147-
env: { es6: true }
147+
]
148148
},
149149
{
150150
code: "`foo${\n\t 5 }bar`;",
151+
env: { es6: true },
151152
errors: [
152153
{
153154
message: "Mixed spaces and tabs.",
154155
type: "Program",
155156
line: 2,
156157
column: 2
157158
}
158-
],
159-
env: { es6: true }
159+
]
160160
}
161161
]
162162
});

0 commit comments

Comments
 (0)