From b329ea748dff45f11c7e218208244dc24fcb5c8f Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Tue, 24 Oct 2023 08:58:43 +0200 Subject: [PATCH] fix: add `;` after JSX nodes in `no-object-constructor` autofix (#17672) Fix `no-object-constructor` autofix after JSX nodes --- lib/rules/no-object-constructor.js | 4 ++-- tests/lib/rules/no-object-constructor.js | 28 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/rules/no-object-constructor.js b/lib/rules/no-object-constructor.js index 0659d163381..e3ac2095734 100644 --- a/lib/rules/no-object-constructor.js +++ b/lib/rules/no-object-constructor.js @@ -35,10 +35,10 @@ const NODE_TYPES_BY_KEYWORD = { }; /* - * Before an opening parenthesis, `>` (for JSX), and postfix `++` and `--` always trigger ASI; + * Before an opening parenthesis, postfix `++` and `--` always trigger ASI; * the tokens `:`, `;`, `{` and `=>` don't expect a semicolon, as that would count as an empty statement. */ -const PUNCTUATORS = new Set([":", ";", ">", "{", "=>", "++", "--"]); +const PUNCTUATORS = new Set([":", ";", "{", "=>", "++", "--"]); /* * Statements that can contain an `ExpressionStatement` after a closing parenthesis. diff --git a/tests/lib/rules/no-object-constructor.js b/tests/lib/rules/no-object-constructor.js index 4d51f2a21d6..464a0779bc7 100644 --- a/tests/lib/rules/no-object-constructor.js +++ b/tests/lib/rules/no-object-constructor.js @@ -168,6 +168,20 @@ ruleTester.run("no-object-constructor", rule, { var foo = { bar: baz } Object() ` + }, + { + code: ` + + Object() + `, + parserOptions: { ecmaFeatures: { jsx: true } } + }, + { + code: ` + + Object() + `, + parserOptions: { ecmaFeatures: { jsx: true } } } ].map(props => ({ ...props, @@ -296,20 +310,6 @@ ruleTester.run("no-object-constructor", rule, { Object() ` }, - { - code: ` - - Object() - `, - parserOptions: { ecmaFeatures: { jsx: true } } - }, - { - code: ` - - Object() - `, - parserOptions: { ecmaFeatures: { jsx: true } } - }, { code: ` const foo = bar