Skip to content

Commit

Permalink
Fix lost adjacent JSX when using Babel (#6881)
Browse files Browse the repository at this point in the history
Bump @babel/parser to 7.7.3. Otherwise Prettier formats "<a/><b/>" to "<a/ >;".
  • Loading branch information
thorn0 authored and lydell committed Nov 8, 2019
1 parent 7959b12 commit ea70396
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@angular/compiler": "8.2.13",
"@babel/code-frame": "7.5.5",
"@babel/parser": "7.7.2",
"@babel/parser": "7.7.3",
"@glimmer/syntax": "0.41.0",
"@iarna/toml": "2.2.3",
"@typescript-eslint/typescript-estree": "2.6.1",
Expand Down
7 changes: 7 additions & 0 deletions tests_integration/__tests__/__snapshots__/format.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`'Adjacent JSX' error should not be swallowed by Babel's error recovery 1`] = `
"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (2:1)
1 | <a></a>
> 2 | <b></b>
| ^"
`;

exports[`html parser should handle CRLF correctly 1`] = `"\\"<!--\\\\r\\\\n test\\\\r\\\\n test\\\\r\\\\n-->\\\\r\\\\n\\""`;

exports[`markdown parser should handle CRLF correctly 1`] = `"\\"\`\`\`\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n\`\`\`\\\\r\\\\n\\""`;
Expand Down
5 changes: 5 additions & 0 deletions tests_integration/__tests__/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ test("should work with foo plugin instance", () => {
`"\\"{\\\\\\"tabWidth\\\\\\":8,\\\\\\"bracketSpacing\\\\\\":false}\\""`
);
});

test("'Adjacent JSX' error should not be swallowed by Babel's error recovery", () => {
const input = "<a></a>\n<b></b>";
expect(() => prettier.format(input)).toThrowErrorMatchingSnapshot();
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,10 @@
esutils "^2.0.2"
js-tokens "^4.0.0"

"@babel/parser@7.7.2", "@babel/parser@^7.1.2", "@babel/parser@^7.1.5", "@babel/parser@^7.4.5", "@babel/parser@^7.5.5", "@babel/parser@^7.7.0", "@babel/parser@^7.7.2":
version "7.7.2"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.2.tgz#ea8334dc77416bfd9473eb470fd00d8245b3943b"
integrity sha512-DDaR5e0g4ZTb9aP7cpSZLkACEBdoLGwJDWgHtBhrGX7Q1RjhdoMOfexICj5cqTAtpowjGQWfcvfnQG7G2kAB5w==
"@babel/parser@7.7.3", "@babel/parser@^7.1.2", "@babel/parser@^7.1.5", "@babel/parser@^7.4.5", "@babel/parser@^7.5.5", "@babel/parser@^7.7.0", "@babel/parser@^7.7.2":
version "7.7.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.3.tgz#5fad457c2529de476a248f75b0f090b3060af043"
integrity sha512-bqv+iCo9i+uLVbI0ILzKkvMorqxouI+GbV13ivcARXn9NNEabi2IEz912IgNpT/60BNXac5dgcfjb94NjsF33A==

"@babel/plugin-proposal-async-generator-functions@^7.7.0":
version "7.7.0"
Expand Down

0 comments on commit ea70396

Please sign in to comment.