Skip to content

Commit 158501c

Browse files
committed
[BE] switch to hermes parser for prettier
1 parent ab1fc96 commit 158501c

File tree

7 files changed

+44
-5
lines changed

7 files changed

+44
-5
lines changed

.prettierrc.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
const {esNextPaths} = require('./scripts/shared/pathsByLanguageVersion');
44

55
module.exports = {
6+
plugins: ['prettier-plugin-hermes-parser'],
67
bracketSpacing: false,
78
singleQuote: true,
89
bracketSameLine: true,
910
trailingComma: 'es5',
1011
printWidth: 80,
11-
parser: 'flow',
12+
parser: 'hermes',
1213
arrowParens: 'avoid',
1314
overrides: [
1415
{
@@ -30,5 +31,21 @@ module.exports = {
3031
parser: 'typescript',
3132
},
3233
},
34+
{
35+
files: [
36+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.js',
37+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.js',
38+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-kitchensink.js',
39+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-inside-logical-expression.js',
40+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/optional-call-logical.js',
41+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.js',
42+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/readonly-object-method-calls.js',
43+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/tagged-template-in-hook.js',
44+
'compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/tagged-template-literal.js',
45+
],
46+
options: {
47+
parser: 'flow',
48+
},
49+
},
3350
],
3451
};

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ternary-expression.expect.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
```javascript
55
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;
77
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
88
return a ? b : null;
99
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ternary-expression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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;
33
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
44
return a ? b : null;
55
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"ncp": "^2.0.0",
8383
"prettier": "^3.3.3",
8484
"prettier-2": "npm:prettier@^2",
85+
"prettier-plugin-hermes-parser": "^0.23.0",
8586
"pretty-format": "^29.4.1",
8687
"prop-types": "^15.6.2",
8788
"random-seed": "^0.3.0",

packages/react-devtools-shared/src/hooks/astUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function getHookVariableName(
289289
const nodeType = hook.node.id.type;
290290
switch (nodeType) {
291291
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;
293293

294294
case AST_NODE_TYPES.IDENTIFIER:
295295
return hook.node.id.name;

packages/react-noop-renderer/src/createReactNoop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
245245
id: instance.id,
246246
type: type,
247247
parent: instance.parent,
248-
children: keepChildren ? instance.children : (children ?? []),
248+
children: keepChildren ? instance.children : children ?? [],
249249
text: shouldSetTextContent(type, newProps)
250250
? computeText((newProps.children: any) + '', instance.context)
251251
: null,

yarn.lock

+21
Original file line numberDiff line numberDiff line change
@@ -9131,13 +9131,25 @@ [email protected]:
91319131
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.22.0.tgz#38559502b119f728901d2cfe2ef422f277802a1d"
91329132
integrity sha512-FLBt5X9OfA8BERUdc6aZS36Xz3rRuB0Y/mfocSADWEJfomc1xfene33GdyAmtTkKTBXTN/EgAy+rjTKkkZJHlw==
91339133

9134+
9135+
version "0.23.0"
9136+
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.23.0.tgz#89c5419877b9d6bce4bb616821f496f5c5daddbc"
9137+
integrity sha512-Rkp0PNLGpORw4ktsttkVbpYJbrYKS3hAnkxu8D9nvQi6LvSbuPa+tYw/t2u3Gjc35lYd/k95YkjqyTcN4zspag==
9138+
91349139
[email protected], hermes-parser@^0.22.0:
91359140
version "0.22.0"
91369141
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.22.0.tgz#fc8e0e6c7bfa8db85b04c9f9544a102c4fcb4040"
91379142
integrity sha512-gn5RfZiEXCsIWsFGsKiykekktUoh0PdFWYocXsUdZIyWSckT6UIyPcyyUIPSR3kpnELWeK3n3ztAse7Mat6PSA==
91389143
dependencies:
91399144
hermes-estree "0.22.0"
91409145

9146+
9147+
version "0.23.0"
9148+
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.0.tgz#3541907b77ca9e94fd093e8ef0ff97ca5340dee8"
9149+
integrity sha512-xLwM4ylfHGwrm+2qXfO1JT/fnqEDGSnpS/9hQ4VLtqTexSviu2ZpBgz07U8jVtndq67qdb/ps0qvaWDZ3fkTyg==
9150+
dependencies:
9151+
hermes-estree "0.23.0"
9152+
91419153
homedir-polyfill@^1.0.0, homedir-polyfill@^1.0.1:
91429154
version "1.0.3"
91439155
resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8"
@@ -13206,6 +13218,15 @@ prepend-http@^2.0.0:
1320613218
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
1320713219
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
1320813220

13221+
[email protected], prettier-plugin-hermes-parser@^0.23.0:
13222+
version "0.23.0"
13223+
resolved "https://registry.yarnpkg.com/prettier-plugin-hermes-parser/-/prettier-plugin-hermes-parser-0.23.0.tgz#67fa061e503600087169283e150bc3f3239bf39c"
13224+
integrity sha512-EMwgZFcKDyVfUCvIy/kxVc4siYEOYPt7lLqtaELVadKYNbOLUFjYW3QKGZ8jzidUy4DonfFbi/hJOXJ5vfRzxA==
13225+
dependencies:
13226+
hermes-estree "0.23.0"
13227+
hermes-parser "0.23.0"
13228+
prettier-plugin-hermes-parser "0.23.0"
13229+
1320913230
prettier@*, prettier@^3.3.3:
1321013231
version "3.3.3"
1321113232
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"

0 commit comments

Comments
 (0)