diff --git a/.eslint-doc-generatorrc.js b/.eslint-doc-generatorrc.js index 1e6d1717f3..81c443bebb 100644 --- a/.eslint-doc-generatorrc.js +++ b/.eslint-doc-generatorrc.js @@ -4,7 +4,7 @@ const config = { ['jsx-runtime', '🏃'], ['recommended', '☑️'], ], - ignoreConfig: ['all'], + ignoreConfig: ['all', 'flat'], urlConfigs: 'https://github.com/jsx-eslint/eslint-plugin-react/#shareable-configs', }; diff --git a/.eslintrc b/.eslintrc index 4991f200f2..894df7caa9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,82 +1,85 @@ { - "root": true, - "extends": ["airbnb-base", "plugin:eslint-plugin/recommended"], - "plugins": ["eslint-plugin"], - "env": { - "es6": true, - "node": true - }, - "parserOptions": { - "ecmaVersion": 6, - "ecmaFeatures": { - "jsx": true - }, - "sourceType": "script", - }, - "ignorePatterns": [ - "coverage/", - ".nyc_output/", - ], - "rules": { - "comma-dangle": [2, "always-multiline"], - "object-shorthand": [2, "always", { - "ignoreConstructors": false, - "avoidQuotes": false, // this is the override vs airbnb - }], - "max-len": [2, 120, { - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreComments": true, - }], - "consistent-return": 0, + "root": true, + "extends": ["airbnb-base", "plugin:eslint-plugin/recommended"], + "plugins": ["eslint-plugin"], + "env": { + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaVersion": 6, + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "script", + }, + "ignorePatterns": [ + "coverage/", + ".nyc_output/", + "test-published-types/", + "tests/fixtures/flat-config/", + "**/*/*.d.ts", + ], + "rules": { + "comma-dangle": [2, "always-multiline"], + "object-shorthand": [2, "always", { + "ignoreConstructors": false, + "avoidQuotes": false, // this is the override vs airbnb + }], + "max-len": [2, 140, { + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreComments": true, + }], + "consistent-return": 0, - "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }], - "prefer-object-spread": 0, // until node 8 is required - "prefer-rest-params": 0, // until node 6 is required - "prefer-spread": 0, // until node 6 is required - "function-call-argument-newline": 1, // TODO: enable - "function-paren-newline": 0, - "no-plusplus": [2, {"allowForLoopAfterthoughts": true}], - "no-param-reassign": 1, - "no-restricted-syntax": [2, { - "selector": "ObjectPattern", - "message": "Object destructuring is not compatible with Node v4" - }], - "strict": [2, "safe"], - "valid-jsdoc": [2, { - "requireReturn": false, - "requireParamDescription": false, - "requireReturnDescription": false, - }], + "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }], + "prefer-object-spread": 0, // until node 8 is required + "prefer-rest-params": 0, // until node 6 is required + "prefer-spread": 0, // until node 6 is required + "function-call-argument-newline": 1, // TODO: enable + "function-paren-newline": 0, + "no-plusplus": [2, {"allowForLoopAfterthoughts": true}], + "no-param-reassign": 1, + "no-restricted-syntax": [2, { + "selector": "ObjectPattern", + "message": "Object destructuring is not compatible with Node v4" + }], + "strict": [2, "safe"], + "valid-jsdoc": [2, { + "requireReturn": false, + "requireParamDescription": false, + "requireReturnDescription": false, + }], - "eslint-plugin/consistent-output": 0, - "eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }], - "eslint-plugin/require-meta-schema": 0, - "eslint-plugin/require-meta-type": 0 + "eslint-plugin/consistent-output": 0, + "eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }], + "eslint-plugin/require-meta-schema": 0, + "eslint-plugin/require-meta-type": 0 + }, + "overrides": [ + { + "files": "tests/**", + "rules": { + "no-template-curly-in-string": 1, + }, }, - "overrides": [ - { - "files": "tests/**", - "rules": { - "no-template-curly-in-string": 1, - }, + { + "files": "markdown.config.js", + "rules": { + "no-console": 0, }, - { - "files": "markdown.config.js", - "rules": { - "no-console": 0, - }, + }, + { + "files": ".github/workflows/*.js", + "parserOptions": { + "ecmaVersion": 2019, }, - { - "files": ".github/workflows/*.js", - "parserOptions": { - "ecmaVersion": 2019, - }, - "rules": { - "camelcase": 0, - "no-console": 0, - "no-restricted-syntax": 0, - }, + "rules": { + "camelcase": 0, + "no-console": 0, + "no-restricted-syntax": 0, }, - ], + }, + ], } diff --git a/.github/workflows/node-18+.yml b/.github/workflows/node-18+.yml index 921db8111b..5a48b15a88 100644 --- a/.github/workflows/node-18+.yml +++ b/.github/workflows/node-18+.yml @@ -26,6 +26,7 @@ jobs: matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} eslint: + - 9 - 8 - 7 - 6 @@ -37,20 +38,78 @@ jobs: - 10 - 9 - 8 + typescript-eslint: + - 5 + - 6 + - 7 + - 8 + exclude: + - eslint: 3 + babel-eslint: 10 + - eslint: 3 + typescript-eslint: 5 + - eslint: 4 + typescript-eslint: 5 + - eslint: 4.14 + typescript-eslint: 5 + - eslint: 5 + typescript-eslint: 5 + - eslint: 3 + typescript-eslint: 6 + - eslint: 4 + typescript-eslint: 6 + - eslint: 4.14 + typescript-eslint: 6 + - eslint: 5 + typescript-eslint: 6 + - eslint: 6 + typescript-eslint: 6 + - eslint: 9 + typescript-eslint: 6 + - eslint: 3 + typescript-eslint: 7 + - eslint: 4 + typescript-eslint: 7 + - eslint: 4.14 + typescript-eslint: 7 + - eslint: 5 + typescript-eslint: 7 + - eslint: 6 + typescript-eslint: 7 + - eslint: 7 + typescript-eslint: 7 + - eslint: 9 + typescript-eslint: 7 + - eslint: 3 + typescript-eslint: 8 + - eslint: 4 + typescript-eslint: 8 + - eslint: 4.14 + typescript-eslint: 8 + - eslint: 5 + typescript-eslint: 8 + - eslint: 6 + typescript-eslint: 8 + - eslint: 7 + typescript-eslint: 8 + - eslint: 9 + typescript-eslint: 5 + - node-version: 19 + typescript-eslint: 7 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} after_install: | - npm install --no-save "eslint@${{ matrix.eslint }}" "@typescript-eslint/parser@5" "babel-eslint@${{ matrix.babel-eslint }}" + npm install --no-save "eslint@${{ matrix.eslint }}" "@typescript-eslint/parser@${{ matrix.typescript-eslint == 8 && 8.17 || matrix.typescript-eslint }}" "babel-eslint@${{ matrix.babel-eslint }}" env: - NPM_CONFIG_LEGACY_PEER_DEPS: true + NPM_CONFIG_LEGACY_PEER_DEPS: "${{ matrix.typescript-eslint >= 6 && 'false' || 'true' }}" - run: npx ls-engines - run: npm run unit-test - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v3.1.5 node: name: 'node 18+' diff --git a/.github/workflows/node-minors.yml b/.github/workflows/node-minors.yml index 2b5230268a..9e227f2b89 100644 --- a/.github/workflows/node-minors.yml +++ b/.github/workflows/node-minors.yml @@ -94,20 +94,20 @@ jobs: eslint: 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} after_install: | - npm install --no-save "eslint@${{ matrix.eslint }}" "@typescript-eslint/parser@${{ matrix.node-version >= 14 && '5' || (matrix.node-version >= 12 && '4' || (matrix.node-version >= 10 && '4.0' || (matrix.node-version >= 8 && '3' || '2'))) }}" "babel-eslint@${{ matrix.babel-eslint }}" + npm install --no-save "eslint@${{ matrix.eslint }}" "@typescript-eslint/parser@${{ matrix.node-version >= 18 && matrix.eslint >= 8 && '8.17' || (matrix.node-version >= 16 && matrix.eslint >= 7 && '6' || (matrix.node-version >= 14 && '5' || (matrix.node-version >= 12 && '4' || (matrix.node-version >= 10 && '4.0' || (matrix.node-version >= 8 && '3' || '2'))))) }}" "babel-eslint@${{ matrix.babel-eslint }}" skip-ls-check: ${{ matrix.node-version < 10 && true || false }} env: - NPM_CONFIG_LEGACY_PEER_DEPS: true + NPM_CONFIG_LEGACY_PEER_DEPS: "${{ matrix.node-version >= 16 && matrix.eslint >= 7 && 'false' || 'true' }}" - run: npx ls-engines if: ${{ matrix.node-version >= 12 }} - run: npm run unit-test - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v3.1.5 node: name: 'node 4 - 17' diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml index 5177ab52fa..ed00d06b47 100644 --- a/.github/workflows/node-pretest.yml +++ b/.github/workflows/node-pretest.yml @@ -7,20 +7,18 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ljharb/actions/node/install@main name: 'nvm install lts/* && npm install' with: node-version: 'lts/*' - env: - NPM_CONFIG_LEGACY_PEER_DEPS: true - run: npm run pretest posttest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ljharb/actions/node/install@main name: 'nvm install lts/* && npm install' with: diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 2b89b601b7..2e654951b6 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -15,7 +15,7 @@ jobs: outputs: is-new-version: ${{ steps.cpv.outputs.is-new-version }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.tag }} @@ -63,7 +63,10 @@ jobs: const pending = checkSuites.filter(({ status }) => status !== 'completed') if (pending.length > 0) { - core.setFailed(`Some workflows for ${context.payload.inputs.tag} are still in-progress: ${JSON.stringify(pending)}`); + core.setFailed(`Some workflows for ${context.payload.inputs.tag} are still in-progress`); + pending.forEach(({ pull_requests, ...x }) => { + core.debug(JSON.stringify(x)); + }); } const result = await Promise.all( @@ -94,7 +97,7 @@ jobs: contents: read id-token: write steps: - - uses: step-security/harden-runner@v1 + - uses: step-security/harden-runner@v2 with: egress-policy: block allowed-endpoints: > @@ -102,8 +105,9 @@ jobs: nodejs.org:443 prod.api.stepsecurity.io:443 registry.npmjs.org:443 + raw.githubusercontent.com:443 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.tag }} diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml index a4d47c74ca..b9e1712fc4 100644 --- a/.github/workflows/rebase.yml +++ b/.github/workflows/rebase.yml @@ -4,12 +4,6 @@ on: [pull_request_target] jobs: _: - name: "Automatic Rebase" - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: ljharb/rebase@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ljharb/actions/.github/workflows/rebase.yml@main + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a110a1f476..d6f97d2e84 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,18 +15,27 @@ jobs: contents: write steps: - - uses: step-security/harden-runner@v1 + - uses: step-security/harden-runner@v2 with: allowed-endpoints: api.github.com:443 github.com:443 + raw.githubusercontent.com:443 + nodejs.org:443 + registry.npmjs.org:443 - name: Get version from tag id: tag_name run: echo "current_version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" shell: bash - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - uses: ljharb/actions/node/install@main + with: + node-version: node + skip-install: true + skip-ls-check: true - uses: mindsers/changelog-reader-action@v2 id: changelog_reader @@ -37,9 +46,9 @@ jobs: id: changelog run: | # Parse the changelog for common links - _links="$(grep -P '^\[.*]:.+' ${GITHUB_WORKSPACE}/CHANGELOG.md | sort -u)" + _links="$(egrep '^\[.*]:.+' ${GITHUB_WORKSPACE:-.}/CHANGELOG.md | sort -u)" _links="${_links//'%'/'%25'}" - _links="${_links//$'\n'/'%0A'}" + # _links="${_links//$'\n'/'%0A'}" _links="${_links//$'\r'/'%0D'}" # Set output 'links' to $_links DELIMITER=$(uuidgen) @@ -47,8 +56,23 @@ jobs: echo "$_links" >> "${GITHUB_OUTPUT}" echo "${DELIMITER}" >> "${GITHUB_OUTPUT}" - - uses: softprops/action-gh-release@v1 + - name: 'concat data > tmp.md' + run: | + cat << 'EOF' > tmp.md + ${{ steps.changelog_reader.outputs.changes }} + ${{ steps.changelog.outputs.links }} + EOF + + - run: cat tmp.md + + - id: prune-footnotes + run: | + DELIMITER=$(uuidgen) + echo "body<<${DELIMITER}" >> "${GITHUB_OUTPUT}" + npx gfm-footnotes -i tmp.md >> "${GITHUB_OUTPUT}" + echo "${DELIMITER}" >> "${GITHUB_OUTPUT}" + + - uses: softprops/action-gh-release@v2 with: body: | - ${{ steps.changelog_reader.outputs.changes }} - ${{ steps.changelog.outputs.links }} + ${{ steps.prune-footnotes.outputs.body }} diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 5c5d99b338..a2dacffb91 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -10,7 +10,7 @@ jobs: if: ${{ github.repository == 'jsx-eslint/eslint-plugin-react' || github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ljharb/actions/node/install@main name: 'nvm install lts/* && npm install' with: diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml new file mode 100644 index 0000000000..0aaca2cb00 --- /dev/null +++ b/.github/workflows/type-check.yml @@ -0,0 +1,77 @@ +name: "Types: check published types" + +on: [pull_request, push] + +permissions: + contents: read + +jobs: + test: + name: TS ${{ matrix.ts_version }}, "${{ matrix.ts_lib }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ts_version: + # The official ESLint types are not compatible with TS 3.9 + # - 3.9 + - '4.0' + - 4.1 + - 4.2 + - 4.3 + - 4.4 + - 4.5 + - '5.0' + - 5.5 + - 5.6 + ts_lib: + - es2015 + - es2015,dom + - es2020 + - esnext + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + show-progress: false + + - uses: ljharb/actions/node/install@main + name: 'nvm install lts/* && npm install' + with: + node-version: 'lts/*' + skip-ls-check: true + + - name: build types + run: npm run build-types + + # Pack the lib into a tarball so that when we install the lib later in the + # test-published-types directory, it's only install `dependencies` of the + # lib. + - name: pack the lib + run: npm pack --pack-destination /tmp/ + + - name: find the packed lib + run: echo "ESLINT_PLUGIN_REACT_PATH=$(ls /tmp/eslint-plugin-react*.tgz | tail -n 1)" >> $GITHUB_ENV + + - name: show the path to the packed lib + run: echo "$ESLINT_PLUGIN_REACT_PATH" + + - name: npm install working directory + run: npm install + working-directory: test-published-types + + - name: install eslint-plugin-react and typescript version ${{ matrix.ts_version }} + run: npm install --no-save "$ESLINT_PLUGIN_REACT_PATH" typescript@${{ matrix.ts_version }} + working-directory: test-published-types + + - name: show installed typescript version + run: npm list typescript --depth=0 + working-directory: test-published-types + + - name: show installed eslint-plugin-react version + run: npm list eslint-plugin-react --depth=0 + working-directory: test-published-types + + - name: check types with lib "${{ matrix.ts_lib }}" + run: npx tsc --lib ${{ matrix.ts_lib }} + working-directory: test-published-types diff --git a/.gitignore b/.gitignore index 453b7fd5f6..43605edffc 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,9 @@ package-lock.json yarn.lock .npmignore + +/lib/**/*.d.ts +/lib/**/*.d.ts.map +!/lib/types.d.ts +/index.d.ts +/index.d.ts.map diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b95e4560f..9696eca775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,265 @@ # Change Log + All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](https://keepachangelog.com). ## Unreleased +### Added +* [`jsx-props-no-multi-spaces`]: improve autofix for multi-line ([#3930][] @justisb) + +### Fixed +* [`no-unknown-property`]: allow `onLoad` on `body` ([#3923][] @DerekStapleton) + +[#3930]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3930 +[#3923]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3923 + +## [7.37.5] - 2025.04.03 + +### Fixed +* [`no-unknown-property`]: allow shadow root attrs on `