@samitouri / QOS-React-1 / commits / 3531b26729

[scripts] Switch back to flow parser for prettier (#33414)

Prettier 3.3 (which we're on) should support modern flow features according to https://prettier.io/blog/2024/06/01/3.3.0

Ricky committed Jun 3, 2025 at 00:00 UTC 3531b2672955285c0a59f84be06ac92b0d987a3e
9 files changed +8 -33
.prettierrc.js
+1 -2
@@ -3,13 +3,12 @@
3 const {esNextPaths} = require('./scripts/shared/pathsByLanguageVersion');
4
5 module.exports = {
6 - plugins: ['prettier-plugin-hermes-parser'],
6 bracketSpacing: false,
7 singleQuote: true,
8 bracketSameLine: true,
9 trailingComma: 'es5',
10 printWidth: 80,
12 - parser: 'hermes',
11 + parser: 'flow',
12 arrowParens: 'avoid',
13 overrides: [
14 {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ternary-expression.expect.md
+1 -1
@@ -3,7 +3,7 @@
3
4 ```javascript
5 function ternary(props) {
6 - const a = props.a && props.b ? props.c || props.d : props.e ?? props.f;
6 + const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
7 const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
8 return a ? b : null;
9 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ternary-expression.js
+1 -1
@@ -1,5 +1,5 @@
1 function ternary(props) {
2 - const a = props.a && props.b ? props.c || props.d : props.e ?? props.f;
2 + const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
3 const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
4 return a ? b : null;
5 }
package.json
-1
@@ -91,7 +91,6 @@
91 "ncp": "^2.0.0",
92 "prettier": "^3.3.3",
93 "prettier-2": "npm:prettier@^2",
94 - "prettier-plugin-hermes-parser": "^0.23.0",
94 "pretty-format": "^29.4.1",
95 "prop-types": "^15.6.2",
96 "random-seed": "^0.3.0",
packages/react-devtools-shared/src/devtools/ContextMenu/types.js
+3 -3
@@ -25,7 +25,7 @@ export type ContextMenuHandle = {
25 hide(): void,
26 };
27
28 -/*::
29 -export type ContextMenuComponent = component(ref: React$RefSetter<ContextMenuHandle>);
30 -*/
28 +export type ContextMenuComponent = component(
29 + ref: React$RefSetter<ContextMenuHandle>,
30 +);
31 export type ContextMenuRef = {current: ContextMenuHandle | null};
packages/react-devtools-shared/src/hooks/astUtils.js
+1 -1
@@ -289,7 +289,7 @@ function getHookVariableName(
289 const nodeType = hook.node.id.type;
290 switch (nodeType) {
291 case AST_NODE_TYPES.ARRAY_PATTERN:
292 - return !isCustomHook ? hook.node.id.elements[0]?.name ?? null : null;
292 + return !isCustomHook ? (hook.node.id.elements[0]?.name ?? null) : null;
293
294 case AST_NODE_TYPES.IDENTIFIER:
295 return hook.node.id.name;
packages/react-noop-renderer/src/createReactNoop.js
+1 -1
@@ -253,7 +253,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
253 id: instance.id,
254 type: type,
255 parent: instance.parent,
256 - children: keepChildren ? instance.children : children ?? [],
256 + children: keepChildren ? instance.children : (children ?? []),
257 text: shouldSetTextContent(type, newProps)
258 ? computeText((newProps.children: any) + '', instance.context)
259 : null,
scripts/flow/config/flowconfig
-2
@@ -14,8 +14,6 @@
14 .*/__mocks__/.*
15 .*/__tests__/.*
16
17 -# contains modern flow syntax that requires a Flow upgrade
18 -.*/node_modules/prettier-plugin-hermes-parser/.*
17
18 # TODO: noop should get its own inlinedHostConfig entry
19 .*/packages/react-noop-renderer/.*
yarn.lock
-21
@@ -9975,11 +9975,6 @@ hermes-eslint@^0.25.1:
9975 hermes-estree "0.25.1"
9976 hermes-parser "0.25.1"
9977
9978 -hermes-estree@0.23.0:
9979 - version "0.23.0"
9980 - resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.23.0.tgz#89c5419877b9d6bce4bb616821f496f5c5daddbc"
9981 - integrity sha512-Rkp0PNLGpORw4ktsttkVbpYJbrYKS3hAnkxu8D9nvQi6LvSbuPa+tYw/t2u3Gjc35lYd/k95YkjqyTcN4zspag==
9982 -
9978 hermes-estree@0.23.1:
9979 version "0.23.1"
9980 resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.23.1.tgz#d0bac369a030188120ee7024926aabe5a9f84fdb"
@@ -9990,13 +9985,6 @@ hermes-estree@0.25.1:
9985 resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480"
9986 integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==
9987
9993 -hermes-parser@0.23.0:
9994 - version "0.23.0"
9995 - resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.0.tgz#3541907b77ca9e94fd093e8ef0ff97ca5340dee8"
9996 - integrity sha512-xLwM4ylfHGwrm+2qXfO1JT/fnqEDGSnpS/9hQ4VLtqTexSviu2ZpBgz07U8jVtndq67qdb/ps0qvaWDZ3fkTyg==
9997 - dependencies:
9998 - hermes-estree "0.23.0"
9999 -
9988 hermes-parser@0.23.1:
9989 version "0.23.1"
9990 resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.1.tgz#e5de648e664f3b3d84d01b48fc7ab164f4b68205"
@@ -14088,15 +14076,6 @@ prepend-http@^2.0.0:
14076 resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
14077 integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
14078
14091 -prettier-plugin-hermes-parser@0.23.0, prettier-plugin-hermes-parser@^0.23.0:
14092 - version "0.23.0"
14093 - resolved "https://registry.yarnpkg.com/prettier-plugin-hermes-parser/-/prettier-plugin-hermes-parser-0.23.0.tgz#67fa061e503600087169283e150bc3f3239bf39c"
14094 - integrity sha512-EMwgZFcKDyVfUCvIy/kxVc4siYEOYPt7lLqtaELVadKYNbOLUFjYW3QKGZ8jzidUy4DonfFbi/hJOXJ5vfRzxA==
14095 - dependencies:
14096 - hermes-estree "0.23.0"
14097 - hermes-parser "0.23.0"
14098 - prettier-plugin-hermes-parser "0.23.0"
14099 -
14079 prettier@*, prettier@^3.3.3:
14080 version "3.3.3"
14081 resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"