Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ; after JSX nodes in no-object-constructor autofix #17672

Merged
merged 1 commit into from Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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