Skip to content

Commit

Permalink
fix: add ; after JSX nodes in no-object-constructor autofix (#17672)
Browse files Browse the repository at this point in the history
Fix `no-object-constructor` autofix after JSX nodes
  • Loading branch information
fasttime committed Oct 24, 2023
1 parent 994596b commit b329ea7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/rules/no-object-constructor.js
Expand Up @@ -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.
Expand Down
28 changes: 14 additions & 14 deletions tests/lib/rules/no-object-constructor.js
Expand Up @@ -168,6 +168,20 @@ ruleTester.run("no-object-constructor", rule, {
var foo = { bar: baz }
Object()
`
},
{
code: `
<foo />
Object()
`,
parserOptions: { ecmaFeatures: { jsx: true } }
},
{
code: `
<foo></foo>
Object()
`,
parserOptions: { ecmaFeatures: { jsx: true } }
}
].map(props => ({
...props,
Expand Down Expand Up @@ -296,20 +310,6 @@ ruleTester.run("no-object-constructor", rule, {
Object()
`
},
{
code: `
<foo />
Object()
`,
parserOptions: { ecmaFeatures: { jsx: true } }
},
{
code: `
<foo></foo>
Object()
`,
parserOptions: { ecmaFeatures: { jsx: true } }
},
{
code: `
const foo = bar
Expand Down

0 comments on commit b329ea7

Please sign in to comment.