Skip to content

refactor(eslint-plugin-react-hooks): move rules to rules folder #32411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/eslint-plugin-react-hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ If you are still using ESLint below 9.0.0, please continue to use `recommended-l
For [ESLint 9.0.0 and above](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/) users, add the `recommended-latest` config.

```js
import reactHooks from 'eslint-plugin-react-hooks';
import * as reactHooks from 'eslint-plugin-react-hooks';

export default [
// ...
Expand Down Expand Up @@ -67,7 +67,7 @@ If you want more fine-grained configuration, you can instead add a snippet like
#### Flat Config (eslint.config.js)

```js
import reactHooks from 'eslint-plugin-react-hooks';
import * as reactHooks from 'eslint-plugin-react-hooks';
Copy link

@silverwind silverwind Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are functionally equal as far as I'm aware. Why change to the (imho) uglier * as form?

Copy link
Contributor Author

@michaelfaith michaelfaith Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For use in TypeScript, since the plugin doesn't have a default export (for backwards compatibility), if a user doesn't have allowSyntheticDefaultImports turned on in their tsconfig, they'll get a type error with the previous form. Figured it would be easier to provide the form that work for both js and ts, rather than have a specific example just for TS.

Copy link

@silverwind silverwind Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess any sane user runs Typescript with allowSyntheticDefaultImports these days, likely coming from moduleResultion: "bundler". But I won't further push regarding this :)


export default [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin-react-hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import RulesOfHooks from './RulesOfHooks';
import ExhaustiveDeps from './ExhaustiveDeps';
import RulesOfHooks from './rules/RulesOfHooks';
import ExhaustiveDeps from './rules/ExhaustiveDeps';
import type {ESLint, Linter, Rule} from 'eslint';

// All rules
Expand Down
Loading