From 69b4cb8df4d3c612f927942098475c7907c70808 Mon Sep 17 00:00:00 2001 From: lauren Date: Tue, 7 Oct 2025 14:44:46 -0400 Subject: [PATCH 1/3] [ci] Allow dry run (#34765) Allow running the compiler release script as dry run. --- .github/workflows/compiler_prereleases.yml | 11 ++++++++++- .github/workflows/compiler_prereleases_manual.yml | 4 ++++ .github/workflows/compiler_prereleases_nightly.yml | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compiler_prereleases.yml b/.github/workflows/compiler_prereleases.yml index bd6d003a4ccba..6f60aac23c1d1 100644 --- a/.github/workflows/compiler_prereleases.yml +++ b/.github/workflows/compiler_prereleases.yml @@ -19,6 +19,9 @@ on: tag_version: required: false type: string + dry_run: + required: false + type: boolean secrets: NPM_TOKEN: required: true @@ -55,7 +58,13 @@ jobs: key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/yarn.lock') }} - run: yarn install --frozen-lockfile if: steps.node_modules.outputs.cache-hit != 'true' - - name: Publish packages to npm + - if: inputs.dry_run == true + name: Publish packages to npm (dry run) + run: | + cp ./scripts/release/ci-npmrc ~/.npmrc + scripts/release/publish.js --ci --versionName=${{ inputs.version_name }} --tag=${{ inputs.dist_tag }} ${{ inputs.tag_version && format('--tagVersion={0}', inputs.tag_version) || '' }} + - if: inputs.dry_run != true + name: Publish packages to npm run: | cp ./scripts/release/ci-npmrc ~/.npmrc scripts/release/publish.js --frfr --ci --versionName=${{ inputs.version_name }} --tag=${{ inputs.dist_tag }} ${{ inputs.tag_version && format('--tagVersion={0}', inputs.tag_version) || '' }} diff --git a/.github/workflows/compiler_prereleases_manual.yml b/.github/workflows/compiler_prereleases_manual.yml index 268b8f24f401d..c4a7a16aca3bf 100644 --- a/.github/workflows/compiler_prereleases_manual.yml +++ b/.github/workflows/compiler_prereleases_manual.yml @@ -17,6 +17,9 @@ on: tag_version: required: false type: string + dry_run: + required: false + type: boolean permissions: {} @@ -33,5 +36,6 @@ jobs: dist_tag: ${{ inputs.dist_tag }} version_name: ${{ inputs.version_name }} tag_version: ${{ inputs.tag_version }} + dry_run: ${{ inputs.dry_run }} secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/compiler_prereleases_nightly.yml b/.github/workflows/compiler_prereleases_nightly.yml index 07919d7843b25..ca2b5589def2b 100644 --- a/.github/workflows/compiler_prereleases_nightly.yml +++ b/.github/workflows/compiler_prereleases_nightly.yml @@ -19,5 +19,6 @@ jobs: release_channel: experimental dist_tag: experimental version_name: '0.0.0' + dry_run: false secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From 5c15c1cd3442f28044217703b5625f98c40042ee Mon Sep 17 00:00:00 2001 From: lauren Date: Tue, 7 Oct 2025 15:16:18 -0400 Subject: [PATCH 2/3] [ci] Dry run with debug mode (#34767) Adds `--debug` to our dry run command so we can see the npm dry run output --- .github/workflows/compiler_prereleases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compiler_prereleases.yml b/.github/workflows/compiler_prereleases.yml index 6f60aac23c1d1..76cd3310b1a72 100644 --- a/.github/workflows/compiler_prereleases.yml +++ b/.github/workflows/compiler_prereleases.yml @@ -62,7 +62,7 @@ jobs: name: Publish packages to npm (dry run) run: | cp ./scripts/release/ci-npmrc ~/.npmrc - scripts/release/publish.js --ci --versionName=${{ inputs.version_name }} --tag=${{ inputs.dist_tag }} ${{ inputs.tag_version && format('--tagVersion={0}', inputs.tag_version) || '' }} + scripts/release/publish.js --frfr --debug --ci --versionName=${{ inputs.version_name }} --tag=${{ inputs.dist_tag }} ${{ inputs.tag_version && format('--tagVersion={0}', inputs.tag_version) || '' }} - if: inputs.dry_run != true name: Publish packages to npm run: | From 848e0e3a4f12022d396ddbc2b52fd8fa7ac31fa9 Mon Sep 17 00:00:00 2001 From: lauren Date: Tue, 7 Oct 2025 16:23:56 -0400 Subject: [PATCH 3/3] [eprh] Update plugin config to be compatible with flat and legacy (#34762) This has been incredibly frustrating as [ESLint's own docs](https://eslint.org/docs/latest/extend/plugins#backwards-compatibility-for-legacy-configs) are clearly wrong (see #34679). This PR uses [eslint-plugin-react's setup](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/index.js) as a reference, where the presets are assigned to `configs.flat` (not documented by eslint). --- fixtures/eslint-v9/eslint.config.ts | 2 +- .../eslint-plugin-react-hooks/package.json | 2 +- .../eslint-plugin-react-hooks/src/index.ts | 95 +++++++++---------- yarn.lock | 20 +++- 4 files changed, 63 insertions(+), 56 deletions(-) diff --git a/fixtures/eslint-v9/eslint.config.ts b/fixtures/eslint-v9/eslint.config.ts index 5a69593befad2..f7d0bddac443e 100644 --- a/fixtures/eslint-v9/eslint.config.ts +++ b/fixtures/eslint-v9/eslint.config.ts @@ -2,6 +2,7 @@ import {defineConfig} from 'eslint/config'; import reactHooks from 'eslint-plugin-react-hooks'; export default defineConfig([ + reactHooks.configs.flat['recommended-latest'], { languageOptions: { ecmaVersion: 'latest', @@ -12,7 +13,6 @@ export default defineConfig([ }, }, }, - extends: [reactHooks.configs['recommended-latest']], rules: { 'react-hooks/exhaustive-deps': 'error', }, diff --git a/packages/eslint-plugin-react-hooks/package.json b/packages/eslint-plugin-react-hooks/package.json index fdea39282033a..ea39fb4903247 100644 --- a/packages/eslint-plugin-react-hooks/package.json +++ b/packages/eslint-plugin-react-hooks/package.json @@ -50,7 +50,7 @@ "@babel/preset-typescript": "^7.26.0", "@babel/types": "^7.19.0", "@tsconfig/strictest": "^2.0.5", - "@types/eslint": "^8.56.12", + "@types/eslint": "^9.6.1", "@types/estree": "^1.0.6", "@types/estree-jsx": "^1.0.5", "@types/node": "^20.2.5", diff --git a/packages/eslint-plugin-react-hooks/src/index.ts b/packages/eslint-plugin-react-hooks/src/index.ts index e26fa5aed7ac7..838b1081a7ef8 100644 --- a/packages/eslint-plugin-react-hooks/src/index.ts +++ b/packages/eslint-plugin-react-hooks/src/index.ts @@ -14,7 +14,6 @@ import { } from './shared/ReactCompiler'; import RulesOfHooks from './rules/RulesOfHooks'; -// All rules const rules = { 'exhaustive-deps': ExhaustiveDeps, 'rules-of-hooks': RulesOfHooks, @@ -23,7 +22,6 @@ const rules = { ), } satisfies Record; -// Basic hooks rules (for recommended config) const basicRuleConfigs = { 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', @@ -38,74 +36,71 @@ const compilerRuleConfigs = Object.fromEntries( }), ) as Record<`react-hooks/${string}`, Linter.RuleEntry>; -// All rules including compiler rules (for recommended-latest config) const allRuleConfigs: Linter.RulesRecord = { ...basicRuleConfigs, ...compilerRuleConfigs, }; -type FlatConfig = { +const plugins = ['react-hooks']; + +type ReactHooksFlatConfig = { plugins: Record; rules: Linter.RulesRecord; }; +const configs = { + 'recommended-legacy': { + plugins, + rules: basicRuleConfigs, + }, + 'recommended-latest-legacy': { + plugins, + rules: allRuleConfigs, + }, + 'flat/recommended': { + plugins, + rules: basicRuleConfigs, + }, + 'recommended-latest': { + plugins, + rules: allRuleConfigs, + }, + recommended: { + plugins, + rules: basicRuleConfigs, + }, + flat: {} as Record, +}; + const plugin = { meta: { name: 'eslint-plugin-react-hooks', }, rules, - configs: {} as { - 'recommended-legacy': { - plugins: Array; - rules: Linter.RulesRecord; - }; - 'recommended-latest-legacy': { - plugins: Array; - rules: Linter.RulesRecord; - }; - 'flat/recommended': Array; - 'recommended-latest': Array; - recommended: Array; - }, + configs, }; -Object.assign(plugin.configs, { +Object.assign(configs.flat, { 'recommended-legacy': { - plugins: ['react-hooks'], - rules: basicRuleConfigs, + plugins: {'react-hooks': plugin}, + rules: configs['recommended-legacy'].rules, }, - 'recommended-latest-legacy': { - plugins: ['react-hooks'], - rules: allRuleConfigs, + plugins: {'react-hooks': plugin}, + rules: configs['recommended-latest-legacy'].rules, + }, + 'flat/recommended': { + plugins: {'react-hooks': plugin}, + rules: configs['flat/recommended'].rules, + }, + 'recommended-latest': { + plugins: {'react-hooks': plugin}, + rules: configs['recommended-latest'].rules, + }, + recommended: { + plugins: {'react-hooks': plugin}, + rules: configs.recommended.rules, }, - - 'flat/recommended': [ - { - plugins: { - 'react-hooks': plugin, - }, - rules: basicRuleConfigs, - }, - ], - - 'recommended-latest': [ - { - plugins: { - 'react-hooks': plugin, - }, - rules: allRuleConfigs, - }, - ], - - recommended: [ - { - plugins: { - 'react-hooks': plugin, - }, - rules: basicRuleConfigs, - }, - ], }); export default plugin; diff --git a/yarn.lock b/yarn.lock index ffb13120b80a3..73519b9f695a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3907,10 +3907,10 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/eslint@^8.56.12": - version "8.56.12" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.12.tgz#1657c814ffeba4d2f84c0d4ba0f44ca7ea1ca53a" - integrity sha512-03ruubjWyOHlmljCVoxSuNDdmfZDzsrrz0P2LeJsOXr+ZwFQ+0yQIwNCwt/GYhV7Z31fgtXJTAEs+FYlEL851g== +"@types/eslint@^9.6.1": + version "9.6.1" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-9.6.1.tgz#d5795ad732ce81715f27f75da913004a56751584" + integrity sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag== dependencies: "@types/estree" "*" "@types/json-schema" "*" @@ -10190,6 +10190,11 @@ hermes-eslint@^0.32.0: hermes-estree "0.32.0" hermes-parser "0.32.0" +hermes-estree@0.25.1: + version "0.25.1" + resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480" + integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw== + hermes-estree@0.29.1: version "0.29.1" resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.29.1.tgz#043c7db076e0e8ef8c5f6ed23828d1ba463ebcc5" @@ -10214,6 +10219,13 @@ hermes-parser@0.32.0, hermes-parser@^0.32.0: dependencies: hermes-estree "0.32.0" +hermes-parser@^0.25.1: + version "0.25.1" + resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.25.1.tgz#5be0e487b2090886c62bd8a11724cd766d5f54d1" + integrity sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA== + dependencies: + hermes-estree "0.25.1" + homedir-polyfill@^1.0.0, homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8"