Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prettier] Combine compiler and runtime configs #30021

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/compiler-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,6 @@ jobs:
- id: set-matrix
run: echo "matrix=$(find packages -mindepth 1 -maxdepth 1 -type d | sed 's!packages/!!g' | tr '\n' ',' | sed s/.$// | jq -Rsc '. / "," - [""]')" >> $GITHUB_OUTPUT

# Hardcoded to improve parallelism for babel-plugin-react-compiler
prettier:
name: Run prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"
cache-dependency-path: compiler/yarn.lock
- name: Restore cached node_modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('compiler/**/yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: yarn prettier:ci

# Hardcoded to improve parallelism
lint:
name: Lint babel-plugin-react-compiler
Expand Down
24 changes: 24 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# react runtime
build

packages/react-devtools-core/dist
Expand All @@ -13,3 +14,26 @@ packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/
packages/react-devtools-shell/dist
packages/react-devtools-timeline/dist
packages/react-devtools-timeline/static

# react compiler
compiler/**/dist
compiler/**/__tests__/fixtures/**/*.expect.md
compiler/**/__tests__/fixtures/**/*.flow.js
compiler/**/.next

compiler/crates
compiler/apps/playground/public

compiler/**/LICENSE
compiler/.*
compiler/*.md*
compiler/*.json
compiler/*.css
compiler/*.webmanifest
compiler/*.map
compiler/*.sh
compiler/*.txt
compiler/*.ico
compiler/*.svg
compiler/*.lock
compiler/*.toml
15 changes: 15 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const {
compilerPaths,
esNextPaths,
typescriptPaths,
} = require('./scripts/shared/pathsByLanguageVersion');
Expand Down Expand Up @@ -33,5 +34,19 @@ module.exports = {
parser: 'typescript',
},
},
{
files: compilerPaths,
options: {
requirePragma: false,
parser: 'babel-ts',
semi: true,
singleQuote: false,
trailingComma: 'es5',
bracketSpacing: true,
bracketSameLine: false,
printWidth: 80,
arrowParens: 'always',
},
},
],
};
21 changes: 0 additions & 21 deletions compiler/.prettierignore

This file was deleted.

9 changes: 0 additions & 9 deletions compiler/.prettierrc.js

This file was deleted.

2 changes: 0 additions & 2 deletions compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"build": "yarn workspaces run build",
"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\"",
"test": "yarn workspaces run test",
"prettier:write": "prettier --write . --log-level=warn",
"prettier:ci": "prettier --check . --log-level=warn",
"snap": "yarn workspace babel-plugin-react-compiler run snap",
"snap:build": "yarn workspace snap run build",
"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",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"flow-ci": "node ./scripts/tasks/flow-ci.js",
"prettier": "node ./scripts/prettier/index.js write-changed",
"prettier-all": "node ./scripts/prettier/index.js write",
"prettier-check": "node ./scripts/prettier/index.js",
"version-check": "node ./scripts/tasks/version-check.js",
"publish-prereleases": "node ./scripts/release/publish-using-ci-workflow.js",
"download-build": "node ./scripts/release/download-experimental-build.js",
Expand Down
7 changes: 5 additions & 2 deletions scripts/prettier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ const ignoredPathsListedInPrettierIgnoreInGlobFormat =
});

const files = glob
.sync('**/*.js', {
.sync('**/*.{js,jsx,ts,tsx}', {
ignore: [
'**/*.d.ts',
'**/node_modules/**',
'**/cjs/**',
'compiler/**',
'**/dist/**',
'**/__snapshots__/**',
'packages/**/*.ts', // runtime prettier uses Flow parser
...ignoredPathsListedInPrettierIgnoreInGlobFormat,
],
})
Expand Down
3 changes: 3 additions & 0 deletions scripts/shared/pathsByLanguageVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
'use strict';

const compilerPaths = ['compiler/**'];

// Files that are transformed and can use ES6/Flow/JSX.
const esNextPaths = [
// Internal forwarding modules
Expand All @@ -28,6 +30,7 @@ const es5Paths = ['packages/*/npm/**/*.js'];
const typescriptPaths = ['packages/**/*.d.ts'];

module.exports = {
compilerPaths,
esNextPaths,
es5Paths,
typescriptPaths,
Expand Down
Loading