@samitouri / QOS-React-1 / commits / 49c37048de

[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: https://github.com/facebook/react/pull/30021

Lauren Tan committed Jun 21, 2024 at 11:41 UTC 49c37048deceb8dcbf88258d73cfc2e17053370e
9 files changed +48 -53
.github/workflows/compiler-typescript.yml
-19
@@ -23,25 +23,6 @@ jobs:
23 - id: set-matrix
24 run: echo "matrix=$(find packages -mindepth 1 -maxdepth 1 -type d | sed 's!packages/!!g' | tr '\n' ',' | sed s/.$// | jq -Rsc '. / "," - [""]')" >> $GITHUB_OUTPUT
25
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 -
26 # Hardcoded to improve parallelism
27 lint:
28 name: Lint babel-plugin-react-compiler
.prettierignore
+24
@@ -1,3 +1,4 @@
1 +# react runtime
2 build
3
4 packages/react-devtools-core/dist
@@ -13,3 +14,26 @@ packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/
14 packages/react-devtools-shell/dist
15 packages/react-devtools-timeline/dist
16 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
@@ -1,6 +1,7 @@
1 'use strict';
2
3 const {
4 + compilerPaths,
5 esNextPaths,
6 typescriptPaths,
7 } = require('./scripts/shared/pathsByLanguageVersion');
@@ -33,5 +34,19 @@ module.exports = {
34 parser: 'typescript',
35 },
36 },
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 + },
51 ],
52 };
compiler/.prettierignore deleted
-21
@@ -1,21 +0,0 @@
1 -**/dist
2 -**/__tests__/fixtures/**/*.expect.md
3 -**/__tests__/fixtures/**/*.flow.js
4 -**/.next
5 -
6 -crates
7 -apps/playground/public
8 -
9 -**/LICENSE
10 -.*
11 -*.md*
12 -*.json
13 -*.css
14 -*.webmanifest
15 -*.map
16 -*.sh
17 -*.txt
18 -*.ico
19 -*.svg
20 -*.lock
21 -*.toml
compiler/.prettierrc.js deleted
-9
@@ -1,9 +0,0 @@
1 -const config = {
2 - requirePragma: false,
3 - parser: "babel-ts",
4 - semi: true,
5 - singleQuote: false,
6 - trailingComma: "es5"
7 -}
8 -
9 -module.exports = config;
compiler/package.json
-2
@@ -22,8 +22,6 @@
22 "build": "yarn workspaces run build",
23 "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\"",
24 "test": "yarn workspaces run test",
25 - "prettier:write": "prettier --write . --log-level=warn",
26 - "prettier:ci": "prettier --check . --log-level=warn",
25 "snap": "yarn workspace babel-plugin-react-compiler run snap",
26 "snap:build": "yarn workspace snap run build",
27 "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
@@ -127,6 +127,7 @@
127 "flow-ci": "node ./scripts/tasks/flow-ci.js",
128 "prettier": "node ./scripts/prettier/index.js write-changed",
129 "prettier-all": "node ./scripts/prettier/index.js write",
130 + "prettier-check": "node ./scripts/prettier/index.js",
131 "version-check": "node ./scripts/tasks/version-check.js",
132 "publish-prereleases": "node ./scripts/release/publish-using-ci-workflow.js",
133 "download-build": "node ./scripts/release/download-experimental-build.js",
scripts/prettier/index.js
+5 -2
@@ -51,11 +51,14 @@ const ignoredPathsListedInPrettierIgnoreInGlobFormat =
51 });
52
53 const files = glob
54 - .sync('**/*.js', {
54 + .sync('**/*.{js,jsx,ts,tsx}', {
55 ignore: [
56 + '**/*.d.ts',
57 '**/node_modules/**',
58 '**/cjs/**',
58 - 'compiler/**',
59 + '**/dist/**',
60 + '**/__snapshots__/**',
61 + 'packages/**/*.ts', // runtime prettier uses Flow parser
62 ...ignoredPathsListedInPrettierIgnoreInGlobFormat,
63 ],
64 })
scripts/shared/pathsByLanguageVersion.js
+3
@@ -6,6 +6,8 @@
6 */
7 'use strict';
8
9 +const compilerPaths = ['compiler/**'];
10 +
11 // Files that are transformed and can use ES6/Flow/JSX.
12 const esNextPaths = [
13 // Internal forwarding modules
@@ -28,6 +30,7 @@ const es5Paths = ['packages/*/npm/**/*.js'];
30 const typescriptPaths = ['packages/**/*.d.ts'];
31
32 module.exports = {
33 + compilerPaths,
34 esNextPaths,
35 es5Paths,
36 typescriptPaths,