Skip to content

Commit 70a686b

Browse files
authored
chore: Convert rule tests to FlatRuleTester (#17819)
* chore: Convert rule tests to FlatRuleTester * Fix ast-utils * Fix no-useless-return * Fix test case ordering
1 parent 9007719 commit 70a686b

293 files changed

Lines changed: 8403 additions & 7855 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,18 @@ module.exports = [
135135
files: ["tests/lib/rules/*", "tests/tools/internal-rules/*"],
136136
...merge({}, eslintPluginTestsRecommendedConfig, {
137137
rules: {
138-
"eslint-plugin/test-case-property-ordering": "error",
138+
"eslint-plugin/test-case-property-ordering": [
139+
"error",
140+
[
141+
"name",
142+
"filename",
143+
"code",
144+
"output",
145+
"options",
146+
"languageOptions",
147+
"errors"
148+
]
149+
],
139150
"eslint-plugin/test-case-shorthand-strings": "error"
140151
}
141152
})

lib/rules/no-invalid-this.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = {
9696

9797
if (codePath.origin === "program") {
9898
const scope = sourceCode.getScope(node);
99-
const features = context.parserOptions.ecmaFeatures || {};
99+
const features = context.languageOptions.parserOptions.ecmaFeatures || {};
100100

101101
// `this` at the top level of scripts always refers to the global object
102102
stack.push({

tests/lib/rules/accessor-pairs.js

Lines changed: 214 additions & 214 deletions
Large diffs are not rendered by default.

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

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//------------------------------------------------------------------------------
1111

1212
const rule = require("../../../lib/rules/array-bracket-newline");
13-
const { RuleTester } = require("../../../lib/rule-tester");
13+
const RuleTester = require("../../../lib/rule-tester/flat-rule-tester");
1414

1515

1616
//------------------------------------------------------------------------------
@@ -281,160 +281,160 @@ ruleTester.run("array-bracket-newline", rule, {
281281
* ArrayPattern
282282
* default { multiline: true }
283283
*/
284-
{ code: "var [] = foo", parserOptions: { ecmaVersion: 6 } },
285-
{ code: "var [a] = foo;", parserOptions: { ecmaVersion: 6 } },
284+
{ code: "var [] = foo", languageOptions: { ecmaVersion: 6 } },
285+
{ code: "var [a] = foo;", languageOptions: { ecmaVersion: 6 } },
286286
{
287287
code: "var /* any comment */[a] = foo;",
288-
parserOptions: { ecmaVersion: 6 }
288+
languageOptions: { ecmaVersion: 6 }
289289
},
290290
{
291291
code: "var /* any comment */\n[a] = foo;",
292-
parserOptions: { ecmaVersion: 6 }
292+
languageOptions: { ecmaVersion: 6 }
293293
},
294-
{ code: "var [a, b] = foo;", parserOptions: { ecmaVersion: 6 } },
294+
{ code: "var [a, b] = foo;", languageOptions: { ecmaVersion: 6 } },
295295
{
296296
code: "var [ // any comment\na, b\n] = foo;",
297-
parserOptions: { ecmaVersion: 6 }
297+
languageOptions: { ecmaVersion: 6 }
298298
},
299299
{
300300
code: "var [\n// any comment\na, b\n] = foo;",
301-
parserOptions: { ecmaVersion: 6 }
301+
languageOptions: { ecmaVersion: 6 }
302302
},
303303
{
304304
code: "var [\na, b\n// any comment\n] = foo;",
305-
parserOptions: { ecmaVersion: 6 }
305+
languageOptions: { ecmaVersion: 6 }
306306
},
307-
{ code: "var [\na,\nb\n] = foo;", parserOptions: { ecmaVersion: 6 } },
307+
{ code: "var [\na,\nb\n] = foo;", languageOptions: { ecmaVersion: 6 } },
308308

309309
// "always"
310310
{
311311
code: "var [\n] = foo;",
312312
options: ["always"],
313-
parserOptions: { ecmaVersion: 6 }
313+
languageOptions: { ecmaVersion: 6 }
314314
},
315315
{
316316
code: "var [\na\n] = foo;",
317317
options: ["always"],
318-
parserOptions: { ecmaVersion: 6 }
318+
languageOptions: { ecmaVersion: 6 }
319319
},
320320
{
321321
code: "var [\n// any\na\n] = foo;",
322322
options: ["always"],
323-
parserOptions: { ecmaVersion: 6 }
323+
languageOptions: { ecmaVersion: 6 }
324324
},
325325
{
326326
code: "var [\n/* any */\na\n] = foo;",
327327
options: ["always"],
328-
parserOptions: { ecmaVersion: 6 }
328+
languageOptions: { ecmaVersion: 6 }
329329
},
330330
{
331331
code: "var [\na, b\n] = foo;",
332332
options: ["always"],
333-
parserOptions: { ecmaVersion: 6 }
333+
languageOptions: { ecmaVersion: 6 }
334334
},
335335
{
336336
code: "var [\na, b // any comment\n] = foo;",
337337
options: ["always"],
338-
parserOptions: { ecmaVersion: 6 }
338+
languageOptions: { ecmaVersion: 6 }
339339
},
340340
{
341341
code: "var [\na, b /* any comment */\n] = foo;",
342342
options: ["always"],
343-
parserOptions: { ecmaVersion: 6 }
343+
languageOptions: { ecmaVersion: 6 }
344344
},
345345
{
346346
code: "var [\na,\nb\n] = foo;",
347347
options: ["always"],
348-
parserOptions: { ecmaVersion: 6 }
348+
languageOptions: { ecmaVersion: 6 }
349349
},
350350

351351
// "consistent"
352352
{
353353
code: "var [] = foo",
354354
options: ["consistent"],
355-
parserOptions: { ecmaVersion: 6 }
355+
languageOptions: { ecmaVersion: 6 }
356356
},
357357
{
358358
code: "var [\n] = foo",
359359
options: ["consistent"],
360-
parserOptions: { ecmaVersion: 6 }
360+
languageOptions: { ecmaVersion: 6 }
361361
},
362362
{
363363
code: "var [a] = foo",
364364
options: ["consistent"],
365-
parserOptions: { ecmaVersion: 6 }
365+
languageOptions: { ecmaVersion: 6 }
366366
},
367367
{
368368
code: "var [\na\n] = foo",
369369
options: ["consistent"],
370-
parserOptions: { ecmaVersion: 6 }
370+
languageOptions: { ecmaVersion: 6 }
371371
},
372372
{
373373
code: "var [//\na\n] = foo",
374374
options: ["consistent"],
375-
parserOptions: { ecmaVersion: 6 }
375+
languageOptions: { ecmaVersion: 6 }
376376
},
377377
{
378378
code: "var [/**/\na\n] = foo",
379379
options: ["consistent"],
380-
parserOptions: { ecmaVersion: 6 }
380+
languageOptions: { ecmaVersion: 6 }
381381
},
382382
{
383383
code: "var [/*\n*/a\n] = foo",
384384
options: ["consistent"],
385-
parserOptions: { ecmaVersion: 6 }
385+
languageOptions: { ecmaVersion: 6 }
386386
},
387387
{
388388
code: "var [//\n] = foo",
389389
options: ["consistent"],
390-
parserOptions: { ecmaVersion: 6 }
390+
languageOptions: { ecmaVersion: 6 }
391391
},
392392

393393
// { multiline: true }
394394
{
395395
code: "var [] = foo;",
396396
options: [{ multiline: true }],
397-
parserOptions: { ecmaVersion: 6 }
397+
languageOptions: { ecmaVersion: 6 }
398398
},
399399
{
400400
code: "var [a] = foo;",
401401
options: [{ multiline: true }],
402-
parserOptions: { ecmaVersion: 6 }
402+
languageOptions: { ecmaVersion: 6 }
403403
},
404404
{
405405
code: "var /* any comment */[a] = foo;",
406406
options: [{ multiline: true }],
407-
parserOptions: { ecmaVersion: 6 }
407+
languageOptions: { ecmaVersion: 6 }
408408
},
409409
{
410410
code: "var /* any comment */\n[a] = foo;",
411411
options: [{ multiline: true }],
412-
parserOptions: { ecmaVersion: 6 }
412+
languageOptions: { ecmaVersion: 6 }
413413
},
414414
{
415415
code: "var [a, b] = foo;",
416416
options: [{ multiline: true }],
417-
parserOptions: { ecmaVersion: 6 }
417+
languageOptions: { ecmaVersion: 6 }
418418
},
419419
{
420420
code: "var [ // any comment\na, b\n] = foo;",
421421
options: [{ multiline: true }],
422-
parserOptions: { ecmaVersion: 6 }
422+
languageOptions: { ecmaVersion: 6 }
423423
},
424424
{
425425
code: "var [\n// any comment\na, b\n] = foo;",
426426
options: [{ multiline: true }],
427-
parserOptions: { ecmaVersion: 6 }
427+
languageOptions: { ecmaVersion: 6 }
428428
},
429429
{
430430
code: "var [\na, b\n// any comment\n] = foo;",
431431
options: [{ multiline: true }],
432-
parserOptions: { ecmaVersion: 6 }
432+
languageOptions: { ecmaVersion: 6 }
433433
},
434434
{
435435
code: "var [\na,\nb\n] = foo;",
436436
options: [{ multiline: true }],
437-
parserOptions: { ecmaVersion: 6 }
437+
languageOptions: { ecmaVersion: 6 }
438438
}
439439
],
440440

@@ -1736,7 +1736,7 @@ ruleTester.run("array-bracket-newline", rule, {
17361736
code: "var [] = foo;",
17371737
output: "var [\n] = foo;",
17381738
options: ["always"],
1739-
parserOptions: { ecmaVersion: 6 },
1739+
languageOptions: { ecmaVersion: 6 },
17401740
errors: [
17411741
{
17421742
messageId: "missingOpeningLinebreak",
@@ -1756,7 +1756,7 @@ ruleTester.run("array-bracket-newline", rule, {
17561756
code: "var [a] = foo;",
17571757
output: "var [\na\n] = foo;",
17581758
options: ["always"],
1759-
parserOptions: { ecmaVersion: 6 },
1759+
languageOptions: { ecmaVersion: 6 },
17601760
errors: [
17611761
{
17621762
messageId: "missingOpeningLinebreak",
@@ -1776,7 +1776,7 @@ ruleTester.run("array-bracket-newline", rule, {
17761776
code: "var [ // any comment\na] = foo;",
17771777
output: "var [ // any comment\na\n] = foo;",
17781778
options: ["always"],
1779-
parserOptions: { ecmaVersion: 6 },
1779+
languageOptions: { ecmaVersion: 6 },
17801780
errors: [
17811781
{
17821782
messageId: "missingClosingLinebreak",
@@ -1790,7 +1790,7 @@ ruleTester.run("array-bracket-newline", rule, {
17901790
code: "var [ /* any comment */\na] = foo;",
17911791
output: "var [ /* any comment */\na\n] = foo;",
17921792
options: ["always"],
1793-
parserOptions: { ecmaVersion: 6 },
1793+
languageOptions: { ecmaVersion: 6 },
17941794
errors: [
17951795
{
17961796
messageId: "missingClosingLinebreak",
@@ -1804,7 +1804,7 @@ ruleTester.run("array-bracket-newline", rule, {
18041804
code: "var [a, b] = foo;",
18051805
output: "var [\na, b\n] = foo;",
18061806
options: ["always"],
1807-
parserOptions: { ecmaVersion: 6 },
1807+
languageOptions: { ecmaVersion: 6 },
18081808
errors: [
18091809
{
18101810
messageId: "missingOpeningLinebreak",
@@ -1824,7 +1824,7 @@ ruleTester.run("array-bracket-newline", rule, {
18241824
code: "var [a, b // any comment\n] = foo;",
18251825
output: "var [\na, b // any comment\n] = foo;",
18261826
options: ["always"],
1827-
parserOptions: { ecmaVersion: 6 },
1827+
languageOptions: { ecmaVersion: 6 },
18281828
errors: [
18291829
{
18301830
messageId: "missingOpeningLinebreak",
@@ -1838,7 +1838,7 @@ ruleTester.run("array-bracket-newline", rule, {
18381838
code: "var [a, b /* any comment */] = foo;",
18391839
output: "var [\na, b /* any comment */\n] = foo;",
18401840
options: ["always"],
1841-
parserOptions: { ecmaVersion: 6 },
1841+
languageOptions: { ecmaVersion: 6 },
18421842
errors: [
18431843
{
18441844
messageId: "missingOpeningLinebreak",
@@ -1858,7 +1858,7 @@ ruleTester.run("array-bracket-newline", rule, {
18581858
code: "var [a,\nb] = foo;",
18591859
output: "var [\na,\nb\n] = foo;",
18601860
options: ["always"],
1861-
parserOptions: { ecmaVersion: 6 },
1861+
languageOptions: { ecmaVersion: 6 },
18621862
errors: [
18631863
{
18641864
messageId: "missingOpeningLinebreak",
@@ -1880,7 +1880,7 @@ ruleTester.run("array-bracket-newline", rule, {
18801880
code: "var [\na] = foo",
18811881
output: "var [\na\n] = foo",
18821882
options: ["consistent"],
1883-
parserOptions: { ecmaVersion: 6 },
1883+
languageOptions: { ecmaVersion: 6 },
18841884
errors: [
18851885
{
18861886
messageId: "missingClosingLinebreak",
@@ -1896,7 +1896,7 @@ ruleTester.run("array-bracket-newline", rule, {
18961896
code: "var [a\n] = foo",
18971897
output: "var [a] = foo",
18981898
options: ["consistent"],
1899-
parserOptions: { ecmaVersion: 6 },
1899+
languageOptions: { ecmaVersion: 6 },
19001900
errors: [
19011901
{
19021902
messageId: "unexpectedClosingLinebreak",
@@ -1912,7 +1912,7 @@ ruleTester.run("array-bracket-newline", rule, {
19121912
code: "var [//\na] = foo",
19131913
output: "var [//\na\n] = foo",
19141914
options: ["consistent"],
1915-
parserOptions: { ecmaVersion: 6 },
1915+
languageOptions: { ecmaVersion: 6 },
19161916
errors: [
19171917
{
19181918
messageId: "missingClosingLinebreak",
@@ -1930,7 +1930,7 @@ ruleTester.run("array-bracket-newline", rule, {
19301930
code: "var [\n] = foo;",
19311931
output: "var [] = foo;",
19321932
options: [{ minItems: 2 }],
1933-
parserOptions: { ecmaVersion: 6 },
1933+
languageOptions: { ecmaVersion: 6 },
19341934
errors: [
19351935
{
19361936
messageId: "unexpectedOpeningLinebreak",
@@ -1950,7 +1950,7 @@ ruleTester.run("array-bracket-newline", rule, {
19501950
code: "var [\na\n] = foo;",
19511951
output: "var [a] = foo;",
19521952
options: [{ minItems: 2 }],
1953-
parserOptions: { ecmaVersion: 6 },
1953+
languageOptions: { ecmaVersion: 6 },
19541954
errors: [
19551955
{
19561956
messageId: "unexpectedOpeningLinebreak",
@@ -1970,7 +1970,7 @@ ruleTester.run("array-bracket-newline", rule, {
19701970
code: "var [a, b] = foo;",
19711971
output: "var [\na, b\n] = foo;",
19721972
options: [{ minItems: 2 }],
1973-
parserOptions: { ecmaVersion: 6 },
1973+
languageOptions: { ecmaVersion: 6 },
19741974
errors: [
19751975
{
19761976
messageId: "missingOpeningLinebreak",
@@ -1990,7 +1990,7 @@ ruleTester.run("array-bracket-newline", rule, {
19901990
code: "var [a,\nb] = foo;",
19911991
output: "var [\na,\nb\n] = foo;",
19921992
options: [{ minItems: 2 }],
1993-
parserOptions: { ecmaVersion: 6 },
1993+
languageOptions: { ecmaVersion: 6 },
19941994
errors: [
19951995
{
19961996
messageId: "missingOpeningLinebreak",

0 commit comments

Comments
 (0)