Fix links to Prettier/Babel/Jest website (#17079)
This commit is contained in:
1 parent
7044fbe827
commit
64e7dab1fd
67 files changed
+186
-186
No files matched your search
@@ -16,7 +16,7 @@ BEFORE SUBMITTING AN ISSUE:
|
||||
2. We get a lot of requests for adding options, but Prettier is
|
||||
built on the principle of being opinionated about code formatting.
|
||||
This means we add options only in the case of strict technical necessity.
|
||||
Find out more: https://prettier.io/docs/en/option-philosophy.html
|
||||
Find out more: https://prettier.io/docs/option-philosophy
|
||||
|
||||
Don't fill the form below manually! Let a program create a report for you:
|
||||
|
||||
|
||||
+1
-1
@@ -3194,7 +3194,7 @@ export const getVehicleDescriptor = async (
|
||||
|
||||
- Config: Match dotfiles in config overrides ([#6194] by [@duailibe])
|
||||
|
||||
When using [`overrides`](https://prettier.io/docs/en/configuration.html#configuration-overrides) in the config file, Prettier was not matching dotfiles (files that start with `.`). This was fixed in 1.18.1
|
||||
When using [`overrides`](https://prettier.io/docs/configuration#configuration-overrides) in the config file, Prettier was not matching dotfiles (files that start with `.`). This was fixed in 1.18.1
|
||||
|
||||
[#6190]: https://github.com/prettier/prettier/pull/6190
|
||||
[#6194]: https://github.com/prettier/prettier/pull/6194
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ yarn test
|
||||
|
||||
## Tests
|
||||
|
||||
The tests use [Jest snapshots](https://facebook.github.io/jest/docs/en/snapshot-testing.html). You can make changes and run `jest -u` (or `yarn test -u`) to update the snapshots. Then run `git diff` to take a look at what changed. Always update the snapshots when opening a PR.
|
||||
The tests use [Jest snapshots](https://jestjs.io/docs/snapshot-testing). You can make changes and run `jest -u` (or `yarn test -u`) to update the snapshots. Then run `git diff` to take a look at what changed. Always update the snapshots when opening a PR.
|
||||
|
||||
Each test directory in `tests/format` has a `format.test.js` file that controls how exactly the rest of the files in the directory are used for tests. This file must contain one or more calls to the `runFormatTest` global function. For example, in directories with JavaScript formatting tests, `format.test.js` generally looks like this:
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</em>
|
||||
<br />
|
||||
<em>
|
||||
<a href="https://prettier.io/docs/en/plugins.html">
|
||||
<a href="https://prettier.io/docs/plugins">
|
||||
Your favorite language?
|
||||
</a>
|
||||
</em>
|
||||
|
||||
@@ -58,7 +58,7 @@ JS (ES Modules):
|
||||
// prettier.config.js, .prettierrc.js, prettier.config.mjs, or .prettierrc.mjs
|
||||
|
||||
/**
|
||||
* @see https://prettier.io/docs/en/configuration.html
|
||||
* @see https://prettier.io/docs/configuration
|
||||
* @type {import("prettier").Config}
|
||||
*/
|
||||
const config = {
|
||||
@@ -77,7 +77,7 @@ JS (CommonJS):
|
||||
// prettier.config.js, .prettierrc.js, prettier.config.cjs, or .prettierrc.cjs
|
||||
|
||||
/**
|
||||
* @see https://prettier.io/docs/en/configuration.html
|
||||
* @see https://prettier.io/docs/configuration
|
||||
* @type {import("prettier").Config}
|
||||
*/
|
||||
const config = {
|
||||
|
||||
+1
-1
@@ -191,4 +191,4 @@ For one-off commands, when you want to exclude some files without adding them to
|
||||
prettier . "!**/*.{js,jsx,vue}" --write
|
||||
```
|
||||
|
||||
See [fast-glob](https://prettier.io/docs/en/cli.html#file-patterns) to learn more about advanced glob syntax.
|
||||
See [fast-glob](https://prettier.io/docs/cli#file-patterns) to learn more about advanced glob syntax.
|
||||
+2
-2
@@ -146,7 +146,7 @@ Print trailing commas wherever possible in multi-line comma-separated syntactic
|
||||
|
||||
Valid options:
|
||||
|
||||
- `"all"` - Trailing commas wherever possible (including [function parameters and calls](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#Trailing_commas_in_functions)). To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or [downlevel compilation](https://babeljs.io/docs/en/index). This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018).
|
||||
- `"all"` - Trailing commas wherever possible (including [function parameters and calls](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#Trailing_commas_in_functions)). To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or [downlevel compilation](https://babeljs.io/docs/index). This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018).
|
||||
- `"es5"` - Trailing commas where valid in ES5 (objects, arrays, etc.). Trailing commas in type parameters in TypeScript and Flow.
|
||||
- `"none"` - No trailing commas.
|
||||
|
||||
@@ -314,7 +314,7 @@ Valid options:
|
||||
- `"css"` (via [postcss](https://github.com/postcss/postcss)) _First available in v1.7.1_
|
||||
- `"scss"` (via [postcss-scss](https://github.com/postcss/postcss-scss)) _First available in v1.7.1_
|
||||
- `"less"` (via [postcss-less](https://github.com/shellscape/postcss-less)) _First available in v1.7.1_
|
||||
- `"json"` (via [@babel/parser parseExpression](https://babeljs.io/docs/en/next/babel-parser.html#babelparserparseexpressioncode-options)) _First available in v1.5.0_
|
||||
- `"json"` (via [@babel/parser parseExpression](https://babeljs.io/docs/babel-parser#babelparserparseexpressioncode-options)) _First available in v1.5.0_
|
||||
- `"json5"` (same parser as `"json"`, but outputs as [json5](https://json5.org/)) _First available in v1.13.0_
|
||||
- `"jsonc"` (same parser as `"json"`, but outputs as "JSON with Comments") _First available in v3.2.0_
|
||||
- `"json-stringify"` (same parser as `"json"`, but outputs like `JSON.stringify`) _First available in v1.13.0_
|
||||
|
||||
Vendored
+2
-2
@@ -578,7 +578,7 @@ export interface CursorResult {
|
||||
}
|
||||
|
||||
/**
|
||||
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/en/options.html) may be provided to override the defaults.
|
||||
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/options) may be provided to override the defaults.
|
||||
*/
|
||||
export function format(source: string, options?: Options): Promise<string>;
|
||||
|
||||
@@ -627,7 +627,7 @@ export interface ResolveConfigOptions {
|
||||
*
|
||||
* A promise is returned which will resolve to:
|
||||
*
|
||||
* - An options object, providing a [config file](https://prettier.io/docs/en/configuration.html) was found.
|
||||
* - An options object, providing a [config file](https://prettier.io/docs/configuration) was found.
|
||||
* - `null`, if no file was found.
|
||||
*
|
||||
* The promise will be rejected if there was an error parsing the configuration file.
|
||||
|
||||
@@ -27,7 +27,7 @@ async function printEmbeddedLanguages(
|
||||
|
||||
if (embed.length > 2) {
|
||||
throw new Error(
|
||||
"printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/en/plugins.html#optional-embed",
|
||||
"printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@ export function formatWithCursor(
|
||||
): Promise<CursorResult>;
|
||||
|
||||
/**
|
||||
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/en/options.html) may be provided to override the defaults.
|
||||
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/options) may be provided to override the defaults.
|
||||
*/
|
||||
export function format(source: string, options?: Options): Promise<string>;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-async-generator-functions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-async-generator-functions
|
||||
|
||||
async function* agf() {
|
||||
await 1;
|
||||
@@ -54,7 +54,7 @@ async function* agf() {
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-async-generator-functions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-async-generator-functions
|
||||
|
||||
async function* agf() {
|
||||
await 1;
|
||||
@@ -338,7 +338,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-class-properties
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-class-properties
|
||||
|
||||
class Bork {
|
||||
//Property initializer syntax
|
||||
@@ -366,7 +366,7 @@ class Bork {
|
||||
console.log(Bork.staticFunction()); // > "babelIsCool"
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-class-properties
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-class-properties
|
||||
|
||||
class Bork {
|
||||
//Property initializer syntax
|
||||
@@ -470,7 +470,7 @@ class C extends HTMLElement {
|
||||
|
||||
exports[`decorators.js [acorn] format 1`] = `
|
||||
"Unexpected character '@' (3:1)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-decorators
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-decorators
|
||||
2 |
|
||||
> 3 | @annotation
|
||||
| ^
|
||||
@@ -482,7 +482,7 @@ Cause: Unexpected character '@' (3:0)"
|
||||
|
||||
exports[`decorators.js [espree] format 1`] = `
|
||||
"Unexpected character '@' (3:1)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-decorators
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-decorators
|
||||
2 |
|
||||
> 3 | @annotation
|
||||
| ^
|
||||
@@ -498,7 +498,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-decorators
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-decorators
|
||||
|
||||
@annotation
|
||||
class MyClass { }
|
||||
@@ -529,7 +529,7 @@ function enumerable(value) {
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-decorators
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-decorators
|
||||
|
||||
@annotation
|
||||
class MyClass {}
|
||||
@@ -674,7 +674,7 @@ class Foo {
|
||||
|
||||
exports[`do-expressions.js [acorn] format 1`] = `
|
||||
"Unexpected token (3:9)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
|
||||
2 |
|
||||
> 3 | let a = do {
|
||||
| ^
|
||||
@@ -686,7 +686,7 @@ Cause: Unexpected token (3:8)"
|
||||
|
||||
exports[`do-expressions.js [espree] format 1`] = `
|
||||
"Unexpected token do (3:9)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
|
||||
2 |
|
||||
> 3 | let a = do {
|
||||
| ^
|
||||
@@ -698,7 +698,7 @@ Cause: Unexpected token do"
|
||||
|
||||
exports[`do-expressions.js [meriyah] format 1`] = `
|
||||
"Unexpected token: 'do' (3:9)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
|
||||
2 |
|
||||
> 3 | let a = do {
|
||||
| ^^
|
||||
@@ -714,7 +714,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-do-expressions
|
||||
|
||||
let a = do {
|
||||
if(x > 10) {
|
||||
@@ -727,7 +727,7 @@ let a = do {
|
||||
let a = x > 10 ? 'big' : 'small';
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-do-expressions
|
||||
|
||||
let a = do {
|
||||
if (x > 10) {
|
||||
@@ -748,7 +748,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-dynamic-import
|
||||
|
||||
// There is no example code on babel website
|
||||
|
||||
@@ -758,7 +758,7 @@ import('./prettier.mjs').then(module => console.log(module));
|
||||
import(prettier).then(module => console.log(module));
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-dynamic-import
|
||||
|
||||
// There is no example code on babel website
|
||||
|
||||
@@ -875,13 +875,13 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-export-default-from
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-export-default-from
|
||||
|
||||
|
||||
export v from 'mod';
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-export-default-from
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-export-default-from
|
||||
|
||||
export v from "mod";
|
||||
|
||||
@@ -894,12 +894,12 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-export-namespace-from
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-export-namespace-from
|
||||
|
||||
export * as ns from 'mod';
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-export-namespace-from
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-export-namespace-from
|
||||
|
||||
export * as ns from "mod";
|
||||
|
||||
@@ -908,7 +908,7 @@ export * as ns from "mod";
|
||||
|
||||
exports[`flow.js [__babel_estree] format 1`] = `
|
||||
"Unexpected token, expected "," (3:17)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-flow
|
||||
1 | // https://babeljs.io/docs/babel-preset-flow
|
||||
2 |
|
||||
> 3 | function foo(one: any, two: number, three?): string {}
|
||||
| ^
|
||||
@@ -918,7 +918,7 @@ Cause: Unexpected token, expected "," (3:16)"
|
||||
|
||||
exports[`flow.js [acorn] format 1`] = `
|
||||
"Unexpected token (3:17)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-flow
|
||||
1 | // https://babeljs.io/docs/babel-preset-flow
|
||||
2 |
|
||||
> 3 | function foo(one: any, two: number, three?): string {}
|
||||
| ^
|
||||
@@ -928,7 +928,7 @@ Cause: Unexpected token (3:16)"
|
||||
|
||||
exports[`flow.js [babel] format 1`] = `
|
||||
"Unexpected token, expected "," (3:17)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-flow
|
||||
1 | // https://babeljs.io/docs/babel-preset-flow
|
||||
2 |
|
||||
> 3 | function foo(one: any, two: number, three?): string {}
|
||||
| ^
|
||||
@@ -942,12 +942,12 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-preset-flow
|
||||
// https://babeljs.io/docs/babel-preset-flow
|
||||
|
||||
function foo(one: any, two: number, three?): string {}
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-preset-flow
|
||||
// https://babeljs.io/docs/babel-preset-flow
|
||||
|
||||
function foo(one: any, two: number, three?): string {}
|
||||
|
||||
@@ -960,12 +960,12 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-preset-flow
|
||||
// https://babeljs.io/docs/babel-preset-flow
|
||||
|
||||
function foo(one: any, two: number, three?): string {}
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-preset-flow
|
||||
// https://babeljs.io/docs/babel-preset-flow
|
||||
|
||||
function foo(one: any, two: number, three?): string {}
|
||||
|
||||
@@ -974,7 +974,7 @@ function foo(one: any, two: number, three?): string {}
|
||||
|
||||
exports[`flow.js [espree] format 1`] = `
|
||||
"Unexpected token : (3:17)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-flow
|
||||
1 | // https://babeljs.io/docs/babel-preset-flow
|
||||
2 |
|
||||
> 3 | function foo(one: any, two: number, three?): string {}
|
||||
| ^
|
||||
@@ -984,7 +984,7 @@ Cause: Unexpected token :"
|
||||
|
||||
exports[`flow.js [meriyah] format 1`] = `
|
||||
"Expected ')' (3:17)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-flow
|
||||
1 | // https://babeljs.io/docs/babel-preset-flow
|
||||
2 |
|
||||
> 3 | function foo(one: any, two: number, three?): string {}
|
||||
| ^
|
||||
@@ -994,7 +994,7 @@ Cause: [3:16-3:17]: Expected ')'"
|
||||
|
||||
exports[`function-bind.js [acorn] format 1`] = `
|
||||
"Unexpected token (3:5)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-function-bind
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
|
||||
2 |
|
||||
> 3 | obj::func
|
||||
| ^
|
||||
@@ -1006,7 +1006,7 @@ Cause: Unexpected token (3:4)"
|
||||
|
||||
exports[`function-bind.js [espree] format 1`] = `
|
||||
"Unexpected token : (3:5)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-function-bind
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
|
||||
2 |
|
||||
> 3 | obj::func
|
||||
| ^
|
||||
@@ -1018,7 +1018,7 @@ Cause: Unexpected token :"
|
||||
|
||||
exports[`function-bind.js [meriyah] format 1`] = `
|
||||
"Unexpected token: ':' (3:5)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-function-bind
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
|
||||
2 |
|
||||
> 3 | obj::func
|
||||
| ^
|
||||
@@ -1034,7 +1034,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-function-bind
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-function-bind
|
||||
|
||||
obj::func
|
||||
// is equivalent to:
|
||||
@@ -1053,7 +1053,7 @@ func.call(obj, val)
|
||||
obj.func.call(obj, val)
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-function-bind
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-function-bind
|
||||
|
||||
obj::func;
|
||||
// is equivalent to:
|
||||
@@ -1115,7 +1115,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-function-sent
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-function-sent
|
||||
|
||||
function* generator() {
|
||||
console.log("Sent", function.sent);
|
||||
@@ -1127,7 +1127,7 @@ iterator.next(1); // Logs "Sent 1"
|
||||
iterator.next(2); // Logs "Yield 2"
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-function-sent
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-function-sent
|
||||
|
||||
function* generator() {
|
||||
console.log("Sent", function.sent);
|
||||
@@ -1227,7 +1227,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-import-meta
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-import-meta
|
||||
|
||||
// Enabled by default https://github.com/babel/babel/pull/11406
|
||||
|
||||
@@ -1247,7 +1247,7 @@ printWidth: 80
|
||||
})();
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-import-meta
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-import-meta
|
||||
|
||||
// Enabled by default https://github.com/babel/babel/pull/11406
|
||||
|
||||
@@ -1275,7 +1275,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-jsx
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-jsx
|
||||
|
||||
var profile = <div>
|
||||
<img src="avatar.png" className="profile" />
|
||||
@@ -1283,7 +1283,7 @@ var profile = <div>
|
||||
</div>;
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-jsx
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-jsx
|
||||
|
||||
var profile = (
|
||||
<div>
|
||||
@@ -1301,7 +1301,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-logical-assignment-operators
|
||||
|
||||
a ||= b;
|
||||
obj.a.b ||= c;
|
||||
@@ -1310,7 +1310,7 @@ a &&= b;
|
||||
obj.a.b &&= c;
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-logical-assignment-operators
|
||||
|
||||
a ||= b;
|
||||
obj.a.b ||= c;
|
||||
@@ -1393,12 +1393,12 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-nullish-coalescing-operator
|
||||
|
||||
var foo = object.foo ?? "default";
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-nullish-coalescing-operator
|
||||
|
||||
var foo = object.foo ?? "default";
|
||||
|
||||
@@ -1411,7 +1411,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-numeric-separator
|
||||
|
||||
let budget = 1_000_000_000_000;
|
||||
|
||||
@@ -1449,7 +1449,7 @@ let c = message & 0xff;
|
||||
console.log(c.toString(16), b); // c0, 192
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-numeric-separator
|
||||
|
||||
let budget = 1_000_000_000_000;
|
||||
|
||||
@@ -1495,7 +1495,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-transform-object-rest-spread
|
||||
// https://babeljs.io/docs/babel-plugin-transform-object-rest-spread
|
||||
|
||||
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
|
||||
console.log(x); // 1
|
||||
@@ -1506,7 +1506,7 @@ let n = { x, y, ...z };
|
||||
console.log(n); // { x: 1, y: 2, a: 3, b: 4 }
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-transform-object-rest-spread
|
||||
// https://babeljs.io/docs/babel-plugin-transform-object-rest-spread
|
||||
|
||||
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
|
||||
console.log(x); // 1
|
||||
@@ -1525,7 +1525,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-optional-catch-binding
|
||||
|
||||
try {
|
||||
throw 0;
|
||||
@@ -1542,7 +1542,7 @@ try {
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-optional-catch-binding
|
||||
|
||||
try {
|
||||
throw 0;
|
||||
@@ -1567,7 +1567,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-optional-chaining
|
||||
|
||||
const obj = {
|
||||
foo: {
|
||||
@@ -1631,7 +1631,7 @@ const obj4 = {
|
||||
const ret = delete obj?.foo?.bar?.baz; // true
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-optional-chaining
|
||||
|
||||
const obj = {
|
||||
foo: {
|
||||
@@ -1776,7 +1776,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-partial-application
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-partial-application
|
||||
|
||||
function add(x, y) { return x + y; }
|
||||
|
||||
@@ -1799,7 +1799,7 @@ o.f(?, x, ?) // partial application for any arg
|
||||
super.f(?) // partial application allowed for call on |SuperProperty|
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-partial-application
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-partial-application
|
||||
|
||||
function add(x, y) {
|
||||
return x + y;
|
||||
@@ -1866,7 +1866,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/valtech-nyc/proposal-fsharp-pipelines
|
||||
|
||||
promise
|
||||
@@ -1902,7 +1902,7 @@ newScore //=> 57
|
||||
let newScore = boundScore(0, 100, add(7, double(person.score)));
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/valtech-nyc/proposal-fsharp-pipelines
|
||||
|
||||
promise
|
||||
@@ -1977,7 +1977,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/js-choi/proposal-hack-pipes
|
||||
|
||||
return list
|
||||
@@ -1987,7 +1987,7 @@ return list
|
||||
// (The % token isn't final; it might instead be @ or ? or #.)
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/js-choi/proposal-hack-pipes
|
||||
|
||||
return list |> take(prefix.length, %) |> equals(%, prefix);
|
||||
@@ -2039,7 +2039,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/tc39/proposal-pipeline-operator/
|
||||
|
||||
let result = exclaim(capitalize(doubleSay("hello")));
|
||||
@@ -2053,7 +2053,7 @@ let result = "hello"
|
||||
result //=> "Hello, hello!"
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/tc39/proposal-pipeline-operator/
|
||||
|
||||
let result = exclaim(capitalize(doubleSay("hello")));
|
||||
@@ -2194,7 +2194,7 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-private-methods
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-private-methods
|
||||
|
||||
// Test for \`classPrivateProperties\` and \`classPrivateMethods\`
|
||||
|
||||
@@ -2215,7 +2215,7 @@ class Counter extends HTMLElement {
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-private-methods
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-private-methods
|
||||
|
||||
// Test for \`classPrivateProperties\` and \`classPrivateMethods\`
|
||||
|
||||
@@ -2406,7 +2406,7 @@ import.source("x");
|
||||
|
||||
exports[`throw-expressions.js [acorn] format 1`] = `
|
||||
"Unexpected token (3:23)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
|
||||
2 |
|
||||
> 3 | function test(param = throw new Error('required!')) {
|
||||
| ^
|
||||
@@ -2418,7 +2418,7 @@ Cause: Unexpected token (3:22)"
|
||||
|
||||
exports[`throw-expressions.js [espree] format 1`] = `
|
||||
"Unexpected token throw (3:23)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
|
||||
2 |
|
||||
> 3 | function test(param = throw new Error('required!')) {
|
||||
| ^
|
||||
@@ -2430,7 +2430,7 @@ Cause: Unexpected token throw"
|
||||
|
||||
exports[`throw-expressions.js [meriyah] format 1`] = `
|
||||
"Unexpected token: 'throw' (3:23)
|
||||
1 | // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions
|
||||
1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
|
||||
2 |
|
||||
> 3 | function test(param = throw new Error('required!')) {
|
||||
| ^^^^^
|
||||
@@ -2446,14 +2446,14 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
|
||||
|
||||
function test(param = throw new Error('required!')) {
|
||||
const test = param === true || throw new Error('Falsy!');
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
|
||||
|
||||
function test(param = throw new Error("required!")) {
|
||||
const test = param === true || throw new Error("Falsy!");
|
||||
@@ -2464,7 +2464,7 @@ function test(param = throw new Error("required!")) {
|
||||
|
||||
exports[`typescript.js [__babel_estree] format 1`] = `
|
||||
"Unexpected token (3:8)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-typescript
|
||||
1 | // https://babeljs.io/docs/babel-preset-typescript
|
||||
2 |
|
||||
> 3 | const x: number = 0;
|
||||
| ^
|
||||
@@ -2474,7 +2474,7 @@ Cause: Unexpected token (3:7)"
|
||||
|
||||
exports[`typescript.js [acorn] format 1`] = `
|
||||
"Unexpected token (3:8)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-typescript
|
||||
1 | // https://babeljs.io/docs/babel-preset-typescript
|
||||
2 |
|
||||
> 3 | const x: number = 0;
|
||||
| ^
|
||||
@@ -2484,7 +2484,7 @@ Cause: Unexpected token (3:7)"
|
||||
|
||||
exports[`typescript.js [babel] format 1`] = `
|
||||
"Unexpected token (3:8)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-typescript
|
||||
1 | // https://babeljs.io/docs/babel-preset-typescript
|
||||
2 |
|
||||
> 3 | const x: number = 0;
|
||||
| ^
|
||||
@@ -2498,12 +2498,12 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-preset-typescript
|
||||
// https://babeljs.io/docs/babel-preset-typescript
|
||||
|
||||
const x: number = 0;
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-preset-typescript
|
||||
// https://babeljs.io/docs/babel-preset-typescript
|
||||
|
||||
const x: number = 0;
|
||||
|
||||
@@ -2516,12 +2516,12 @@ parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// https://babeljs.io/docs/en/babel-preset-typescript
|
||||
// https://babeljs.io/docs/babel-preset-typescript
|
||||
|
||||
const x: number = 0;
|
||||
|
||||
=====================================output=====================================
|
||||
// https://babeljs.io/docs/en/babel-preset-typescript
|
||||
// https://babeljs.io/docs/babel-preset-typescript
|
||||
|
||||
const x: number = 0;
|
||||
|
||||
@@ -2530,7 +2530,7 @@ const x: number = 0;
|
||||
|
||||
exports[`typescript.js [espree] format 1`] = `
|
||||
"Unexpected token : (3:8)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-typescript
|
||||
1 | // https://babeljs.io/docs/babel-preset-typescript
|
||||
2 |
|
||||
> 3 | const x: number = 0;
|
||||
| ^
|
||||
@@ -2540,7 +2540,7 @@ Cause: Unexpected token :"
|
||||
|
||||
exports[`typescript.js [meriyah] format 1`] = `
|
||||
"Missing initializer in const declaration (3:8)
|
||||
1 | // https://babeljs.io/docs/en/babel-preset-typescript
|
||||
1 | // https://babeljs.io/docs/babel-preset-typescript
|
||||
2 |
|
||||
> 3 | const x: number = 0;
|
||||
| ^
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-async-generator-functions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-async-generator-functions
|
||||
|
||||
async function* agf() {
|
||||
await 1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-class-properties
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-class-properties
|
||||
|
||||
class Bork {
|
||||
//Property initializer syntax
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-decorators
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-decorators
|
||||
|
||||
@annotation
|
||||
class MyClass { }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-do-expressions
|
||||
|
||||
let a = do {
|
||||
if(x > 10) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-dynamic-import
|
||||
|
||||
// There is no example code on babel website
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-export-default-from
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-export-default-from
|
||||
|
||||
|
||||
export v from 'mod';
|
||||
@@ -1,3 +1,3 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-export-namespace-from
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-export-namespace-from
|
||||
|
||||
export * as ns from 'mod';
|
||||
@@ -1,3 +1,3 @@
|
||||
// https://babeljs.io/docs/en/babel-preset-flow
|
||||
// https://babeljs.io/docs/babel-preset-flow
|
||||
|
||||
function foo(one: any, two: number, three?): string {}
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-function-bind
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-function-bind
|
||||
|
||||
obj::func
|
||||
// is equivalent to:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-function-sent
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-function-sent
|
||||
|
||||
function* generator() {
|
||||
console.log("Sent", function.sent);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-import-meta
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-import-meta
|
||||
|
||||
// Enabled by default https://github.com/babel/babel/pull/11406
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-syntax-jsx
|
||||
// https://babeljs.io/docs/babel-plugin-syntax-jsx
|
||||
|
||||
var profile = <div>
|
||||
<img src="avatar.png" className="profile" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-logical-assignment-operators
|
||||
|
||||
a ||= b;
|
||||
obj.a.b ||= c;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-nullish-coalescing-operator
|
||||
|
||||
var foo = object.foo ?? "default";
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-numeric-separator
|
||||
|
||||
let budget = 1_000_000_000_000;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-transform-object-rest-spread
|
||||
// https://babeljs.io/docs/babel-plugin-transform-object-rest-spread
|
||||
|
||||
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
|
||||
console.log(x); // 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-optional-catch-binding
|
||||
|
||||
try {
|
||||
throw 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-optional-chaining
|
||||
|
||||
const obj = {
|
||||
foo: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-partial-application
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-partial-application
|
||||
|
||||
function add(x, y) { return x + y; }
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/valtech-nyc/proposal-fsharp-pipelines
|
||||
|
||||
promise
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/js-choi/proposal-hack-pipes
|
||||
|
||||
return list
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
|
||||
// https://github.com/tc39/proposal-pipeline-operator/
|
||||
|
||||
let result = exclaim(capitalize(doubleSay("hello")));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-private-methods
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-private-methods
|
||||
|
||||
// Test for `classPrivateProperties` and `classPrivateMethods`
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
|
||||
|
||||
function test(param = throw new Error('required!')) {
|
||||
const test = param === true || throw new Error('Falsy!');
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// https://babeljs.io/docs/en/babel-preset-typescript
|
||||
// https://babeljs.io/docs/babel-preset-typescript
|
||||
|
||||
const x: number = 0;
|
||||
@@ -10,7 +10,7 @@ runFormatTest(
|
||||
"const i = %DebugPrint;",
|
||||
|
||||
// partialApplication
|
||||
// https://babeljs.io/docs/en/babel-plugin-proposal-partial-application#invalid-usage
|
||||
// https://babeljs.io/docs/babel-plugin-proposal-partial-application#invalid-usage
|
||||
"f(x + ?)", // `?` not in top-level Arguments of call
|
||||
"x + ?", // `?` not in top-level Arguments of call
|
||||
"?.f()", // `?` not in top-level Arguments of call
|
||||
|
||||
@@ -7,4 +7,4 @@ exports[`embed API in plugins with new signature should work 1`] = `
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`embed API in plugins with outdated signature should cause error 1`] = `"printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/en/plugins.html#optional-embed"`;
|
||||
exports[`embed API in plugins with outdated signature should cause error 1`] = `"printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed"`;
|
||||
+3
-3
@@ -22,7 +22,7 @@ https://prettier.io/
|
||||
|
||||
This starts a server hosting the website locally at `http://localhost:3000/`. Any changes to the site's source files are reflected after refreshing the page, i.e. the server does not need to be restarted to show changes.
|
||||
|
||||
When working on the docs, you need to go to `http://localhost:3000/docs/en/next/index.html` (note “next”) to see your changes.
|
||||
When working on the docs, you need to go to `http://localhost:3000/docs/next/index.html` (note “next”) to see your changes.
|
||||
|
||||
## Docusaurus
|
||||
|
||||
@@ -40,7 +40,7 @@ The Playground is not integrated with the Docusaurus infrastructure. Its UI (`we
|
||||
|
||||
The entry point of the playground is at `static/playground/index.html`.
|
||||
|
||||
Another part of the Playground is a web worker where formatting happens. It’s not managed by webpack and resides directly in `static/worker.js`. It expects to find the [UMD bundles of Prettier](https://prettier.io/docs/en/browser.html) in `static/lib/`. That’s why running `yarn build:website` or `PULL_REQUEST=true yarn build:website` in the project root is a required step.
|
||||
Another part of the Playground is a web worker where formatting happens. It’s not managed by webpack and resides directly in `static/worker.js`. It expects to find the [UMD bundles of Prettier](https://prettier.io/docs/browser) in `static/lib/`. That’s why running `yarn build:website` or `PULL_REQUEST=true yarn build:website` in the project root is a required step.
|
||||
|
||||
Finally, there is a service worker that caches Prettier’s relatively heavy bundles (`static/service-worker.js`).
|
||||
|
||||
@@ -54,7 +54,7 @@ id: doc1 # used for docs to find each other and to map links
|
||||
title: Document Title
|
||||
layout: docs1 # used to determine different sidebar groupings
|
||||
category: Sidebar Category 1 # Category on the sidebar under which this doc goes
|
||||
permalink: docs/en/doc1.html # link to the document that is used for site
|
||||
permalink: docs/doc1.html # link to the document that is used for site
|
||||
previous: doc0 # previous doc on sidebar for navigation
|
||||
next: doc2 # next doc on the sidebar for navigation
|
||||
# don’t include next if this is the last doc; don’t include previous if first doc
|
||||
|
||||
@@ -43,7 +43,7 @@ you and you may call me V.
|
||||
```
|
||||
|
||||
> ~~Note: We're considering adding an option for this, check [#3183](https://github.com/prettier/prettier/pull/3183) for discussion.~~
|
||||
> Update: We've added an option in `1.8.2` called [`--no-prose-wrap`](https://prettier.io/docs/en/options.html#prose-wrap)
|
||||
> Update: We've added an option in `1.8.2` called [`--no-prose-wrap`](https://prettier.io/docs/options#prose-wrap)
|
||||
|
||||
> Note for CJK users: If your markdown renderer does not support CJK line ending, you'll have to use plugin like [markdown-it-perfect-newline-for-cjk](https://www.npmjs.com/package/markdown-it-perfect-newline-for-cjk), [hexo-filter-fix-cjk-spacing](https://www.npmjs.com/package/hexo-filter-fix-cjk-spacing), etc. to remove additional spaces.
|
||||
>
|
||||
@@ -134,7 +134,7 @@ const markdown = md`
|
||||
|
||||
#### Add option to insert `@format` to first docblock if absent ([#2865](https://github.com/prettier/prettier/pull/2865)) by [@samouri](https://github.com/samouri)
|
||||
|
||||
In 1.7, we added an option called `--require-pragma` to require files contain an `/** @format */` pragma to be formatted. In order to add this pragma to a large set of files you can now use [`--insert-pragma`](https://prettier.io/docs/en/cli.html#insert-pragma) flag.
|
||||
In 1.7, we added an option called `--require-pragma` to require files contain an `/** @format */` pragma to be formatted. In order to add this pragma to a large set of files you can now use [`--insert-pragma`](https://prettier.io/docs/cli#insert-pragma) flag.
|
||||
|
||||
```
|
||||
prettier --write "folder/**/*.js" --insert-pragma
|
||||
@@ -142,7 +142,7 @@ prettier --write "folder/**/*.js" --insert-pragma
|
||||
|
||||
#### Add `--loglevel` option ([#2992](https://github.com/prettier/prettier/pull/2992)) by [@ikatyang](https://github.com/ikatyang)
|
||||
|
||||
This [nifty feature](https://prettier.io/docs/en/cli.html#loglevel) allows you to opt in (or out) of Prettier's logging. We've also cleaned up the logging substantially since 1.7.
|
||||
This [nifty feature](https://prettier.io/docs/cli#loglevel) allows you to opt in (or out) of Prettier's logging. We've also cleaned up the logging substantially since 1.7.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```bash
|
||||
|
||||
@@ -456,4 +456,4 @@ Similarly, "JSON with comments" will also be detected.
|
||||
[#3643]: https://github.com/prettier/prettier/pull/3643
|
||||
[#3649]: https://github.com/prettier/prettier/pull/3649
|
||||
[#3694]: https://github.com/prettier/prettier/pull/3694
|
||||
[plugin api]: https://prettier.io/docs/en/plugins.html
|
||||
[plugin api]: https://prettier.io/docs/plugins
|
||||
@@ -17,7 +17,7 @@ Adding support for a new language to Prettier requires two things:
|
||||
|
||||
While we could benefit from existing work on the parsing side, the printer had to be developed from scratch to support all of PHP's various AST node types. Our first alpha release today means that we are confident that the printer can re-print your code without breaking it.
|
||||
|
||||
If you'd like to read more about the plugin API, see [the docs](https://prettier.io/docs/en/plugins.html).
|
||||
If you'd like to read more about the plugin API, see [the docs](https://prettier.io/docs/plugins).
|
||||
|
||||
## Philosophy
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ const {
|
||||
|
||||
#### Support hasPragma/insertPragma ([#4275](https://github.com/prettier/prettier/pull/4275) by [@ikatyang](https://github.com/ikatyang))
|
||||
|
||||
Prettier 1.7.0 and 1.8.0 introduced two new options, [`--require-pragma`](https://prettier.io/docs/en/options.html#require-pragma) and [`--insert-pragma`](https://prettier.io/docs/en/options.html#insert-pragma). However, these options were only supported in JavaScript. Now these options are available in Markdown, too!
|
||||
Prettier 1.7.0 and 1.8.0 introduced two new options, [`--require-pragma`](https://prettier.io/docs/options#require-pragma) and [`--insert-pragma`](https://prettier.io/docs/options#insert-pragma). However, these options were only supported in JavaScript. Now these options are available in Markdown, too!
|
||||
|
||||
```md
|
||||
<!-- @prettier -->
|
||||
@@ -232,7 +232,7 @@ A long time ago, in my hometown of Ericsburgh...
|
||||
|
||||
When using tools such as [all-contributors](https://github.com/kentcdodds/all-contributors) or [markdown-toc](https://github.com/jonschlinkert/markdown-toc), users were running into situations where autogenerated Markdown content was formatted oddly by Prettier, or Prettier's `--list-different` mode was flagging autogenerated content that the user didn't care about formatting.
|
||||
|
||||
To solve these problems, we have added a new type of ignore comment to Markdown, called [Range Ignore](https://prettier.io/docs/en/ignore.html#range-ignore):
|
||||
To solve these problems, we have added a new type of ignore comment to Markdown, called [Range Ignore](https://prettier.io/docs/ignore#range-ignore):
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```md
|
||||
@@ -267,7 +267,7 @@ Prettier 1.11.1 failed to parse the new style; we now support both styles.
|
||||
|
||||
#### Move pragma detection/insertion to plugins ([#3685](https://github.com/prettier/prettier/pull/3685) by [@duailibe](https://github.com/duailibe))
|
||||
|
||||
Prettier plugins can now include a `hasPragma` function in their [parser](https://prettier.io/docs/en/plugins.html#parsers) and an `insertPragma` function in their [printer](https://prettier.io/docs/en/plugins.html#printers) to opt-in to `--insert-pragma` and `--require-pragma` support. These are their signatures:
|
||||
Prettier plugins can now include a `hasPragma` function in their [parser](https://prettier.io/docs/plugins#parsers) and an `insertPragma` function in their [printer](https://prettier.io/docs/plugins#printers) to opt-in to `--insert-pragma` and `--require-pragma` support. These are their signatures:
|
||||
|
||||
```ts
|
||||
function hasPragma(text: string): boolean;
|
||||
@@ -883,7 +883,7 @@ Prettier 1.11.1 did not handle self-closing style or script tags correctly in vu
|
||||
|
||||
#### Fix printing ignored files with --debug-check ([#4066](https://github.com/prettier/prettier/pull/4066) by [@duailibe](https://github.com/duailibe))
|
||||
|
||||
Prettier 1.11.1 was mistakenly outputting the contents of ignored files when the [`--debug-check`](https://prettier.io/docs/en/cli.html#debug-check) flag was used. In Prettier 1.12.0, the contents of ignored files are no longer written to stdout.
|
||||
Prettier 1.11.1 was mistakenly outputting the contents of ignored files when the [`--debug-check`](https://prettier.io/docs/cli#debug-check) flag was used. In Prettier 1.12.0, the contents of ignored files are no longer written to stdout.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ formatButton.addEventListener("click", function() {
|
||||
});</script>
|
||||
```
|
||||
|
||||
Read more about it in the [docs](https://prettier.io/docs/en/browser.html) or try it on this [JS Bin](https://jsbin.com/vabiyomoso/edit?html,output).
|
||||
Read more about it in the [docs](https://prettier.io/docs/browser) or try it on this [JS Bin](https://jsbin.com/vabiyomoso/edit?html,output).
|
||||
|
||||
#### Don't default to the JavaScript parser ([#4528] by [@duailibe])
|
||||
|
||||
@@ -51,13 +51,13 @@ When using the JavaScript API, `prettier.format` and `prettier.formatWithCursor`
|
||||
|
||||
When invoking Prettier from the API, there was no way to find out if a file should be ignored or not (for `.prettierignore`) so editor integration plugins would have to implement this logic. Also, there was no way to find out if a file was supported by Prettier, so users would need to call Prettier anyway. In 1.13 there's a way to check if a parser will be inferred (and which one) and if the file is ignored or not before actually calling `format`.
|
||||
|
||||
You can read more about this in the [docs](https://prettier.io/docs/en/api.html#prettiergetfileinfofilepath-options).
|
||||
You can read more about this in the [docs](https://prettier.io/docs/api#prettiergetfileinfofilepath-options).
|
||||
|
||||
#### Support for global Prettier and plugins ([#4192] by [@kachkaev])
|
||||
|
||||
When installing Prettier and plugins globally, Prettier was not able to automatically load plugins because it searched for them in the nearest `package.json`. Now Prettier will look for plugins in the `node_modules` directory it's installed in. Additionally, for cases where Prettier can't find the plugins automatically (because of other setups we haven't added support for), a new `--plugin-search-dir` option was added so you can specify where Prettier should search for plugins.
|
||||
|
||||
You can read more about this in the [Plugin docs](https://prettier.io/docs/en/plugins.html#using-plugins).
|
||||
You can read more about this in the [Plugin docs](https://prettier.io/docs/plugins#using-plugins).
|
||||
|
||||
#### Improve cursor offset tracking ([#4397] by [@ds300])
|
||||
|
||||
@@ -133,7 +133,7 @@ d3.select("body")
|
||||
|
||||
#### Format new `describe.each` table in Jest 23 ([#4423] by [@ikatyang])
|
||||
|
||||
Jest 23 introduced a new feature called [data driven tests](https://facebook.github.io/jest/docs/en/api.html#describeeachtable-name-fn) where you can describe examples to test in a table. Prettier 1.13 includes support for this feature, and will automatically indent the table when using data driven tests.
|
||||
Jest 23 introduced a new feature called [data driven tests](https://jestjs.io/docs/api#describename-fn) where you can describe examples to test in a table. Prettier 1.13 includes support for this feature, and will automatically indent the table when using data driven tests.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
|
||||
@@ -46,7 +46,7 @@ Output: (`--prose-wrap always`)
|
||||
that it’s my very good honour to meet you and you may call me V.
|
||||
```
|
||||
|
||||
> Note: the [`proseWrap`](https://prettier.io/docs/en/options.html#prose-wrap) option is set to `preserve` by default so you’ll have to specify `always` or `never` to enable this feature.
|
||||
> Note: the [`proseWrap`](https://prettier.io/docs/options#prose-wrap) option is set to `preserve` by default so you’ll have to specify `always` or `never` to enable this feature.
|
||||
|
||||
##### Ignore a portion of the file
|
||||
|
||||
@@ -96,8 +96,8 @@ content
|
||||
#### Support `requirePragma`/`insertPragma` in every language ([#4688], [#4699], [#4713] by [@ikatyang])
|
||||
|
||||
Prettier 1.7.0 and 1.8.0 introduced two new options:
|
||||
[`--require-pragma`](https://prettier.io/docs/en/options.html#require-pragma) and
|
||||
[`--insert-pragma`](https://prettier.io/docs/en/options.html#insert-pragma).
|
||||
[`--require-pragma`](https://prettier.io/docs/options#require-pragma) and
|
||||
[`--insert-pragma`](https://prettier.io/docs/options#insert-pragma).
|
||||
However, these options were only supported in a few languages.
|
||||
Now these options are available in every language, including YAML!
|
||||
|
||||
@@ -662,7 +662,7 @@ const doBothThings = async () => {
|
||||
#### Allow top level `super` and `await` ([#4823] by [@ikatyang])
|
||||
|
||||
`super` and `await` are not allowed to be in places other than classes and async functions, respectively,
|
||||
but our [range format](https://prettier.io/docs/en/options.html#range) option didn’t quite work properly when selecting the contents of a function.
|
||||
but our [range format](https://prettier.io/docs/options#range) option didn’t quite work properly when selecting the contents of a function.
|
||||
Prettier 1.14 allows them to be everywhere.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
@@ -958,7 +958,7 @@ Prettier 1.14 correctly recognizes these characters so they won’t be transform
|
||||
|
||||
#### Support range format for Vue files ([#4868] by [@ikatyang])
|
||||
|
||||
Previously, [range formatting](https://prettier.io/docs/en/options.html#range) was not available in Vue,
|
||||
Previously, [range formatting](https://prettier.io/docs/options#range) was not available in Vue,
|
||||
but Prettier 1.14 adds support for it.
|
||||
|
||||
### GraphQL
|
||||
|
||||
@@ -116,7 +116,7 @@ Prettier uses filename to infer which parser to use. Here's the default patterns
|
||||
Make sure your filename matches the correct parser (especially for Angular users); if it does not,
|
||||
you will have to manually specify which parser to use via the [overrides] field.
|
||||
|
||||
[overrides]: https://prettier.io/docs/en/configuration.html#configuration-overrides
|
||||
[overrides]: https://prettier.io/docs/configuration#configuration-overrides
|
||||
|
||||
Note that framework-specific formatting won't be triggered in `--parser html`.
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ The `babylon` parser name is now deprecated but it still works.
|
||||
If you need to change your config due to this change, please take a second to read
|
||||
[our docs on the `parser` option], especially the note at the bottom.
|
||||
|
||||
[our docs on the `parser` option]: https://prettier.io/docs/en/configuration.html#setting-the-parser-docs-en-optionshtml-parser-option
|
||||
[our docs on the `parser` option]: https://prettier.io/docs/configuration#setting-the-parser-docs-en-optionshtml-parser-option
|
||||
|
||||
### Flow
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ This release adds the long awaited `--vue-indent-script-and-style` option, suppo
|
||||
|
||||
#### Add `--vue-indent-script-and-style` ([#6157] by [@kamilic])
|
||||
|
||||
The new [`--vue-indent-script-and-style`](https://prettier.io/docs/en/options.html#vue-files-script-and-style-tags-indentation) option controls whether or not to indent the code inside `<script>` and `<style>` tags in Vue files. Some people (like [the creator of Vue](https://github.com/prettier/prettier/issues/3888#issuecomment-459521863)) don’t indent to save an indentation level, but this might break code folding in your editor. This closes our most commented issue so far, and should improve lots of Vue coders’ editing experience!
|
||||
The new [`--vue-indent-script-and-style`](https://prettier.io/docs/options#vue-files-script-and-style-tags-indentation) option controls whether or not to indent the code inside `<script>` and `<style>` tags in Vue files. Some people (like [the creator of Vue](https://github.com/prettier/prettier/issues/3888#issuecomment-459521863)) don’t indent to save an indentation level, but this might break code folding in your editor. This closes our most commented issue so far, and should improve lots of Vue coders’ editing experience!
|
||||
|
||||
### TypeScript
|
||||
|
||||
@@ -1103,7 +1103,7 @@ Previously, even if the line length was shorter than `printWidth`, Prettier woul
|
||||
|
||||
#### Script tags are now treated as blocks for the purposes of formatting ([#6423] by [@thorn0])
|
||||
|
||||
Previously, in the [whitespace-sensitive mode](https://prettier.io/docs/en/options.html#html-whitespace-sensitivity), they were formatted as if they were inline.
|
||||
Previously, in the [whitespace-sensitive mode](https://prettier.io/docs/options#html-whitespace-sensitivity), they were formatted as if they were inline.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
|
||||
@@ -111,7 +111,7 @@ The minimal required Node version now is 10.13.0. For our contributors, this mea
|
||||
Before version 2.0, Prettier was avoiding trailing commas by default where possible.
|
||||
This made the resulting JavaScript compatible with now very old environments such as IE8, but implied [some missed opportunities](https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8).
|
||||
|
||||
Prettier has included an [option to configure trailing commas](https://prettier.io/docs/en/options.html#trailing-commas) since its early days, and an initiative to change the default value has been out there [for over three years](https://github.com/prettier/prettier/issues/68).
|
||||
Prettier has included an [option to configure trailing commas](https://prettier.io/docs/options#trailing-commas) since its early days, and an initiative to change the default value has been out there [for over three years](https://github.com/prettier/prettier/issues/68).
|
||||
Finally, the default value becomes `es5` instead of `none` in Prettier v2.0.
|
||||
|
||||
If the old behavior is still preferred, please configure Prettier with `{ "trailingComma": "none" }`.
|
||||
@@ -130,7 +130,7 @@ There is a possibility that the default value will change to `all` (meaning even
|
||||
|
||||
#### Change default value for `arrowParens` to `always` ([#7430](https://github.com/prettier/prettier/pull/7430) by [@kachkaev](https://github.com/kachkaev))
|
||||
|
||||
[Since version 1.9](https://prettier.io/blog/2017/12/05/1.9.0.html#option-to-add-parens-in-arrow-function-arguments-3324httpsgithubcomprettierprettierpull3324-by-rattrayalexhttpsgithubcomrattrayalex-and-suchipihttpsgithubcomsuchipi), Prettier has had an [option](https://prettier.io/docs/en/options.html#arrow-function-parentheses) to always wrap arrow function arguments with parentheses.
|
||||
[Since version 1.9](https://prettier.io/blog/2017/12/05/1.9.0.html#option-to-add-parens-in-arrow-function-arguments-3324httpsgithubcomprettierprettierpull3324-by-rattrayalexhttpsgithubcomrattrayalex-and-suchipihttpsgithubcomsuchipi), Prettier has had an [option](https://prettier.io/docs/options#arrow-function-parentheses) to always wrap arrow function arguments with parentheses.
|
||||
In version 2.0, this behavior has become the default.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
@@ -165,7 +165,7 @@ Besides, contributors on different operating systems could accidentally change l
|
||||
Doing so would produce a large `git diff` and thus make the line-by-line history for a file (`git blame`) harder to explore.
|
||||
|
||||
You are encouraged to use the new default value for `endOfLine`, which is now `lf`.
|
||||
It may be also worth [checking the option docs](https://prettier.io/docs/en/options.html#end-of-line) to ensure your project repository is configured correctly.
|
||||
It may be also worth [checking the option docs](https://prettier.io/docs/options#end-of-line) to ensure your project repository is configured correctly.
|
||||
This will help you avoid a mix of line endings in the repo and a broken `git blame`.
|
||||
If the old behavior is still preferred, please configure Prettier with `{ "endOfLine": "auto" }`.
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ export default class Foo {
|
||||
|
||||
#### Improve detection of source elements for range formatting ([#8419](https://github.com/prettier/prettier/pull/8419) by [@thorn0](https://github.com/thorn0))
|
||||
|
||||
Not all statement types were detected (read [here](https://prettier.io/docs/en/options.html#range) how range formatting works in Prettier).
|
||||
Not all statement types were detected (read [here](https://prettier.io/docs/options#range) how range formatting works in Prettier).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
@@ -1251,7 +1251,7 @@ Non-ASCII whitespace characters like `U+00A0` `U+2005` etc. are not considered w
|
||||
|
||||
#### Support legacy HTML-like comments script blocks ([#8173](https://github.com/prettier/prettier/pull/8173) by [@fisker](https://github.com/fisker), [#8394](https://github.com/prettier/prettier/pull/8394) by [@fisker](https://github.com/fisker))
|
||||
|
||||
Previously we parse html `<script>` blocks as "module"([ECMAScript Module grammar](https://babeljs.io/docs/en/options#sourcetype)), this is why we can't parse comments starts with `<!--`(aka [HTML-like comments](https://tc39.es/ecma262/#sec-html-like-comments)), now we parse `<script>` blocks as "script", unless this `<script>`
|
||||
Previously we parse html `<script>` blocks as "module"([ECMAScript Module grammar](https://babeljs.io/docs/options#sourcetype)), this is why we can't parse comments starts with `<!--`(aka [HTML-like comments](https://tc39.es/ecma262/#sec-html-like-comments)), now we parse `<script>` blocks as "script", unless this `<script>`
|
||||
|
||||
1. `type="module"`
|
||||
2. `type="text/babel"` and `data-type="module"`, [introduced in babel@v7.10.0](https://github.com/babel/babel/pull/11466)
|
||||
@@ -1506,7 +1506,7 @@ Previously, Prettier always [preserved line breaks][#5596] around inline nodes (
|
||||
|
||||
#### Improve formatting Vue SFC root blocks ([#8023](https://github.com/prettier/prettier/pull/8023) by [@sosukesuzuki](https://github.com/sosukesuzuki), [#8465](https://github.com/prettier/prettier/pull/8465) by [@fisker](https://github.com/fisker))
|
||||
|
||||
Support formatting all [language blocks](https://vue-loader.vuejs.org/spec.html#language-blocks)(including [custom blocks](https://vue-loader.vuejs.org/spec.html#custom-blocks) with `lang` attribute) with [builtin parsers](https://prettier.io/docs/en/options.html#parser) and [plugins](https://prettier.io/docs/en/plugins.html).
|
||||
Support formatting all [language blocks](https://vue-loader.vuejs.org/spec.html#language-blocks)(including [custom blocks](https://vue-loader.vuejs.org/spec.html#custom-blocks) with `lang` attribute) with [builtin parsers](https://prettier.io/docs/options#parser) and [plugins](https://prettier.io/docs/plugins).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
|
||||
@@ -9,7 +9,7 @@ After 1500 commits and 50 releases since July 2018, we're happy to announce that
|
||||
|
||||
## How does it work?
|
||||
|
||||
Prettier for Ruby works through Prettier's [plugin API](https://prettier.io/docs/en/plugins.html). Its `parse` function works by spawning a Ruby process and using Ruby's own parser (known as `Ripper`). After tracking all of the various node types, comments, location information, and other various metadata, it returns a built abstract syntax tree (AST) to the Prettier process. Finally it converts that AST into Prettier's intermediate representation (known as `Doc`) before allowing Prettier to handle printing it back out.
|
||||
Prettier for Ruby works through Prettier's [plugin API](https://prettier.io/docs/plugins). Its `parse` function works by spawning a Ruby process and using Ruby's own parser (known as `Ripper`). After tracking all of the various node types, comments, location information, and other various metadata, it returns a built abstract syntax tree (AST) to the Prettier process. Finally it converts that AST into Prettier's intermediate representation (known as `Doc`) before allowing Prettier to handle printing it back out.
|
||||
|
||||
## Philosophy
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ We are grateful to our financial contributors: [Salesforce](https://engineering.
|
||||
|
||||
Most of the changes in this release are thanks to the hard work of [Fisker Cheung](https://github.com/fisker), [Georgii Dolzhykov](https://github.com/thorn0), and [Sosuke Suzuki](https://github.com/sosukesuzuki), along with many other contributors.
|
||||
|
||||
And just a reminder, when Prettier is installed or updated, it’s [strongly recommended](https://prettier.io/docs/en/install.html#summary) to specify the exact version in `package.json`: `"2.3.0"`, not `"^2.3.0"`.
|
||||
And just a reminder, when Prettier is installed or updated, it’s [strongly recommended](https://prettier.io/docs/install#summary) to specify the exact version in `package.json`: `"2.3.0"`, not `"^2.3.0"`.
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
@@ -103,10 +103,10 @@ See the formatter in action on the [playground][playground-glimmer]!
|
||||
|
||||
[glimmer]: https://www.npmjs.com/package/@glimmer/syntax
|
||||
[ember]: https://emberjs.com
|
||||
[hws-option]: https://prettier.io/docs/en/options.html#html-whitespace-sensitivity
|
||||
[hws-option]: https://prettier.io/docs/options#html-whitespace-sensitivity
|
||||
[handlebars]: https://handlebarsjs.com/
|
||||
[parser-option]: https://prettier.io/docs/en/options.html#parser
|
||||
[configuration overrides]: https://prettier.io/docs/en/configuration.html#configuration-overrides
|
||||
[parser-option]: https://prettier.io/docs/options#parser
|
||||
[configuration overrides]: https://prettier.io/docs/configuration#configuration-overrides
|
||||
[playground-glimmer]: https://prettier.io/playground/#N4Igxg9gdgLgprEAuEACVAeAJgSwG7qFgA2AhgM7kC8AOiAjAE4CedhqAfDVOhgBYBGDsGDoYOGMTjsAvjIwB6QVx6ZcBdCQrU6AIwhZWIFe1OERhfYbOE53Reo6YFjkABoQEAA7jo5ZKCkjIwQAO4ACkEI-iikxKGkzP4euoykYADWcDAAyl7pOFAA5shMAK5wHnAAtrpwWFj1ADKkxWWkRXAAYhCM1aQw4sXIIKRlMBDuIHww1cQA6nwScOT5YHA50RL4Eswj5Ew4YDBTheRwjDDhaUX9yABmceceAFbkAB4AQmmZ2Tmk1TgTUKcAeT0qIDe7xyhSKUgAimUIPAwcRniB8oxzowRnCcNVATiPF5GIUYPMcFgYHxkAAOAAMxJC53maS8IxJKwueFBHgAjkj4NdvDFRuQALRQOD1epTRhwAU4eXXDp3JCPNEQ87VHClRgVDzkWEIwWg9XgjwwUi6ClUmlIABMlrSOGIsIAwhACaQRisAKxTMrnAAq1piGvReAqAEkoI1YDkwKSfABBOM5GDMKSo85yIA
|
||||
|
||||
## Formatting Improvements
|
||||
@@ -378,7 +378,7 @@ b;
|
||||
|
||||
#### Don’t format nodes that end just before `rangeStart` ([#9704](https://github.com/prettier/prettier/pull/9704) by [@fisker](https://github.com/fisker))
|
||||
|
||||
Previously, when [range formatting](https://prettier.io/docs/en/options.html#range) was performed, such nodes were considered part of the range, now they're excluded. This affects other languages that the range formatting feature supports, not only JavaScript.
|
||||
Previously, when [range formatting](https://prettier.io/docs/options#range) was performed, such nodes were considered part of the range, now they're excluded. This affects other languages that the range formatting feature supports, not only JavaScript.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
@@ -1689,7 +1689,7 @@ The `.prettierrc` file can be written in either JSON or YAML. Previously, when P
|
||||
|
||||
To simplify the code of AST printers, the data structure for the concatenation command has been changed from `{ type: 'concat', parts: Doc[] }` to `Doc[]`. The old format is deprecated, but for compatibility, the doc printer still supports it, and `doc.builders.concat` (as well as some other builder functions) will keep using it until the next major version of Prettier.
|
||||
|
||||
If you're a plugin author, this change should only concern you if your plugin introspects or modifies composed docs. If it happens to be the case, please make your plugin compatible with future versions of Prettier by tweaking the introspecting code to support the new format. There also is an off-chance where this change can break things, namely if a plugin calls another plugin to [print an embedded language](https://prettier.io/docs/en/plugins.html#optional-embed) and then introspects the returned doc. There seems to be no reason for plugins to do that though.
|
||||
If you're a plugin author, this change should only concern you if your plugin introspects or modifies composed docs. If it happens to be the case, please make your plugin compatible with future versions of Prettier by tweaking the introspecting code to support the new format. There also is an off-chance where this change can break things, namely if a plugin calls another plugin to [print an embedded language](https://prettier.io/docs/plugins#optional-embed) and then introspects the returned doc. There seems to be no reason for plugins to do that though.
|
||||
|
||||
To replace `concat(…)` calls in your plugins, you can try auto-fix by this ESLint rule [`prettier-doc/no-concat`](https://github.com/fisker/eslint-plugin-prettier-doc#no-concat).
|
||||
|
||||
@@ -1776,7 +1776,7 @@ To print a sub-property of the current node, use `["property1", "property2"]`:
|
||||
}
|
||||
```
|
||||
|
||||
See also an example in the [docs](https://prettier.io/docs/en/plugins.html#print).
|
||||
See also an example in the [docs](https://prettier.io/docs/plugins#print).
|
||||
|
||||
### CLI
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ foo1(/叱叱叱/)
|
||||
|
||||
The proposed [hack-style pipeline syntax](https://github.com/js-choi/proposal-hack-pipes) is now supported by Prettier. We are using `%` as the topic token, following the official explainer — although this may change in future releases as the proposal progresses.
|
||||
|
||||
As part of this change, support for the [“smart” pipeline syntax](https://github.com/js-choi/proposal-smart-pipelines) has been removed. See [our policy on non-standardized syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax) for the rationale behind this decision.
|
||||
As part of this change, support for the [“smart” pipeline syntax](https://github.com/js-choi/proposal-smart-pipelines) has been removed. See [our policy on non-standardized syntax](https://prettier.io/docs/rationale#disclaimer-about-non-standard-syntax) for the rationale behind this decision.
|
||||
|
||||
```js
|
||||
// Input
|
||||
|
||||
@@ -3,7 +3,7 @@ authors: "sosukesuzuki"
|
||||
title: "Prettier 2.6: new singleAttributePerLine option and new JavaScript features!"
|
||||
---
|
||||
|
||||
This release includes a new `singleAttributePerLine` option. This is an option to print only one attribute per line in Vue SFC templates, HTML, and JSX. Per our [Option Philosophy](https://prettier.io/docs/en/option-philosophy.html), we would prefer not to add such an option. However, there are many users who want this feature, and major style guides like [Airbnb’s JavaScript Style Guide](https://github.com/airbnb/javascript/blob/274c8d570155a05b016980294d4204c5711bce86/packages/eslint-config-airbnb/rules/react.js#L97-L99) and [Vue’s style guide](https://vuejs.org/style-guide/rules-strongly-recommended.html#multi-attribute-elements) recommend the single attribute per line style. A [PR](https://github.com/prettier/prettier/pull/6644) to add this feature was opened in October 2019, and both it and the [corresponding issue](https://github.com/prettier/prettier/issues/5501) have received a significant amount of support from users. For us it was a hard decision to add this option. We hope the addition of this option will benefit many users without significantly harming our principles.
|
||||
This release includes a new `singleAttributePerLine` option. This is an option to print only one attribute per line in Vue SFC templates, HTML, and JSX. Per our [Option Philosophy](https://prettier.io/docs/option-philosophy), we would prefer not to add such an option. However, there are many users who want this feature, and major style guides like [Airbnb’s JavaScript Style Guide](https://github.com/airbnb/javascript/blob/274c8d570155a05b016980294d4204c5711bce86/packages/eslint-config-airbnb/rules/react.js#L97-L99) and [Vue’s style guide](https://vuejs.org/style-guide/rules-strongly-recommended.html#multi-attribute-elements) recommend the single attribute per line style. A [PR](https://github.com/prettier/prettier/pull/6644) to add this feature was opened in October 2019, and both it and the [corresponding issue](https://github.com/prettier/prettier/issues/5501) have received a significant amount of support from users. For us it was a hard decision to add this option. We hope the addition of this option will benefit many users without significantly harming our principles.
|
||||
|
||||
We've also added support formatting for some new JavaScript syntax proposals via Babel.
|
||||
|
||||
@@ -305,7 +305,7 @@ class Foo extends /** @type {Type} */ (Bar) {}
|
||||
|
||||
The Stage 3 proposal for [Unicode Set Notation](https://github.com/tc39/proposal-regexp-set-notation/) in regular expressions is now supported via [Babel 7.17.0](https://babeljs.io/blog/2022/02/02/7.17.0).
|
||||
|
||||
See [the release blog post of Babel v7.17.0](https://babeljs.io/blog/2022/02/02/7.17.0#regexp-set-notation-and-properties-of-strings-14125httpsgithubcombabelbabelpull14125) and [the README of this proposal](https://github.com/tc39/proposal-regexp-set-notation/) for details. Also keep in mind our [policy on non-standardized syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax) before using this proposed syntax feature with Prettier.
|
||||
See [the release blog post of Babel v7.17.0](https://babeljs.io/blog/2022/02/02/7.17.0#regexp-set-notation-and-properties-of-strings-14125httpsgithubcombabelbabelpull14125) and [the README of this proposal](https://github.com/tc39/proposal-regexp-set-notation/) for details. Also keep in mind our [policy on non-standardized syntax](https://prettier.io/docs/rationale#disclaimer-about-non-standard-syntax) before using this proposed syntax feature with Prettier.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
@@ -400,7 +400,7 @@ type Props =
|
||||
|
||||
#### Add support for destructuring of private fields ([#12276](https://github.com/prettier/prettier/pull/12276) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
|
||||
The Stage 2 TC39 proposal for [destructuring of private fields](https://github.com/tc39/proposal-destructuring-private) is now supported via [Babel 7.17](https://babeljs.io/blog/2022/02/02/7.17.0). Please read our [policy on non-standardized syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax) before you decide to use this proposed syntax feature with Prettier.
|
||||
The Stage 2 TC39 proposal for [destructuring of private fields](https://github.com/tc39/proposal-destructuring-private) is now supported via [Babel 7.17](https://babeljs.io/blog/2022/02/02/7.17.0). Please read our [policy on non-standardized syntax](https://prettier.io/docs/rationale#disclaimer-about-non-standard-syntax) before you decide to use this proposed syntax feature with Prettier.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
@@ -416,7 +416,7 @@ class Foo {
|
||||
|
||||
#### Support decorator auto accessors syntax ([#12299](https://github.com/prettier/prettier/pull/12299) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
|
||||
Support auto accessors syntax that is introduced in [new decorators proposal](https://github.com/tc39/proposal-decorators). Please read our [policy on non-standardized syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax) before you decide to use this proposed syntax feature with Prettier.
|
||||
Support auto accessors syntax that is introduced in [new decorators proposal](https://github.com/tc39/proposal-decorators). Please read our [policy on non-standardized syntax](https://prettier.io/docs/rationale#disclaimer-about-non-standard-syntax) before you decide to use this proposed syntax feature with Prettier.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
|
||||
@@ -62,7 +62,7 @@ type FirstString<T> = T extends [infer S extends string, ...unknown[]]
|
||||
|
||||
Two new CLI options have been added for a caching system similar to [ESLint's one](https://eslint.org/docs/user-guide/command-line-interface#caching).
|
||||
|
||||
Please see [the doc](https://prettier.io/docs/en/cli.html#--cache) for more details.
|
||||
Please see [the doc](https://prettier.io/docs/cli#--cache) for more details.
|
||||
|
||||
##### `--cache`
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ incididunt` ut labore et dolore magna aliqua.
|
||||
|
||||
#### Improve MDX range ignore support ([#12208](https://github.com/prettier/prettier/pull/12208) by [@nickrttn](https://github.com/nickrttn))
|
||||
|
||||
Adds support for using Markdown [range ignore](https://prettier.io/docs/en/ignore.html#range-ignore) directives in MDX, using JSX comments.
|
||||
Adds support for using Markdown [range ignore](https://prettier.io/docs/ignore#range-ignore) directives in MDX, using JSX comments.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```mdx
|
||||
|
||||
@@ -130,9 +130,9 @@ In this sentence, if you break the line between “3” and “분”, a space w
|
||||
|
||||
#### Support plugins with async parsers ([#12748](https://github.com/prettier/prettier/pull/12748) by [@fisker](https://github.com/fisker), [#13211](https://github.com/prettier/prettier/pull/13211) by [@thorn0](https://github.com/thorn0) and [@fisker](https://github.com/fisker))
|
||||
|
||||
[`parse` function](https://prettier.io/docs/en/plugins.html#parsers) in a plugin can return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) now.
|
||||
[`parse` function](https://prettier.io/docs/plugins#parsers) in a plugin can return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) now.
|
||||
|
||||
In order to support async parsers for embedded languages, we had to introduce a breaking change to the plugin API. Namely, the `embed` method of a printer has now to match a completely new signature, incompatible with previous versions. If you're a plugin author and your plugins don't define `embed`, you have nothing to worry about, otherwise see the [docs](https://prettier.io/docs/en/plugins.html#optional-embed) for details.
|
||||
In order to support async parsers for embedded languages, we had to introduce a breaking change to the plugin API. Namely, the `embed` method of a printer has now to match a completely new signature, incompatible with previous versions. If you're a plugin author and your plugins don't define `embed`, you have nothing to worry about, otherwise see the [docs](https://prettier.io/docs/plugins#optional-embed) for details.
|
||||
|
||||
Also, the `preprocess` method of a printer can return a promise now.
|
||||
|
||||
@@ -154,7 +154,7 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
**[Shareable config package](https://prettier.io/docs/en/configuration.html#sharing-configurations) can also be a pure ESM package.**
|
||||
**[Shareable config package](https://prettier.io/docs/configuration#sharing-configurations) can also be a pure ESM package.**
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
@@ -511,7 +511,7 @@ The `label` doc builder has been changed. See the [documentation](https://github
|
||||
|
||||
#### `getFileInfo()` resolves config by default ([#14108](https://github.com/prettier/prettier/pull/14108) by [@fisker](https://github.com/fisker))
|
||||
|
||||
`options.resolveConfig` default to `true` now, see the [documentation](https://prettier.io/docs/en/api.html#prettiergetfileinfofilepath--options).
|
||||
`options.resolveConfig` default to `true` now, see the [documentation](https://prettier.io/docs/api#prettiergetfileinfofilepath--options).
|
||||
|
||||
#### Plugin search feature has been removed ([#14759](https://github.com/prettier/prettier/pull/14759) by [@fisker](https://github.com/fisker))
|
||||
|
||||
@@ -519,7 +519,7 @@ The plugin auto search feature didn't work well when using pnpm, and cause slown
|
||||
|
||||
`--plugin-search-dir`, `--no-plugin-search` flags for CLI and `pluginSearchDirs` in API options has been removed in Prettier 3.0.
|
||||
|
||||
`--plugin` flag and `plugins` option should be used instead, see [documentation](https://prettier.io/docs/en/plugins.html#using-plugins).
|
||||
`--plugin` flag and `plugins` option should be used instead, see [documentation](https://prettier.io/docs/plugins#using-plugins).
|
||||
|
||||
### CLI
|
||||
|
||||
@@ -848,7 +848,7 @@ foo(/* HTML */ `
|
||||
|
||||
The Stage 2 proposal ["Explicit Resource Management"](https://github.com/tc39/proposal-explicit-resource-management/) is now supported via Babel [7.20.0](https://babeljs.io/blog/2022/10/27/7.20.0) and [7.22.0](https://babeljs.io/blog/2023/05/26/7.22.0).
|
||||
|
||||
Also keep in mind our [policy on non-standardized syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax) before using this proposed syntax feature with Prettier.
|
||||
Also keep in mind our [policy on non-standardized syntax](https://prettier.io/docs/rationale#disclaimer-about-non-standard-syntax) before using this proposed syntax feature with Prettier.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
@@ -866,7 +866,7 @@ Also keep in mind our [policy on non-standardized syntax](https://prettier.io/do
|
||||
|
||||
#### Add support for "Import Reflection" proposal ([#13771](https://github.com/prettier/prettier/pull/13771) by [@fisker](https://github.com/fisker))
|
||||
|
||||
The Stage 2 proposal ["Import Reflection"](https://github.com/tc39/proposal-import-reflection) is now supported via Babel 7.20.0. Also keep in mind our [policy on non-standardized syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax) before using this proposed syntax feature with Prettier.
|
||||
The Stage 2 proposal ["Import Reflection"](https://github.com/tc39/proposal-import-reflection) is now supported via Babel 7.20.0. Also keep in mind our [policy on non-standardized syntax](https://prettier.io/docs/rationale#disclaimer-about-non-standard-syntax) before using this proposed syntax feature with Prettier.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
@@ -2036,7 +2036,7 @@ Add type definition files required to use Prettier's JavaScript API from TypeScr
|
||||
|
||||
Use `prettier.util.isNextLineEmpty` instead.
|
||||
|
||||
See the [documentation](https://prettier.io/docs/en/plugins.html#utility-functions) for details.
|
||||
See the [documentation](https://prettier.io/docs/plugins#utility-functions) for details.
|
||||
|
||||
#### Fix plugin loading cache ([#14576](https://github.com/prettier/prettier/pull/14576) by [@fisker](https://github.com/fisker))
|
||||
|
||||
|
||||
@@ -598,7 +598,7 @@ The semi-voiced sound mark now keeps attached to the hiragana "け".
|
||||
|
||||
#### Accept `URL` in `prettier.{resolveConfig,resolveConfigFile,getFileInfo}()` ([#15332](https://github.com/prettier/prettier/pull/15332), [#15354](https://github.com/prettier/prettier/pull/15354), [#15360](https://github.com/prettier/prettier/pull/15360), [#15364](https://github.com/prettier/prettier/pull/15364) by [@fisker](https://github.com/fisker))
|
||||
|
||||
[`prettier.resolveConfig()`](https://prettier.io/docs/en/api#prettierresolveconfigfileurlorpath--options), [`prettier.resolveConfigFile()`](https://prettier.io/docs/en/api#prettierresolveconfigfilefileurlorpath), and [`prettier.getFileInfo()`](https://prettier.io/docs/en/api#prettiergetfileinfofileurlorpath--options) now accepts an [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) with `file:` protocol or a url string starts with `file://`.
|
||||
[`prettier.resolveConfig()`](https://prettier.io/docs/api#prettierresolveconfigfileurlorpath--options), [`prettier.resolveConfigFile()`](https://prettier.io/docs/api#prettierresolveconfigfilefileurlorpath), and [`prettier.getFileInfo()`](https://prettier.io/docs/api#prettiergetfileinfofileurlorpath--options) now accepts an [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) with `file:` protocol or a url string starts with `file://`.
|
||||
|
||||
```js
|
||||
// `URL`
|
||||
|
||||
@@ -45,7 +45,7 @@ Prettier's CLI works roughly like in the diagram above:
|
||||
2. We need to actually find all the files to execute this action on.
|
||||
3. We need to resolve `.gitignore` and `.prettierignore` files, to figure out if some of those files are to be ignored.
|
||||
4. We need to resolve `.editorconfig` files, for [EditorConfig](https://editorconfig.org)-specific formatting configurations for those files.
|
||||
5. We need to resolve `.prettierrc` files, and [~10 more](https://prettier.io/docs/en/configuration), for Prettier-specific formatting configurations for those files.
|
||||
5. We need to resolve `.prettierrc` files, and [~10 more](https://prettier.io/docs/configuration), for Prettier-specific formatting configurations for those files.
|
||||
6. We need to check if each of the files matches its formatting configuration.
|
||||
7. Finally we need to output some kind of result to the terminal.
|
||||
|
||||
@@ -156,7 +156,7 @@ It's basically an identical situation to what we had for EditorConfig-specific c
|
||||
|
||||
The main aspects to consider here for the future are, in my opinion:
|
||||
|
||||
1. A large number of [different configuration files](https://prettier.io/docs/en/configuration) are supported. In Babel's monorepo this translates to ~150k lookups in the object of known paths we created in the first step, which while not super expensive it's not free either. If this number could be reduced by a lot it would speed things up a bit.
|
||||
1. A large number of [different configuration files](https://prettier.io/docs/configuration) are supported. In Babel's monorepo this translates to ~150k lookups in the object of known paths we created in the first step, which while not super expensive it's not free either. If this number could be reduced by a lot it would speed things up a bit.
|
||||
2. Also some of the parsers required to parse those configuration files are relatively expensive, the [`json5`](https://npmjs.com/package/json5) parser requires ~100x as much code as the smallest [JSONC](https://code.visualstudio.com/docs/languages/json) (JSON with Comments) parser that I know of for JavaScript, while being in some cases ~50x slower at parsing also. If fewer formats could be supported the CLI would be leaner as a result.
|
||||
3. If we could check just once if a file named for example `.prettierrc.json5` got found anywhere in the repo we could reduce the number of checks for these configuration files by an order of magnitude, because if no file with that name was found anywhere in the repo then we don't need to ask each of Babel's ~13k folders if they have it. The list of all known file names is another piece of valuable information that the glob library we are using could give us for free.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ The new added `jsonc` parser:
|
||||
|
||||
- Always quote the object keys.
|
||||
- Wrap strings with double quotes.
|
||||
- Of course, respect the [`trailingComma`](https://prettier.io/docs/en/options#trailing-commas) option.
|
||||
- Of course, respect the [`trailingComma`](https://prettier.io/docs/options#trailing-commas) option.
|
||||
|
||||
### Angular
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ After discussing this internally, the Prettier team concluded that removing usel
|
||||
|
||||
This change disables the removal of useless escape characters in string literals across all languages supported by Prettier. To keep the previous behavior, we recommend using ESLint rules like [`no-useless-escape`](https://eslint.org/docs/latest/rules/no-useless-escape).
|
||||
|
||||
Escaped quotes (e.g. `"\"\'"`) may get unescaped when changing between different quotes. This is explained on the [Rationale](https://prettier.io/docs/en/rationale.html#strings) page of the official documentation.
|
||||
Escaped quotes (e.g. `"\"\'"`) may get unescaped when changing between different quotes. This is explained on the [Rationale](https://prettier.io/docs/rationale#strings) page of the official documentation.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
@@ -107,7 +107,7 @@ const str = "\a";
|
||||
- `DecimalLiteral` - The [Decimal proposal](https://github.com/tc39/proposal-decimal) decided not to introduce new syntax. The `decimal` plugin will be removed from Babel 8.
|
||||
- `importReflection` - The "Import Reflection" proposal has been renamed to ["Source Phase Imports"](https://github.com/tc39/proposal-source-phase-imports)
|
||||
|
||||
- [Disclaimer about non-standard syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax)
|
||||
- [Disclaimer about non-standard syntax](https://prettier.io/docs/rationale#disclaimer-about-non-standard-syntax)
|
||||
|
||||
### TypeScript
|
||||
|
||||
@@ -792,7 +792,7 @@ For performance reason, `prettier.doc.printDocToString` used to mutate `.parts`
|
||||
|
||||
This change makes the internal `getPreferredQuote` function a part of the public API.
|
||||
|
||||
In languages like JavaScript, both single quotes and double quotes can be used for string literals. Prettier determines the quote to enclose a string literal based on the number of quotes within the string and the value of the [`singleQuote`](https://prettier.io/docs/en/options#quotes) option. For more details, please refer to the [Rationale](https://prettier.io/docs/en/rationale.html#strings) page.
|
||||
In languages like JavaScript, both single quotes and double quotes can be used for string literals. Prettier determines the quote to enclose a string literal based on the number of quotes within the string and the value of the [`singleQuote`](https://prettier.io/docs/options#quotes) option. For more details, please refer to the [Rationale](https://prettier.io/docs/rationale#strings) page.
|
||||
|
||||
The `getPreferredQuote` function determines the appropriate quote to enclose a string literal and has the following interface:
|
||||
|
||||
@@ -825,7 +825,7 @@ Making this function public will benefit plugin developers. Since the function i
|
||||
|
||||
#### Fix loading ESM-style shared config file in Node.js 23 ([#16857](https://github.com/prettier/prettier/pull/16857) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
|
||||
In Prettier 3.3, attempting to load an ESM-style [shared config file](https://prettier.io/docs/en/sharing-configurations) in Node.js 23 resulted in the following warnings, preventing the options from being loaded:
|
||||
In Prettier 3.3, attempting to load an ESM-style [shared config file](https://prettier.io/docs/sharing-configurations) in Node.js 23 resulted in the following warnings, preventing the options from being loaded:
|
||||
|
||||
```
|
||||
[warn] Ignored unknown option { __esModule: true }.
|
||||
|
||||
@@ -377,7 +377,7 @@ The first symbol between 60 and 100 in the above example is U+FF5E FULLWIDTH TIL
|
||||
|
||||
However, since it's just a Bun feature and not supported by Node.js, it can only work when running Prettier with Bun.
|
||||
|
||||
Important note: Prettier uses [`json-stringify` parser](https://prettier.io/docs/en/options#parser) to format `package.json` file by default, to support formatting `package.json` file with JSONC syntax, you need override the parser option
|
||||
Important note: Prettier uses [`json-stringify` parser](https://prettier.io/docs/options#parser) to format `package.json` file by default, to support formatting `package.json` file with JSONC syntax, you need override the parser option
|
||||
|
||||
```js
|
||||
export default {
|
||||
@@ -392,7 +392,7 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
If you can't upgrade Prettier for some reason, you can still use JSONC syntax in `package.json`, but don't put your `prettier` config in it, you'll have to use another [configuration file](https://prettier.io/docs/en/configuration).
|
||||
If you can't upgrade Prettier for some reason, you can still use JSONC syntax in `package.json`, but don't put your `prettier` config in it, you'll have to use another [configuration file](https://prettier.io/docs/configuration).
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
|
||||
@@ -34,4 +34,4 @@
|
||||
- image: /images/editors/editor_webstorm.svg
|
||||
name: WebStorm
|
||||
content: |
|
||||
[Built-in support](https://prettier.io/docs/en/webstorm.html)
|
||||
[Built-in support](https://prettier.io/docs/webstorm)
|
||||
@@ -34,7 +34,7 @@
|
||||
image: /images/languages/tools_yaml.svg
|
||||
variants: []
|
||||
- name: Community Plugins
|
||||
nameLink: ./docs/en/plugins.html#community-plugins
|
||||
nameLink: ./docs/plugins#community-plugins
|
||||
image: /images/languages/tools_wip.svg
|
||||
variants:
|
||||
- "[Apex](https://github.com/dangmai/prettier-plugin-apex)"
|
||||
|
||||
@@ -58,7 +58,7 @@ JS (ES Modules):
|
||||
// prettier.config.js, .prettierrc.js, prettier.config.mjs, or .prettierrc.mjs
|
||||
|
||||
/**
|
||||
* @see https://prettier.io/docs/en/configuration.html
|
||||
* @see https://prettier.io/docs/configuration
|
||||
* @type {import("prettier").Config}
|
||||
*/
|
||||
const config = {
|
||||
@@ -77,7 +77,7 @@ JS (CommonJS):
|
||||
// prettier.config.js, .prettierrc.js, prettier.config.cjs, or .prettierrc.cjs
|
||||
|
||||
/**
|
||||
* @see https://prettier.io/docs/en/configuration.html
|
||||
* @see https://prettier.io/docs/configuration
|
||||
* @type {import("prettier").Config}
|
||||
*/
|
||||
const config = {
|
||||
|
||||
@@ -191,4 +191,4 @@ For one-off commands, when you want to exclude some files without adding them to
|
||||
prettier . "!**/*.{js,jsx,vue}" --write
|
||||
```
|
||||
|
||||
See [fast-glob](https://prettier.io/docs/en/cli.html#file-patterns) to learn more about advanced glob syntax.
|
||||
See [fast-glob](https://prettier.io/docs/cli#file-patterns) to learn more about advanced glob syntax.
|
||||
@@ -146,7 +146,7 @@ Print trailing commas wherever possible in multi-line comma-separated syntactic
|
||||
|
||||
Valid options:
|
||||
|
||||
- `"all"` - Trailing commas wherever possible (including [function parameters and calls](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#Trailing_commas_in_functions)). To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or [downlevel compilation](https://babeljs.io/docs/en/index). This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018).
|
||||
- `"all"` - Trailing commas wherever possible (including [function parameters and calls](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#Trailing_commas_in_functions)). To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or [downlevel compilation](https://babeljs.io/docs/index). This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018).
|
||||
- `"es5"` - Trailing commas where valid in ES5 (objects, arrays, etc.). Trailing commas in type parameters in TypeScript and Flow.
|
||||
- `"none"` - No trailing commas.
|
||||
|
||||
@@ -314,7 +314,7 @@ Valid options:
|
||||
- `"css"` (via [postcss](https://github.com/postcss/postcss)) _First available in v1.7.1_
|
||||
- `"scss"` (via [postcss-scss](https://github.com/postcss/postcss-scss)) _First available in v1.7.1_
|
||||
- `"less"` (via [postcss-less](https://github.com/shellscape/postcss-less)) _First available in v1.7.1_
|
||||
- `"json"` (via [@babel/parser parseExpression](https://babeljs.io/docs/en/next/babel-parser.html#babelparserparseexpressioncode-options)) _First available in v1.5.0_
|
||||
- `"json"` (via [@babel/parser parseExpression](https://babeljs.io/docs/babel-parser#babelparserparseexpressioncode-options)) _First available in v1.5.0_
|
||||
- `"json5"` (same parser as `"json"`, but outputs as [json5](https://json5.org/)) _First available in v1.13.0_
|
||||
- `"jsonc"` (same parser as `"json"`, but outputs as "JSON with Comments") _First available in v3.2.0_
|
||||
- `"json-stringify"` (same parser as `"json"`, but outputs like `JSON.stringify`) _First available in v1.13.0_
|
||||
|
||||
Reference in new issue
Block a user