Skip to content

Comments

refactor(linter): reduce repeat code in JS plugin linting#17087

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/12-18-refactor_linter_reduce_repeat_code_in_js_plugin_linting
Dec 18, 2025
Merged

refactor(linter): reduce repeat code in JS plugin linting#17087
graphite-app[bot] merged 1 commit intomainfrom
om/12-18-refactor_linter_reduce_repeat_code_in_js_plugin_linting

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 18, 2025

Follow-on after #17013. Refactor.

Reduce repeated code by getting a &mut Program out of the ContextHost at the start of the process, instead of in 2 places later on.

This also enables an optimization in next PR.

Copy link
Member Author

overlookmotel commented Dec 18, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 18, 2025

CodSpeed Performance Report

Merging #17087 will not alter performance

Comparing om/12-18-refactor_linter_reduce_repeat_code_in_js_plugin_linting (fee8a45) with main (fb9e193)1

Summary

✅ 4 untouched
⏩ 41 skipped2

Footnotes

  1. No successful run was found on om/12-18-refactor_linter_reduce_repeated_logic_in_js_plugin_linting (9a293a2) during the generation of this report, so main (fb9e193) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 41 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the JS plugin linting code to reduce duplication by extracting the &mut Program from ContextHost once at the beginning of run_external_rules, rather than performing this extraction in two separate code paths. This simplification makes the code more maintainable and sets up for future optimizations.

Key changes:

  • Moved the Semantic extraction and Program pointer creation to happen before branching on js_allocator_pool
  • Updated clone_into_fixed_size_allocator_and_run_external_rules to accept an already-extracted &Program instead of extracting it internally
  • Swapped parameter order in convert_and_call_external_linter to place program before allocator for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel self-assigned this Dec 18, 2025
@overlookmotel overlookmotel added the A-linter-plugins Area - Linter JS plugins label Dec 18, 2025
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 18, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 18, 2025

Merge activity

Follow-on after #17013. Refactor.

Reduce repeated code by getting a `&mut Program` out of the `ContextHost` at the start of the process, instead of in 2 places later on.

This also enables an optimization in next PR.
@graphite-app graphite-app bot force-pushed the om/12-18-refactor_linter_reduce_repeated_logic_in_js_plugin_linting branch from 9a293a2 to 61f2138 Compare December 18, 2025 23:45
@graphite-app graphite-app bot force-pushed the om/12-18-refactor_linter_reduce_repeat_code_in_js_plugin_linting branch from fee8a45 to 22124c0 Compare December 18, 2025 23:46
graphite-app bot pushed a commit that referenced this pull request Dec 18, 2025
…ize allocator (#17088)

Follow-on after #17013.

We already copy the source text into the new fixed-sized allocator. Prevent the source also being cloned by `program.clone_in(allocator)` - that's unnecessary as we immediately overwrite it.

This is enabled by #17087, which allows us to have a `&mut Program` at this point.
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 18, 2025
Base automatically changed from om/12-18-refactor_linter_reduce_repeated_logic_in_js_plugin_linting to main December 18, 2025 23:54
@graphite-app graphite-app bot merged commit 22124c0 into main Dec 18, 2025
21 checks passed
@graphite-app graphite-app bot deleted the om/12-18-refactor_linter_reduce_repeat_code_in_js_plugin_linting branch December 18, 2025 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant