Skip to content

Commit 49c3704

Browse files
committed
[prettier] Combine compiler and runtime configs
Merges the existing config to the root one so we can have a single configuration file. I've tried to keep the compiler config as much as possible in this PR so that no formatting changes occur. ghstack-source-id: 8bbfc9f269c4b2d740803937a4f2401d44cce9e4 Pull Request resolved: facebook#30021
1 parent 49a4887 commit 49c3704

9 files changed

+48
-53
lines changed

.github/workflows/compiler-typescript.yml

-19
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,6 @@ jobs:
2323
- id: set-matrix
2424
run: echo "matrix=$(find packages -mindepth 1 -maxdepth 1 -type d | sed 's!packages/!!g' | tr '\n' ',' | sed s/.$// | jq -Rsc '. / "," - [""]')" >> $GITHUB_OUTPUT
2525

26-
# Hardcoded to improve parallelism for babel-plugin-react-compiler
27-
prettier:
28-
name: Run prettier
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@v4
32-
- uses: actions/setup-node@v4
33-
with:
34-
node-version: 18.x
35-
cache: "yarn"
36-
cache-dependency-path: compiler/yarn.lock
37-
- name: Restore cached node_modules
38-
uses: actions/cache@v4
39-
with:
40-
path: "**/node_modules"
41-
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('compiler/**/yarn.lock') }}
42-
- run: yarn install --frozen-lockfile
43-
- run: yarn prettier:ci
44-
4526
# Hardcoded to improve parallelism
4627
lint:
4728
name: Lint babel-plugin-react-compiler

.prettierignore

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# react runtime
12
build
23

34
packages/react-devtools-core/dist
@@ -13,3 +14,26 @@ packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/
1314
packages/react-devtools-shell/dist
1415
packages/react-devtools-timeline/dist
1516
packages/react-devtools-timeline/static
17+
18+
# react compiler
19+
compiler/**/dist
20+
compiler/**/__tests__/fixtures/**/*.expect.md
21+
compiler/**/__tests__/fixtures/**/*.flow.js
22+
compiler/**/.next
23+
24+
compiler/crates
25+
compiler/apps/playground/public
26+
27+
compiler/**/LICENSE
28+
compiler/.*
29+
compiler/*.md*
30+
compiler/*.json
31+
compiler/*.css
32+
compiler/*.webmanifest
33+
compiler/*.map
34+
compiler/*.sh
35+
compiler/*.txt
36+
compiler/*.ico
37+
compiler/*.svg
38+
compiler/*.lock
39+
compiler/*.toml

.prettierrc.js

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
compilerPaths,
45
esNextPaths,
56
typescriptPaths,
67
} = require('./scripts/shared/pathsByLanguageVersion');
@@ -33,5 +34,19 @@ module.exports = {
3334
parser: 'typescript',
3435
},
3536
},
37+
{
38+
files: compilerPaths,
39+
options: {
40+
requirePragma: false,
41+
parser: 'babel-ts',
42+
semi: true,
43+
singleQuote: false,
44+
trailingComma: 'es5',
45+
bracketSpacing: true,
46+
bracketSameLine: false,
47+
printWidth: 80,
48+
arrowParens: 'always',
49+
},
50+
},
3651
],
3752
};

compiler/.prettierignore

-21
This file was deleted.

compiler/.prettierrc.js

-9
This file was deleted.

compiler/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
"build": "yarn workspaces run build",
2323
"dev": "concurrently --kill-others -n compiler,runtime,playground \"yarn workspace babel-plugin-react-compiler run build --watch\" \"yarn workspace react-compiler-runtime run build --watch\" \"wait-on packages/babel-plugin-react-compiler/dist/index.js && yarn workspace playground run dev\"",
2424
"test": "yarn workspaces run test",
25-
"prettier:write": "prettier --write . --log-level=warn",
26-
"prettier:ci": "prettier --check . --log-level=warn",
2725
"snap": "yarn workspace babel-plugin-react-compiler run snap",
2826
"snap:build": "yarn workspace snap run build",
2927
"postinstall": "perl -p -i -e 's/react\\.element/react.transitional.element/' packages/snap/node_modules/fbt/lib/FbtReactUtil.js && perl -p -i -e 's/didWarnAboutUsingAct = false;/didWarnAboutUsingAct = true;/' packages/babel-plugin-react-compiler/node_modules/react-dom/cjs/react-dom-test-utils.development.js",

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"flow-ci": "node ./scripts/tasks/flow-ci.js",
128128
"prettier": "node ./scripts/prettier/index.js write-changed",
129129
"prettier-all": "node ./scripts/prettier/index.js write",
130+
"prettier-check": "node ./scripts/prettier/index.js",
130131
"version-check": "node ./scripts/tasks/version-check.js",
131132
"publish-prereleases": "node ./scripts/release/publish-using-ci-workflow.js",
132133
"download-build": "node ./scripts/release/download-experimental-build.js",

scripts/prettier/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ const ignoredPathsListedInPrettierIgnoreInGlobFormat =
5151
});
5252

5353
const files = glob
54-
.sync('**/*.js', {
54+
.sync('**/*.{js,jsx,ts,tsx}', {
5555
ignore: [
56+
'**/*.d.ts',
5657
'**/node_modules/**',
5758
'**/cjs/**',
58-
'compiler/**',
59+
'**/dist/**',
60+
'**/__snapshots__/**',
61+
'packages/**/*.ts', // runtime prettier uses Flow parser
5962
...ignoredPathsListedInPrettierIgnoreInGlobFormat,
6063
],
6164
})

scripts/shared/pathsByLanguageVersion.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
'use strict';
88

9+
const compilerPaths = ['compiler/**'];
10+
911
// Files that are transformed and can use ES6/Flow/JSX.
1012
const esNextPaths = [
1113
// Internal forwarding modules
@@ -28,6 +30,7 @@ const es5Paths = ['packages/*/npm/**/*.js'];
2830
const typescriptPaths = ['packages/**/*.d.ts'];
2931

3032
module.exports = {
33+
compilerPaths,
3134
esNextPaths,
3235
es5Paths,
3336
typescriptPaths,

0 commit comments

Comments
 (0)