Skip to content

Commit 1ceba3b

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Prepare react-native for prettier v3 (facebook#52717)
Summary: Pull Request resolved: facebook#52717 Prettier v3 no longer loads plugin implicitly. This diff first configures the hermes-parser plugin explicitly to prepare for v3 rollout. Changelog: [Internal] Reviewed By: pieterv Differential Revision: D78590158 fbshipit-source-id: dba06f5a823488b72a30ae5b58e37e172f4e736f
1 parent b3d1d2a commit 1ceba3b

File tree

2 files changed

+48
-36
lines changed

2 files changed

+48
-36
lines changed

.prettierrc

Lines changed: 0 additions & 36 deletions
This file was deleted.

.prettierrc.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
module.exports = {
11+
arrowParens: 'avoid',
12+
bracketSameLine: true,
13+
bracketSpacing: false,
14+
requirePragma: true,
15+
singleQuote: true,
16+
trailingComma: 'all',
17+
endOfLine: 'lf',
18+
plugins: [
19+
// Using module.parent and createRequire hack to simulate prettier v2 plugin resolution behavior.
20+
// The hack allows us to resolve the plugin from the install location of prettier.
21+
(module.parent
22+
? require('module').createRequire(module.parent.id)
23+
: require
24+
).resolve('prettier-plugin-hermes-parser'),
25+
],
26+
overrides: [
27+
{
28+
files: ['*.code-workspace'],
29+
options: {
30+
parser: 'json',
31+
},
32+
},
33+
{
34+
files: ['*.js', '*.js.flow'],
35+
options: {
36+
parser: 'hermes',
37+
},
38+
},
39+
{
40+
files: ['**/__docs__/*.md'],
41+
options: {
42+
parser: 'markdown',
43+
proseWrap: 'always',
44+
requirePragma: false,
45+
},
46+
},
47+
],
48+
};

0 commit comments

Comments
 (0)