Skip to content

Commit 7970ee9

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Prepare react-native for prettier v3: 2/n (#52745)
Summary: Pull Request resolved: #52745 Prettier v3 no longer loads plugin implicitly. This diff first configures the hermes-parser plugin explicitly to prepare for v3 rollout. D78590158 missed this config. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D78673890 fbshipit-source-id: 1931718ef2b3f011621bf4d64c8936a698506374
1 parent 976055e commit 7970ee9

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

packages/react-native-codegen/.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"bracketSpacing": false,
55
"requirePragma": true,
66
"singleQuote": true,
7-
"trailingComma": "all"
7+
"trailingComma": "all",
8+
"parser": "babel"
89
}

private/helloworld/.prettierrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,20 @@ module.exports = {
1313
bracketSpacing: false,
1414
singleQuote: true,
1515
trailingComma: 'all',
16+
plugins: [
17+
// Using module.parent and createRequire hack to simulate prettier v2 plugin resolution behavior.
18+
// The hack allows us to resolve the plugin from the install location of prettier.
19+
(module.parent
20+
? require('module').createRequire(module.parent.id)
21+
: require
22+
).resolve('prettier-plugin-hermes-parser'),
23+
],
24+
overrides: [
25+
{
26+
files: ['*.js', '*.js.flow'],
27+
options: {
28+
parser: 'hermes',
29+
},
30+
},
31+
],
1632
};

0 commit comments

Comments
 (0)