diff --git a/.github/workflows/compiler-typescript.yml b/.github/workflows/compiler-typescript.yml index 4b4a668c724e1..71cfe426c171a 100644 --- a/.github/workflows/compiler-typescript.yml +++ b/.github/workflows/compiler-typescript.yml @@ -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 diff --git a/.prettierignore b/.prettierignore index 24caf7a7a1d70..1c461d88c6e51 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ +# react runtime build 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-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 diff --git a/.prettierrc.js b/.prettierrc.js index 43f9b6671c326..5f3e78b0b83d2 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,6 +1,7 @@ 'use strict'; const { + compilerPaths, esNextPaths, typescriptPaths, } = require('./scripts/shared/pathsByLanguageVersion'); @@ -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', + }, + }, ], }; diff --git a/compiler/.prettierignore b/compiler/.prettierignore deleted file mode 100644 index 410e88836cb6c..0000000000000 --- a/compiler/.prettierignore +++ /dev/null @@ -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 diff --git a/compiler/.prettierrc.js b/compiler/.prettierrc.js deleted file mode 100644 index 37917d7082fb5..0000000000000 --- a/compiler/.prettierrc.js +++ /dev/null @@ -1,9 +0,0 @@ -const config = { - requirePragma: false, - parser: "babel-ts", - semi: true, - singleQuote: false, - trailingComma: "es5" -} - -module.exports = config; diff --git a/compiler/package.json b/compiler/package.json index 9037808df9877..92100f030dc5e 100644 --- a/compiler/package.json +++ b/compiler/package.json @@ -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", diff --git a/package.json b/package.json index fc482724ee7a0..663538b506c44 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/prettier/index.js b/scripts/prettier/index.js index 0a71cff7b2197..81786aecc081e 100644 --- a/scripts/prettier/index.js +++ b/scripts/prettier/index.js @@ -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, ], }) diff --git a/scripts/shared/pathsByLanguageVersion.js b/scripts/shared/pathsByLanguageVersion.js index d4ee6daef3c16..d3843f54dea83 100644 --- a/scripts/shared/pathsByLanguageVersion.js +++ b/scripts/shared/pathsByLanguageVersion.js @@ -6,6 +6,8 @@ */ 'use strict'; +const compilerPaths = ['compiler/**']; + // Files that are transformed and can use ES6/Flow/JSX. const esNextPaths = [ // Internal forwarding modules @@ -28,6 +30,7 @@ const es5Paths = ['packages/*/npm/**/*.js']; const typescriptPaths = ['packages/**/*.d.ts']; module.exports = { + compilerPaths, esNextPaths, es5Paths, typescriptPaths,