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/jsdoc): Implement require-param rule #3554

Merged
merged 10 commits into from
Jun 7, 2024

Conversation

leaysgur
Copy link
Member

@leaysgur leaysgur commented Jun 6, 2024

Part of #1170

https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md

NOTE: config.useDefaultObjectProperties is not implemented for now.

Copy link

graphite-app bot commented Jun 6, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added the A-linter Area - Linter label Jun 6, 2024
@leaysgur
Copy link
Member Author

leaysgur commented Jun 6, 2024

$ ./typos .
Warning: "bject" should be "object".
error: `bject` should be `object`
  --> ./crates/oxc_linter/src/rules/jsdoc/require_param.rs:90:14
   |
90 |     "^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$".to_string()
   |              ^^^^^
   |

How to fix this..?

Copy link

codspeed-hq bot commented Jun 6, 2024

CodSpeed Performance Report

Merging #3554 will not alter performance

Comparing linter-jsdoc-require_param (45bb316) with main (e8a20f8)

Summary

✅ 22 untouched benchmarks

@Boshen
Copy link
Member

Boshen commented Jun 6, 2024

It seems like there is a huge performance regression, would you like to investigate?

@Boshen
Copy link
Member

Boshen commented Jun 6, 2024

$ ./typos .
Warning: "bject" should be "object".
error: `bject` should be `object`
  --> ./crates/oxc_linter/src/rules/jsdoc/require_param.rs:90:14
   |
90 |     "^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$".to_string()
   |              ^^^^^
   |

How to fix this..?

I found two intresting cases where we can implement line or block ignore:

@leaysgur
Copy link
Member Author

leaysgur commented Jun 6, 2024

Thanks!

It seems like there is a huge performance regression, would you like to investigate?

Yes..., I will try it later. 😢

@leaysgur
Copy link
Member Author

leaysgur commented Jun 6, 2024

About previous rules, I have been re-implemented them in an efficient way, by first understanding all the implementation (and test cases and configuration).

However, this time, this rule was so complex and I gave up. So basically code flow is following the original.

Then, how to fix this... 🤔


Notes: Add collect_params() to another rules and check whether perf drops or not.

@Boshen
Copy link
Member

Boshen commented Jun 6, 2024

        let check_types_regex = Regex::new(config.check_types_pattern.as_str())
            .expect("`config.checkTypesPattern` should be a valid regex pattern");
image

Codspeed to the rescue! Constructing the regex on each turn is expensive! You need to cache it / make it static 😅

@leaysgur
Copy link
Member Author

leaysgur commented Jun 6, 2024

Oh~~~, thank you very much indeed! (I've just learned such view exists...)

You need to cache it / make it static

I will try! 💪🏻

@leaysgur
Copy link
Member Author

leaysgur commented Jun 6, 2024

🎉

@leaysgur leaysgur requested a review from Boshen June 6, 2024 14:24
Copy link
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

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

Nice work! Learned something new!

@Boshen Boshen merged commit 4a075cc into main Jun 7, 2024
23 checks passed
@Boshen Boshen deleted the linter-jsdoc-require_param branch June 7, 2024 07:58
@github-actions github-actions bot mentioned this pull request Jun 7, 2024
Boshen added a commit that referenced this pull request Jun 7, 2024
## [0.4.3] - 2024-06-07

### Features

- 1fb9d23 linter: Add fixer for no-useless-fallback-in-spread rule
(#3544) (Don Isaac)
- 6506d08 linter: Add fixer for no-single-promise-in-promise-methods
(#3531) (Don Isaac)
- daf559f linter: Eslint-plugin-jest/no-large-snapshot (#3436) (cinchen)
- 4c17bc6 linter: Eslint/no-constructor-return (#3321) (谭光志)
- 4a075cc linter/jsdoc: Implement require-param rule (#3554) (Yuji
Sugiura)
- 747500a linter/jsdoc: Implement require-returns-type rule (#3458)
(Yuji Sugiura)
- 6b39654 linter/tree-shaking: Support options (#3504) (Wang Wenzhe)
- 0cdb45a oxc_codegen: Preserve annotate comment (#3465)
(IWANABETHATGUY)

### Bug Fixes

- b188778 linter/eslint: Fix `require-await` false positives in
`ForOfStatement`. (#3457) (rzvxa)
- 350cd91 parser: Should parser error when function declaration has no
name (#3461) (Dunqing)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants