Skip to content
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

feat(linter/react): add the rules_of_hooks rule. #3071

Merged

Conversation

rzvxa
Copy link
Collaborator

@rzvxa rzvxa commented Apr 22, 2024

RulesOfHooks, docs, npm
This one sounds like something straight out of Mortal Kombat!

@github-actions github-actions bot added the A-linter Area - Linter label Apr 22, 2024
Copy link

codspeed-hq bot commented Apr 22, 2024

CodSpeed Performance Report

Merging #3071 will not alter performance

Comparing 04-22-feat_linter_react_add_the_rules_of_hooks_rule (1f135ce) with main (d9e2431)

Summary

✅ 27 untouched benchmarks

@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from 968ce65 to 5804a32 Compare April 22, 2024 23:50
@rzvxa rzvxa changed the base branch from main to 04-23-feat_ast_add_callee_name_method_to_the_callexpression_ April 22, 2024 23:50
Base automatically changed from 04-23-feat_ast_add_callee_name_method_to_the_callexpression_ to main April 23, 2024 01:47
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch 4 times, most recently from 7b0cfda to 78c9ba8 Compare April 28, 2024 20:20
@rzvxa rzvxa changed the base branch from main to 04-28-fix_connect_test_expression_of_for_statements_to_the_cfg April 28, 2024 20:20
@rzvxa rzvxa force-pushed the 04-28-fix_connect_test_expression_of_for_statements_to_the_cfg branch from fef3ca3 to d24c226 Compare April 29, 2024 06:14
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from 35acd51 to a2fdc69 Compare April 29, 2024 06:14
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from a2fdc69 to b790ee0 Compare April 29, 2024 06:48
@rzvxa rzvxa changed the base branch from 04-28-fix_connect_test_expression_of_for_statements_to_the_cfg to 04-29-fix_semantic_add_cfg_nodes_for_conditionalexpression_s April 29, 2024 06:48
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from 99ffcd0 to 6d5706a Compare April 29, 2024 06:53
@rzvxa
Copy link
Collaborator Author

rzvxa commented May 1, 2024

Status update:

This PR passes all react's official tests(even some that aren't passing in the original rule) there is only one situation that isn't detected... The labeled blocks with [labeled] breaks.

These don't have a correct cfg representation.

@rzvxa rzvxa force-pushed the 04-29-fix_semantic_add_cfg_nodes_for_conditionalexpression_s branch from 84f7348 to b76f2e0 Compare May 9, 2024 12:14
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from c5ad952 to 840eb52 Compare May 9, 2024 12:14
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from 840eb52 to 1fa5287 Compare May 10, 2024 11:26
@rzvxa rzvxa changed the base branch from 04-29-fix_semantic_add_cfg_nodes_for_conditionalexpression_s to 05-10-improvement_semantic_add_explicit_break_block_element May 10, 2024 11:26
@github-actions github-actions bot added the A-semantic Area - Semantic label May 10, 2024
@rzvxa rzvxa force-pushed the 05-10-improvement_semantic_add_explicit_break_block_element branch from ee83b4b to e3171a0 Compare May 10, 2024 12:53
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from d64d780 to 2cf4ee0 Compare May 10, 2024 12:53
@rzvxa rzvxa force-pushed the 05-10-improvement_semantic_add_explicit_break_block_element branch from e3171a0 to 0812788 Compare May 10, 2024 13:05
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from 2cf4ee0 to c59a2a2 Compare May 10, 2024 13:05
@rzvxa rzvxa marked this pull request as ready for review May 10, 2024 13:15
@rzvxa rzvxa requested a review from Boshen May 10, 2024 13:18
@rzvxa rzvxa marked this pull request as draft May 10, 2024 13:19
@rzvxa rzvxa removed the request for review from Boshen May 10, 2024 13:19
@rzvxa rzvxa marked this pull request as ready for review May 10, 2024 13:49
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from fcbb1dd to b0e22c1 Compare May 10, 2024 13:58
Boshen pushed a commit that referenced this pull request May 10, 2024
…fg. (#3122)

I don't know if it is correct or not, Fixes my issues with dangling cfg nodes created in for statements. #3071
@Boshen Boshen requested a review from mysteryven May 10, 2024 14:15
@Boshen
Copy link
Member

Boshen commented May 10, 2024

@mysteryven Good luck reviewing this ... and take your time :-)

@Boshen Boshen force-pushed the 05-10-improvement_semantic_add_explicit_break_block_element branch from 1a2657b to 7e78502 Compare May 10, 2024 14:17
Base automatically changed from 05-10-improvement_semantic_add_explicit_break_block_element to main May 10, 2024 14:22
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from b0e22c1 to beb07b8 Compare May 10, 2024 15:09
@Boshen Boshen self-assigned this May 12, 2024
Copy link
Member

