+
Skip to content

feat(biome_js_analyze): implement noExcessiveLinesPerFunction #6166

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 7 commits into from
Jun 24, 2025

Conversation

mehm8128
Copy link
Contributor

@mehm8128 mehm8128 commented May 29, 2025

Summary

close #5740

I implemented this rule with some options which are included in eslint/max-lines-per-function, but I excluded skipComments option because it's implementation is expected to be complicated as the first PR for this rule. So if the option is needed for this rule, please split into another issue.

Test Plan

See some test cases.

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels May 29, 2025
@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch 2 times, most recently from 770bbac to 01f0f5f Compare May 29, 2025 12:11
@github-actions github-actions bot added the A-CLI Area: CLI label May 29, 2025
@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from 01f0f5f to 67d5faa Compare May 29, 2025 12:28
Copy link

codspeed-hq bot commented May 29, 2025

CodSpeed Performance Report

Merging #6166 will degrade performances by 13.24%

Comparing mehm8128:feat/impl-noExcessiveLinesPerFunction (0bdf096) with main (72623fa)

Summary

❌ 3 regressions
✅ 112 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
js_analyzer[css_16118272471217147034.js] 19.9 ms 21.2 ms -6.05%
router_17129688031671448157.ts[uncached] 2.2 ms 2.4 ms -8.14%
eucjp_1600564308684076393.json[cached] 764.5 µs 881.2 µs -13.24%

@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch 4 times, most recently from bf3902f to a73c0ab Compare May 30, 2025 15:23
@github-actions github-actions bot added the A-Parser Area: parser label May 30, 2025
@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from f629982 to ce4997e Compare May 30, 2025 16:20
@mehm8128 mehm8128 requested a review from ematipico May 30, 2025 16:21
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you @mehm8128 for this PR. There's some work to do yet, however I left some useful comments that should help you getting to the finish line.

@mehm8128
Copy link
Contributor Author

Thank you for your review! I'll check them and work for it!

@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from ce4997e to 741eacf Compare May 31, 2025 08:31
@mehm8128
Copy link
Contributor Author

@ematipico
There is one point I still can't understand what should I do, but I have fixed everything else according to your help.
Please review again it🙏

@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from 741eacf to ee2c510 Compare May 31, 2025 08:47
@mehm8128 mehm8128 requested a review from ematipico May 31, 2025 09:27
@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from e56d852 to 3bf0689 Compare June 2, 2025 11:26
@mehm8128 mehm8128 requested a review from dyc3 June 3, 2025 09:57
Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Looks good!

FYI, ematipico is on vacation this week. Once he's back this can move forward.

@mehm8128
Copy link
Contributor Author

mehm8128 commented Jun 3, 2025

@dyc3
Thank you!
and I have one more question (I forgot to ask you). because unlike ESLint and Oxc as I mentioned, this rule checks only the code of function body, so should I change source_kind: RuleSourceKind::SameLogic to source_kind: RuleSourceKind::Inspired?

@dyc3
Copy link
Contributor

dyc3 commented Jun 3, 2025

Since it doesn't match that rule exactly, yeah.

The rule will be in nursery, so this is fine as a first iteration. We can always update it to more accurately match the source rule later. Or you can do that in this PR. Personally, I would prefer the rule to exactly match the source rule to make migrating easier.

@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from b19e4ab to 89d728e Compare June 3, 2025 13:56
@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from 89d728e to 75499d7 Compare June 8, 2025 13:50
@mehm8128
Copy link
Contributor Author

@ematipico @dyc3
Hi, should I work on resolving CodSpeed Performance Analysis degradation? (if yes, how can I approach to it?)

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you @mehm812! The PR is excellent, I left just a nit around the options. You don't need to look into the performance part. Usually, rules that inspect tokens such as this one are very difficult to optimise.

@stavalfi
Copy link

any update? + can you please support all eslint options? https://eslint.org/docs/latest/rules/max-lines-per-function#options

Options
This rule has the following options that can be specified using an object:

"max" (default 50) enforces a maximum number of lines in a function.

"skipBlankLines" (default false) ignore lines made up purely of whitespace.

"skipComments" (default false) ignore lines containing just comments.

"IIFEs" (default false) include any code included in IIFEs.

@mehm8128
Copy link
Contributor Author

@stavalfi
Thank you for comment, but as I wrote in the PR description, I don't intend to support all options existing in ESLint in this PR because of its complexity. If you want it, please create another issue.

@ematipico
Could you merge this PR? or are you waiting for something?

@ematipico
Copy link
Member

@mehm8128 we're close to ship V2 stable so we're trying to avoid too many changes unless they are bug fixes.

We'll merge the PR after v2 is out.

@mehm8128
Copy link
Contributor Author

OK, I'll wait for it.
I'm looking for v2 being released!

@arendjr arendjr added this to the Biome 2.1 milestone Jun 23, 2025
@mehm8128 mehm8128 force-pushed the feat/impl-noExcessiveLinesPerFunction branch from 344e5fa to f20c4c7 Compare June 23, 2025 15:35
Copy link

changeset-bot bot commented Jun 23, 2025

🦋 Changeset detected

Latest commit: 0bdf096

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@arendjr arendjr merged commit b8cbd83 into biomejs:main Jun 24, 2025
29 checks passed
@github-actions github-actions bot mentioned this pull request Jun 24, 2025
@arendjr
Copy link
Contributor

arendjr commented Jun 24, 2025

Merged for the next patch release, since nursery rules indeed don't need to wait for 2.1 (I removed the milestone).

@arendjr arendjr removed this from the Biome 2.1 milestone Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Parser Area: parser A-Project Area: project L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📎 Implement lint/useMaxLinesPerFunction - eslint/max-lines-per-function
5 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载