diff --git a/.markdownlint.json b/.markdownlint.json index e44d96997..8881abb75 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,6 +1,7 @@ { "extends": "markdownlint/style/all", "MD013": false, + "MD024": false, "MD033": false, "MD041": false } diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9733113..49d3ca964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## v1.22.2 (Draft) + +### πŸͺ„ Improvements + +- refactor: JSX fragments related rules no longer rely on `jsxPragma` and `jsxFragmentPragma` settings to perform their checks +- refactor: improve applicability of the `no-useless-fragment` and `prefer-shorthand-fragment` rules +- refactor: deprecate `settings["react-x"].jsxPragma` and `settings["react-x"].jsxFragmentPragma` + ## v1.22.2 (Mon 30 Dec 2024) ### πŸͺ„ Improvements @@ -9,11 +17,11 @@ ### πŸͺ„ Improvements -- docs: add getting started guides for JavaScript, TypeScript, and JavaScript with Babel. -- docs: improve code samples in rules docs. -- docs: improve `eslint.config.js` examples in README.md, docs and the examples folder. -- docs: improve the error message and description of various rules. -- refactor(website): better website layout and navigation experience. +- docs: add getting started guides for JavaScript, TypeScript, and JavaScript with Babel +- docs: improve code samples in rules docs +- docs: improve `eslint.config.js` examples in README.md, docs and the examples folder +- docs: improve the error message and description of various rules +- refactor(website): better website layout and navigation experience ### πŸ“ Changes in examples @@ -25,17 +33,17 @@ This approach can fundamentally avoid the errors[[1](https://typescript-eslint.i ### πŸͺ„ Improvements -- refactor(plugins/x): rename `jsx-use-vars` to `use-jsx-vars`. -- refactor(plugins/x): rename `jsx-no-duplicate-props` to `no-duplicate-jsx-props`. -- refactor(plugins/dom): rename `no-children-in-void-dom-elements` to `no-void-elements-with-children`. +- refactor(plugins/x): rename `jsx-use-vars` to `use-jsx-vars` +- refactor(plugins/x): rename `jsx-no-duplicate-props` to `no-duplicate-jsx-props` +- refactor(plugins/dom): rename `no-children-in-void-dom-elements` to `no-void-elements-with-children` ### πŸ“ Changes you should be aware of The following rules have been renamed: -- `jsx-uses-vars` to `use-jsx-vars`. -- `jsx-no-duplicate-props` to `no-duplicate-jsx-props`. -- `dom/no-children-in-void-dom-elements` to `dom/no-void-elements-with-children`. +- `jsx-uses-vars` to `use-jsx-vars` +- `jsx-no-duplicate-props` to `no-duplicate-jsx-props` +- `dom/no-children-in-void-dom-elements` to `dom/no-void-elements-with-children` The new rule names are aligned with the same rules in the [biomejs/rules-sources/#eslint-plugin-react](https://biomejs.dev/linter/rules-sources/#eslint-plugin-react) (if any) to enhance consistency. The old rule names will still be available until the next major update to avoid breaking changes. @@ -47,7 +55,7 @@ The new rule names are aligned with the same rules in the [biomejs/rules-sources ### πŸͺ„ Improvements -- refactor(plugins/hooks-extra): deprecate rule `no-redundant-custom-hook` in favor of `no-useless-custom-hooks` (the previous rule will still be available until the next major update to avoid breaking changes). +- refactor(plugins/hooks-extra): deprecate rule `no-redundant-custom-hook` in favor of `no-useless-custom-hooks` (the previous rule will still be available until the next major update to avoid breaking changes) ### πŸ“ Changes in Rule implementation @@ -97,7 +105,7 @@ function useAuth() { - refactor(plugins/eslint-plugin): remove `prefer-read-only-props` from `recommended-type-checked` preset by @rEl1cx in - refactor(plugins/eslint-plugin): hide `avoid-shorthand-boolean` and `avoid-shorthand-fragment` from presets and docs by @rEl1cx in -- Update `@typescript-eslint`'s packages to `^8.18.0`. +- Update `@typescript-eslint`'s packages to `^8.18.0` ## v1.18.0 (Sun 8 Dec 2024) @@ -119,15 +127,15 @@ function useAuth() { ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `^8.17.0`. +- Update `@typescript-eslint`'s packages to `^8.17.0` ## v1.17.2 (Sun 1 Dec 2024) ### πŸͺ„ Improvements -- Update `eslint`'s packages to `^9.16.0`. -- Update `@typescript-eslint`'s packages to `^8.16.0`. -- Update `ts-api-utils` to `^2.0.0`. +- Update `eslint`'s packages to `^9.16.0` +- Update `@typescript-eslint`'s packages to `^8.16.0` +- Update `ts-api-utils` to `^2.0.0` ## v1.17.1 (Fri 22 Nov 2024) @@ -183,13 +191,13 @@ function useAuth() { ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `^8.12.2`. +- Update `@typescript-eslint`'s packages to `^8.12.2` ## v1.15.2 (Tue 29 Oct 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `^8.12.1`. +- Update `@typescript-eslint`'s packages to `^8.12.1` ## v1.15.1 (Sat 26 Oct 2024) @@ -231,54 +239,54 @@ function useAuth() { ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `^8.7.0`. +- Update `@typescript-eslint`'s packages to `^8.7.0` ## v1.14.2 (Fri 20 Sep 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `^8.6.0`. +- Update `@typescript-eslint`'s packages to `^8.6.0` ## v1.14.1 (Thu 12 Sep 2024) ### 🐞 Fixes -- Fixed false positives in rule `web-api/no-leaked-resize-observer`. +- Fixed false positives in rule `web-api/no-leaked-resize-observer` ## v1.14.0 (Tue 10 Sep 2024) ### 🐞 Fixes -- Fixed modular plugins missing default export. -- Fixed component name detection when the component name starts with a underscore. +- Fixed modular plugins missing default export +- Fixed component name detection when the component name starts with a underscore ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `^8.5.0`. +- Update `@typescript-eslint`'s packages to `^8.5.0` ## v1.13.1 (Mon 09 Sep 2024) ### 🐞 Fixes -- Fixed `hooks-extra/no-unnecessary-use-callback` and `hooks-extra/no-unnecessary-use-memo` false positives when there are references from nested scopes. +- Fixed `hooks-extra/no-unnecessary-use-callback` and `hooks-extra/no-unnecessary-use-memo` false positives when there are references from nested scopes ## v1.13.0 (Wed 04 Sep 2024) ### ✨ New -- Added `web-api/no-leaked-resize-observer` rule to prevent leaked `ResizeObserver`. +- Added `web-api/no-leaked-resize-observer` rule to prevent leaked `ResizeObserver` ### 🐞 Fixes -- `hooks-extra/no-useless-custom-hooks` should allow custom Hooks with empty body. +- `hooks-extra/no-useless-custom-hooks` should allow custom Hooks with empty body ### πŸͺ„ Improvements -- Rename `debug/react-hooks` to `debug/hook`. -- Rename `hooks-extra/ensure-custom-using-hooks` to `hooks-extra/no-useless-custom-hooks`. -- Rename `hooks-extra/ensure-use-memo-has-non-empty-deps` to `hooks-extra/no-unnecessary-use-memo`. -- Rename `hooks-extra/ensure-use-callback-has-non-empty-deps` to `hooks-extra/no-unnecessary-use-callback`. -- Upgrade `@typescript-eslint`'s packages to `^8.4.0`. +- Rename `debug/react-hooks` to `debug/hook` +- Rename `hooks-extra/ensure-custom-using-hooks` to `hooks-extra/no-useless-custom-hooks` +- Rename `hooks-extra/ensure-use-memo-has-non-empty-deps` to `hooks-extra/no-unnecessary-use-memo` +- Rename `hooks-extra/ensure-use-callback-has-non-empty-deps` to `hooks-extra/no-unnecessary-use-callback` +- Upgrade `@typescript-eslint`'s packages to `^8.4.0` (The rules that were renamed in this release will still be available until the next major update to avoid breaking changes.) @@ -286,265 +294,265 @@ function useAuth() { ### ✨ New -- Added `useLayoutEffect` and `useInsertionEffect` support to `hooks-extra/no-direct-set-state-in-use-effect`. +- Added `useLayoutEffect` and `useInsertionEffect` support to `hooks-extra/no-direct-set-state-in-use-effect` ### πŸͺ„ Improvements -- Deprecate rule `hooks-extra/no-direct-set-state-in-use-layout-effect` in favor of `hooks-extra/no-direct-set-state-in-use-effect` (the previous rule will still be available until the next major update to avoid breaking changes). +- Deprecate rule `hooks-extra/no-direct-set-state-in-use-layout-effect` in favor of `hooks-extra/no-direct-set-state-in-use-effect` (the previous rule will still be available until the next major update to avoid breaking changes) ## v1.12.3 (Thu 29 Aug 2024) ### ✨ New -- Added support for detecting event listeners removed by abort signal in rule `web-api/no-leaked-event-listener`. +- Added support for detecting event listeners removed by abort signal in rule `web-api/no-leaked-event-listener` ### 🐞 Fixes -- Fixed `no-duplicate-key` rule false positives when the key is an variable. -- Fixed `web-api/no-leaked-set-timeout` and `web-api/no-leaked-set-interval` false positives when a timer is assigned to a variable declared by `let` but not initialized. +- Fixed `no-duplicate-key` rule false positives when the key is an variable +- Fixed `web-api/no-leaked-set-timeout` and `web-api/no-leaked-set-interval` false positives when a timer is assigned to a variable declared by `let` but not initialized ## v1.12.3 (Thu 29 Aug 2024) ### ✨ New -- Added support for detecting event listeners removed by abort signal in rule `web-api/no-leaked-event-listener`. +- Added support for detecting event listeners removed by abort signal in rule `web-api/no-leaked-event-listener` ### 🐞 Fixes -- Fixed `no-duplicate-key` rule false positives when the key is an variable. -- Fixed `web-api/no-leaked-set-timeout` and `web-api/no-leaked-set-interval` false positives when a timer is assigned to a variable declared by `let` but not initialized. +- Fixed `no-duplicate-key` rule false positives when the key is an variable +- Fixed `web-api/no-leaked-set-timeout` and `web-api/no-leaked-set-interval` false positives when a timer is assigned to a variable declared by `let` but not initialized ### πŸͺ„ Improvements -- Allow upper case letters in the rule `naming-convention/component-name` when the component name is less than 4 characters, e.g. `UI`, `CSS`, `SVG`. +- Allow upper case letters in the rule `naming-convention/component-name` when the component name is less than 4 characters, e.g. `UI`, `CSS`, `SVG` ## v1.12.2 (Tue 27 Aug 2024) ### ✨ New -- Added type declarations for `react-x` settings to the `@typescript-eslint/utils/ts-eslint` module via the `SharedConfigurationSettings` interface. +- Added type declarations for `react-x` settings to the `@typescript-eslint/utils/ts-eslint` module via the `SharedConfigurationSettings` interface ### πŸͺ„ Improvements -- Improve the performance of the `no-missing-key` and `no-duplicate-key` rules. -- Upgrade `@typescript-eslint`'s packages to `^8.3.0`. +- Improve the performance of the `no-missing-key` and `no-duplicate-key` rules +- Upgrade `@typescript-eslint`'s packages to `^8.3.0` ## v1.12.1 (Thu 22 Aug 2024) ### ✨ New -- Add the options `allowAllCaps`, `allowNamespace`, `allowLeadingUnderscore` to `naming-convention/component-name` and set their default values to `false`. +- Add the options `allowAllCaps`, `allowNamespace`, `allowLeadingUnderscore` to `naming-convention/component-name` and set their default values to `false` ### πŸͺ„ Improvements -- Normalize the component name in rule `naming-convention/component-name` before checking it against the pattern. +- Normalize the component name in rule `naming-convention/component-name` before checking it against the pattern ## v1.12.0 (Wed 21 Aug 2024) ### ✨ New -- Added `hooks-extra` rules to `recommended` and `recommended-legacy` presets. +- Added `hooks-extra` rules to `recommended` and `recommended-legacy` presets ## v1.11.0 (Tue 20 Aug 2024) ### ✨ New -- Added `eslint-plugin-react-web-api` - A plugin that provides rules for interacting with Web APIs in React applications. -- Added `web-api/no-leaked-timeout` rule to prevent leaked `setTimeout`. -- Added `web-api/no-leaked-interval` rule to prevent leaked `setInterval`. -- Added `web-api/no-leaked-event-listener` rule to prevent leaked `addEventListener`. -- Added `web-api` and `web-api-legacy` presets to enable all rules provided by `eslint-plugin-react-web-api`. -- Added `react-web-api/no-leaked-event-listener` to `recommended` and `recommended-legacy` presets. +- Added `eslint-plugin-react-web-api` - A plugin that provides rules for interacting with Web APIs in React applications +- Added `web-api/no-leaked-timeout` rule to prevent leaked `setTimeout` +- Added `web-api/no-leaked-interval` rule to prevent leaked `setInterval` +- Added `web-api/no-leaked-event-listener` rule to prevent leaked `addEventListener` +- Added `web-api` and `web-api-legacy` presets to enable all rules provided by `eslint-plugin-react-web-api` +- Added `react-web-api/no-leaked-event-listener` to `recommended` and `recommended-legacy` presets ### πŸͺ„ Improvements -- Improve performance by skipping unnecessary checks when possible. -- Improve dts generation of the `@eslint-react/eslint-plugin` package. -- Improve website and documentation. -- Upgrade `@typescript-eslint`'s packages to `^8.2.0`. +- Improve performance by skipping unnecessary checks when possible +- Improve dts generation of the `@eslint-react/eslint-plugin` package +- Improve website and documentation +- Upgrade `@typescript-eslint`'s packages to `^8.2.0` ## v1.10.1 (Tue 13 Aug 2024) ### 🐞 Fixes -- Fixed `hooks-extra/prefer-use-state-lazy-initialization` false positive when using an initializer function. +- Fixed `hooks-extra/prefer-use-state-lazy-initialization` false positive when using an initializer function ### πŸͺ„ Improvements -- Improve rule `no-implicit-key` error marker position and range. -- Upgrade `@typescript-eslint`'s packages to `^8.1.0`. -- Improve website and documentation. +- Improve rule `no-implicit-key` error marker position and range +- Upgrade `@typescript-eslint`'s packages to `^8.1.0` +- Improve website and documentation ## v1.10.0 (Sun 11 Aug 2024) ### ✨ New -- Added `disable-type-checked` and `disable-type-checked-legacy` presets to disable all type-checked rules. +- Added `disable-type-checked` and `disable-type-checked-legacy` presets to disable all type-checked rules ### πŸͺ„ Improvements -- Rename `off-dom` and `off-dom-legacy` presets to `disable-dom` and `disable-dom-legacy` (the old names will still be available until the next major update to avoid breaking changes). +- Rename `off-dom` and `off-dom-legacy` presets to `disable-dom` and `disable-dom-legacy` (the old names will still be available until the next major update to avoid breaking changes) ## v1.9.1 (Thu 08 Aug 2024) ### 🐞 Fixes -- Fixed `dom/no-missing-iframe-sandbox` false positive when the `sandbox` attribute is set to `sandbox=""`. -- Fixed `all` and `all-legacy` presets not including `hooks-extra` rules. +- Fixed `dom/no-missing-iframe-sandbox` false positive when the `sandbox` attribute is set to `sandbox=""` +- Fixed `all` and `all-legacy` presets not including `hooks-extra` rules ## v1.9.0 (Tue 06 Aug 2024) ### ✨ New -- Add `core` preset that includes the most essential rules. +- Add `core` preset that includes the most essential rules ### πŸͺ„ Improvements -- Upgrade `@typescript-eslint`'s packages to `8.0.1`. +- Upgrade `@typescript-eslint`'s packages to `8.0.1` ## v1.8.2 (Sat 03 Aug 2024) ### 🐞 Fixes -- Fixed legacy presets not being exported correctly in `@eslint-react/eslint-plugin`. +- Fixed legacy presets not being exported correctly in `@eslint-react/eslint-plugin` ## v1.8.1 (Sat 03 Aug 2024) ### πŸͺ„ Improvements -- Enhance rule `hooks-extra/no-direct-set-state-in-use-effect` and `hooks-extra/no-direct-set-state-in-use-layout-effect` to support `set` function directly passed to `useCallback` and `useMemo` without explicitly calling it. -- Improve website and documentation. +- Enhance rule `hooks-extra/no-direct-set-state-in-use-effect` and `hooks-extra/no-direct-set-state-in-use-layout-effect` to support `set` function directly passed to `useCallback` and `useMemo` without explicitly calling it +- Improve website and documentation ## v1.8.0 (Fri 02 Aug 2024) ### 🐞 Fixes -- Fixed `ESLintReactSettings` type not being exported correctly. -- Fixed the `set` function calls that are wrapped in a `useMemo` or `useCallback` like hook not being detected by `hooks-extra/no-direct-set-state-in-use-effect` and `hooks-extra/no-direct-set-state-in-use-layout-effect`. +- Fixed `ESLintReactSettings` type not being exported correctly +- Fixed the `set` function calls that are wrapped in a `useMemo` or `useCallback` like hook not being detected by `hooks-extra/no-direct-set-state-in-use-effect` and `hooks-extra/no-direct-set-state-in-use-layout-effect` ### πŸͺ„ Improvements -- Upgrade `@typescript-eslint`'s packages to `8.0.0`. -- Improve website and documentation. +- Upgrade `@typescript-eslint`'s packages to `8.0.0` +- Improve website and documentation ## v1.7.1 (Wed 31 Jul 2024) ### 🐞 Fixes -- Fixed the spread attributes support for dom related rules. -- Fixed the issue where the overridden value was retrieved when there were duplicate attributes on a JSX element. +- Fixed the spread attributes support for dom related rules +- Fixed the issue where the overridden value was retrieved when there were duplicate attributes on a JSX element ### πŸͺ„ Improvements -- Rule `no-leaked-conditional-rendering` now allows a falsy boolean literal to be used on the left side of the logical expression. -- Tweaked the default settings shipped with various presets. -- Overall performance improvements. +- Rule `no-leaked-conditional-rendering` now allows a falsy boolean literal to be used on the left side of the logical expression +- Tweaked the default settings shipped with various presets +- Overall performance improvements ## v1.7.0 (Tue 30 Jul 2024) ### ✨ New -- Add `settings["react-x"].polymorphicPropName` setting to specify the name of the prop that is used to determine the component type. +- Add `settings["react-x"].polymorphicPropName` setting to specify the name of the prop that is used to determine the component type ### πŸͺ„ Improvements -- Dropped the current incomplete lint support for `React.createElement` to improve performance and subsequent code maintainability. +- Dropped the current incomplete lint support for `React.createElement` to improve performance and subsequent code maintainability ## v1.6.0 (Sat 27 Jul 2024) ### ✨ New -- Add `controlled` setting to `settings["react-x"].additionalComponents`' `attributes` object to set whether it is controlled or not. -- Add glob support to `settings["react-x"].additionalComponents`' `name` setting. -- Add default settings for `react-x` settings to presets. -- Undeprecate rule `no-implicit-key` and improve its usefulness. -- Undeprecate rule `no-complicated-conditional-rendering` and rename it to `no-complex-conditional-rendering` (the previous rule will still be available until the next major update to avoid breaking changes). +- Add `controlled` setting to `settings["react-x"].additionalComponents`' `attributes` object to set whether it is controlled or not +- Add glob support to `settings["react-x"].additionalComponents`' `name` setting +- Add default settings for `react-x` settings to presets +- Undeprecate rule `no-implicit-key` and improve its usefulness +- Undeprecate rule `no-complicated-conditional-rendering` and rename it to `no-complex-conditional-rendering` (the previous rule will still be available until the next major update to avoid breaking changes) ### 🐞 Fixes -- `no-direct-set-state-in-use-(layout?)-effect` should warn only for the `set` function. +- `no-direct-set-state-in-use-(layout?)-effect` should warn only for the `set` function ### πŸͺ„ Improvements -- Remove `no-direct-set-state-in-use-(layout?)-effect` from recommended presets. +- Remove `no-direct-set-state-in-use-(layout?)-effect` from recommended presets ## v1.5.30 (Mon 22 Jul 2024) ### 🐞 Fixes -- Revert ~~change `@typescript-eslint`'s packages in `dependencies` to `"^7.16.1 || ^rc-v8"`~~ as this format is not supported by all package managers. +- Revert ~~change `@typescript-eslint`'s packages in `dependencies` to `"^7.16.1 || ^rc-v8"`~~ as this format is not supported by all package managers ## v1.5.29 (Mon 22 Jul 2024) ### ✨ New -- Add rule `no-prop-types`. -- Add rule `no-default-props`. -- Add experimental `settings["react-x"].additionalComponents` settings (currently only the `no-unsafe-target-blank` rule uses it, but more rules will use it in the future). +- Add rule `no-prop-types` +- Add rule `no-default-props` +- Add experimental `settings["react-x"].additionalComponents` settings (currently only the `no-unsafe-target-blank` rule uses it, but more rules will use it in the future) ### πŸͺ„ Improvements -- Add rule `no-prop-types` to recommended presets. -- Add rule `no-default-props` to recommended presets. -- Remove rule `no-useless-fragment` from recommended presets. -- Optimize performance of rule `no-create-ref`. -- Change `@typescript-eslint`' packages in `dependencies` to `"^7.16.1 || ^rc-v8"`. +- Add rule `no-prop-types` to recommended presets +- Add rule `no-default-props` to recommended presets +- Remove rule `no-useless-fragment` from recommended presets +- Optimize performance of rule `no-create-ref` +- Change `@typescript-eslint`' packages in `dependencies` to `"^7.16.1 || ^rc-v8"` ## v1.5.28 (Sat 20 Jul 2024) ### 🐞 Fixes -- Fix false positives and negatives in rule `hooks-extra/no-direct-set-state-in-use-effect`. -- Fix false positives and negatives in rule `hooks-extra/no-direct-set-state-in-use-layout-effect`. -- Fix rule `prefer-read-only-props` reports only the first component in a file. +- Fix false positives and negatives in rule `hooks-extra/no-direct-set-state-in-use-effect` +- Fix false positives and negatives in rule `hooks-extra/no-direct-set-state-in-use-layout-effect` +- Fix rule `prefer-read-only-props` reports only the first component in a file ### πŸͺ„ Improvements -- Improve website and documentation. +- Improve website and documentation ## v1.5.27 (Tue 16 Jul 2024) ### 🐞 Fixes -- Fix rule `prefer-read-only-props` that was accidentally added to the recommended type-checked presets. -- Fix false negatives in rule `hooks-extra/no-direct-set-state-in-use-effect` when call `set` function inside a non-function scope. -- Fix false negatives in rule `hooks-extra/no-direct-set-state-in-use-layout-effect` when call `set` function inside a non-function scope. +- Fix rule `prefer-read-only-props` that was accidentally added to the recommended type-checked presets +- Fix false negatives in rule `hooks-extra/no-direct-set-state-in-use-effect` when call `set` function inside a non-function scope +- Fix false negatives in rule `hooks-extra/no-direct-set-state-in-use-layout-effect` when call `set` function inside a non-function scope ### πŸͺ„ Improvements - Rule `no-leaked-conditional-rendering` now supports BigInt literals on the left side of the logical expression -- Rule `no-leaked-conditional-rendering` now allows a truthy number literal to be used on the left side of the logical expression. -- Optimize bundle size. +- Rule `no-leaked-conditional-rendering` now allows a truthy number literal to be used on the left side of the logical expression +- Optimize bundle size ## v1.5.26 (Mon 15 Jul 2024) ### ✨ New -- Add rule `hooks-extra/no-direct-set-state-in-use-effect`. -- Add rule `hooks-extra/no-direct-set-state-in-use-layout-effect`. +- Add rule `hooks-extra/no-direct-set-state-in-use-effect` +- Add rule `hooks-extra/no-direct-set-state-in-use-layout-effect` ### 🐞 Fixes -- Fix false positives in rule `hooks-extra/ensure-use-memo-has-non-empty-deps` when referencing component block scope. -- Fix false positives in rule `hooks-extra/no-unnecessary-use-callback` when referencing component block scope. +- Fix false positives in rule `hooks-extra/ensure-use-memo-has-non-empty-deps` when referencing component block scope +- Fix false positives in rule `hooks-extra/no-unnecessary-use-callback` when referencing component block scope ### πŸͺ„ Improvements -- Add rule `hooks-extra/no-direct-set-state-in-use-effect` to recommended presets. -- Add rule `hooks-extra/no-direct-set-state-in-use-layout-effect` to recommended presets. -- Add rule `hooks-extra/prefer-use-state-lazy-initialization` to recommended presets. +- Add rule `hooks-extra/no-direct-set-state-in-use-effect` to recommended presets +- Add rule `hooks-extra/no-direct-set-state-in-use-layout-effect` to recommended presets +- Add rule `hooks-extra/prefer-use-state-lazy-initialization` to recommended presets ## v1.5.25 (Sat 13 Jul 2024) ### πŸͺ„ Improvements -- Optimize bundle size. +- Optimize bundle size ## v1.5.24 (Thu 11 Jul 2024) ### 🐞 Fixes -- Fix rule `prefer-read-only-props` false positive when using `ObjectPattern` in function arguments. +- Fix rule `prefer-read-only-props` false positive when using `ObjectPattern` in function arguments ### πŸͺ„ Improvements @@ -554,274 +562,274 @@ function useAuth() { ### 🐞 Fixes -- Fix rule `prefer-read-only-props` false negative when using `ObjectPattern` in function arguments. +- Fix rule `prefer-read-only-props` false negative when using `ObjectPattern` in function arguments ### πŸͺ„ Improvements -- Improve website and documentation. +- Improve website and documentation ## v1.5.22 (Fri 5 Jul 2024) ### ✨ New -- Add rule `prefer-read-only-props`. +- Add rule `prefer-read-only-props` ### πŸͺ„ Improvements -- Downgrade `@typescript-eslint`'s packages to v7, due to stability issues with v8. +- Downgrade `@typescript-eslint`'s packages to v7, due to stability issues with v8 ## v1.5.21 (Wed 3 Jul 2024) ### 🐞 Fixes -- Add missing dependencies to `@eslint-react/eslint-plugin`. -- Fix rule `no-nested-components` false negative when placing components inside JSX props. +- Add missing dependencies to `@eslint-react/eslint-plugin` +- Fix rule `no-nested-components` false negative when placing components inside JSX props ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to v8. -- Improve rule `no-leaked-conditional-rendering` compatibility with different versions of `typescript-eslint`. +- Update `@typescript-eslint`'s packages to v8 +- Improve rule `no-leaked-conditional-rendering` compatibility with different versions of `typescript-eslint` ## v1.5.20 (Tue 02 Jul 2024) ### 🐞 Fixes -- Fix rule `prefer-destructuring-assignment` false positive when the function looks like a component. +- Fix rule `prefer-destructuring-assignment` false positive when the function looks like a component ### πŸͺ„ Improvements -- Improve `utilities/jsx/is-jsx-value` to better distinguish between normal values and JSX values. -- Improve `core/component-collector` to better distinguish between normal functions and components. -- Prevent potential function component detection related false positives. -- Switch to a more appropriate value for `DEFAULT_COMPONENT_HINT`. +- Improve `utilities/jsx/is-jsx-value` to better distinguish between normal values and JSX values +- Improve `core/component-collector` to better distinguish between normal functions and components +- Prevent potential function component detection related false positives +- Switch to a more appropriate value for `DEFAULT_COMPONENT_HINT` ## v1.5.19 (30 Sun Jun 2024) ### πŸͺ„ Improvements -- Reduce the number of dependencies by inlining tree-shaking optimized code while bundling. -- Deprecate `reactOptions` in favor of `react-x` in [ESLint Shared Settings](https://eslint.org/docs/latest/use/configure/configuration-files#configuring-shared-settings). +- Reduce the number of dependencies by inlining tree-shaking optimized code while bundling +- Deprecate `reactOptions` in favor of `react-x` in [ESLint Shared Settings](https://eslint.org/docs/latest/use/configure/configuration-files#configuring-shared-settings) ## v1.5.18 (28 Fri Jun 2024) ### 🐞 Fixes -- Fix rule `no-useless-fragment` not respecting `jsxPragma` settings. +- Fix rule `no-useless-fragment` not respecting `jsxPragma` settings ### πŸͺ„ Improvements -- Update documentation for rule `no-useless-fragment` to reflect the actual behavior of the rule. +- Update documentation for rule `no-useless-fragment` to reflect the actual behavior of the rule ## v1.5.17 (Wed 26 Jun 2024) ### πŸͺ„ Improvements -- Remove rule `no-children-prop` from recommended presets. -- Improve documentation for rule `no-useless-fragment`. +- Remove rule `no-children-prop` from recommended presets +- Improve documentation for rule `no-useless-fragment` ## v1.5.16 (Mon 17 Jun 2024) ### 🐞 Fixes -- Fix debug rules not exporting correctly in `@eslint-react/eslint-plugin`. +- Fix debug rules not exporting correctly in `@eslint-react/eslint-plugin` ### πŸͺ„ Improvements -- Remove rule `prefer-shorthand-boolean` from recommended presets. -- Remove rule `prefer-shorthand-fragment` from recommended presets. -- Remove rule `prefer-destructuring-assignment` from recommended presets. +- Remove rule `prefer-shorthand-boolean` from recommended presets +- Remove rule `prefer-shorthand-fragment` from recommended presets +- Remove rule `prefer-destructuring-assignment` from recommended presets ## v1.5.15 (Sat 08 Jun 2024) ### 🐞 Fixes -- Remove `languageOptions.parser` from presets. -- Remove `@typescript-eslint/parser` from peer dependencies. -- Rule `no-leaked-conditional-rendering`: object should be considered as valid left-hand type. +- Remove `languageOptions.parser` from presets +- Remove `@typescript-eslint/parser` from peer dependencies +- Rule `no-leaked-conditional-rendering`: object should be considered as valid left-hand type ## v1.5.14 (Thu 30 May 2024) ### ✨ New -- Add rule `avoid-shorthand-boolean`. -- Add rule `avoid-shorthand-fragment`. +- Add rule `avoid-shorthand-boolean` +- Add rule `avoid-shorthand-fragment` ### 🐞 Fixes -- Fix rule `dom/no-missing-button-type` false positive when using `type` attribute in a JSX expression. +- Fix rule `dom/no-missing-button-type` false positive when using `type` attribute in a JSX expression ## v1.5.13 (Tue 28 May 2024) ### 🐞 Fixes -- Fix components that use `getDerivedStateFromError` should not be warned by rule `no-class-component`. +- Fix components that use `getDerivedStateFromError` should not be warned by rule `no-class-component` ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `7.11.0`. +- Update `@typescript-eslint`'s packages to `7.11.0` ## v1.5.12 (Fri 17 May 2024) ### 🐞 Fixes -- Fix ESLint peer dependency range in `package.json`. +- Fix ESLint peer dependency range in `package.json` ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `7.9.0`. -- Minor improvements. +- Update `@typescript-eslint`'s packages to `7.9.0` +- Minor improvements ## v1.5.11 (Wed 08 May 2024) ### ✨ New -- Rule `no-class-component` rule now allows class components with a `componentDidCatch` method. -- Settings `reactOptions` now supports `importSource` to specify the import source for React. +- Rule `no-class-component` rule now allows class components with a `componentDidCatch` method +- Settings `reactOptions` now supports `importSource` to specify the import source for React ### πŸ—‘οΈ Deprecations -- Deprecate rule `no-implicit-key` because it is stylistic and opinionated. -- Deprecate rule `no-complicated-conditional-rendering` because it is stylistic and opinionated. +- Deprecate rule `no-implicit-key` because it is stylistic and opinionated +- Deprecate rule `no-complicated-conditional-rendering` because it is stylistic and opinionated ### πŸͺ„ Improvements -- Refactor React pragma and import name retrieval utils to support custom import source. -- Update `@typescript-eslint`'s packages to `7.8.0`. +- Refactor React pragma and import name retrieval utils to support custom import source +- Update `@typescript-eslint`'s packages to `7.8.0` ## v1.5.10 (Sun 28 Apr 2024) ### πŸͺ„ Improvements -- Update `react` to `18.3.1`. -- Update `@typescript-eslint`'s packages to `7.7.1`. -- Use a wider range of peerDependencies. +- Update `react` to `18.3.1` +- Update `@typescript-eslint`'s packages to `7.7.1` +- Use a wider range of peerDependencies ## v1.5.9 (Fri 19 Apr 2024) ### πŸͺ„ Improvements -- Optimize error messages of rules. -- Update `@typescript-eslint`'s packages to `7.7.0`. +- Optimize error messages of rules +- Update `@typescript-eslint`'s packages to `7.7.0` ## v1.5.8 (Thu 11 Apr 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `7.6.0`. +- Update `@typescript-eslint`'s packages to `7.6.0` ## v1.5.7 (Thu 28 Mar 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `7.4.0`. +- Update `@typescript-eslint`'s packages to `7.4.0` ## v1.5.6 (Tue 12 Mar 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `7.2.0`. +- Update `@typescript-eslint`'s packages to `7.2.0` ## v1.5.5 (Sun Feb 18 2024) ### 🐞 Fixes -- Fix rule `no-component-will-receive-props` not working as expected. +- Fix rule `no-component-will-receive-props` not working as expected ### πŸͺ„ Improvements -- Improve error messages and code samples in rule docs. +- Improve error messages and code samples in rule docs ## v1.5.4 (Fri Feb 16 2024) ### 🐞 Fixes -- Fix rule `dom/no-render-return-value` not renamed in v1.0.0. +- Fix rule `dom/no-render-return-value` not renamed in v1.0.0 ### πŸͺ„ Improvements -- Improve code samples in rule docs. -- Update `effect` to `2.3.5`. -- Update `@typescript-eslint`'s packages to `7.0.1`. +- Improve code samples in rule docs +- Update `effect` to `2.3.5` +- Update `@typescript-eslint`'s packages to `7.0.1` ## v1.5.3 (Sat Feb 10 2024) ### πŸͺ„ Improvements -- Improve diagnostic messages. -- Remove needless deps from `peerDependencies`. -- Update `@typescript-eslint`'s packages to `6.21.0`. +- Improve diagnostic messages +- Remove needless deps from `peerDependencies` +- Update `@typescript-eslint`'s packages to `6.21.0` ## v1.5.2 (Wed Jan 31 2024) ### πŸͺ„ Improvements -- Remove needless deps from `peerDependencies`. -- Update `@typescript-eslint`'s packages to `6.20.0`. -- Update `effect` to `2.2.3`. +- Remove needless deps from `peerDependencies` +- Update `@typescript-eslint`'s packages to `6.20.0` +- Update `effect` to `2.2.3` ## v1.5.2-beta.2 (Wed Jan 31 2024) ### πŸͺ„ Improvements -- Update `effect` to `2.2.3`. -- Remove needless deps from `peerDependencies`. +- Update `effect` to `2.2.3` +- Remove needless deps from `peerDependencies` ## v1.5.2-beta.0 (Thu Jan 30 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.20.0`. +- Update `@typescript-eslint`'s packages to `6.20.0` ## v1.5.1 (Mon Jan 29 2024) ### ✨ New -- Add `off-dom` and `off-dom-legacy` presets to disable all DOM related rules. +- Add `off-dom` and `off-dom-legacy` presets to disable all DOM related rules ### πŸͺ„ Improvements -- Reduce dependencies size. +- Reduce dependencies size ## v1.5.0 (Mon Jan 29 2024) ### πŸ’₯ Breaking Changes -- Remove rule `max-depth`. -- Rename rule `no-spreading-key` to `no-implicit-key`. -- Rename rule `no-constructed-context-value` to `no-unstable-context-value`. -- Rename rule `no-unstable-nested-components` to `no-nested-components`. -- Switch to new name prefix of rules in `@eslint-react/eslint-plugin`. - - Replace `jsx/` with `` in rule names. - - Replace `react/` with `` in rule names. - - Replace `react-dom/` with `dom/` in rule names. - - Replace `react-hooks/` with `hooks-extra/` in rule names. -- Switch to new settings schema. - - Put settings under `reactOptions` instead of `eslintReact`. - - Replace `jsx.pragma` with `jsxPragma`. - - Replace `jsx.fragment` with `jsxPragmaFrag`. - - Replace `react.version` with `version`. - - Remove `jsx.extensions`. +- Remove rule `max-depth` +- Rename rule `no-spreading-key` to `no-implicit-key` +- Rename rule `no-constructed-context-value` to `no-unstable-context-value` +- Rename rule `no-unstable-nested-components` to `no-nested-components` +- Switch to new name prefix of rules in `@eslint-react/eslint-plugin` + - Replace `jsx/` with `` in rule names + - Replace `react/` with `` in rule names + - Replace `react-dom/` with `dom/` in rule names + - Replace `react-hooks/` with `hooks-extra/` in rule names +- Switch to new settings schema + - Put settings under `reactOptions` instead of `eslintReact` + - Replace `jsx.pragma` with `jsxPragma` + - Replace `jsx.fragment` with `jsxPragmaFrag` + - Replace `react.version` with `version` + - Remove `jsx.extensions` ## v1.0.2 (Sat Jan 27 2024) ### 🐞 Fixes -- Fix rule `react-dom/no-namespace` not renamed in v1.0.0. -- Fix rule `react-dom/no-void-elements-with-children` not renamed in v1.0.0. +- Fix rule `react-dom/no-namespace` not renamed in v1.0.0 +- Fix rule `react-dom/no-void-elements-with-children` not renamed in v1.0.0 ### πŸͺ„ Improvements -- Improve rules overview page on website. -- Remove `jsx` and `hooks` presets from documentation. +- Improve rules overview page on website +- Remove `jsx` and `hooks` presets from documentation ## v1.0.1 (Sat Jan 27 2024) ### πŸͺ„ Improvements -- Improve `jsx` and `jsx-legacy` presets. -- Improve `core` and `core-legacy` presets. -- Improve `recommended` and `recommended-legacy` presets. -- Improve `recommended-type-checked` and `recommended-type-checked-legacy` presets. +- Improve `jsx` and `jsx-legacy` presets +- Improve `core` and `core-legacy` presets +- Improve `recommended` and `recommended-legacy` presets +- Improve `recommended-type-checked` and `recommended-type-checked-legacy` presets ## v1.0.0 (Sat Jan 27 2024) @@ -829,52 +837,52 @@ function useAuth() { #### All DOM related rules are moved to `react-dom` namespace -- Rename rule `react/no-void-elements-with-children` to `react-dom/no-void-elements-with-children`. -- Rename rule `react/no-dangerously-set-innerhtml-with-children` to `react-dom/no-dangerously-set-innerhtml-with-children`. -- Rename rule `react/no-dangerously-set-innerhtml` to `react-dom/no-dangerously-set-innerhtml`. -- Rename rule `react/no-find-dom-node` to `react-dom/no-find-dom-node`. -- Rename rule `react/no-missing-button-type` to `react-dom/no-missing-button-type`. -- Rename rule `react/no-missing-iframe-sandbox` to `react-dom/no-missing-iframe-sandbox`. -- Rename rule `react/no-namespace` to `react-dom/no-namespace`. -- Rename rule `react/no-render-return-value` to `react-dom/no-render-return-value`. -- Rename rule `react/no-script-url` to `react-dom/no-script-url`. -- Rename rule `react/no-unsafe-iframe-sandbox` to `react-dom/no-unsafe-iframe-sandbox`. -- Rename rule `react/no-unsafe-target-blank` to `react-dom/no-unsafe-target-blank`. +- Rename rule `react/no-void-elements-with-children` to `react-dom/no-void-elements-with-children` +- Rename rule `react/no-dangerously-set-innerhtml-with-children` to `react-dom/no-dangerously-set-innerhtml-with-children` +- Rename rule `react/no-dangerously-set-innerhtml` to `react-dom/no-dangerously-set-innerhtml` +- Rename rule `react/no-find-dom-node` to `react-dom/no-find-dom-node` +- Rename rule `react/no-missing-button-type` to `react-dom/no-missing-button-type` +- Rename rule `react/no-missing-iframe-sandbox` to `react-dom/no-missing-iframe-sandbox` +- Rename rule `react/no-namespace` to `react-dom/no-namespace` +- Rename rule `react/no-render-return-value` to `react-dom/no-render-return-value` +- Rename rule `react/no-script-url` to `react-dom/no-script-url` +- Rename rule `react/no-unsafe-iframe-sandbox` to `react-dom/no-unsafe-iframe-sandbox` +- Rename rule `react/no-unsafe-target-blank` to `react-dom/no-unsafe-target-blank` ### ✨ New -- Make `dom` an alias of `react-dom` preset. -- Make `hooks` an alias of `react-hooks` preset. -- Add preset `jsx` and `jsx-legacy`. -- Add preset `react-dom` and `dom-legacy`. -- Add preset `core` and `core-legacy`. -- Add preset `react-hooks` and `hooks-legacy`. +- Make `dom` an alias of `react-dom` preset +- Make `hooks` an alias of `react-hooks` preset +- Add preset `jsx` and `jsx-legacy` +- Add preset `react-dom` and `dom-legacy` +- Add preset `core` and `core-legacy` +- Add preset `react-hooks` and `hooks-legacy` ### 🐞 Fixes -- Fix the lint message for rule `react-dom/no-dangerously-set-innerhtml`. +- Fix the lint message for rule `react-dom/no-dangerously-set-innerhtml` ## v1.0.0-beta.3 (Fri Jan 26 2024) ### 🐞 Fixes -- Fix the name prefix for react-dom rules. +- Fix the name prefix for react-dom rules ## v1.0.0-beta.2 (Fri Jan 26 2024) ### ✨ New -- Make `dom` an alias of `react-dom` preset. -- Make `hooks` an alias of `react-hooks` preset. +- Make `dom` an alias of `react-dom` preset +- Make `hooks` an alias of `react-hooks` preset ## v1.0.0-beta.1 (Fri Jan 26 2024) ### ✨ New -- Add preset `jsx` and `jsx-legacy`. -- Add preset `dom` and `dom-legacy`. -- Add preset `core` and `core-legacy`. -- Add preset `hooks` and `hooks-legacy`. +- Add preset `jsx` and `jsx-legacy` +- Add preset `dom` and `dom-legacy` +- Add preset `core` and `core-legacy` +- Add preset `hooks` and `hooks-legacy` ## v1.0.0-beta.0 (Fri Jan 26 2024) @@ -882,407 +890,407 @@ function useAuth() { #### All DOM related rules are moved to `react-dom` namespace -- Rename rule `react/no-dangerously-set-innerhtml` to `react-dom/no-dangerously-set-innerhtml`. -- Rename rule `react/no-dangerously-set-innerhtml-with-children` to `react-dom/no-dangerously-set-innerhtml-with-children`. -- Rename rule `react/no-find-dom-node` to `react-dom/no-find-dom-node`. -- Rename rule `react/no-missing-button-type` to `react-dom/no-missing-button-type`. -- Rename rule `react/no-missing-iframe-sandbox` to `react-dom/no-missing-iframe-sandbox`. -- Rename rule `react/no-script-url` to `react-dom/no-script-url`. -- Rename rule `react/no-unsafe-iframe-sandbox` to `react-dom/no-unsafe-iframe-sandbox`. -- Rename rule `react/no-unsafe-target-blank` to `react-dom/no-unsafe-target-blank`. +- Rename rule `react/no-dangerously-set-innerhtml` to `react-dom/no-dangerously-set-innerhtml` +- Rename rule `react/no-dangerously-set-innerhtml-with-children` to `react-dom/no-dangerously-set-innerhtml-with-children` +- Rename rule `react/no-find-dom-node` to `react-dom/no-find-dom-node` +- Rename rule `react/no-missing-button-type` to `react-dom/no-missing-button-type` +- Rename rule `react/no-missing-iframe-sandbox` to `react-dom/no-missing-iframe-sandbox` +- Rename rule `react/no-script-url` to `react-dom/no-script-url` +- Rename rule `react/no-unsafe-iframe-sandbox` to `react-dom/no-unsafe-iframe-sandbox` +- Rename rule `react/no-unsafe-target-blank` to `react-dom/no-unsafe-target-blank` ## v0.10.12 (Sun Jan 21 2024) ### πŸͺ„ Improvements -- Remove unnecessary `parserOptions` fields from presets. +- Remove unnecessary `parserOptions` fields from presets ## v0.10.12-beta.0 (Sun Jan 21 2024) ### πŸͺ„ Improvements -- Remove unnecessary `parserOptions` fields from presets. +- Remove unnecessary `parserOptions` fields from presets ## v0.10.11 (Sat Jan 20 2024) ### ✨ New -- Add rule `react/no-access-state-in-setstate`. +- Add rule `react/no-access-state-in-setstate` ### πŸͺ„ Improvements -- Improve rule `react/no-unused-state` to respect the usage of `getDerivedStateFromProps`. -- Update `@typescript-eslint`'s packages to `6.19.0`. +- Improve rule `react/no-unused-state` to respect the usage of `getDerivedStateFromProps` +- Update `@typescript-eslint`'s packages to `6.19.0` ## v0.10.11-beta.2 (Fri Jan 19 2024) ### ✨ New -- Add rule `react/no-access-state-in-setstate`. +- Add rule `react/no-access-state-in-setstate` ## v0.10.11-beta.1 (Tue Jan 16 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.19.0`. +- Update `@typescript-eslint`'s packages to `6.19.0` ## v0.10.11-beta.0 (Mon Jan 15 2024) ### πŸͺ„ Improvements -- Improve rule `react/no-unused-state` to respect the usage of `getDerivedStateFromProps`. +- Improve rule `react/no-unused-state` to respect the usage of `getDerivedStateFromProps` ## v0.10.10 (Sun Jan 14 2024) ### πŸͺ„ Improvements -- Improve rule `react/no-unused-state` to support checking for more cases. -- Improve rule `react/no-direct-mutation-state` to support checking for more cases. -- Improve rule `react/no-unused-class-component-members` to support checking for more cases. +- Improve rule `react/no-unused-state` to support checking for more cases +- Improve rule `react/no-direct-mutation-state` to support checking for more cases +- Improve rule `react/no-unused-class-component-members` to support checking for more cases ## v0.10.10-beta.0 (Sun Jan 14 2024) ### πŸͺ„ Improvements -- Improve rule `react/no-unused-state` to support checking for more cases. -- Improve rule `react/no-direct-mutation-state` to support checking for more cases. -- Improve rule `react/no-unused-class-component-members` to support checking for more cases. +- Improve rule `react/no-unused-state` to support checking for more cases +- Improve rule `react/no-direct-mutation-state` to support checking for more cases +- Improve rule `react/no-unused-class-component-members` to support checking for more cases ## v0.10.9 (Fri Jan 12 2024) ### 🐞 Fixes -- Fix bundle size is larger than expected. +- Fix bundle size is larger than expected ## v0.10.8 (Thu Jan 11 2024) ### 🐞 Fixes -- Fix version format in v0.10.7's package.json. +- Fix version format in v0.10.7's package.json ## v0.10.7 (Thu Jan 11 2024) ### ✨ New -- Add rule `react/no-unused-state`. +- Add rule `react/no-unused-state` ## v0.10.6 (Tue Jan 9 2024) ### 🐞 Fixes -- Fix an issue where `react/no-constructed-context-value` and `react/no-unstable-default-props` would report false negatives when using LogicalExpression and ConditionalExpression. +- Fix an issue where `react/no-constructed-context-value` and `react/no-unstable-default-props` would report false negatives when using LogicalExpression and ConditionalExpression ## v0.10.6-beta.0 (Mon Jan 8 2024) ### 🐞 Fixes -- Fix an issue where `react/no-constructed-context-value` and `react/no-unstable-default-props` would report false negatives when using LogicalExpression and ConditionalExpression. +- Fix an issue where `react/no-constructed-context-value` and `react/no-unstable-default-props` would report false negatives when using LogicalExpression and ConditionalExpression ## v0.10.5 (Mon Jan 8 2024) ### ✨ New -- Add rule `react/no-unused-class-component-members`. +- Add rule `react/no-unused-class-component-members` ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.18.0`. +- Update `@typescript-eslint`'s packages to `6.18.0` ## v0.10.5-beta.0 (Sun Jan 7 2024) ### ✨ New -- Add rule `react/no-unused-class-component-members`. +- Add rule `react/no-unused-class-component-members` ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.18.0`. +- Update `@typescript-eslint`'s packages to `6.18.0` ## v0.10.4 (Sat Jan 6 2024) ### πŸͺ„ Improvements -- Improve rule `react/no-unstable-default-props` to support checking for ObjectPatterns within VariableDeclarators that occur on props. -- Improve function component detection in rule `react/no-unstable-nested-components` and `debug/function-component`. +- Improve rule `react/no-unstable-default-props` to support checking for ObjectPatterns within VariableDeclarators that occur on props +- Improve function component detection in rule `react/no-unstable-nested-components` and `debug/function-component` ### 🐞 Fixes -- Fix same kind of error inside a component should not only be reported once in rule `react/no-create-ref` and `react/no-constructed-context-value`. -- Fix an issue where render functions wrapped in `useCallback` were accidentally detected as function components in rules `react/no-unstable-nested-components` and `debug/function-component`. +- Fix same kind of error inside a component should not only be reported once in rule `react/no-create-ref` and `react/no-constructed-context-value` +- Fix an issue where render functions wrapped in `useCallback` were accidentally detected as function components in rules `react/no-unstable-nested-components` and `debug/function-component` ## v0.10.4-beta.1 (Sat Jan 6 2024) ### πŸͺ„ Improvements -- Improve function component detection in rule `react/no-unstable-nested-components` and `debug/function-component`. +- Improve function component detection in rule `react/no-unstable-nested-components` and `debug/function-component` ### 🐞 Fixes -- Fix an issue where render functions wrapped in `useCallback` were accidentally detected as function components in rules `react/no-unstable-nested-components` and `debug/function-component`. +- Fix an issue where render functions wrapped in `useCallback` were accidentally detected as function components in rules `react/no-unstable-nested-components` and `debug/function-component` ## v0.10.4-beta.0 (Sat Jan 6 2024) ### πŸͺ„ Improvements -- Improve rule `react/no-unstable-default-props` to support checking for ObjectPatterns within VariableDeclarators that occur on props. +- Improve rule `react/no-unstable-default-props` to support checking for ObjectPatterns within VariableDeclarators that occur on props ### 🐞 Fixes -- Fix same kind of error inside a component should not only be reported once in rule `react/no-create-ref` and `react/no-constructed-context-value`. +- Fix same kind of error inside a component should not only be reported once in rule `react/no-create-ref` and `react/no-constructed-context-value` ## v0.10.3 (Fri Jan 5 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.17.0`. +- Update `@typescript-eslint`'s packages to `6.17.0` ## v0.10.3-beta.0 (Tue Jan 2 2024) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.17.0`. +- Update `@typescript-eslint`'s packages to `6.17.0` ## v0.10.2 (Sat Dec 30 2023) ### ✨ New -- Add [`reactHooks.alias`](https://eslint-react.xyz/docs/configuration#reacthooksalias) setting support. +- Add [`reactHooks.alias`](https://eslint-react.xyz/docs/configuration#reacthooksalias) setting support ## v0.10.2-beta.0 (Sat Dec 30 2023) ### ✨ New -- Add [`reactHooks.alias`](https://eslint-react.xyz/docs/configuration#reacthooksalias) setting support. +- Add [`reactHooks.alias`](https://eslint-react.xyz/docs/configuration#reacthooksalias) setting support ## v0.10.1 (Wed Dec 27 2023) ### πŸͺ„ Improvements -- Add `react/no-clone-element` to `recommended` and `recommended-legacy` presets. -- Improve rule `react/no-unstable-nested-components`, make its behavior closer to [react-hooks/no-nested-components](https://github.com/facebook/react/pull/25360). -- Update `@typescript-eslint`'s packages to `6.16.0`. +- Add `react/no-clone-element` to `recommended` and `recommended-legacy` presets +- Improve rule `react/no-unstable-nested-components`, make its behavior closer to [react-hooks/no-nested-components](https://github.com/facebook/react/pull/25360) +- Update `@typescript-eslint`'s packages to `6.16.0` ## v0.10.1-beta.1 (Tue Dec 26 2023) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.16.0`. +- Update `@typescript-eslint`'s packages to `6.16.0` ## v0.10.1-beta.0 (Mon Dec 25 2023) ### πŸͺ„ Improvements -- Add `react/no-clone-element` to `recommended` and `recommended-legacy` presets. -- Improve rule `react/no-unstable-nested-components`, make its behavior closer to [react-hooks/no-nested-components](https://github.com/facebook/react/pull/25360). +- Add `react/no-clone-element` to `recommended` and `recommended-legacy` presets +- Improve rule `react/no-unstable-nested-components`, make its behavior closer to [react-hooks/no-nested-components](https://github.com/facebook/react/pull/25360) ## v0.10.0 (Thu Dec 21 2023) ### ✨ New -- Add rule `jsx/max-depth`. +- Add rule `jsx/max-depth` ### πŸͺ„ Improvements -- Improve `recommended` and `recommended-legacy` presets. +- Improve `recommended` and `recommended-legacy` presets ## v0.10.0-beta.0 (Thu Dec 21 2023) ### ✨ New -- Add rule `jsx/max-depth`. +- Add rule `jsx/max-depth` ### πŸͺ„ Improvements -- Improve `recommended` and `recommended-legacy` presets. +- Improve `recommended` and `recommended-legacy` presets ## v0.9.8 (Tue Dec 19 2023) ### ✨ New -- Add rule `react/ensure-forward-ref-using-ref`. +- Add rule `react/ensure-forward-ref-using-ref` ### πŸͺ„ Improvements -- Reduce false positives in rule `react/no-unstable-nested-components`. +- Reduce false positives in rule `react/no-unstable-nested-components` - Reduce false positives in rule `debug/function-component` -- Optimize `recommended` and `recommended-legacy` presets. -- Update `@typescript-eslint`'s packages to `6.15.0`. +- Optimize `recommended` and `recommended-legacy` presets +- Update `@typescript-eslint`'s packages to `6.15.0` ## v0.9.8-beta.2 (Tue Dec 19 2023) ### πŸͺ„ Improvements -- Optimize `recommended` and `recommended-legacy` presets. +- Optimize `recommended` and `recommended-legacy` presets ## v0.9.8-beta.1 (Tue Dec 19 2023) ### πŸͺ„ Improvements -- Minor improvements. +- Minor improvements ## v0.9.8-beta.0 (Sun Dec 17 2023) ### ✨ New -- Add rule `react/ensure-forward-ref-using-ref`. +- Add rule `react/ensure-forward-ref-using-ref` ### πŸͺ„ Improvements -- Reduce false positives in rule `react/no-unstable-nested-components`. +- Reduce false positives in rule `react/no-unstable-nested-components` -- Reduce false positives in rule `debug/function-component`. +- Reduce false positives in rule `debug/function-component` ## v0.9.7 (Sun Dec 17 2023) ### πŸ’₯ Breaking Changes -- Rule `named-convention/filename-extension` rename `rule` option to `allow`. +- Rule `named-convention/filename-extension` rename `rule` option to `allow` ### 🐞 Fixes -- Fix where functions in `
} />` or `
} />` are treated as components. -- Fix false positive in rule `react/no-unstable-nested-components`. -- Fix false positive in rule `debug/function-component`. +- Fix where functions in `
} />` or `
} />` are treated as components +- Fix false positive in rule `react/no-unstable-nested-components` +- Fix false positive in rule `debug/function-component` ### πŸͺ„ Improvements -- Rules now support reading JSX extensions from `settings.eslintReact.jsx.extensions`. +- Rules now support reading JSX extensions from `settings.eslintReact.jsx.extensions` -- Replace ❌ Incorrect and βœ… Correct with Failing and Passing in rule docs. +- Replace ❌ Incorrect and βœ… Correct with Failing and Passing in rule docs ## v0.9.7-beta.2 (Sat Dec 16 2023) ### 🐞 Fixes -- Update default rule option in `named-convention/filename` to `PascalCase`. +- Update default rule option in `named-convention/filename` to `PascalCase` ## v0.9.7-beta.1 (Thu Dec 14 2023) ### πŸͺ„ Improvements -- Minor improvements. +- Minor improvements ## v0.9.7-beta.0 (Thu Dec 14 2023) ### πŸ’₯ Breaking Changes -- Rule `named-convention/filename-extension` rename `rule` option to `allow`. +- Rule `named-convention/filename-extension` rename `rule` option to `allow` ✨ New -- Rule `named-convention/filename` add `extensions` option. -- Rule `named-convention/filename-extension` add `extensions` option. +- Rule `named-convention/filename` add `extensions` option +- Rule `named-convention/filename-extension` add `extensions` option ## v0.9.6 (Tue Dec 12 2023) ### ✨ New -- Add rule `react-hooks/prefer-use-state-lazy-initialization`. +- Add rule `react-hooks/prefer-use-state-lazy-initialization` ### πŸͺ„ Improvements -- Rule `named-convention/component-name` add both `string` and `object` options support. -- Rule `named-convention/filename` add both `string` and `object` options support. -- Rule `named-convention/filename-extension` add both `string` and `object` options support. -- Rule `debug/react-hooks` reports `hookCalls.length` instead of `cost`. -- Update `@typescript-eslint`'s packages to `6.14.0`. +- Rule `named-convention/component-name` add both `string` and `object` options support +- Rule `named-convention/filename` add both `string` and `object` options support +- Rule `named-convention/filename-extension` add both `string` and `object` options support +- Rule `debug/react-hooks` reports `hookCalls.length` instead of `cost` +- Update `@typescript-eslint`'s packages to `6.14.0` ## v0.9.6-beta.5 (Tue Dec 12 2023) ### πŸͺ„ Improvements -- Update `@typescript-eslint`'s packages to `6.14.0`. +- Update `@typescript-eslint`'s packages to `6.14.0` ## v0.9.6-beta.4 (Mon Dec 11 2023) ### πŸͺ„ Improvements -- Rule `named-convention/component-name` add both `string` and `object` options support. -- Rule `named-convention/filename` add both `string` and `object` options support. -- Rule `named-convention/filename-extension` add both `string` and `object` options support. +- Rule `named-convention/component-name` add both `string` and `object` options support +- Rule `named-convention/filename` add both `string` and `object` options support +- Rule `named-convention/filename-extension` add both `string` and `object` options support ## v0.9.6-beta.3 (Mon Dec 11 2023) ### πŸͺ„ Improvements -- Remove rule `react-hooks/prefer-use-state-lazy-initialization` from `recommended` and `recommended-legacy` presets. +- Remove rule `react-hooks/prefer-use-state-lazy-initialization` from `recommended` and `recommended-legacy` presets ## v0.9.6-beta.2 (Mon Dec 11 2023) ### ✨ New -- Add rule `react-hooks/prefer-use-state-lazy-initialization`. +- Add rule `react-hooks/prefer-use-state-lazy-initialization` ### πŸͺ„ Improvements -- Rule `named-convention/filename-extension` switch options format from object to string. +- Rule `named-convention/filename-extension` switch options format from object to string ## v0.9.6-beta.1 (Mon Dec 11 2023) ### πŸͺ„ Improvements -- Rule `debug/react-hooks` reports `hookCalls.length` instead of `cost`. +- Rule `debug/react-hooks` reports `hookCalls.length` instead of `cost` ## v0.9.5 (Mon Dec 11 2023) ### πŸͺ„ Improvements -- Improve rule `jsx/no-leaked-conditional-rendering` error marker position and range. -- Improve rule `react/no-missing-button-type` error marker position and range. -- Improve rule `react/no-missing-iframe-sandbox` error marker position and range. -- Improve rule `react/no-unsafe-iframe-sandbox` error marker position and range. +- Improve rule `jsx/no-leaked-conditional-rendering` error marker position and range +- Improve rule `react/no-missing-button-type` error marker position and range +- Improve rule `react/no-missing-iframe-sandbox` error marker position and range +- Improve rule `react/no-unsafe-iframe-sandbox` error marker position and range ## v0.9.4 (Fri Dec 8 2023) ### πŸͺ„ Improvements -- Improve rule docs. +- Improve rule docs ## v0.9.3 (Fri Dec 8 2023) ### ✨ New -- Add rule `react/no-direct-mutation-state`. -- Add rule `naming-convention/use-state`. +- Add rule `react/no-direct-mutation-state` +- Add rule `naming-convention/use-state` ### πŸͺ„ Improvements -- Update `recommended` and `recommended-legacy` presets. -- Improve rules overview page. +- Update `recommended` and `recommended-legacy` presets +- Improve rules overview page ## v0.9.2 (Wed Dec 6 2023) ### ✨ New -- Add rule `react/no-component-will-update`. -- Add rule `react/no-unsafe-component-will-update`. -- Add rule `react/no-component-will-receive-props`. -- Add rule `react/no-unsafe-component-will-receive-props`. -- Add rule `react/no-set-state-in-component-did-mount`. -- Add rule `react/no-set-state-in-component-did-update`. -- Add rule `react/no-set-state-in-component-will-update`. +- Add rule `react/no-component-will-update` +- Add rule `react/no-unsafe-component-will-update` +- Add rule `react/no-component-will-receive-props` +- Add rule `react/no-unsafe-component-will-receive-props` +- Add rule `react/no-set-state-in-component-did-mount` +- Add rule `react/no-set-state-in-component-did-update` +- Add rule `react/no-set-state-in-component-will-update` ## v0.9.1 (Tue Dec 5 2023) ### ✨ New -- Add rule `react/no-component-will-mount`. -- Add rule `react/no-unsafe-component-will-mount`. +- Add rule `react/no-component-will-mount` +- Add rule `react/no-unsafe-component-will-mount` ## v0.9.0 (Fri Dec 1 2023) ### πŸ’₯ Breaking Changes - `@eslint-react/eslint-plugin-jsx` - - Remove `allowExpressions` option from rule `jsx/no-useless-fragment`. + - Remove `allowExpressions` option from rule `jsx/no-useless-fragment` - `@eslint-react/jsx` - - Remove `isFragmentWithOnlyTextAndIsNotChild`, `isFragmentHasLessThanTwoChildren`, `isFragmentWithSingleExpression` from `@eslint-react/jsx`'s API. + - Remove `isFragmentWithOnlyTextAndIsNotChild`, `isFragmentHasLessThanTwoChildren`, `isFragmentWithSingleExpression` from `@eslint-react/jsx`'s API ### ✨ New -- Add rule `react/no-redundant-should-component-update`. +- Add rule `react/no-redundant-should-component-update` ### πŸͺ„ Improvements -- Update Options of rule `jsx/no-useless-fragment`. -- Optimize bundle size. +- Update Options of rule `jsx/no-useless-fragment` +- Optimize bundle size diff --git a/packages/core/docs/README.md b/packages/core/docs/README.md index 417fdb153..33c6034e3 100644 --- a/packages/core/docs/README.md +++ b/packages/core/docs/README.md @@ -75,7 +75,6 @@ - [isDeclaredInRenderPropLoose](functions/isDeclaredInRenderPropLoose.md) - [isForwardRef](functions/isForwardRef.md) - [isForwardRefCall](functions/isForwardRefCall.md) -- [isFragmentElement](functions/isFragmentElement.md) - [isFromReact](functions/isFromReact.md) - [isFunctionOfRenderMethod](functions/isFunctionOfRenderMethod.md) - [isInitializedFromReact](functions/isInitializedFromReact.md) diff --git a/packages/core/docs/functions/isFragmentElement.md b/packages/core/docs/functions/isFragmentElement.md deleted file mode 100644 index e7ade1975..000000000 --- a/packages/core/docs/functions/isFragmentElement.md +++ /dev/null @@ -1,31 +0,0 @@ -[**@eslint-react/core**](../README.md) - -*** - -[@eslint-react/core](../README.md) / isFragmentElement - -# Function: isFragmentElement() - -> **isFragmentElement**(`node`, `context`): `boolean` - -Check if a node is `` or `` - -## Parameters - -### node - -`JSXElement` - -The JSX element node to check - -### context - -`Readonly`\<`RuleContext`\<`string`, readonly `unknown`[]\>\> - -The rule context - -## Returns - -`boolean` - -`true` if the node is a fragment element, `false` otherwise diff --git a/packages/core/docs/functions/isInitializedFromReact.md b/packages/core/docs/functions/isInitializedFromReact.md index 4bea65bc1..a790aca91 100644 --- a/packages/core/docs/functions/isInitializedFromReact.md +++ b/packages/core/docs/functions/isInitializedFromReact.md @@ -166,6 +166,8 @@ The identifier that’s used for JSX Element creation. `"createElement"` +**Deprecated** + #### jsxPragmaFrag `string` @@ -180,6 +182,8 @@ This should not be a member expression (i.e. use "Fragment" instead of "React.Fr `"Fragment"` +**Deprecated** + #### polymorphicPropName `string` diff --git a/packages/core/src/element/index.ts b/packages/core/src/element/index.ts index 59476fbb6..960d186b6 100644 --- a/packages/core/src/element/index.ts +++ b/packages/core/src/element/index.ts @@ -1,3 +1,2 @@ export * from "./get-element-represent-name"; export * from "./hierarchy"; -export * from "./misc"; diff --git a/packages/core/src/element/misc.ts b/packages/core/src/element/misc.ts deleted file mode 100644 index 84605e0d1..000000000 --- a/packages/core/src/element/misc.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { decodeSettings } from "@eslint-react/shared"; -import type { RuleContext } from "@eslint-react/types"; -import type { TSESTree } from "@typescript-eslint/types"; -import { AST_NODE_TYPES } from "@typescript-eslint/types"; - -import { isInitializedFromReact } from "../utils"; - -/** - * Check if a node is `` or `` - * @param node The JSX element node to check - * @param context The rule context - * @returns `true` if the node is a fragment element, `false` otherwise - */ -export function isFragmentElement(node: TSESTree.JSXElement, context: RuleContext) { - const settings = decodeSettings(context.settings); - const { jsxPragma = "React", jsxPragmaFrag = "Fragment" } = settings; - const { name } = node.openingElement; - // - if (name.type === AST_NODE_TYPES.JSXIdentifier && name.name === jsxPragmaFrag) return true; - // - return name.type === AST_NODE_TYPES.JSXMemberExpression - && name.object.type === AST_NODE_TYPES.JSXIdentifier - && ( - name.object.name === jsxPragma - || isInitializedFromReact(name.object.name, context.sourceCode.getScope(node), settings) - ) - && name.property.name === jsxPragmaFrag; -} diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.spec.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.spec.ts index 47dcde9a2..6432f0522 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.spec.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.spec.ts @@ -197,9 +197,9 @@ ruleTester.run(RULE_NAME, rule, { /* tsx */ `<>{cloneElement(children, { ref: childrenRef })}`, { code: /* tsx */ ` - + {} - + `, settings: { "react-x": { @@ -208,14 +208,6 @@ ruleTester.run(RULE_NAME, rule, { }, }, }, - { - code: /* tsx */ ``, - settings: { - "react-x": { - strictImportCheck: true, - }, - }, - }, { code: /* tsx */ `{foo}`, options: [{ allowExpressions: false }], diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts index e7a42d8bb..164c58a24 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts @@ -1,10 +1,8 @@ import * as AST from "@eslint-react/ast"; -import { isFragmentElement } from "@eslint-react/core"; import * as JSX from "@eslint-react/jsx"; import type { RuleContext, RuleFeature } from "@eslint-react/types"; import { AST_NODE_TYPES } from "@typescript-eslint/types"; import type { TSESTree } from "@typescript-eslint/utils"; -import { isMatching, P } from "ts-pattern"; import { createRule } from "../utils"; @@ -19,48 +17,62 @@ export type MessageID = | "noUselessFragment" | "noUselessFragmentInBuiltIn"; -// eslint-disable-next-line @typescript-eslint/consistent-return -function check( +type Options = [ + { + allowExpressions: boolean; + }, +]; + +const defaultOptions = [{ + allowExpressions: true, +}] as const satisfies Options; + +function checkAndReport( node: TSESTree.JSXElement | TSESTree.JSXFragment, context: RuleContext, allowExpressions: boolean, ) { const initialScope = context.sourceCode.getScope(node); + // return if the fragment is keyed (e.g. ) if (JSX.isKeyedElement(node, initialScope)) return; + // report if the fragment is placed inside a built-in component (e.g.
<>
) if (JSX.isBuiltInElement(node.parent)) context.report({ messageId: "noUselessFragmentInBuiltIn", node }); + // report and return if the fragment has no children (e.g. <>) if (node.children.length === 0) return context.report({ messageId: "noUselessFragment", node }); - const isChildren = AST.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent); - const [firstChildren] = node.children; - // ee eeee eeee ...} /> - if (allowExpressions && node.children.length === 1 && JSX.isLiteral(firstChildren) && !isChildren) return; - if (!allowExpressions && isChildren) { + const isChildElement = AST.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent); + switch (true) { + // ee eeee eeee ...} /> + case allowExpressions + && !isChildElement + && node.children.length === 1 + && JSX.isLiteral(node.children.at(0)): { + return; + } // <>hello, world - return context.report({ messageId: "noUselessFragment", node }); - } else if (!allowExpressions && !isChildren && node.children.length === 1) { - // const foo = <>{children}; - // return <>{children}; - return context.report({ messageId: "noUselessFragment", node }); + case !allowExpressions + && isChildElement: { + return context.report({ messageId: "noUselessFragment", node }); + } + case !allowExpressions + && !isChildElement + && node.children.length === 1: { + // const foo = <>{children}; + // return <>{children}; + return context.report({ messageId: "noUselessFragment", node }); + } } const nonPaddingChildren = node.children.filter((child) => !JSX.isPaddingSpaces(child)); - if (nonPaddingChildren.length > 1) return; - if (nonPaddingChildren.length === 0) return context.report({ messageId: "noUselessFragment", node }); - const [first] = nonPaddingChildren; - if ( - isMatching({ type: AST_NODE_TYPES.JSXExpressionContainer, expression: P.not(AST_NODE_TYPES.CallExpression) }, first) - ) return; - context.report({ messageId: "noUselessFragment", node }); + const firstNonPaddingChild = nonPaddingChildren.at(0); + switch (true) { + case nonPaddingChildren.length === 0: + case nonPaddingChildren.length === 1 + && firstNonPaddingChild?.type !== AST_NODE_TYPES.JSXExpressionContainer: { + return context.report({ messageId: "noUselessFragment", node }); + } + } + return; } -type Options = [ - { - allowExpressions: boolean; - }, -]; - -const defaultOptions = [{ - allowExpressions: true, -}] as const satisfies Options; - export default createRule({ meta: { type: "problem", @@ -88,11 +100,11 @@ export default createRule({ const { allowExpressions = true } = option; return { JSXElement(node) { - if (!isFragmentElement(node, context)) return; - check(node, context, allowExpressions); + if (JSX.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return; + checkAndReport(node, context, allowExpressions); }, JSXFragment(node) { - check(node, context, allowExpressions); + checkAndReport(node, context, allowExpressions); }, }; }, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.spec.ts b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.spec.ts index 079f00694..fabc19db9 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.spec.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.spec.ts @@ -33,13 +33,5 @@ ruleTester.run(RULE_NAME, rule, { "{item.value}", "eeee ee eeeeeee eeeeeeee} />", "<>{foos.map(foo => foo)}", - { - code: /* tsx */ ``, - settings: { - "react-x": { - strictImportCheck: true, - }, - }, - }, ], }); diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts index baba372a1..3281fdd76 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts @@ -1,5 +1,5 @@ -import { isFragmentElement } from "@eslint-react/core"; import { F, O } from "@eslint-react/eff"; +import * as JSX from "@eslint-react/jsx"; import type { RuleFeature } from "@eslint-react/types"; import type { TSESTree } from "@typescript-eslint/types"; import type { ReportDescriptor } from "@typescript-eslint/utils/ts-eslint"; @@ -30,7 +30,7 @@ export default createRule<[], MessageID>({ name: RULE_NAME, create(context) { function getReportDescriptor(node: TSESTree.JSXElement): O.Option> { - if (!isFragmentElement(node, context)) return O.none(); + if (JSX.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return O.none(); const hasAttributes = node.openingElement.attributes.length > 0; if (hasAttributes) return O.none(); return O.some({ diff --git a/packages/shared/docs/functions/defineSettings.md b/packages/shared/docs/functions/defineSettings.md index abddfd502..1aca8136c 100644 --- a/packages/shared/docs/functions/defineSettings.md +++ b/packages/shared/docs/functions/defineSettings.md @@ -154,6 +154,8 @@ The identifier that’s used for JSX Element creation. `"createElement"` +**Deprecated** + #### jsxPragmaFrag `string` = `...` @@ -168,6 +170,8 @@ This should not be a member expression (i.e. use "Fragment" instead of "React.Fr `"Fragment"` +**Deprecated** + #### polymorphicPropName `string` = `...` @@ -335,7 +339,7 @@ This allows to specify a custom import location for React when not using the off `"@pika/react"` ``` -### jsxPragma? +### ~~jsxPragma?~~ > `optional` **jsxPragma**: `string` @@ -345,7 +349,9 @@ The identifier that’s used for JSX Element creation. `"createElement"` -### jsxPragmaFrag? +#### Deprecated + +### ~~jsxPragmaFrag?~~ > `optional` **jsxPragmaFrag**: `string` @@ -359,6 +365,8 @@ This should not be a member expression (i.e. use "Fragment" instead of "React.Fr `"Fragment"` +#### Deprecated + ### polymorphicPropName? > `optional` **polymorphicPropName**: `string` diff --git a/packages/shared/src/schemas.ts b/packages/shared/src/schemas.ts index 0af59c874..7521a8714 100644 --- a/packages/shared/src/schemas.ts +++ b/packages/shared/src/schemas.ts @@ -101,12 +101,14 @@ export const ESLintReactSettingsSchema = object({ /** * The identifier that’s used for JSX Element creation. * @default `"createElement"` + * @deprecated */ jsxPragma: optional(string()), /** * The identifier that’s used for JSX fragment elements. * @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment"). * @default `"Fragment"` + * @deprecated */ jsxPragmaFrag: optional(string()), /** diff --git a/website/pages/docs/advanced-configuration.mdx b/website/pages/docs/advanced-configuration.mdx index da7826af1..ef1a00de3 100644 --- a/website/pages/docs/advanced-configuration.mdx +++ b/website/pages/docs/advanced-configuration.mdx @@ -17,8 +17,6 @@ export default [ settings: { "react-x": { importSource: "react", - jsxPragma: "createElement", - jsxPragmaFrag: "Fragment", additionalHooks: { useLayoutEffect: ["useIsomorphicLayoutEffect"], }, diff --git a/website/pages/docs/configurations.mdx b/website/pages/docs/configurations.mdx index 772218159..dfff33f05 100644 --- a/website/pages/docs/configurations.mdx +++ b/website/pages/docs/configurations.mdx @@ -15,20 +15,6 @@ This allows to specify a custom import location for React when not using the off (e.g. `@pika/react`, etc) -### `jsxPragma` - -(type: `string`, default: `"createElement"`) - -The identifier that's used for JSX Element creation.\ -This should not be a member expression (i.e. use `"createElement"` instead of `"React.createElement"`). - -### `jsxPragmaFrag` - -(type: `string`, default: `"Fragment"`) - -The identifier that's used for JSX fragment elements.\ -This should not be a member expression (i.e. use `"Fragment"` instead of `"React.Fragment"`). - ### `version` (type: `string`, default: `"detect"`) @@ -82,9 +68,6 @@ export default [ ...eslintReact.configs.recommended, settings: { "react-x": { - importSource: "react", - jsxPragma: "createElement", - jsxPragmaFrag: "Fragment", additionalHooks: { useLayoutEffect: ["useIsomorphicLayoutEffect"], },