Skip to content

Commit ea70396

Browse files
thorn0lydell
authored andcommitted
Fix lost adjacent JSX when using Babel (prettier#6881)
Bump @babel/parser to 7.7.3. Otherwise Prettier formats "<a/><b/>" to "<a/ >;".
1 parent 7959b12 commit ea70396

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dependencies": {
1717
"@angular/compiler": "8.2.13",
1818
"@babel/code-frame": "7.5.5",
19-
"@babel/parser": "7.7.2",
19+
"@babel/parser": "7.7.3",
2020
"@glimmer/syntax": "0.41.0",
2121
"@iarna/toml": "2.2.3",
2222
"@typescript-eslint/typescript-estree": "2.6.1",

tests_integration/__tests__/__snapshots__/format.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`'Adjacent JSX' error should not be swallowed by Babel's error recovery 1`] = `
4+
"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (2:1)
5+
1 | <a></a>
6+
> 2 | <b></b>
7+
| ^"
8+
`;
9+
310
exports[`html parser should handle CRLF correctly 1`] = `"\\"<!--\\\\r\\\\n test\\\\r\\\\n test\\\\r\\\\n-->\\\\r\\\\n\\""`;
411

512
exports[`markdown parser should handle CRLF correctly 1`] = `"\\"\`\`\`\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n\`\`\`\\\\r\\\\n\\""`;

tests_integration/__tests__/format.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ test("should work with foo plugin instance", () => {
5353
`"\\"{\\\\\\"tabWidth\\\\\\":8,\\\\\\"bracketSpacing\\\\\\":false}\\""`
5454
);
5555
});
56+
57+
test("'Adjacent JSX' error should not be swallowed by Babel's error recovery", () => {
58+
const input = "<a></a>\n<b></b>";
59+
expect(() => prettier.format(input)).toThrowErrorMatchingSnapshot();
60+
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@
378378
esutils "^2.0.2"
379379
js-tokens "^4.0.0"
380380

381-
"@babel/[email protected].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":
382-
version "7.7.2"
383-
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.2.tgz#ea8334dc77416bfd9473eb470fd00d8245b3943b"
384-
integrity sha512-DDaR5e0g4ZTb9aP7cpSZLkACEBdoLGwJDWgHtBhrGX7Q1RjhdoMOfexICj5cqTAtpowjGQWfcvfnQG7G2kAB5w==
381+
"@babel/[email protected].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":
382+
version "7.7.3"
383+
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.3.tgz#5fad457c2529de476a248f75b0f090b3060af043"
384+
integrity sha512-bqv+iCo9i+uLVbI0ILzKkvMorqxouI+GbV13ivcARXn9NNEabi2IEz912IgNpT/60BNXac5dgcfjb94NjsF33A==
385385

386386
"@babel/plugin-proposal-async-generator-functions@^7.7.0":
387387
version "7.7.0"

0 commit comments

Comments
 (0)