Merge branch 'main' into next
# Conflicts: # scripts/tools/bundle-test/package.json # scripts/tools/bundle-test/yarn.lock # src/language-js/needs-parens.js # tests/format/typescript/typeof/jsfmt.spec.js # website/package.json # website/yarn.lock
This commit is contained in:
commit
883324dbb6
12 files changed
+50
-34
No files matched your search
@@ -0,0 +1,13 @@
|
||||
#### Add parentheses for `TypeofTypeAnnotation` to improve readability (#14458 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
type A = (typeof node.children)[];
|
||||
|
||||
// Prettier stable
|
||||
type A = typeof node.children[];
|
||||
|
||||
// Prettier main
|
||||
type A = (typeof node.children)[];
|
||||
```
|
||||
+1
-1
@@ -51,7 +51,7 @@ Indent lines with tabs instead of spaces.
|
||||
|
||||
Setting `indent_style` in an [`.editorconfig` file](https://editorconfig.org/) will configure Prettier’s tab usage, unless overridden.
|
||||
|
||||
(Tabs will be used for _indentation_ but Prettier uses spaces to _align_ things, such as in ternaries.)
|
||||
(Tabs will be used for _indentation_ but Prettier uses spaces to _align_ things, such as in ternaries. This behavior is known as [SmartTabs](https://www.emacswiki.org/emacs/SmartTabs).)
|
||||
|
||||
## Semicolons
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ To turn off plugin autoloading, use `--no-plugin-search` when using Prettier CLI
|
||||
- [`prettier-plugin-properties`](https://github.com/eemeli/prettier-plugin-properties) by [**@eemeli**](https://github.com/eemeli)
|
||||
- [`prettier-plugin-sh`](https://github.com/un-ts/prettier/tree/master/packages/sh) by [**@JounQin**](https://github.com/JounQin)
|
||||
- [`prettier-plugin-sql`](https://github.com/un-ts/prettier/tree/master/packages/sql) by [**@JounQin**](https://github.com/JounQin)
|
||||
- [`prettier-plugin-sql-cst`](https://github.com/nene/prettier-plugin-sql-cst) by [**@nene**](https://github.com/nene)
|
||||
- [`prettier-plugin-solidity`](https://github.com/prettier-solidity/prettier-plugin-solidity) by [**@mattiaerre**](https://github.com/mattiaerre)
|
||||
- [`prettier-plugin-svelte`](https://github.com/UnwrittenFun/prettier-plugin-svelte) by [**@UnwrittenFun**](https://github.com/UnwrittenFun)
|
||||
- [`prettier-plugin-toml`](https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml) by [**@bd82**](https://github.com/bd82)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"webpack": "5.76.1"
|
||||
"webpack": "5.76.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node ./index.js"
|
||||
|
||||
@@ -61,7 +61,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@prettier/bundle-test@workspace:."
|
||||
dependencies:
|
||||
webpack: 5.76.1
|
||||
webpack: 5.76.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -693,9 +693,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"webpack@npm:5.76.1":
|
||||
version: 5.76.1
|
||||
resolution: "webpack@npm:5.76.1"
|
||||
"webpack@npm:5.76.2":
|
||||
version: 5.76.2
|
||||
resolution: "webpack@npm:5.76.2"
|
||||
dependencies:
|
||||
"@types/eslint-scope": ^3.7.3
|
||||
"@types/estree": ^0.0.51
|
||||
@@ -726,6 +726,6 @@ __metadata:
|
||||
optional: true
|
||||
bin:
|
||||
webpack: bin/webpack.js
|
||||
checksum: b01fe0bc2dbca0e10d290ddb0bf81e807a031de48028176e2b21afd696b4d3f25ab9accdad888ef4a1f7c7f4d41f13d5bf2395b7653fdf3e5e3dafa54e56dab2
|
||||
checksum: 86db98299a175c371031449c26077e87b33acd8f45de7f7945ed4b9b37c8ca11bc5169af9c44743efccd4d55e08042a3aa3a3bc42aff831309a0821ffbcd395e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
@@ -537,6 +537,14 @@ function needsParens(path, options) {
|
||||
(key === "objectType" && parent.type === "TSIndexedAccessType") ||
|
||||
(key === "elementType" && parent.type === "TSArrayType")
|
||||
);
|
||||
// Same as `TSTypeQuery`, but for Flow syntax
|
||||
case "TypeofTypeAnnotation":
|
||||
return (
|
||||
(key === "objectType" &&
|
||||
(parent.type === "IndexedAccessType" ||
|
||||
parent.type === "OptionalIndexedAccessType")) ||
|
||||
(key === "elementType" && parent.type === "ArrayTypeAnnotation")
|
||||
);
|
||||
case "ArrayTypeAnnotation":
|
||||
return parent.type === "NullableTypeAnnotation";
|
||||
|
||||
@@ -599,13 +607,6 @@ function needsParens(path, options) {
|
||||
case "OptionalIndexedAccessType":
|
||||
return key === "objectType" && parent.type === "IndexedAccessType";
|
||||
|
||||
case "TypeofTypeAnnotation":
|
||||
return (
|
||||
key === "objectType" &&
|
||||
(parent.type === "IndexedAccessType" ||
|
||||
parent.type === "OptionalIndexedAccessType")
|
||||
);
|
||||
|
||||
case "StringLiteral":
|
||||
case "NumericLiteral":
|
||||
case "Literal":
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
exports[`typeof.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
parsers: ["typescript", "flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
a as (typeof node.children)[number]
|
||||
a as (typeof node.children)[]
|
||||
a as ((typeof node.children)[number])[]
|
||||
a as number[(typeof node.children)]
|
||||
type A = (typeof node.children)[number];
|
||||
type B = (typeof node.children)[];
|
||||
type C = ((typeof node.children)[number])[];
|
||||
type D = number[(typeof node.children)];
|
||||
|
||||
=====================================output=====================================
|
||||
a as (typeof node.children)[number];
|
||||
a as (typeof node.children)[];
|
||||
a as (typeof node.children)[number][];
|
||||
a as number[typeof node.children];
|
||||
type A = (typeof node.children)[number];
|
||||
type B = (typeof node.children)[];
|
||||
type C = (typeof node.children)[number][];
|
||||
type D = number[typeof node.children];
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -1 +1 @@
|
||||
run_spec(import.meta, ["typescript"]);
|
||||
run_spec(import.meta, ["typescript", "flow"]);
|
||||
@@ -1,4 +1,4 @@
|
||||
a as (typeof node.children)[number]
|
||||
a as (typeof node.children)[]
|
||||
a as ((typeof node.children)[number])[]
|
||||
a as number[(typeof node.children)]
|
||||
type A = (typeof node.children)[number];
|
||||
type B = (typeof node.children)[];
|
||||
type C = ((typeof node.children)[number])[];
|
||||
type D = number[(typeof node.children)];
|
||||
@@ -22,7 +22,7 @@
|
||||
"concurrently": "7.6.0",
|
||||
"docusaurus": "1.14.7",
|
||||
"js-yaml": "4.1.0",
|
||||
"webpack": "5.76.1",
|
||||
"webpack": "5.76.2",
|
||||
"webpack-cli": "5.0.1"
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ To turn off plugin autoloading, use `--no-plugin-search` when using Prettier CLI
|
||||
- [`prettier-plugin-properties`](https://github.com/eemeli/prettier-plugin-properties) by [**@eemeli**](https://github.com/eemeli)
|
||||
- [`prettier-plugin-sh`](https://github.com/un-ts/prettier/tree/master/packages/sh) by [**@JounQin**](https://github.com/JounQin)
|
||||
- [`prettier-plugin-sql`](https://github.com/un-ts/prettier/tree/master/packages/sql) by [**@JounQin**](https://github.com/JounQin)
|
||||
- [`prettier-plugin-sql-cst`](https://github.com/nene/prettier-plugin-sql-cst) by [**@nene**](https://github.com/nene)
|
||||
- [`prettier-plugin-solidity`](https://github.com/prettier-solidity/prettier-plugin-solidity) by [**@mattiaerre**](https://github.com/mattiaerre)
|
||||
- [`prettier-plugin-svelte`](https://github.com/UnwrittenFun/prettier-plugin-svelte) by [**@UnwrittenFun**](https://github.com/UnwrittenFun)
|
||||
- [`prettier-plugin-toml`](https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml) by [**@bd82**](https://github.com/bd82)
|
||||
|
||||
+5
-5
@@ -8699,7 +8699,7 @@ __metadata:
|
||||
prop-types: 15.8.1
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0
|
||||
webpack: 5.76.1
|
||||
webpack: 5.76.2
|
||||
webpack-cli: 5.0.1
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -10180,9 +10180,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"webpack@npm:5.76.1":
|
||||
version: 5.76.1
|
||||
resolution: "webpack@npm:5.76.1"
|
||||
"webpack@npm:5.76.2":
|
||||
version: 5.76.2
|
||||
resolution: "webpack@npm:5.76.2"
|
||||
dependencies:
|
||||
"@types/eslint-scope": ^3.7.3
|
||||
"@types/estree": ^0.0.51
|
||||
@@ -10213,7 +10213,7 @@ __metadata:
|
||||
optional: true
|
||||
bin:
|
||||
webpack: bin/webpack.js
|
||||
checksum: b01fe0bc2dbca0e10d290ddb0bf81e807a031de48028176e2b21afd696b4d3f25ab9accdad888ef4a1f7c7f4d41f13d5bf2395b7653fdf3e5e3dafa54e56dab2
|
||||
checksum: 86db98299a175c371031449c26077e87b33acd8f45de7f7945ed4b9b37c8ca11bc5169af9c44743efccd4d55e08042a3aa3a3bc42aff831309a0821ffbcd395e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in new issue
Block a user