From e69ed161fea91c1eb28f166b5d23e34322d4dfac Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Tue, 20 Sep 2022 18:23:59 +0900 Subject: [PATCH] test: specify `ecmaVersion` at `RuleTester` --- tests/lib/rules/no-empty-static-block.js | 28 ++++++------------------ 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/tests/lib/rules/no-empty-static-block.js b/tests/lib/rules/no-empty-static-block.js index 1a63f454d2ce..7e7176cc5cfd 100644 --- a/tests/lib/rules/no-empty-static-block.js +++ b/tests/lib/rules/no-empty-static-block.js @@ -15,46 +15,32 @@ const rule = require("../../../lib/rules/no-empty-static-block"), // Tests //------------------------------------------------------------------------------ -const ruleTester = new RuleTester(); +const ruleTester = new RuleTester({ + parserOptions: { ecmaVersion: 2022 } +}); ruleTester.run("no-empty-static-block", rule, { valid: [ - { - code: "class Foo { static { bar(); } }", - parserOptions: { ecmaVersion: 2022 } - }, - { - code: "class Foo { static { /* comments */ } }", - parserOptions: { ecmaVersion: 2022 } - }, - { - code: "class Foo { static {\n// comment\n} }", - parserOptions: { ecmaVersion: 2022 } - }, - { - code: "class Foo { static { bar(); } static { bar(); } }", - parserOptions: { ecmaVersion: 2022 } - } + "class Foo { static { bar(); } }", + "class Foo { static { /* comments */ } }", + "class Foo { static {\n// comment\n} }", + "class Foo { static { bar(); } static { bar(); } }" ], invalid: [ { code: "class Foo { static {} }", - parserOptions: { ecmaVersion: 2022 }, errors: [{ messageId: "unexpected" }] }, { code: "class Foo { static { } }", - parserOptions: { ecmaVersion: 2022 }, errors: [{ messageId: "unexpected" }] }, { code: "class Foo { static { \n\n } }", - parserOptions: { ecmaVersion: 2022 }, errors: [{ messageId: "unexpected" }] }, { code: "class Foo { static { bar(); } static {} }", - parserOptions: { ecmaVersion: 2022 }, errors: [{ messageId: "unexpected" }] } ]