forked from prettier/prettier
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support babel v7.21 (prettier#14391)
- Loading branch information
Showing
26 changed files
with
519 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#### Support regexp modifiers proposal (#14391 by @fisker) | ||
|
||
See [Regular Expression Pattern Modifiers for ECMAScript](https://github.com/tc39/proposal-regexp-modifiers). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#### Support TypeScript 5.0 via `babel-ts` parser (#14391 by @fisker) | ||
|
||
TypeScript 5.0 introduces two new syntactic features: | ||
|
||
- `const` modifiers for type parameters | ||
- `export type *` declarations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
run_spec(import.meta, ["flow"], { | ||
errors: { "babel-flow": ["await_parse.js"] }, | ||
}); | ||
run_spec(import.meta, ["flow"]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const re = /^(?i:[a-z])[a-z]$/; |
98 changes: 98 additions & 0 deletions
98
tests/format/js/new-target/__snapshots__/jsfmt.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`outside-functions.js [acorn] format 1`] = ` | ||
"'new.target' can only be used in functions and class static block (1:11) | ||
> 1 | const x = new.target; | ||
| ^ | ||
2 |" | ||
`; | ||
|
||
exports[`outside-functions.js [espree] format 1`] = ` | ||
"'new.target' can only be used in functions and class static block (1:11) | ||
> 1 | const x = new.target; | ||
| ^ | ||
2 |" | ||
`; | ||
|
||
exports[`outside-functions.js [flow] format 1`] = ` | ||
"Unexpected token \`.\` (1:14) | ||
> 1 | const x = new.target; | ||
| ^ | ||
2 |" | ||
`; | ||
|
||
exports[`outside-functions.js [meriyah] format 1`] = ` | ||
"new.target only allowed within functions (1:20) | ||
> 1 | const x = new.target; | ||
| ^ | ||
2 |" | ||
`; | ||
|
||
exports[`outside-functions.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel", "flow", "typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const x = new.target; | ||
=====================================output===================================== | ||
const x = new.target; | ||
================================================================================ | ||
`; | ||
|
||
exports[`range.js [acorn] format 1`] = ` | ||
"'new.target' can only be used in functions and class static block (2:1) | ||
1 | const x = | ||
> 2 | new.target; | ||
| ^" | ||
`; | ||
|
||
exports[`range.js [espree] format 1`] = ` | ||
"'new.target' can only be used in functions and class static block (2:1) | ||
1 | const x = | ||
> 2 | new.target; | ||
| ^" | ||
`; | ||
|
||
exports[`range.js [flow] format 1`] = ` | ||
"Unexpected token \`.\` (2:4) | ||
1 | const x = | ||
> 2 | new.target; | ||
| ^" | ||
`; | ||
|
||
exports[`range.js [meriyah] format 1`] = ` | ||
"new.target only allowed within functions (2:10) | ||
1 | const x = | ||
> 2 | new.target; | ||
| ^" | ||
`; | ||
|
||
exports[`range.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel", "flow", "typescript"] | ||
printWidth: 80 | ||
rangeEnd: 52 | ||
rangeStart: 38 | ||
| | printWidth | ||
=====================================input====================================== | ||
1 | class A { | ||
2 | constructor() { | ||
> 3 | const x = | ||
| ^^^ | ||
> 4 | new.target; | ||
| ^^^^^^^^^^ | ||
5 | } | ||
6 | } | ||
7 | | ||
=====================================output===================================== | ||
class A { | ||
constructor() { | ||
const x = new.target; | ||
} | ||
} | ||
================================================================================ | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
run_spec(import.meta, ["babel", "flow", "typescript"], { | ||
errors: { | ||
acorn: true, | ||
espree: true, | ||
meriyah: true, | ||
flow: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const x = new.target; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class A { | ||
constructor() { | ||
const <<<PRETTIER_RANGE_START>>>x = | ||
new.target<<<PRETTIER_RANGE_END>>>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
run_spec(import.meta, ["babel", "flow", "typescript"], { | ||
errors: { | ||
flow: ["v-flag.js"], | ||
acorn: ["v-flag.js"], | ||
espree: ["v-flag.js"], | ||
meriyah: ["v-flag.js"], | ||
acorn: ["v-flag.js", "regexp-modifiers.js"], | ||
espree: ["v-flag.js", "regexp-modifiers.js"], | ||
meriyah: ["v-flag.js", "regexp-modifiers.js"], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/(?ims:^[a-z])/u; | ||
/(?-ims:^[a-z].)(^[a-z].)/uims; | ||
/(?ims:^[a-z].1$)/; |
33 changes: 33 additions & 0 deletions
33
tests/format/misc/errors/js/decorators/__snapshots__/jsfmt.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`snippet: #0 [babel] format 1`] = ` | ||
"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time. (2:8) | ||
1 | @decorator1 | ||
> 2 | export @decorator2 class A{} | ||
| ^" | ||
`; | ||
|
||
exports[`snippet: #1 [babel] format 1`] = ` | ||
"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time. (2:16) | ||
1 | @decorator1 | ||
> 2 | export default @decorator2 class A{} | ||
| ^" | ||
`; | ||
|
||
exports[`snippet: #2 [babel] format 1`] = ` | ||
"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time. (1:20) | ||
> 1 | @decorator1 export @decorator2 class A {} | ||
| ^" | ||
`; | ||
|
||
exports[`snippet: #3 [babel] format 1`] = ` | ||
"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time. (1:28) | ||
> 1 | @decorator1 export default @decorator2 class A {} | ||
| ^" | ||
`; | ||
|
||
exports[`snippet: #4 [babel] format 1`] = ` | ||
"Leading decorators must be attached to a class declaration. (1:20) | ||
> 1 | export @decorator2 default class A {} | ||
| ^" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { outdent } from "outdent"; | ||
|
||
run_spec( | ||
{ | ||
importMeta: import.meta, | ||
snippets: [ | ||
outdent` | ||
@decorator1 | ||
export @decorator2 class A{} | ||
`, | ||
outdent` | ||
@decorator1 | ||
export default @decorator2 class A{} | ||
`, | ||
"@decorator1 export @decorator2 class A {}", | ||
"@decorator1 export default @decorator2 class A {}", | ||
"export @decorator2 default class A {}", | ||
], | ||
}, | ||
["babel"] | ||
); |
Oops, something went wrong.