diff --git a/src/language-js/clean.js b/src/language-js/clean.js index 51fdb1fba..827bdc828 100644 --- a/src/language-js/clean.js +++ b/src/language-js/clean.js @@ -95,7 +95,9 @@ function clean(ast, newObj, parent) { if ( ast.type === "JSXElement" && ast.openingElement.name.name === "style" && - ast.openingElement.attributes.some((attr) => attr.name.name === "jsx") + ast.openingElement.attributes.some( + (attr) => attr.type === "JSXAttribute" && attr.name.name === "jsx", + ) ) { for (const { type, expression } of newObj.children) { if ( diff --git a/tests/integration/__tests__/__snapshots__/debug-check.js.snap b/tests/integration/__tests__/__snapshots__/debug-check.js.snap index 7f0900816..3726d090d 100644 --- a/tests/integration/__tests__/__snapshots__/debug-check.js.snap +++ b/tests/integration/__tests__/__snapshots__/debug-check.js.snap @@ -20,6 +20,12 @@ exports[`should not exit non-zero for already prettified code with --debug-check exports[`should not exit non-zero for already prettified code with --debug-check + --list-different (write) 1`] = `[]`; +exports[`should not exit non-zero for jsx style element with spread attribute (stderr) 1`] = `""`; + +exports[`should not exit non-zero for jsx style element with spread attribute (stdout) 1`] = `"issue-15094.jsx"`; + +exports[`should not exit non-zero for jsx style element with spread attribute (write) 1`] = `[]`; + exports[`show diff for 2+ error files with --debug-check (stderr) 1`] = ` "[error] a.debug-check: prettier(input) !== prettier(prettier(input)) [error] Index: diff --git a/tests/integration/__tests__/debug-check.js b/tests/integration/__tests__/debug-check.js index d0f9a58b9..16131b4e3 100644 --- a/tests/integration/__tests__/debug-check.js +++ b/tests/integration/__tests__/debug-check.js @@ -46,3 +46,9 @@ describe("should not exit non-zero for already prettified code with --debug-chec status: 0, }); }); + +describe("should not exit non-zero for jsx style element with spread attribute", () => { + runCli("cli/debug-check", ["issue-15094.jsx", "--debug-check"]).test({ + status: 0, + }); +}); diff --git a/tests/integration/cli/debug-check/issue-15094.jsx b/tests/integration/cli/debug-check/issue-15094.jsx new file mode 100644 index 000000000..d23790019 --- /dev/null +++ b/tests/integration/cli/debug-check/issue-15094.jsx @@ -0,0 +1 @@ +