[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
This commit is contained in:
Ricky 2025-06-03 00:00:28 -04:00 committed by GitHub
parent 4a1f29079c
commit 3531b26729
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 8 additions and 33 deletions

View File

@ -3,13 +3,12 @@
const {esNextPaths} = require('./scripts/shared/pathsByLanguageVersion'); const {esNextPaths} = require('./scripts/shared/pathsByLanguageVersion');
module.exports = { module.exports = {
plugins: ['prettier-plugin-hermes-parser'],
bracketSpacing: false, bracketSpacing: false,
singleQuote: true, singleQuote: true,
bracketSameLine: true, bracketSameLine: true,
trailingComma: 'es5', trailingComma: 'es5',
printWidth: 80, printWidth: 80,
parser: 'hermes', parser: 'flow',
arrowParens: 'avoid', arrowParens: 'avoid',
overrides: [ overrides: [
{ {

View File

@ -3,7 +3,7 @@
```javascript ```javascript
function ternary(props) { function ternary(props) {
const a = props.a && props.b ? props.c || props.d : props.e ?? props.f; const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f; const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
return a ? b : null; return a ? b : null;
} }

View File

@ -1,5 +1,5 @@
function ternary(props) { function ternary(props) {
const a = props.a && props.b ? props.c || props.d : props.e ?? props.f; const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f; const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
return a ? b : null; return a ? b : null;
} }

View File

@ -91,7 +91,6 @@
"ncp": "^2.0.0", "ncp": "^2.0.0",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"prettier-2": "npm:prettier@^2", "prettier-2": "npm:prettier@^2",
"prettier-plugin-hermes-parser": "^0.23.0",
"pretty-format": "^29.4.1", "pretty-format": "^29.4.1",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"random-seed": "^0.3.0", "random-seed": "^0.3.0",

View File

@ -25,7 +25,7 @@ export type ContextMenuHandle = {
hide(): void, hide(): void,
}; };
/*:: export type ContextMenuComponent = component(
export type ContextMenuComponent = component(ref: React$RefSetter<ContextMenuHandle>); ref: React$RefSetter<ContextMenuHandle>,
*/ );
export type ContextMenuRef = {current: ContextMenuHandle | null}; export type ContextMenuRef = {current: ContextMenuHandle | null};

View File

@ -289,7 +289,7 @@ function getHookVariableName(
const nodeType = hook.node.id.type; const nodeType = hook.node.id.type;
switch (nodeType) { switch (nodeType) {
case AST_NODE_TYPES.ARRAY_PATTERN: case AST_NODE_TYPES.ARRAY_PATTERN:
return !isCustomHook ? hook.node.id.elements[0]?.name ?? null : null; return !isCustomHook ? (hook.node.id.elements[0]?.name ?? null) : null;
case AST_NODE_TYPES.IDENTIFIER: case AST_NODE_TYPES.IDENTIFIER:
return hook.node.id.name; return hook.node.id.name;

View File

@ -253,7 +253,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
id: instance.id, id: instance.id,
type: type, type: type,
parent: instance.parent, parent: instance.parent,
children: keepChildren ? instance.children : children ?? [], children: keepChildren ? instance.children : (children ?? []),
text: shouldSetTextContent(type, newProps) text: shouldSetTextContent(type, newProps)
? computeText((newProps.children: any) + '', instance.context) ? computeText((newProps.children: any) + '', instance.context)
: null, : null,

View File

@ -14,8 +14,6 @@
.*/__mocks__/.* .*/__mocks__/.*
.*/__tests__/.* .*/__tests__/.*
# contains modern flow syntax that requires a Flow upgrade
.*/node_modules/prettier-plugin-hermes-parser/.*
# TODO: noop should get its own inlinedHostConfig entry # TODO: noop should get its own inlinedHostConfig entry
.*/packages/react-noop-renderer/.* .*/packages/react-noop-renderer/.*

View File

@ -9975,11 +9975,6 @@ hermes-eslint@^0.25.1:
hermes-estree "0.25.1" hermes-estree "0.25.1"
hermes-parser "0.25.1" hermes-parser "0.25.1"
hermes-estree@0.23.0:
version "0.23.0"
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.23.0.tgz#89c5419877b9d6bce4bb616821f496f5c5daddbc"
integrity sha512-Rkp0PNLGpORw4ktsttkVbpYJbrYKS3hAnkxu8D9nvQi6LvSbuPa+tYw/t2u3Gjc35lYd/k95YkjqyTcN4zspag==
hermes-estree@0.23.1: hermes-estree@0.23.1:
version "0.23.1" version "0.23.1"
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.23.1.tgz#d0bac369a030188120ee7024926aabe5a9f84fdb" resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.23.1.tgz#d0bac369a030188120ee7024926aabe5a9f84fdb"
@ -9990,13 +9985,6 @@ hermes-estree@0.25.1:
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480" resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480"
integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw== integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==
hermes-parser@0.23.0:
version "0.23.0"
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.0.tgz#3541907b77ca9e94fd093e8ef0ff97ca5340dee8"
integrity sha512-xLwM4ylfHGwrm+2qXfO1JT/fnqEDGSnpS/9hQ4VLtqTexSviu2ZpBgz07U8jVtndq67qdb/ps0qvaWDZ3fkTyg==
dependencies:
hermes-estree "0.23.0"
hermes-parser@0.23.1: hermes-parser@0.23.1:
version "0.23.1" version "0.23.1"
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.1.tgz#e5de648e664f3b3d84d01b48fc7ab164f4b68205" resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.1.tgz#e5de648e664f3b3d84d01b48fc7ab164f4b68205"
@ -14088,15 +14076,6 @@ prepend-http@^2.0.0:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
prettier-plugin-hermes-parser@0.23.0, prettier-plugin-hermes-parser@^0.23.0:
version "0.23.0"
resolved "https://registry.yarnpkg.com/prettier-plugin-hermes-parser/-/prettier-plugin-hermes-parser-0.23.0.tgz#67fa061e503600087169283e150bc3f3239bf39c"
integrity sha512-EMwgZFcKDyVfUCvIy/kxVc4siYEOYPt7lLqtaELVadKYNbOLUFjYW3QKGZ8jzidUy4DonfFbi/hJOXJ5vfRzxA==
dependencies:
hermes-estree "0.23.0"
hermes-parser "0.23.0"
prettier-plugin-hermes-parser "0.23.0"
prettier@*, prettier@^3.3.3: prettier@*, prettier@^3.3.3:
version "3.3.3" version "3.3.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"