Clean changelog
This commit is contained in:
1 parent
adf67577ee
commit
266344398c
92 files changed
-2010
No files matched your search
@@ -1,28 +0,0 @@
|
||||
#### Update `@angular/compiler` to v14 (#13609 by @fisker)
|
||||
|
||||
- Support shorthand object
|
||||
- [Drop support for quote expressions](https://github.com/angular/angular/pull/44915)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<div [input]="{a, b : 2 }"></div>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
Error: Cannot find front char /:/ from index 0 in "{a, b : 2 }"
|
||||
|
||||
<!-- Prettier main -->
|
||||
<div [input]="{ a, b: 2 }"></div>
|
||||
```
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<a [href]="http://google.com">Click me</a>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<a [href]="http: //google.com">Click me</a>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<div [href]="http://google.com"></div>
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Fix parentheses with nullish coalescing operator (#14216 by @thron0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<img [src]="(x && y) ?? z" />
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<img [src]="x && y ?? z" />
|
||||
|
||||
<!-- Prettier main -->
|
||||
<img [src]="(x && y) ?? z" />
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Support computed optional chaining (#14658 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<img [src]=" a?.[0]" />
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<img [src]=" a?.[0]" />
|
||||
|
||||
<!-- Prettier main -->
|
||||
<img [src]="a?.[0]" />
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Remove space after pipe name (#14961 by @waterplea)
|
||||
|
||||
We introduced [a new format for pipe in Prettier 2.8](https://prettier.io/blog/2022/11/23/2.8.0.html#insert-spaces-in-pipe-13100httpsgithubcomprettierprettierpull13100-by-sosukesuzukihttpsgithubcomsosukesuzuki), but this was not accepted by the community.
|
||||
|
||||
Therefore, we are introducing a new format that reflects community input.
|
||||
|
||||
For more information on the discussion, please see https://github.com/prettier/prettier/issues/13887.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<my-component
|
||||
[value]="value | transform: arg1 : arg2 | format: arg3 : arg4"
|
||||
></my-component>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<my-component
|
||||
[value]="value | transform : arg1 : arg2 | format : arg3 : arg4"
|
||||
></my-component>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<my-component
|
||||
[value]="value | transform: arg1 : arg2 | format: arg3 : arg4"
|
||||
></my-component>
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
#### [BREAKING] Drop support for Node.js 10 and 12 (#11830 by @fisker, #13118 by @sosukesuzuki)
|
||||
|
||||
The minimal required Node.js version is v14
|
||||
@@ -1,13 +0,0 @@
|
||||
#### [BREAKING] Change public APIs to asynchronous (#12574, #12788, #12790, #13265 by @fisker)
|
||||
|
||||
- `prettier.format()` returns `Promise<string>`
|
||||
- `prettier.formatWithCursor()` returns `Promise<{formatted: string, cursorOffset: number}>`
|
||||
- `prettier.formatAST()` returns `Promise<string>`
|
||||
- `prettier.check()` returns `Promise<boolean>`
|
||||
- `prettier.getSupportInfo()` returns `Promise`
|
||||
- `prettier.clearConfigCache()` returns `Promise<void>`
|
||||
- `prettier.resolveConfig.sync` is removed
|
||||
- `prettier.resolveConfigFile.sync` is removed
|
||||
- `prettier.getFileInfo.sync` is removed
|
||||
|
||||
If you still need sync APIs, you can try [`@prettier/sync`](https://github.com/prettier/prettier-synchronized)
|
||||
@@ -1,61 +0,0 @@
|
||||
#### [BREAKING] npm package file structures changed (#12740 by @fisker, #13530 by @fisker, #14570 by @fisker)
|
||||
|
||||
File structures changes:
|
||||
|
||||
- `bin-prettier.js` -> `bin/prettier.cjs`
|
||||
- `esm/standalone.mjs` -> `standalone.mjs`
|
||||
- `esm/parser-angular.mjs` -> `plugins/angular.mjs`
|
||||
- `parser-angular.js` -> `plugins/angular.js`
|
||||
- `esm/parser-babel.mjs` -> `plugins/babel.mjs`
|
||||
- `parser-babel.js` -> `plugins/babel.js`
|
||||
- `esm/parser-espree.mjs` -> `plugins/acorn-and-espree.mjs`
|
||||
- `parser-espree.js` -> `plugins/acorn.js`\
|
||||
global object renamed `prettierPlugins.espree` -> `prettierPlugins.acorn`
|
||||
- `esm/parser-flow.mjs` -> `plugins/flow.mjs`
|
||||
- `parser-flow.js` -> `plugins/flow.js`
|
||||
- `esm/parser-glimmer.mjs` -> `plugins/glimmer.mjs`
|
||||
- `parser-glimmer.js` -> `plugins/glimmer.js`
|
||||
- `esm/parser-graphql.mjs` -> `plugins/graphql.mjs`
|
||||
- `parser-graphql.js` -> `plugins/graphql.js`
|
||||
- `esm/parser-html.mjs` -> `plugins/html.mjs`
|
||||
- `parser-html.js` -> `plugins/html.js`
|
||||
- `esm/parser-markdown.mjs` -> `plugins/markdown.mjs`
|
||||
- `parser-markdown.js` -> `plugins/markdown.js`
|
||||
- `esm/parser-meriyah.mjs` -> `plugins/meriyah.mjs`
|
||||
- `parser-meriyah.js` -> `plugins/meriyah.js`
|
||||
- `esm/parser-postcss.mjs` -> `plugins/postcss.mjs`
|
||||
- `parser-postcss.js` -> `plugins/postcss.js`
|
||||
- `esm/parser-typescript.mjs` -> `plugins/typescript.mjs`
|
||||
- `parser-typescript.js` -> `plugins/typescript.js`
|
||||
- `esm/parser-yaml.mjs` -> `plugins/yaml.mjs`
|
||||
- `parser-yaml.js` -> `plugins/yaml.js`
|
||||
|
||||
Check full list on <https://unpkg.com/browse/prettier@3.0.0/>.
|
||||
|
||||
A new plugin has been added:
|
||||
|
||||
- `plugins/estree.mjs` (ESM version)
|
||||
- `plugins/estree.js` (UMD version)
|
||||
|
||||
If you use standalone version, this plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
|
||||
|
||||
```diff
|
||||
import { format } from "prettier/standalone";
|
||||
- import prettierPluginBabel from "prettier/parser-babel";
|
||||
+ import * as prettierPluginBabel from "prettier/plugins/babel";
|
||||
+ import * as prettierPluginEstree from "prettier/plugins/estree";
|
||||
|
||||
console.log(
|
||||
- format(code, {
|
||||
+ await format(code, {
|
||||
parser: "babel",
|
||||
- plugins: [prettierPluginBabel],
|
||||
+ plugins: [prettierPluginBabel, prettierPluginEstree],
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
```diff
|
||||
- node ./node_modules/prettier/bin-prettier.js . --write
|
||||
+ node ./node_modules/prettier/bin/prettier.cjs . --write
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
#### [HIGHLIGHT] Support plugins with async parsers (#12748 by @fisker, #13211 by @thorn0 and @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.
|
||||
|
||||
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](/docs/plugins.html#optional-embed) for details.
|
||||
|
||||
Also, the `preprocess` method of a printer can return a promise now.
|
||||
@@ -1,19 +0,0 @@
|
||||
#### [HIGHLIGHT]Support config files in ESM (#13130 by @fisker)
|
||||
|
||||
Config files in ESM are supported, supported config file names:
|
||||
|
||||
- `prettier.config.js` (in place with `{"type": "module"}` in `package.json`)
|
||||
- `.prettierrc.js` (same as above)
|
||||
- `prettier.config.mjs`
|
||||
- `.prettierrc.mjs`.
|
||||
|
||||
```js
|
||||
export default {
|
||||
trailingComma: "es5",
|
||||
tabWidth: 4,
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
};
|
||||
```
|
||||
|
||||
**[Shareable config package](https://prettier.io/docs/en/configuration.html#sharing-configurations) can also be a pure ESM package.**
|
||||
@@ -1,15 +0,0 @@
|
||||
#### [BREAKING] Support plugins in ESM (#13201 by @fisker)
|
||||
|
||||
Since v3.0.0, we load plugins via `import()` instead of `require()`, plugins can be ESM modules now.
|
||||
|
||||
If you use `--plugin` by directory path, or file path without extensions, the plugin may not able to load.
|
||||
|
||||
```diff
|
||||
- prettier . --plugin=path/to/my-plugin-directory
|
||||
+ prettier . --plugin=path/to/my-plugin-directory/index.js
|
||||
```
|
||||
|
||||
```diff
|
||||
- prettier . --plugin=path/to/my-plugin-file
|
||||
+ prettier . --plugin=path/to/my-plugin-file.js
|
||||
```
|
||||
@@ -1,11 +0,0 @@
|
||||
#### [BREAKING] Update `prettier.doc` (#13203, #14456 by @fisker)
|
||||
|
||||
`prettier.doc.builders.concat` [was deprecated in v2.3.0](https://prettier.io/blog/2021/05/09/2.3.0.html#use-arrays-instead-of-concat-9733httpsgithubcomprettierprettierpull9733-by-fiskerhttpsgithubcomfisker-thorn0httpsgithubcomthorn0), now it's removed.
|
||||
|
||||
The following apis are never documented, they mean to only use internally, now they are removed.
|
||||
|
||||
- `prettier.doc.utils.getDocParts`
|
||||
- `prettier.doc.utils.propagateBreaks`
|
||||
- `prettier.doc.utils.cleanDoc`
|
||||
- `prettier.doc.utils.getDocType`
|
||||
- `prettier.doc.debug.printDocToDebug`
|
||||
@@ -1,5 +0,0 @@
|
||||
#### [BREAKING] `textToDoc` trims trailing hard lines (#13220 by @fisker)
|
||||
|
||||
Previously, in all core languages, after embedded code printed to `Doc`, we call `prettier.doc.utils.stripTrailingHardline()` to remove the trailing hard lines.
|
||||
|
||||
We believe make `textToDoc` return docs without trailing hard lines makes the plugins easier to do `embed` print.
|
||||
@@ -1,3 +0,0 @@
|
||||
#### [BREAKING] Removed support for custom parser api (#13250 by @fisker and @thorn0)
|
||||
|
||||
Before [plugins](/docs/en/plugins.html) were a thing, Prettier had a similar but more limited feature called custom parsers. It’s been removed in v3.0.0 as its functionality was a subset of what the Plugin API did. If you used it, please check [how to migrate](/docs/en/api.html#custom-parser-api).
|
||||
@@ -1,61 +0,0 @@
|
||||
#### [BREAKING] The second argument `parsers` passed to `parsers.parse` has been removed (#13268 by @fisker)
|
||||
|
||||
The plugin's `print` function signature changed from
|
||||
|
||||
```ts
|
||||
function parse(text: string, parsers: object, options: object): AST;
|
||||
```
|
||||
|
||||
to
|
||||
|
||||
```ts
|
||||
function parse(text: string, options: object): Promise<AST> | AST;
|
||||
```
|
||||
|
||||
The second argument `parsers` has been removed, if you still need other parser during parse process, you can:
|
||||
|
||||
1. Import the plugin yourself (recommended)
|
||||
|
||||
```js
|
||||
import * as pluginBabel from "prettier/plugins/babel";
|
||||
|
||||
const myCustomPlugin = {
|
||||
parsers: {
|
||||
"my-custom-parser": {
|
||||
async parse(text) {
|
||||
const ast = await pluginBabel.parsers.babel.parse(text);
|
||||
ast.program.body[0].expression.callee.name = "_";
|
||||
return ast;
|
||||
},
|
||||
astFormat: "estree",
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
1. Get the parser from the `options` argument
|
||||
|
||||
```js
|
||||
function getParserFromOptions(options, parserName) {
|
||||
const parserOrParserInitFunction = options.plugins.find(
|
||||
(plugin) => plugin.parsers && Object.hasOwn(plugin.parsers, parserName),
|
||||
)?.parsers[parserName];
|
||||
return typeof parserOrParserInitFunction === "function"
|
||||
? parserOrParserInitFunction()
|
||||
: parserOrParserInitFunction;
|
||||
}
|
||||
|
||||
const myCustomPlugin = {
|
||||
parsers: {
|
||||
"my-custom-parser": {
|
||||
async parse(text, options) {
|
||||
const babelParser = await getParserFromOptions(options, "babel");
|
||||
const ast = await babelParser.parse(text);
|
||||
ast.program.body[0].expression.callee.name = "_";
|
||||
return ast;
|
||||
},
|
||||
astFormat: "estree",
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### [BREAKING] `undefined` and `null` are not passed to plugin's `print` function (#13397 by @fisker)
|
||||
|
||||
If your plugin happened to use `print` to print them, please check them in the parent node instead.
|
||||
|
||||
```diff
|
||||
function print(path, print) {
|
||||
- const value = path.getValue();
|
||||
- if (!value?.type) {
|
||||
- return String(value);
|
||||
- }
|
||||
|
||||
- return path.map(print, "values");
|
||||
|
||||
+ return path.map(({node}) => (node?.type ? print() : String(node)), "values");
|
||||
}
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
#### [BREAKING] Allow using arbitrary truthy values for `label` docs (#13532 by @thorn0)
|
||||
|
||||
The `label` doc builder has been changed. See the [documentation](https://github.com/prettier/prettier/blob/main/commands.md#label).
|
||||
@@ -1,3 +0,0 @@
|
||||
#### [BREAKING] `getFileInfo()` resolves config by default (#14108 by @fisker)
|
||||
|
||||
`options.resolveConfig` default to `true` now, see the [documentation](https://prettier.io/docs/en/api.html#prettiergetfileinfofilepath--options).
|
||||
@@ -1,3 +0,0 @@
|
||||
#### Add `.d.ts` files (#14212 by @sosukesuzuki, @fisker)
|
||||
|
||||
Add type definition files required to use Prettier's JavaScript API from TypeScript. This eliminates the need for users to install `@types/prettier`.
|
||||
@@ -1,65 +0,0 @@
|
||||
#### Update `prettier.util` (#14317, #14320 by @fisker)
|
||||
|
||||
- Added `prettier.util.getNextNonSpaceNonCommentCharacter`
|
||||
- Changed `prettier.util.getNextNonSpaceNonCommentCharacter`
|
||||
|
||||
Signature changed from
|
||||
|
||||
```ts
|
||||
function getNextNonSpaceNonCommentCharacterIndex<N>(
|
||||
text: string,
|
||||
node: N,
|
||||
locEnd: (node: N) => number,
|
||||
): number | false;
|
||||
```
|
||||
|
||||
to
|
||||
|
||||
```ts
|
||||
function getNextNonSpaceNonCommentCharacterIndex(
|
||||
text: string,
|
||||
startIndex: number,
|
||||
): number | false;
|
||||
```
|
||||
|
||||
- Changed `prettier.util.isPreviousLineEmpty`
|
||||
|
||||
Signature changed from
|
||||
|
||||
```ts
|
||||
function isPreviousLineEmpty<N>(
|
||||
text: string,
|
||||
node: N,
|
||||
locStart: (node: N) => number,
|
||||
): boolean;
|
||||
```
|
||||
|
||||
to
|
||||
|
||||
```ts
|
||||
function isPreviousLineEmpty(text: string, startIndex: number): boolean;
|
||||
```
|
||||
|
||||
- Changed `prettier.util.isNextLineEmpty`
|
||||
|
||||
Signature changed from
|
||||
|
||||
```ts
|
||||
function isNextLineEmpty<N>(
|
||||
text: string,
|
||||
node: N,
|
||||
locEnd: (node: N) => number,
|
||||
): boolean;
|
||||
```
|
||||
|
||||
to
|
||||
|
||||
```ts
|
||||
function isNextLineEmpty(text: string, startIndex: number): boolean;
|
||||
```
|
||||
|
||||
- Deprecated `prettier.util.isNextLineEmptyAfterIndex`
|
||||
|
||||
Use `prettier.util.isNextLineEmpty` instead.
|
||||
|
||||
See the [documentation](https://prettier.io/docs/en/plugins.html#utility-functions) for details.
|
||||
@@ -1,3 +0,0 @@
|
||||
#### Fix plugin loading cache (#14576 by @fisker)
|
||||
|
||||
Plugin instances are incorrectly memoized, check this [issue](https://github.com/prettier/prettier/issues/13235) for details.
|
||||
@@ -1,12 +0,0 @@
|
||||
#### Stop formatting unknown code with `babel` parser (#14718 by @fisker)
|
||||
|
||||
```console
|
||||
await prettier.format("foo")
|
||||
|
||||
// Prettier stable
|
||||
No parser and no filepath given, using 'babel' the parser now but this will throw an error in the future. Please specify a parser or a filepath so one can be inferred.
|
||||
'foo;\n'
|
||||
|
||||
// Prettier main
|
||||
UndefinedParserError: No parser and no file path given, couldn't infer a parser.
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
#### [BREAKING] plugin search feature has been removed (#14759 by @fisker)
|
||||
|
||||
The plugin auto search feature didn't work well when using pnpm, and cause slowness.
|
||||
|
||||
`--plugin-search-dir`, `--no-plugin-search` flags for CLI and `pluginSearchDirs` in API options has been removed in Prettier main.
|
||||
|
||||
`--plugin` flag and `plugins` option should be used instead, see [documentation](https://prettier.io/docs/en/plugins.html#using-plugins).
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
author: "Sosuke Suzuki (@sosukesuzuki)"
|
||||
authorURL: "https://github.com/sosukesuzuki"
|
||||
title: "Prettier 3.0: Hello, ECMAScript Modules!"
|
||||
---
|
||||
|
||||
We are excited to announce the release of the new version of Prettier!
|
||||
|
||||
We have made the migration to using ECMAScript Modules for all our source code. This change has significantly improved the development experience for the Prettier team. Please rest assured that when using Prettier as a library, you can still use it as CommonJS as well.
|
||||
|
||||
This update comes with several breaking changes. One notable example is the alteration in markdown formatting - spaces are no longer inserted between Latin characters and Chinese or Japanese characters. We'd like to extend our gratitude to [Tatsunori Uchino](https://github.com/tats-u), who has made significant contributions to Prettier over the past year, particularly with this feature. Additionally, the default value of `trailingComma` has been changed to `"all"`.
|
||||
|
||||
Another important change in this release is the significant overhaul of the plugin interface. Prettier now supports plugins written using ECMAScript Modules and async parsers. If you're a plugin developer, please exercise caution while updating. You can find [the migration guide](https://github.com/prettier/prettier/wiki/How-to-migrate-my-plugin-to-support-Prettier-v3%3F) here. As always, we welcome bug reports and feedback!
|
||||
|
||||
This release also includes numerous formatting improvements and bug fixes.
|
||||
|
||||
If you appreciate Prettier and would like to support our work, please consider sponsoring us directly via [our OpenCollective](https://opencollective.com/prettier) or by sponsoring the projects we depend on, such as [typescript-eslint](https://opencollective.com/typescript-eslint), [remark](https://opencollective.com/unified), and [Babel](https://opencollective.com/babel). Thank you for your continued support!
|
||||
@@ -1,7 +0,0 @@
|
||||
#### Updated failure message to be more informative (#11369 by @webark)
|
||||
|
||||
Updated the "Forgot to run Prettier?" to "Run Prettier to fix."
|
||||
|
||||
This keeps the same spirit of the message, but is less likely to be
|
||||
misinterpreted as it's a more formal message rather than being
|
||||
somewhat familial.
|
||||
@@ -1,10 +0,0 @@
|
||||
#### Change `--loglevel` to `--log-level` (#13204 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```sh
|
||||
# Prettier stable
|
||||
prettier test.js --loglevel=debug
|
||||
|
||||
# Prettier main
|
||||
prettier test.js --log-level=debug
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
#### Accept multiple `--ignore-path` (#14332 by @fisker)
|
||||
|
||||
You can now pass multiple `--ignore-path`.
|
||||
|
||||
```console
|
||||
prettier . --ignore-path=.prettier-ignore --ignore-path=.eslintignore
|
||||
```
|
||||
@@ -1,18 +0,0 @@
|
||||
#### Display posix style paths on Windows (#14333 by @fisker)
|
||||
|
||||
Align with other tools like ESLint and Stylelint.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Prettier stable
|
||||
Checking formatting...
|
||||
[warn] src\utils\create-get-visitor-keys.js
|
||||
[warn] src\utils\unexpected-node-error.js
|
||||
[warn] Code style issues found in 2 files. Forgot to run Prettier?
|
||||
|
||||
// Prettier main
|
||||
Checking formatting...
|
||||
[warn] src/utils/create-get-visitor-keys.js
|
||||
[warn] src/utils/unexpected-node-error.js
|
||||
[warn] Code style issues found in 2 files. Forgot to run Prettier?
|
||||
```
|
||||
@@ -1,6 +0,0 @@
|
||||
#### Don’t expand globs via symbolic links (#14627 by @andersk)
|
||||
|
||||
Prettier no longer follows symbolic links while expanding command line
|
||||
arguments. This avoids problems in many scenarios such as symlinks
|
||||
outside the source tree, symlinks to ignored files, and cycles of
|
||||
symlinks.
|
||||
@@ -1,8 +0,0 @@
|
||||
#### [BREAKING] Ignore `.gitignore`d files by default (#14731 by @fisker)
|
||||
|
||||
Prettier ignores files ignored by `.gitignore` by default.
|
||||
If you want the old behavior(only ignore files ignored by `.prettierignore`), use
|
||||
|
||||
```console
|
||||
prettier . --write --ignore-path=.prettierignore
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
#### Print line breaking after file path with errors (#14788 by @sosukesuzuki)
|
||||
|
||||
Previously, only the `--write` option printed a newline before the error, but other options and no options print a newline as well.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```sh
|
||||
# Input
|
||||
prettier ./test.js
|
||||
|
||||
# Prettier stable
|
||||
test.js[error] test.js: SyntaxError: Unexpected token: ')' (1:6)
|
||||
[error] > 1 | 1 (+-) hoge
|
||||
[error] | ^
|
||||
|
||||
# Prettier main
|
||||
test.js
|
||||
[error] test.js: SyntaxError: Unexpected token: ')' (1:6)
|
||||
[error] > 1 | 1 (+-) hoge
|
||||
[error] |
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### Clear filename before print ignored file code to screen (#14794 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```sh
|
||||
# Input
|
||||
echo test.js > .prettierignore
|
||||
echo code > test.js
|
||||
prettier ./test.js
|
||||
|
||||
# Prettier stable
|
||||
test.jscode
|
||||
|
||||
# Prettier main
|
||||
code
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Keep trailing-comma for `var` function (#13402 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
/* Input */
|
||||
.foo {
|
||||
--bar: var(--baz,);
|
||||
}
|
||||
|
||||
/* Prettier stable */
|
||||
.foo {
|
||||
--bar: var(--baz);
|
||||
}
|
||||
|
||||
/* Prettier main */
|
||||
.foo {
|
||||
--bar: var(--baz,);
|
||||
}
|
||||
```
|
||||
@@ -1,23 +0,0 @@
|
||||
#### Fix line break in CSS declaration with comma (#14208 by @mvorisek)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
// Input
|
||||
.myclass {
|
||||
box-shadow:
|
||||
inset 0 0 10px #555,
|
||||
0 0 20px black;
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
.myclass {
|
||||
box-shadow: inset 0 0 10px #555, 0 0 20px black;
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
.myclass {
|
||||
box-shadow:
|
||||
inset 0 0 10px #555,
|
||||
0 0 20px black;
|
||||
}
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Fix url contains comma (#14476 by @seiyab)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
/* Input */
|
||||
@font-face {
|
||||
src: url(RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght.ttf);
|
||||
}
|
||||
|
||||
/* Prettier stable */
|
||||
@font-face {
|
||||
src: url(RobotoFlex-VariableFont_GRADXTRAYOPQYTASYTDEYTFIYTLCYTUCopszslntwdthwght.ttf);
|
||||
}
|
||||
|
||||
/* Prettier main */
|
||||
@font-face {
|
||||
src: url(RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght.ttf);
|
||||
}
|
||||
```
|
||||
@@ -1,41 +0,0 @@
|
||||
#### [BREAKING] Add the pure `css` parser (#7933, #9092, #9093 by @fisker)
|
||||
|
||||
Previously, when `--parser=css` was passed, Prettier tried to parse the content using `postcss-scss` and `postcss-less`. This caused confusion, and made syntax errors difficult to spot. Now `--parser=css` works only with the vanilla CSS syntax.
|
||||
|
||||
_If you use `parser="css"` for your `.less`/`.scss` files, update it to the correct parser or remove the `parser` option to let Prettier auto-detect the parser by the file extension._
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```less
|
||||
/* Input */
|
||||
/* Less Syntax with `--parser=css` */
|
||||
a {.bordered();}
|
||||
|
||||
/* Prettier stable */
|
||||
/* Less Syntax with `--parser=css` */
|
||||
a {
|
||||
.bordered();
|
||||
}
|
||||
|
||||
/* Prettier main */
|
||||
SyntaxError: (postcss) CssSyntaxError Unknown word (2:4)
|
||||
1 | /* Less Syntax with `--parser=css` */
|
||||
> 2 | a {.bordered();}
|
||||
```
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```scss
|
||||
/* Input */
|
||||
/* Scss Syntax with `--parser=css` */
|
||||
::before {content: #{$foo}}
|
||||
|
||||
/* Prettier stable */
|
||||
/* Scss Syntax with `--parser=css` */
|
||||
::before {
|
||||
content: #{$foo};
|
||||
}
|
||||
|
||||
/* Prettier main */
|
||||
SyntaxError: (postcss) CssSyntaxError Unknown word (2:22)
|
||||
1 | /* Scss Syntax with `--parser=css` */
|
||||
> 2 | ::before {content: #{$foo}}
|
||||
```
|
||||
@@ -1,42 +0,0 @@
|
||||
#### Improve custom properties format (#9209 by @fisker)
|
||||
|
||||
Thanks to [`PostCSS 8.0`](https://github.com/postcss/postcss/releases/tag/8.0.0), we can handle these edge cases on custom properties.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
/* Input */
|
||||
:root {
|
||||
--empty: ;
|
||||
--JSON: [1, "2", {"three": {"a":1}}, [4]];
|
||||
--javascript: function(rule) { console.log(rule) };
|
||||
}
|
||||
|
||||
@supports (--element(".minwidth", { "minWidth": 300 })) {
|
||||
[--self] {
|
||||
background: greenyellow;
|
||||
}
|
||||
}
|
||||
|
||||
/* Prettier stable */
|
||||
SyntaxError: (postcss) CssSyntaxError Missed semicolon (3:20)
|
||||
1 | :root {
|
||||
2 | --empty: ;
|
||||
> 3 | --JSON: [1, "2", {"three": {"a":1}}, [4]];
|
||||
| ^
|
||||
4 | --javascript: function(rule) { console.log(rule) };
|
||||
5 | }
|
||||
6 |
|
||||
|
||||
/* Prettier main */
|
||||
:root {
|
||||
--empty: ;
|
||||
--JSON: [1, "2", {"three": {"a": 1}}, [4]];
|
||||
--javascript: function(rule) {console.log(rule)};
|
||||
}
|
||||
|
||||
@supports (--element(".minwidth", {"minWidth": 300})) {
|
||||
[--self] {
|
||||
background: greenyellow;
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
#### An object type in a `declare function` signature now breaks before the return type (#13396 by @thorn0)
|
||||
|
||||
This behavior has been unified with how TypeScript is formatted.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
declare function bla (props: { a: boolean, b: string, c: number }): Promise<Array<foo>>
|
||||
|
||||
// Prettier stable
|
||||
declare function bla(props: { a: boolean, b: string, c: number }): Promise<
|
||||
Array<foo>
|
||||
>;
|
||||
|
||||
// Prettier main
|
||||
declare function bla(props: {
|
||||
a: boolean;
|
||||
b: string;
|
||||
c: number;
|
||||
}): Promise<Array<foo>>;
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
#### [BREAKING] Remove support for Flow comments (#13687, #13703 by @thorn0)
|
||||
|
||||
Being a kind of preprocessor, [Flow comments](https://flow.org/blog/2015/02/20/Flow-Comments/) AKA [comment types](https://flow.org/en/docs/types/comments/) are processed on the token level and can't be represented in an AST in the general case. Flow builds the AST as if these special comment tokens didn't exist. Example:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
/*:: if */ (x) + y;
|
||||
```
|
||||
|
||||
This is parsed as `if (x) +y;` by Flow and as `x + y;` by JS parsers that don't support Flow.
|
||||
|
||||
Previously, for some special cases, Prettier tried to detect that this syntax was used and to preserve it. As an attempt to solve an unsolvable problem, this limited support was fragile and riddled with bugs, so it has been removed. Now if the `parser` option is set to `flow` or `babel-flow`, Flow comments will be parsed and reprinted like normal code. If a parser that doesn't support Flow is used, they will be treated like usual comments.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
let a /*: foo */ = b;
|
||||
|
||||
// Prettier stable
|
||||
let a /*: foo */ = b;
|
||||
|
||||
// Prettier main with --parser flow
|
||||
let a: foo = b;
|
||||
|
||||
// Prettier main with --parser babel
|
||||
let a /*: foo */ = b;
|
||||
```
|
||||
@@ -1,40 +0,0 @@
|
||||
#### [BREAKING] Print trailing comma in type parameters and tuple types when `--trailing-comma=es5` (#14086, #14085 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
type Foo = [
|
||||
{
|
||||
from: string,
|
||||
to: string,
|
||||
}, // <- 1
|
||||
];
|
||||
type Foo = Promise<
|
||||
| { ok: true, bar: string, baz: SomeOtherLongType }
|
||||
| { ok: false, bar: SomeOtherLongType }, // <- 2
|
||||
>;
|
||||
|
||||
// Prettier stable
|
||||
type Foo = [
|
||||
{
|
||||
from: string,
|
||||
to: string,
|
||||
} // <- 1
|
||||
];
|
||||
type Foo = Promise<
|
||||
| { ok: true, bar: string, baz: SomeOtherLongType }
|
||||
| { ok: false, bar: SomeOtherLongType } // <- 2
|
||||
>;
|
||||
|
||||
// Prettier main
|
||||
type Foo = [
|
||||
{
|
||||
from: string,
|
||||
to: string,
|
||||
}, // <- 1
|
||||
];
|
||||
type Foo = Promise<
|
||||
| { ok: true, bar: string, baz: SomeOtherLongType }
|
||||
| { ok: false, bar: SomeOtherLongType }, // <- 2
|
||||
>;
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
#### Support conditional type and infer type (#14573 by @SamChou19815)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
type TestReturnType<T extends (...args: any[]) => any> = T extends (...args: any[]) => infer R ? R : any;
|
||||
|
||||
// Prettier stable
|
||||
// Does not parse
|
||||
|
||||
// Prettier main
|
||||
type TestReturnType<T extends (...args: any[]) => any> = T extends (
|
||||
...args: any[]
|
||||
) => infer R
|
||||
? R
|
||||
: any;
|
||||
```
|
||||
@@ -1,12 +0,0 @@
|
||||
#### Support Mapped Types and keyof (#14619 by @jbrown215)
|
||||
|
||||
```jsx
|
||||
// Input
|
||||
type Mapped = {[key in keyof O]:number};
|
||||
|
||||
// Prettier stable
|
||||
// Does not parse
|
||||
|
||||
// Prettier main
|
||||
type Mapped = { [key in keyof O]: number };
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### Support type guards (#14767 by @panagosg7)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
function isString (x: mixed): x is string { return typeof x === "string"; }
|
||||
|
||||
// Prettier stable
|
||||
// Does not parse
|
||||
|
||||
// Prettier main
|
||||
function isString(x: mixed): x is string {
|
||||
return typeof x === 'string';
|
||||
}
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### [BREAKING] Drop support for "comma separated interfaces" syntax (#12835 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```graphql
|
||||
# Input
|
||||
type Type1 implements A, B {a: a}
|
||||
|
||||
# Prettier stable
|
||||
type Type1 implements A, B {
|
||||
a: a
|
||||
}
|
||||
|
||||
# Prettier main
|
||||
SyntaxError: Syntax Error: Unexpected Name "B". (1:26)
|
||||
> 1 | type Type1 implements A, B {a: a}
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
#### Update angular-html-parser (#13578 by @thorn0)
|
||||
|
||||
Prettier's fork of Angular's HTML parser was synced with the upstream.
|
||||
@@ -1,38 +0,0 @@
|
||||
#### Format `<script>` inside SVG (#14400 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<script>
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded', () => {
|
||||
const element = document.getElementById('foo')
|
||||
if (element) {
|
||||
element.fillStyle = 'currentColor'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</svg>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<script>
|
||||
document.addEventListener( 'DOMContentLoaded', () => { const element =
|
||||
document.getElementById('foo') if (element) { element.fillStyle =
|
||||
'currentColor' } });
|
||||
</script>
|
||||
</svg>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const element = document.getElementById("foo");
|
||||
if (element) {
|
||||
element.fillStyle = "currentColor";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</svg>
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
#### Recognize `<search>` element (#14615 by @fisker)
|
||||
|
||||
HTML spec added [`<search>` element](https://html.spec.whatwg.org/multipage/grouping-content.html#the-search-element).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<SEARCH title="Website">
|
||||
...
|
||||
</SEARCH>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<SEARCH title="Website"> ... </SEARCH>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<search title="Website">...</search>
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Print HTML5 `doctype` in lowercase (#7391 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<!DocType html>
|
||||
<html><head></head><body></body></html>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head></head>
|
||||
<body></body>
|
||||
</html>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head></head>
|
||||
<body></body>
|
||||
</html>
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
#### Support the "decorated function" pattern (#10714 by @thorn0)
|
||||
|
||||
In this case the developer is usually willing to sacrifice the readability of the arrow function's signature to get less indentation in its body. Prettier now recognizes this pattern and keeps the arrow function hugged even if the signature breaks.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Prettier stable
|
||||
const Counter = decorator("my-counter")(
|
||||
(props: { initialCount?: number; label?: string }) => {
|
||||
// ...
|
||||
}
|
||||
);
|
||||
|
||||
// Prettier main
|
||||
const Counter = decorator("my-counter")((props: {
|
||||
initialCount?: number;
|
||||
label?: string;
|
||||
}) => {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
#### [BREAKING] Change the default value for `trailingComma` to `all` (#11479 by @fisker, #13143 by @sosukesuzuki)
|
||||
|
||||
Since version 2.0. we've changed the default value for `trailingComma` to `es5`.
|
||||
|
||||
[Internet Explorer, the last browser to not allow trailing commas in function calls, has been unsupported on June 15, 2022.](https://docs.microsoft.com/en-us/lifecycle/announcements/internet-explorer-11-end-of-support) Accordingly, change the default value for `trailingComma` to `all`.
|
||||
|
||||
If the old behavior is still preferred, please configure Prettier with `{ "trailingComma": "es5" }`.
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Fix cursor positioning for files containing emoji (#13340 by @fisker)
|
||||
|
||||
```console
|
||||
$ cat test.js
|
||||
const { formatWithCursor } = await import("prettier");
|
||||
const code = "'😀😀😀😀'";
|
||||
await formatWithCursor(code, {parser: "babel", cursorOffset: 9})
|
||||
|
||||
# Prettier stable
|
||||
$ node test.js
|
||||
{ formatted: '"😀😀😀😀";\n', cursorOffset: 5, comments: [] }
|
||||
|
||||
# Prettier main
|
||||
$ node test.js
|
||||
{ formatted: '"😀😀😀😀";\n', cursorOffset: 9, comments: [] }
|
||||
```
|
||||
@@ -1,68 +0,0 @@
|
||||
#### Fix edge cases of the first call argument expansion (#13341 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
export default whatever(function (a: {
|
||||
aaaaaaaaa: string;
|
||||
bbbbbbbbb: string;
|
||||
ccccccccc: string;
|
||||
}) {
|
||||
return null;
|
||||
}, "xyz");
|
||||
|
||||
call(
|
||||
function() {
|
||||
return 1;
|
||||
},
|
||||
$var ?? $var ?? $var ?? $var ?? $var ?? $var ?? $var ?? $var ?? $var ?? 'test'
|
||||
);
|
||||
|
||||
// Prettier stable
|
||||
export default whatever(function (a: {
|
||||
aaaaaaaaa: string;
|
||||
bbbbbbbbb: string;
|
||||
ccccccccc: string;
|
||||
}) {
|
||||
return null;
|
||||
},
|
||||
"xyz");
|
||||
|
||||
call(function () {
|
||||
return 1;
|
||||
}, $var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
"test");
|
||||
|
||||
// Prettier main
|
||||
export default whatever(function (a: {
|
||||
aaaaaaaaa: string,
|
||||
bbbbbbbbb: string,
|
||||
ccccccccc: string,
|
||||
}) {
|
||||
return null;
|
||||
}, "xyz");
|
||||
|
||||
call(
|
||||
function () {
|
||||
return 1;
|
||||
},
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
$var ??
|
||||
"test",
|
||||
);
|
||||
```
|
||||
@@ -1,33 +0,0 @@
|
||||
#### Fix indentation of arrow function chains in call arguments and binary expressions (#13391 by @thorn0)
|
||||
|
||||
The motivation behind the chosen formatting is to make it clear how many arguments the call has.
|
||||
However, there was a bug with the indentation of the first signature in the chain if that signature didn't fit on one line.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Prettier stable
|
||||
askTrovenaBeenaDependsRowans(
|
||||
glimseGlyphsHazardNoopsTieTie,
|
||||
(
|
||||
averredBathersBoxroomBuggyNurl,
|
||||
anodyneCondosMalateOverateRetinol = "default"
|
||||
) =>
|
||||
(annularCooeedSplicesWalksWayWay) =>
|
||||
(kochabCooieGameOnOboleUnweave) =>
|
||||
abugidicRomanocastorProvider,
|
||||
weaponizedStellatedOctahedron
|
||||
);
|
||||
|
||||
// Prettier main
|
||||
askTrovenaBeenaDependsRowans(
|
||||
glimseGlyphsHazardNoopsTieTie,
|
||||
(
|
||||
averredBathersBoxroomBuggyNurl,
|
||||
anodyneCondosMalateOverateRetinol = "default",
|
||||
) =>
|
||||
(annularCooeedSplicesWalksWayWay) =>
|
||||
(kochabCooieGameOnOboleUnweave) =>
|
||||
abugidicRomanocastorProvider,
|
||||
weaponizedStellatedOctahedron,
|
||||
);
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Don't break signature of hugged function expression if parameters are identifiers without types (#13410 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Prettier stable
|
||||
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
|
||||
props,
|
||||
ref
|
||||
) {
|
||||
return <ThemeUILink ref={ref} variant="default" {...props} />;
|
||||
});
|
||||
|
||||
// Prettier main
|
||||
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
||||
function Link(props, ref) {
|
||||
return <ThemeUILink ref={ref} variant="default" {...props} />;
|
||||
},
|
||||
);
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Fix interleaved comments (#13438 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
function x() {
|
||||
} // first
|
||||
; // second
|
||||
|
||||
// Prettier stable
|
||||
function x() {} // first // second
|
||||
|
||||
// Prettier main
|
||||
function x() {} // first
|
||||
// second
|
||||
```
|
||||
@@ -1,60 +0,0 @@
|
||||
#### Support nestled JSDoc comments (#13445 by @thorn0)
|
||||
|
||||
This kind of comments is used to document overloaded functions (see https://github.com/jsdoc/jsdoc/issues/1017).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
/**
|
||||
* @template T
|
||||
* @param {Type} type
|
||||
* @param {T} value
|
||||
* @return {Value}
|
||||
*//**
|
||||
* @param {Type} type
|
||||
* @return {Value}
|
||||
*/
|
||||
function value(type, value) {
|
||||
if (arguments.length === 2) {
|
||||
return new ConcreteValue(type, value);
|
||||
} else {
|
||||
return new Value(type);
|
||||
}
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
/**
|
||||
* @template T
|
||||
* @param {Type} type
|
||||
* @param {T} value
|
||||
* @return {Value}
|
||||
*/ /**
|
||||
* @param {Type} type
|
||||
* @return {Value}
|
||||
*/
|
||||
function value(type, value) {
|
||||
if (arguments.length === 2) {
|
||||
return new ConcreteValue(type, value);
|
||||
} else {
|
||||
return new Value(type);
|
||||
}
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
/**
|
||||
* @template T
|
||||
* @param {Type} type
|
||||
* @param {T} value
|
||||
* @return {Value}
|
||||
*//**
|
||||
* @param {Type} type
|
||||
* @return {Value}
|
||||
*/
|
||||
function value(type, value) {
|
||||
if (arguments.length === 2) {
|
||||
return new ConcreteValue(type, value);
|
||||
} else {
|
||||
return new Value(type);
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,32 +0,0 @@
|
||||
#### Fix unstable template literals with embedded languages (#13532 by @thorn0)
|
||||
|
||||
If a template literal with embedded syntax is the only argument of a call or the body of an arrow function and has leading and trailing whitespace, it won't be printed on a new line.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
foo(/* HTML */ ` <!-- bar1 --> bar <!-- bar2 --> `);
|
||||
|
||||
// Prettier stable (first output)
|
||||
foo(
|
||||
/* HTML */ `
|
||||
<!-- bar1 -->
|
||||
bar
|
||||
<!-- bar2 -->
|
||||
`
|
||||
);
|
||||
|
||||
// Prettier stable (second output)
|
||||
foo(/* HTML */ `
|
||||
<!-- bar1 -->
|
||||
bar
|
||||
<!-- bar2 -->
|
||||
`);
|
||||
|
||||
// Prettier main (first output)
|
||||
foo(/* HTML */ `
|
||||
<!-- bar1 -->
|
||||
bar
|
||||
<!-- bar2 -->
|
||||
`);
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
#### Fix indention of expressions in template literals (#13621 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
`
|
||||
1. Go to ${chalk.green.underline(FOO_LINK)}
|
||||
2. Click "${chalk.green(
|
||||
"Run workflow"
|
||||
)}" button, type "${chalk.yellow.underline(
|
||||
version
|
||||
)}", hit the "${chalk.bgGreen("Run workflow")}" button.
|
||||
`
|
||||
|
||||
// Prettier stable
|
||||
`
|
||||
1. Go to ${chalk.green.underline(FOO_LINK)}
|
||||
2. Click "${chalk.green(
|
||||
"Run workflow"
|
||||
)}" button, type "${chalk.yellow.underline(
|
||||
version
|
||||
)}", hit the "${chalk.bgGreen("Run workflow")}" button.
|
||||
`;
|
||||
|
||||
// Prettier main
|
||||
`
|
||||
1. Go to ${chalk.green.underline(FOO_LINK)}
|
||||
2. Click "${chalk.green(
|
||||
"Run workflow",
|
||||
)}" button, type "${chalk.yellow.underline(
|
||||
version,
|
||||
)}", hit the "${chalk.bgGreen("Run workflow")}" button.
|
||||
`;
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Add support for "Explicit Resource Management" proposal (#13752 by @fisker, #14862 by @sosukesuzuki)
|
||||
|
||||
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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Examples
|
||||
{
|
||||
using obj = g(); // block-scoped declaration
|
||||
const r = obj.next();
|
||||
} // calls finally blocks in `g`
|
||||
|
||||
{
|
||||
await using obj = g(); // block-scoped declaration
|
||||
const r = obj.next();
|
||||
} // calls finally blocks in `g`
|
||||
```
|
||||
@@ -1,9 +0,0 @@
|
||||
#### Add support for "Import Reflection" proposal (#13771 by @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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Examples
|
||||
import module x from "<specifier>";
|
||||
```
|
||||
@@ -1,28 +0,0 @@
|
||||
#### Fix inconsistent between array/tuple and object/record (#14065 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
foo.a().b().c([n, o])
|
||||
foo.a().b().c(#[n, o])
|
||||
foo.a().b().c({n, o})
|
||||
foo.a().b().c(#{n, o})
|
||||
|
||||
// Prettier stable
|
||||
foo.a().b().c([n, o]);
|
||||
foo
|
||||
.a()
|
||||
.b()
|
||||
.c(#[n, o]);
|
||||
foo.a().b().c({ n, o });
|
||||
foo
|
||||
.a()
|
||||
.b()
|
||||
.c(#{ n, o });
|
||||
|
||||
// Prettier main
|
||||
foo.a().b().c([n, o]);
|
||||
foo.a().b().c(#[n, o]);
|
||||
foo.a().b().c({ n, o });
|
||||
foo.a().b().c(#{ n, o });
|
||||
```
|
||||
@@ -1,18 +0,0 @@
|
||||
#### Fix cursor tracking inside JSX Text (#14163 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Prettier stable
|
||||
formatWithCursor(
|
||||
["<>a", " <div>hi</div>", "</>"].join("\n"),
|
||||
{ cursorOffset: 3, parser: "babel" }
|
||||
).cursorOffset;
|
||||
// -> 2
|
||||
|
||||
// Prettier main
|
||||
(await formatWithCursor(
|
||||
["<>a", " <div>hi</div>", "</>"].join("\n"),
|
||||
{ cursorOffset: 3, parser: "babel" }
|
||||
)).cursorOffset;
|
||||
// -> 6
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Avoid unnecessarily indenting nested `await` expressions (#14192 by @thorn0)
|
||||
|
||||
A refinement of [this change in v2.3](https://prettier.io/blog/2021/05/09/2.3.0.html#improve-formatting-for-nested-await-expressions-in-heads-of-member-and-call-expressions-10342httpsgithubcomprettierprettierpull10342-by-thorn0httpsgithubcomthorn0). Sometimes there is no need to force indentation of nested `await` expressions.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Prettier stable
|
||||
await Promise.all(
|
||||
(
|
||||
await readdir("src")
|
||||
).map((path) => {
|
||||
import(`./${path}`);
|
||||
})
|
||||
);
|
||||
|
||||
// Prettier main
|
||||
await Promise.all(
|
||||
(await readdir("src")).map((path) => {
|
||||
import(`./${path}`);
|
||||
}),
|
||||
);
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
#### [BREAKING] Remove Flow syntax support from `babel` parser (#14314 by @fisker, @thorn0)
|
||||
|
||||
For historical reasons, Prettier used to recognize Flow syntax in JS files when the `parser` option was set to `babel` even if the file didn't include the `@flow` pragma. This support was limited and bad for performance, so it has been removed in Prettier main. Prettier with the `babel` parser still automatically switches to the Flow syntax if it finds the `@flow` pragma or the file has the `.js.flow` extension.
|
||||
@@ -1,3 +0,0 @@
|
||||
#### Support regexp modifiers proposal (#14391 by @fisker)
|
||||
|
||||
See [Regular Expression Pattern Modifiers for ECMAScript](https://github.com/tc39/proposal-regexp-modifiers).
|
||||
@@ -1,46 +0,0 @@
|
||||
#### Fix missing parentheses and semicolons around `prettier-ignore`d nodes (#14406 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
async function request(url) {
|
||||
return (
|
||||
// prettier-ignore
|
||||
await fetch(url)
|
||||
).json()
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
async function request(url) {
|
||||
return (
|
||||
// prettier-ignore
|
||||
await fetch(url).json()
|
||||
);
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
async function request(url) {
|
||||
return (
|
||||
// prettier-ignore
|
||||
(await fetch(url)).json()
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
foo();
|
||||
// prettier-ignore
|
||||
[bar, baz].forEach(console.log)
|
||||
|
||||
// Prettier stable (--no-semi)
|
||||
foo()
|
||||
// prettier-ignore
|
||||
[bar, baz].forEach(console.log)
|
||||
|
||||
// Prettier main
|
||||
foo()
|
||||
// prettier-ignore
|
||||
;[bar, baz].forEach(console.log)
|
||||
```
|
||||
@@ -1,23 +0,0 @@
|
||||
#### Remove unnecessary parentheses around class expression (#14409 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
call(
|
||||
@dec class {}
|
||||
);
|
||||
|
||||
// Prettier stable
|
||||
call(
|
||||
(
|
||||
@dec
|
||||
class {}
|
||||
)
|
||||
);
|
||||
|
||||
// Prettier main
|
||||
call(
|
||||
@dec
|
||||
class {},
|
||||
);
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Add parentheses to head of `ExpressionStatement` instead of the whole statement (#14599 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const isArray = (object) => ({}).toString.call(foo) === "[object Array]";
|
||||
|
||||
// Prettier stable
|
||||
const isArray = (object) => ({}.toString.call(foo) === "[object Array]");
|
||||
|
||||
// Prettier main
|
||||
const isArray = (object) => ({}).toString.call(foo) === "[object Array]";
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Improve consistency between curried and non-curried arrow function (#14633 by @seiyab, @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
Y(() => a ? b : c);
|
||||
Y(() => () => a ? b : c);
|
||||
|
||||
// Prettier stable
|
||||
Y(() => (a ? b : c));
|
||||
Y(() => () => a ? b : c);
|
||||
|
||||
// Prettier main
|
||||
Y(() => (a ? b : c));
|
||||
Y(() => () => (a ? b : c));
|
||||
```
|
||||
@@ -1,24 +0,0 @@
|
||||
#### Fix empty line check between array elements (#14736 by @solarized-fox)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
[
|
||||
(a = b),
|
||||
|
||||
c // comment
|
||||
]
|
||||
|
||||
// Prettier stable
|
||||
[
|
||||
(a = b),
|
||||
c, // comment
|
||||
];
|
||||
|
||||
// Prettier main
|
||||
[
|
||||
(a = b),
|
||||
|
||||
c, // comment
|
||||
];
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Support trailing comments in function parameters for all param types (#14835 by @pieterv)
|
||||
|
||||
Support function parameter trailing comments for `RestElement`, `ArrayPattern` and `ObjectPattern` parameter node types.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
function Foo(
|
||||
...bar
|
||||
// Trailing comment
|
||||
) {}
|
||||
|
||||
// Prettier stable
|
||||
function Foo(...bar) // Trailing comment
|
||||
{}
|
||||
|
||||
// Prettier main
|
||||
function Foo(
|
||||
...bar
|
||||
// Trailing comment
|
||||
) {}
|
||||
```
|
||||
@@ -1,9 +0,0 @@
|
||||
#### Support Import Attributes (#14861, #14863 by @sosukesuzuki)
|
||||
|
||||
Support [Import Attributes](https://github.com/tc39/proposal-import-attributes) proposal.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
import json from "./foo.json" with { type: "json" };
|
||||
import("./foo.json", { with: { type: "json" } });
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Fix interpolation parse error (#11343 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```less
|
||||
// Input
|
||||
@{selector}-title{ @{prop}-size: @{color} }
|
||||
|
||||
// Prettier stable
|
||||
SyntaxError: CssSyntaxError: Unknown word (1:20)
|
||||
> 1 | @{selector}-title{ @{prop}-size: @{color} }
|
||||
|
||||
// Prettier main
|
||||
@{selector}-title {
|
||||
@{prop}-size: @{color};
|
||||
}
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
#### Keep inline JavaScript code as it is (#14109 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```less
|
||||
// Input
|
||||
.calcPxMixin() {
|
||||
@functions: ~`(function() {
|
||||
const designWidth = 3840
|
||||
const actualWidth = 5760
|
||||
this.calcPx = function(_) {
|
||||
return _ * actualWidth / designWidth + 'px'
|
||||
}
|
||||
})()`;
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
.calcPxMixin() {
|
||||
@functions: ~`(
|
||||
function() {const designWidth = 3840 const actualWidth = 5760 this.calcPx =
|
||||
function(_) {return _ * actualWidth / designWidth + "px"}}
|
||||
)
|
||||
() `;
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
<Same as input>
|
||||
```
|
||||
@@ -1,104 +0,0 @@
|
||||
#### [HIGHLIGHT] Improve handling of whitespace for Chinese, Japanese, and Korean (#11597 by @tats-u)
|
||||
|
||||
##### Stop inserting spaces between Chinese or Japanese and Western characters
|
||||
|
||||
Previously, Prettier would insert spaces between Chinese or Japanese and Western characters (letters and digits). While some people prefer this style, it isn’t standard, and is in fact contrary to official guidelines. Please see [here](https://github.com/tats-u/prettier-plugin-md-nocjsp#why-this-plugin-is-needed) for more details. We decided it’s not Prettier’s job to enforce a particular style in this case, so spaces aren’t inserted anymore, while existing ones are preserved. If you need a tool for enforcing spacing style, consider [textlint-ja](https://github.com/textlint-ja/textlint-rule-preset-ja-spacing/tree/master/packages/textlint-rule-ja-space-between-half-and-full-width) or [lint-md](https://github.com/lint-md/lint-md) (rules `space-round-alphabet` and `space-round-number`).
|
||||
|
||||
The tricky part of this change were ambiguous line breaks between Chinese or Japanese and Western characters. When Prettier unwraps text, it needs to decide whether such a line break should be simply removed or replaced with a space. For that Prettier examines the surrounding text and infers the preferred style.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
漢字
|
||||
Alphabetsひらがな12345カタカナ67890
|
||||
|
||||
漢字 Alphabets ひらがな 12345 カタカナ 67890
|
||||
|
||||
<!-- Prettier stable -->
|
||||
漢字 Alphabets ひらがな 12345 カタカナ 67890
|
||||
|
||||
漢字 Alphabets ひらがな 12345 カタカナ 67890
|
||||
|
||||
<!-- Prettier main -->
|
||||
漢字Alphabetsひらがな12345カタカナ67890
|
||||
|
||||
漢字 Alphabets ひらがな 12345 カタカナ 67890
|
||||
```
|
||||
|
||||
##### Comply to line breaking rules in Chinese and Japanese
|
||||
|
||||
There are rules that prohibit certain characters from appearing at the beginning or the end of a line in [Chinese](https://www.w3.org/TR/clreq/#prohibition_rules_for_line_start_end) and [Japanese](https://www.w3.org/TR/jlreq/#characters_not_starting_a_line). E.g., full stop characters `。`, `.`, and `.` shouldn’t start a line whereas `(` shouldn’t end a line. Prettier now follows these rules when it wraps text, that is when `proseWrap` is set to `always`.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
HTCPCPのエラー418は、ティーポットにコーヒーを淹(い)れさせようとしたときに返されるステータスコードだ。
|
||||
|
||||
<!-- Prettier stable with --prose-wrap always --print-width 8 -->
|
||||
HTCPCP の
|
||||
エラー
|
||||
418 は、
|
||||
ティーポ
|
||||
ットにコ
|
||||
ーヒーを
|
||||
淹(い)
|
||||
れさせよ
|
||||
うとした
|
||||
ときに返
|
||||
されるス
|
||||
テータス
|
||||
コードだ
|
||||
。
|
||||
|
||||
<!-- Prettier main with the same options -->
|
||||
HTCPCPの
|
||||
エラー
|
||||
418は、
|
||||
ティー
|
||||
ポットに
|
||||
コーヒー
|
||||
を淹
|
||||
(い)れ
|
||||
させよう
|
||||
としたと
|
||||
きに返さ
|
||||
れるス
|
||||
テータス
|
||||
コード
|
||||
だ。
|
||||
```
|
||||
|
||||
##### Do not break lines inside Korean words
|
||||
|
||||
Korean uses spaces to divide words, and an inappropriate division may change the meaning of a sentence:
|
||||
|
||||
- `노래를 못해요.`: I’m not good at singing.
|
||||
- `노래를 못 해요.`: I can’t sing (for some reason).
|
||||
|
||||
Previously, when `proseWrap` was set to `always`, successive Hangul characters could get split by a line break, which could later be converted to a space when the document is edited and reformatted. This doesn’t happen anymore. Korean text is now wrapped like English.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
노래를 못해요.
|
||||
|
||||
<!-- Prettier stable with --prose-wrap always --print-width 9 -->
|
||||
노래를 못
|
||||
해요.
|
||||
|
||||
<!-- Prettier stable, subsequent reformat with --prose-wrap always --print-width 80 -->
|
||||
노래를 못 해요.
|
||||
|
||||
<!-- Prettier main with --prose-wrap always --print-width 9 -->
|
||||
노래를
|
||||
못해요.
|
||||
|
||||
<!-- Prettier main, subsequent reformat with --prose-wrap always --print-width 80 -->
|
||||
노래를 못해요.
|
||||
```
|
||||
|
||||
A line break between Hangul and non-Hangul letters and digits is converted to a space when Prettier unwraps the text. Consider this example:
|
||||
|
||||
> 3분 기다려 주지.
|
||||
|
||||
In this sentence, if you break the line between “3” and “분”, a space will be inserted there when the text gets unwrapped.
|
||||
@@ -1,15 +0,0 @@
|
||||
#### Preserve multiple spaces in inline code (#13590 by @kachkaev and @thorn0)
|
||||
|
||||
Previously, multiple whitespace characters in inline code were collapsed into a single space. This is no longer happening to match [CommonMark spec](https://spec.commonmark.org/0.30/#backtick-string).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
` foo bar baz `
|
||||
|
||||
<!-- Prettier stable -->
|
||||
` foo bar baz `
|
||||
|
||||
<!-- Prettier main -->
|
||||
` foo bar baz `
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Fix formatting string value that includes escape `\` (#13487 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```scss
|
||||
/* Input */
|
||||
$description: "Lorem ipsum dolor sit \"amet\", consectetur adipiscing elit, " +
|
||||
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
|
||||
|
||||
/* Prettier stable */
|
||||
$description: 'Lorem ipsum dolor sit "amet", consectetur adipiscing elit, '+ "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
|
||||
|
||||
/* Prettier main */
|
||||
$description: 'Lorem ipsum dolor sit "amet", consectetur adipiscing elit, ' +
|
||||
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
|
||||
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Fix leading comments in mapped types with `readonly` (#13427 by @thorn0, @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
type Type = {
|
||||
// comment
|
||||
readonly [key in Foo];
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
type Type = {
|
||||
readonly // comment
|
||||
[key in Foo];
|
||||
};
|
||||
|
||||
// Prettier main
|
||||
type Type = {
|
||||
// comment
|
||||
readonly [key in Foo];
|
||||
};
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
#### Consistent dangling comments formatting for tuple types and arrays (#13608 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
type Foo = [
|
||||
// comment
|
||||
];
|
||||
const bar = [
|
||||
// comment
|
||||
];
|
||||
|
||||
// Prettier stable
|
||||
type Foo = [// comment];
|
||||
const bar = [
|
||||
// comment
|
||||
];
|
||||
|
||||
// Prettier main
|
||||
type Foo = [
|
||||
// comment
|
||||
];
|
||||
const bar = [
|
||||
// comment
|
||||
];
|
||||
|
||||
```
|
||||
@@ -1,18 +0,0 @@
|
||||
#### Fix union type should be printed in the multi-line variant when there are comments (#13860 by @PerfectPan)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
type FooBar =
|
||||
| Number // this documents the first option
|
||||
| void // this documents the second option
|
||||
;
|
||||
|
||||
// Prettier stable
|
||||
type FooBar = Number | void; // this documents the first option // this documents the second option
|
||||
|
||||
// Prettier main
|
||||
type FooBar =
|
||||
| Number // this documents the first option
|
||||
| void; // this documents the second option
|
||||
```
|
||||
@@ -1,33 +0,0 @@
|
||||
#### Improve comment print and cursor tracking around type annotation (#14171 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
let foo /* comment */ : number;
|
||||
|
||||
// Prettier stable
|
||||
let foo: /* comment */ number;
|
||||
|
||||
// Prettier main
|
||||
<Same as input>
|
||||
```
|
||||
|
||||
```js
|
||||
// Prettier stable
|
||||
prettier.formatWithCursor("let foo: number", {
|
||||
cursorOffset: 7,
|
||||
parser: "babel",
|
||||
}).cursorOffset;
|
||||
|
||||
// -> 9
|
||||
|
||||
// Prettier main
|
||||
(
|
||||
await prettier.formatWithCursor("let foo: number", {
|
||||
cursorOffset: 7,
|
||||
parser: "babel",
|
||||
})
|
||||
).cursorOffset;
|
||||
|
||||
// -> 7
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Break on TypeScript parameter properties (#14402 by @seiyab)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
class MyClass {
|
||||
constructor(
|
||||
protected x: number,
|
||||
private y: string
|
||||
) {}
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
class MyClass {
|
||||
constructor(protected x: number, private y: string) {}
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
class MyClass {
|
||||
constructor(
|
||||
protected x: number,
|
||||
private y: string,
|
||||
) {}
|
||||
}
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
#### Fix formatting of union type with single type (#14654 by @fisker and @auvred)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
type T =
|
||||
| (
|
||||
| {
|
||||
value: number
|
||||
}
|
||||
| {
|
||||
value: string
|
||||
}
|
||||
)
|
||||
|
||||
// Prettier stable
|
||||
type T =
|
||||
|
|
||||
| {
|
||||
value: number;
|
||||
}
|
||||
| {
|
||||
value: string;
|
||||
};
|
||||
|
||||
// Prettier main
|
||||
type T =
|
||||
| {
|
||||
value: number;
|
||||
}
|
||||
| {
|
||||
value: string;
|
||||
};
|
||||
```
|
||||
@@ -1,24 +0,0 @@
|
||||
#### Improve new line detection in mapped type (#14659 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
type A1 = { [A in B]:
|
||||
T}
|
||||
type A2 = {
|
||||
[A in B]:T}
|
||||
|
||||
// Prettier stable
|
||||
type A1 = {
|
||||
[A in B]: T;
|
||||
};
|
||||
type A2 = {
|
||||
[A in B]: T;
|
||||
};
|
||||
|
||||
// Prettier main
|
||||
type A1 = { [A in B]: T };
|
||||
type A2 = {
|
||||
[A in B]: T;
|
||||
};
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
#### Line breaking after `extends` in type parameters (#14672, #14858 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
export type OuterType2<
|
||||
LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLongerLongerLongerOtherType
|
||||
> = { a: 1 };
|
||||
|
||||
// Prettier stable
|
||||
export type OuterType2<
|
||||
LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLongerLongerLongerOtherType
|
||||
> = { a: 1 };
|
||||
|
||||
// Prettier main
|
||||
export type OuterType2<
|
||||
LongerLongerLongerLongerInnerType extends
|
||||
LongerLongerLongerLongerLongerLongerLongerLongerOtherType,
|
||||
> = { a: 1 };
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### Fix missing required comma in type parameters (#14688 by @fisker, @sosukesuzuki)
|
||||
|
||||
Previously, we only print trailing comma when file extension is `.tsx`, turns out `.mts`, `.cts` files requires it to parse too.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
export const unsafeCoerce = <T,>(u: unknown): T => u as T
|
||||
|
||||
// Prettier stable
|
||||
export const unsafeCoerce = <T>(u: unknown): T => u as T;
|
||||
|
||||
// Prettier main
|
||||
export const unsafeCoerce = <T,>(u: unknown): T => u as T;
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Keep parentheses around `TSInstantiationExpression` followed by a property access (#14701 by @morsko1)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
(Array<string>).a;
|
||||
(Array<string>)?.a;
|
||||
(Array<string>)[a];
|
||||
(Array<string>)?.[a];
|
||||
|
||||
// Prettier stable
|
||||
Array<string>.a;
|
||||
Array<string>?.a;
|
||||
Array<string>[a];
|
||||
Array<string>?.[a];
|
||||
|
||||
// Prettier main
|
||||
(Array<string>).a;
|
||||
(Array<string>)?.a;
|
||||
(Array<string>)[a];
|
||||
(Array<string>)?.[a];
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Fix issue with double semicolon caused by `// prettier-ignore` on a call signature line (#14830 by @ot07)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
type Foo = {
|
||||
(): void; // prettier-ignore
|
||||
second: string;
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
type Foo = {
|
||||
(): void;; // prettier-ignore
|
||||
second: string;
|
||||
};
|
||||
|
||||
// Prettier main
|
||||
type Foo = {
|
||||
(): void; // prettier-ignore
|
||||
second: string;
|
||||
};
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Ignore `htmlWhitespaceSensitivity` when formatting Vue SFC root blocks (#14401 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<docs lang=unknown></docs><docs lang=unknown></docs><!-- display: inline --><docs lang=unknown></docs><docs lang=unknown style="display: inline"></docs>
|
||||
|
||||
<!-- Prettier stable (--html-whitespace-sensitivity=strict) -->
|
||||
<docs lang="unknown"></docs>><docs lang="unknown"></docs
|
||||
><!-- display: inline --><docs lang="unknown"></docs
|
||||
>><docs lang="unknown" style="display: inline"></docs>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<docs lang="unknown"></docs>
|
||||
<docs lang="unknown"></docs>
|
||||
<!-- display: inline -->
|
||||
<docs lang="unknown"></docs>
|
||||
<docs lang="unknown" style="display: inline"></docs>
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Format TypeScript expression in attribute bindings (#14506 by @seiyab)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```vue
|
||||
<!-- Input -->
|
||||
<script lang="ts"></script>
|
||||
<template>
|
||||
<comp :foo=" (a:string)=>1"/>
|
||||
</template>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<script lang="ts"></script>
|
||||
<template>
|
||||
<comp :foo=" (a:string)=>1" />
|
||||
</template>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<script lang="ts"></script>
|
||||
<template>
|
||||
<comp :foo="(a: string) => 1" />
|
||||
</template>
|
||||
```
|
||||
@@ -1,55 +0,0 @@
|
||||
#### Fix Vue filter detection (#14542 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```vue
|
||||
<!-- Input -->
|
||||
<template>
|
||||
<div>
|
||||
{{
|
||||
fn(
|
||||
bitwise | or | operator | a_long_long_long_long_long_long_long_long_long_long_variable
|
||||
)
|
||||
| filter1
|
||||
| filter2
|
||||
| filter3
|
||||
| filter4
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<template>
|
||||
<div>
|
||||
{{
|
||||
fn(
|
||||
bitwise
|
||||
| or
|
||||
| operator
|
||||
| a_long_long_long_long_long_long_long_long_long_long_variable
|
||||
)
|
||||
| filter1
|
||||
| filter2
|
||||
| filter3
|
||||
| filter4
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<template>
|
||||
<div>
|
||||
{{
|
||||
fn(
|
||||
bitwise |
|
||||
or |
|
||||
operator |
|
||||
a_long_long_long_long_long_long_long_long_long_long_variable,
|
||||
)
|
||||
| filter1
|
||||
| filter2
|
||||
| filter3
|
||||
| filter4
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Avoid unnecessary leading semicolon (#14557 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```vue
|
||||
<!-- Input -->
|
||||
<template>
|
||||
<div @click="[foo, bar].forEach(fn => void fn())"></div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier stable (With `--no-semi` option) -->
|
||||
<template>
|
||||
<div @click=";[foo, bar].forEach((fn) => void fn())"></div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<template>
|
||||
<div @click="[foo, bar].forEach((fn) => void fn())"></div>
|
||||
</template>
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Format TS expressions when any script tag has `lang="ts"` (#14587 by @seiyab)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```vue
|
||||
<!-- Input -->
|
||||
<script></script>
|
||||
<script setup lang="ts"></script>
|
||||
<template>
|
||||
{{ (x as number).toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<script></script>
|
||||
<script setup lang="ts"></script>
|
||||
<template>
|
||||
{{ (x as number).toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<script></script>
|
||||
<script setup lang="ts"></script>
|
||||
<template>
|
||||
{{ (x as number).toFixed(2) }}
|
||||
</template>
|
||||
```
|
||||
Reference in new issue
Block a user