@mysteryven mysteryven left a comment

Choose a reason for hiding this comment

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

LGTM, learned something new, thanks!

crates/oxc_linter/src/rules/react/rules_of_hooks.rs Outdated Show resolved Hide resolved
@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from 75cd771 to 24171a9 Compare May 12, 2024 18:59
@rzvxa rzvxa added the merge label May 12, 2024
Copy link

graphite-app bot commented May 12, 2024

Merge activity

  • May 12, 3:19 PM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • May 12, 3:20 PM EDT: rzvxa added this pull request to the Graphite merge queue.
  • May 12, 3:24 PM EDT: rzvxa merged this pull request with the Graphite merge queue.

@rzvxa rzvxa force-pushed the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch from 33633ba to 1f135ce Compare May 12, 2024 19:20
@graphite-app graphite-app bot merged commit 1f135ce into main May 12, 2024
29 checks passed
@graphite-app graphite-app bot deleted the 04-22-feat_linter_react_add_the_rules_of_hooks_rule branch May 12, 2024 19:24
Brooooooklyn pushed a commit to toeverything/AFFiNE that referenced this pull request May 16, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [oxlint](https://oxc-project.github.io) ([source](https://togithub.com/oxc-project/oxc/tree/HEAD/npm/oxlint)) | [`0.3.2` -> `0.3.5`](https://renovatebot.com/diffs/npm/oxlint/0.3.2/0.3.5) | [![age](https://developer.mend.io/api/mc/badges/age/npm/oxlint/0.3.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/oxlint/0.3.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/oxlint/0.3.2/0.3.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/oxlint/0.3.2/0.3.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>oxc-project/oxc (oxlint)</summary>

### [`v0.3.5`](https://togithub.com/oxc-project/oxc/releases/tag/oxlint_v0.3.5): oxlint v0.3.5

[Compare Source](https://togithub.com/oxc-project/oxc/compare/7193d75e9444ae8c2ba757b3bc64459abd0e128a...754d9f4c98aab052cf6b2756f7af12557042708d)

#### What's Changed

-   feat(linter): add use-isnan fixer for (in)equality operations by [@&#8203;DonIsaac](https://togithub.com/DonIsaac) in [oxc-project/oxc#3284
-   feat(linter/eslint): Implement fixer for unicode-bom rule by [@&#8203;jelly](https://togithub.com/jelly) in [oxc-project/oxc#3259
-   fix(linter/no-direct-mutation-state): false positive when class is declared inside a `CallExpression` by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3294
-   fix(parser): parse `DecoratorCallExpression` when `Arguments` contains `MemberExpression` by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3265
-   perf(ast): inline all `ASTBuilder` methods by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3295
-   perf(lexer): dedupe numeric separator check by [@&#8203;DonIsaac](https://togithub.com/DonIsaac) in [oxc-project/oxc#3283
-   perf(linter): rewrite react/require-render-return by [@&#8203;mysteryven](https://togithub.com/mysteryven) in [oxc-project/oxc#3276

#### New Contributors

-   [@&#8203;g-plane](https://togithub.com/g-plane) made their first contribution in [oxc-project/oxc#3268

**Full Changelog**: oxc-project/oxc@oxlint_v0.3.4...oxlint_v0.3.5

### [`v0.3.4`](https://togithub.com/oxc-project/oxc/releases/tag/oxlint_v0.3.4): oxlint v0.3.4

[Compare Source](https://togithub.com/oxc-project/oxc/compare/6149e49ef79a22004e36820c81afcb0c755fcc81...7193d75e9444ae8c2ba757b3bc64459abd0e128a)

#### What's Changed

-   [feat(linter): move react/rules_of_hooks to nursery](https://togithub.com/oxc-project/oxc/commit/6edcae86cda8922ea8f9e5eae91290018e1b1637)
-   feat(linter/eslint): Implement max-classes-per-file by [@&#8203;jelly](https://togithub.com/jelly) in [oxc-project/oxc#3241
-

**Full Changelog**: oxc-project/oxc@oxlint_v0.3.3...oxlint_v0.3.4

***

### From v0.3.3

#### What's Changed

##### Features

-   add `--symlinks` to allow symbolic walking by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3244
-   add `--format github` for github check annotation by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3191
-   change the category of all react-perf rules to perf by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3243
-   remove deprecated eslint v9 rules `no-return-await` and `no-mixed-operators` by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3188
-   move prefer-node-protocol to restriction by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3171

##### New Rules

-   react/rules-of-hooks by [@&#8203;rzvxa](https://togithub.com/rzvxa) in [oxc-project/oxc#3071
-   eslint/radix by [@&#8203;KubaJastrz](https://togithub.com/KubaJastrz) in [oxc-project/oxc#3167
-   eslint/no-new-native-nonconstructor by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3187
-   eslint/unicode-bom by [@&#8203;jelly](https://togithub.com/jelly) in [oxc-project/oxc#3239
-   eslint/no-empty-function rule by [@&#8203;jelly](https://togithub.com/jelly) in [oxc-project/oxc#3181
-   eslint-plugin-next/no-duplicate-head by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3174
-   eslint-plugin-next/no-page-custom-font by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3185
-   eslint-plugin-next/no-styled-jsx-in-document by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3184
-   unicorn/no-anonymous-default-export by [@&#8203;1zumii](https://togithub.com/1zumii) in [oxc-project/oxc#3220

##### Bug Fixes

-   improve `prefer-string-starts-ends-with` rule by [@&#8203;camc314](https://togithub.com/camc314) in [oxc-project/oxc#3176
-   import/export: improve multiple exports error message by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3160
-   import/named: handle `import { default as foo }` by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3255
-   shorten eslint/eqeqeq rule error message's span by [@&#8203;mysteryven](https://togithub.com/mysteryven) in [oxc-project/oxc#3193
-   fix(parser): correctly parse cls.fn<C> = x by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3208

#### New Contributors

-   [@&#8203;KubaJastrz](https://togithub.com/KubaJastrz) made their first contribution in [oxc-project/oxc#3167
-   [@&#8203;1zumii](https://togithub.com/1zumii) made their first contribution in [oxc-project/oxc#3220

**Full Changelog**: oxc-project/oxc@oxlint_v0.3.2...oxlint_v0.3.3

### [`v0.3.3`](https://togithub.com/oxc-project/oxc/releases/tag/oxlint_v0.3.3): oxlint v0.3.3

[Compare Source](https://togithub.com/oxc-project/oxc/compare/a7940868c6e66d16814ebef5c8dbbfd9b948a0cd...6149e49ef79a22004e36820c81afcb0c755fcc81)

#### What's Changed

##### Features

-   add `--symlinks` to allow symbolic walking by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3244
-   add `--format github` for github check annotation by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3191
-   change the category of all react-perf rules to perf by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3243
-   remove deprecated eslint v9 rules `no-return-await` and `no-mixed-operators` by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3188
-   move prefer-node-protocol to restriction by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3171

##### New Rules

-   react/rules-of-hooks by [@&#8203;rzvxa](https://togithub.com/rzvxa) in [oxc-project/oxc#3071
-   eslint/radix by [@&#8203;KubaJastrz](https://togithub.com/KubaJastrz) in [oxc-project/oxc#3167
-   eslint/no-new-native-nonconstructor by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3187
-   eslint/unicode-bom by [@&#8203;jelly](https://togithub.com/jelly) in [oxc-project/oxc#3239
-   eslint/no-empty-function rule by [@&#8203;jelly](https://togithub.com/jelly) in [oxc-project/oxc#3181
-   eslint-plugin-next/no-duplicate-head by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3174
-   eslint-plugin-next/no-page-custom-font by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3185
-   eslint-plugin-next/no-styled-jsx-in-document by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3184
-   unicorn/no-anonymous-default-export by [@&#8203;1zumii](https://togithub.com/1zumii) in [oxc-project/oxc#3220

##### Bug Fixes

-   improve `prefer-string-starts-ends-with` rule by [@&#8203;camc314](https://togithub.com/camc314) in [oxc-project/oxc#3176
-   import/export: improve multiple exports error message by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3160
-   import/named: handle `import { default as foo }` by [@&#8203;Boshen](https://togithub.com/Boshen) in [oxc-project/oxc#3255
-   shorten eslint/eqeqeq rule error message's span by [@&#8203;mysteryven](https://togithub.com/mysteryven) in [oxc-project/oxc#3193
-   fix(parser): correctly parse cls.fn<C> = x by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [oxc-project/oxc#3208

#### New Contributors

-   [@&#8203;KubaJastrz](https://togithub.com/KubaJastrz) made their first contribution in [oxc-project/oxc#3167
-   [@&#8203;1zumii](https://togithub.com/1zumii) made their first contribution in [oxc-project/oxc#3220

**Full Changelog**: oxc-project/oxc@oxlint_v0.3.2...oxlint_v0.3.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNTEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
Boshen pushed a commit that referenced this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter A-semantic Area - Semantic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants