mirror of
https://github.com/facebook/react.git
synced 2026-02-21 19:31:52 +00:00
[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: 8bbfc9f269
Pull Request resolved: https://github.com/facebook/react/pull/30021
This commit is contained in:
19
.github/workflows/compiler-typescript.yml
vendored
19
.github/workflows/compiler-typescript.yml
vendored
@@ -23,25 +23,6 @@ jobs:
|
|||||||
- id: set-matrix
|
- 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
|
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
|
# Hardcoded to improve parallelism
|
||||||
lint:
|
lint:
|
||||||
name: Lint babel-plugin-react-compiler
|
name: Lint babel-plugin-react-compiler
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# react runtime
|
||||||
build
|
build
|
||||||
|
|
||||||
packages/react-devtools-core/dist
|
packages/react-devtools-core/dist
|
||||||
@@ -13,3 +14,26 @@ packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/
|
|||||||
packages/react-devtools-shell/dist
|
packages/react-devtools-shell/dist
|
||||||
packages/react-devtools-timeline/dist
|
packages/react-devtools-timeline/dist
|
||||||
packages/react-devtools-timeline/static
|
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
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
compilerPaths,
|
||||||
esNextPaths,
|
esNextPaths,
|
||||||
typescriptPaths,
|
typescriptPaths,
|
||||||
} = require('./scripts/shared/pathsByLanguageVersion');
|
} = require('./scripts/shared/pathsByLanguageVersion');
|
||||||
@@ -33,5 +34,19 @@ module.exports = {
|
|||||||
parser: 'typescript',
|
parser: 'typescript',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
files: compilerPaths,
|
||||||
|
options: {
|
||||||
|
requirePragma: false,
|
||||||
|
parser: 'babel-ts',
|
||||||
|
semi: true,
|
||||||
|
singleQuote: false,
|
||||||
|
trailingComma: 'es5',
|
||||||
|
bracketSpacing: true,
|
||||||
|
bracketSameLine: false,
|
||||||
|
printWidth: 80,
|
||||||
|
arrowParens: 'always',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
**/dist
|
|
||||||
**/__tests__/fixtures/**/*.expect.md
|
|
||||||
**/__tests__/fixtures/**/*.flow.js
|
|
||||||
**/.next
|
|
||||||
|
|
||||||
crates
|
|
||||||
apps/playground/public
|
|
||||||
|
|
||||||
**/LICENSE
|
|
||||||
.*
|
|
||||||
*.md*
|
|
||||||
*.json
|
|
||||||
*.css
|
|
||||||
*.webmanifest
|
|
||||||
*.map
|
|
||||||
*.sh
|
|
||||||
*.txt
|
|
||||||
*.ico
|
|
||||||
*.svg
|
|
||||||
*.lock
|
|
||||||
*.toml
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
const config = {
|
|
||||||
requirePragma: false,
|
|
||||||
parser: "babel-ts",
|
|
||||||
semi: true,
|
|
||||||
singleQuote: false,
|
|
||||||
trailingComma: "es5"
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = config;
|
|
||||||
@@ -22,8 +22,6 @@
|
|||||||
"build": "yarn workspaces run build",
|
"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\"",
|
"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",
|
"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": "yarn workspace babel-plugin-react-compiler run snap",
|
||||||
"snap:build": "yarn workspace snap run build",
|
"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",
|
"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",
|
||||||
|
|||||||
@@ -127,6 +127,7 @@
|
|||||||
"flow-ci": "node ./scripts/tasks/flow-ci.js",
|
"flow-ci": "node ./scripts/tasks/flow-ci.js",
|
||||||
"prettier": "node ./scripts/prettier/index.js write-changed",
|
"prettier": "node ./scripts/prettier/index.js write-changed",
|
||||||
"prettier-all": "node ./scripts/prettier/index.js write",
|
"prettier-all": "node ./scripts/prettier/index.js write",
|
||||||
|
"prettier-check": "node ./scripts/prettier/index.js",
|
||||||
"version-check": "node ./scripts/tasks/version-check.js",
|
"version-check": "node ./scripts/tasks/version-check.js",
|
||||||
"publish-prereleases": "node ./scripts/release/publish-using-ci-workflow.js",
|
"publish-prereleases": "node ./scripts/release/publish-using-ci-workflow.js",
|
||||||
"download-build": "node ./scripts/release/download-experimental-build.js",
|
"download-build": "node ./scripts/release/download-experimental-build.js",
|
||||||
|
|||||||
@@ -51,11 +51,14 @@ const ignoredPathsListedInPrettierIgnoreInGlobFormat =
|
|||||||
});
|
});
|
||||||
|
|
||||||
const files = glob
|
const files = glob
|
||||||
.sync('**/*.js', {
|
.sync('**/*.{js,jsx,ts,tsx}', {
|
||||||
ignore: [
|
ignore: [
|
||||||
|
'**/*.d.ts',
|
||||||
'**/node_modules/**',
|
'**/node_modules/**',
|
||||||
'**/cjs/**',
|
'**/cjs/**',
|
||||||
'compiler/**',
|
'**/dist/**',
|
||||||
|
'**/__snapshots__/**',
|
||||||
|
'packages/**/*.ts', // runtime prettier uses Flow parser
|
||||||
...ignoredPathsListedInPrettierIgnoreInGlobFormat,
|
...ignoredPathsListedInPrettierIgnoreInGlobFormat,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const compilerPaths = ['compiler/**'];
|
||||||
|
|
||||||
// Files that are transformed and can use ES6/Flow/JSX.
|
// Files that are transformed and can use ES6/Flow/JSX.
|
||||||
const esNextPaths = [
|
const esNextPaths = [
|
||||||
// Internal forwarding modules
|
// Internal forwarding modules
|
||||||
@@ -28,6 +30,7 @@ const es5Paths = ['packages/*/npm/**/*.js'];
|
|||||||
const typescriptPaths = ['packages/**/*.d.ts'];
|
const typescriptPaths = ['packages/**/*.d.ts'];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
compilerPaths,
|
||||||
esNextPaths,
|
esNextPaths,
|
||||||
es5Paths,
|
es5Paths,
|
||||||
typescriptPaths,
|
typescriptPaths,
|
||||||
|
|||||||
Reference in New Issue
Block a user