Skip to content

feat(linter/unicorn): implement prefer-export-from rule#22686

Closed
AliceLanniste wants to merge 11 commits into
oxc-project:mainfrom
AliceLanniste:prefer_export_from
Closed

feat(linter/unicorn): implement prefer-export-from rule#22686
AliceLanniste wants to merge 11 commits into
oxc-project:mainfrom
AliceLanniste:prefer_export_from

Conversation

@AliceLanniste

Copy link
Copy Markdown
Contributor

prefer_export_from part of #684

@AliceLanniste AliceLanniste marked this pull request as ready for review May 23, 2026 12:19
@AliceLanniste AliceLanniste requested a review from camc314 as a code owner May 23, 2026 12:19
@codspeed-hq

codspeed-hq Bot commented May 23, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 81.09%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 4 untouched benchmarks
⏩ 52 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation linter[cal.com.tsx] 580.2 ms 3,068.7 ms -81.09%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing AliceLanniste:prefer_export_from (ec7bdf7) with main (27268a0)

Open in CodSpeed

Footnotes

  1. 52 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@AliceLanniste AliceLanniste marked this pull request as draft May 23, 2026 12:36
@AliceLanniste AliceLanniste marked this pull request as ready for review May 23, 2026 14:26
@camc314 camc314 self-assigned this May 24, 2026
@camc314 camc314 changed the title feat(linter): complete prefer-export-from rule feat(linter/unicorn): implement prefer-export-from rule May 28, 2026
@camc314 camc314 force-pushed the prefer_export_from branch from d538ce5 to 6ce7970 Compare May 28, 2026 10:36

@camc314 camc314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi! Thanks for working on this and putting up this PR.

I've pushed some changes refactoring to get the code a little more idomatic.

But there is a large performance regression. This is likely due to looping over all nodes.

Please take a look.

Thanks!

Comment on lines +167 to +168
ctx.semantic()
.nodes()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looping over all nodes is slow, as there are thousands per ast.

ctx: &LintContext<'a>,
import_decl: &'a ImportDeclaration<'a>,
) -> Option<&'a ExportNamedDeclaration<'a>> {
ctx.semantic().nodes().iter().find_map(|n| {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looping over all nodes is slow as there are thousands in a single AST

@camc314 camc314 marked this pull request as draft May 28, 2026 10:38
@camc314 camc314 force-pushed the prefer_export_from branch from 48cf2bd to ec7bdf7 Compare May 28, 2026 10:40
@camc314

camc314 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Closing for now - please feel free to open once CI is passing, and the performance concerns have been fixed.

Thanks!

@camc314 camc314 closed this Jun 1, 2026
@AliceLanniste AliceLanniste deleted the prefer_export_from branch June 3, 2026 10:02
@AliceLanniste AliceLanniste restored the prefer_export_from branch June 3, 2026 10:02
@AliceLanniste AliceLanniste deleted the prefer_export_from branch June 3, 2026 10:08
camc314 added a commit that referenced this pull request Jun 11, 2026
## Summary
- Adds Unicorn `prefer-export-from` to report import-then-re-export
patterns and suggest direct `export ... from` declarations.
- Ports upstream coverage for default, named, namespace, TypeScript,
import-attributes, and `checkUsedVariables` cases.
- Exposes the rule option in the oxlint JSON schema and generated
TypeScript config types.

Related #22686

AI-assisted: this PR was prepared with AI assistance; the contributor
remains responsible for reviewing and validating the changes.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cameron Clark <cameron.clark@hey.com>
camc314 added a commit that referenced this pull request Jul 3, 2026
## Summary
- Adds Unicorn `prefer-export-from` to report import-then-re-export
patterns and suggest direct `export ... from` declarations.
- Ports upstream coverage for default, named, namespace, TypeScript,
import-attributes, and `checkUsedVariables` cases.
- Exposes the rule option in the oxlint JSON schema and generated
TypeScript config types.

Related #22686

AI-assisted: this PR was prepared with AI assistance; the contributor
remains responsible for reviewing and validating the changes.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cameron Clark <cameron.clark@hey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants