Skip to content

Comments

test(linter): add debug assertions for skipping rules#13724

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/09-12-test_linter_add_debug_assertions_for_skipping_rules
Sep 16, 2025
Merged

test(linter): add debug assertions for skipping rules#13724
graphite-app[bot] merged 1 commit intomainfrom
c/09-12-test_linter_add_debug_assertions_for_skipping_rules

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Sep 12, 2025

No description provided.

@github-actions github-actions bot added A-linter Area - Linter C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Sep 12, 2025
Copy link
Contributor Author

camc314 commented Sep 12, 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 Sep 12, 2025

CodSpeed Instrumentation Performance Report

Merging #13724 will not alter performance

Comparing c/09-12-test_linter_add_debug_assertions_for_skipping_rules (18a1145) with main (3af1e5d)1

Summary

✅ 37 untouched

Footnotes

  1. No successful run was found on main (18a1145) during the generation of this report, so 3af1e5d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camchenry
Copy link
Member

@camc314 What do you think about allowing this optimization to be disabled via an environment variable? We could do two runs: one with the optimization enabled, and another one with it disabled and then compare the diagnostics output. This way, we don't need to maintain quite as much code in the linter itself and we can defer most of the testing code to another script.

@camchenry
Copy link
Member

I put a little bit of work into this. I think this might be a viable solution: #13735, oxc-project/oxc-ecosystem-ci#52

@camc314 camc314 force-pushed the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch from 4a4950e to e347ee8 Compare September 16, 2025 10:41
@camc314 camc314 changed the base branch from main to graphite-base/13724 September 16, 2025 16:16
@camc314 camc314 force-pushed the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch from e347ee8 to b887309 Compare September 16, 2025 16:16
@camc314 camc314 force-pushed the graphite-base/13724 branch from 26af302 to 3a73d7c Compare September 16, 2025 16:16
@camc314 camc314 changed the base branch from graphite-base/13724 to c/09-17-refactor_linter_derive_inmpls_for_partialeq_eq_over_manual_ones September 16, 2025 16:17
@camc314 camc314 force-pushed the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch from b887309 to 200170a Compare September 16, 2025 16:32
@graphite-app graphite-app bot changed the base branch from c/09-17-refactor_linter_derive_inmpls_for_partialeq_eq_over_manual_ones to graphite-base/13724 September 16, 2025 16:47
@graphite-app graphite-app bot force-pushed the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch from 200170a to 9ad6d96 Compare September 16, 2025 16:51
@graphite-app graphite-app bot force-pushed the graphite-base/13724 branch from f87153b to 395d40d Compare September 16, 2025 16:51
@graphite-app graphite-app bot changed the base branch from graphite-base/13724 to main September 16, 2025 16:52
@graphite-app graphite-app bot force-pushed the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch from 9ad6d96 to 9b1d310 Compare September 16, 2025 16:52
Copy link
Contributor Author

camc314 commented Sep 16, 2025

I had a think about both approaches, and I think the debug assersions is going to be slightly better solution - if'll run anytime someone runs a debug/coverage build, which will happen a lot more often thatn just in ecosystem CI. It'll alwo happen anytime the tests run in oxc repo which should help catch any issues. I refactored the code to reduce the duplicate as the original implementation was much more complex than it needed to be

@camc314 camc314 marked this pull request as ready for review September 16, 2025 18:01
Copilot AI review requested due to automatic review settings September 16, 2025 18:01
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 adds debug assertions to verify that AST node type filtering optimizations don't change linting behavior. The changes ensure that in debug builds, the linter runs both with and without optimizations and asserts that the same diagnostics are produced.

  • Refactors rule execution into a reusable closure that can be run with/without AST filtering
  • Adds debug-only methods to track and compare diagnostic counts and contents
  • Implements assertion logic to verify optimization correctness in debug builds

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
crates/oxc_linter/src/lib.rs Adds debug assertions by refactoring rule execution and comparing optimized vs unoptimized runs
crates/oxc_linter/src/context/host.rs Adds debug-only helper methods for accessing diagnostics and counts

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@camc314 camc314 force-pushed the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch from 9b1d310 to e1ae00c Compare September 16, 2025 18:03
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Sep 16, 2025
Copy link
Contributor Author

camc314 commented Sep 16, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch from e1ae00c to 18a1145 Compare September 16, 2025 18:11
@graphite-app graphite-app bot merged commit 18a1145 into main Sep 16, 2025
25 checks passed
@graphite-app graphite-app bot deleted the c/09-12-test_linter_add_debug_assertions_for_skipping_rules branch September 16, 2025 18:15
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 16, 2025
This was referenced Sep 16, 2025
camc314 added a commit that referenced this pull request Sep 16, 2025
## [1.16.0] - 2025-09-16

### 🚀 Features

- 97c8d06 linter: Add `preserve-caught-error` rule (#13748) (孔辉)
- 8c19b18 linter/exhaustive-deps: Implement fixer for dep in global
scope (#13783) (camc314)
- 06bce8f linter/exhaustive-deps: Implement fixer for missing dep
(#13782) (camc314)
- a8675f4 linter: Add eslint/class-methods-use-this rule (#12977) (Peter
Cardenas)
- db33196 parser: Adds typescript rule for empty argument list (#13730)
(Karan Kiri)
- 2751193 linter: Add `eslint/no-useless-computed-key` rule (#13428)
(yefan)
- 9a205d1 regex-parser: Parse simple `TemplateLiterals` (#13265) (Sysix)

### 🐛 Bug Fixes

- a2c91cd linter: Drop `rules` to allow mutable access to `ctx_host` in
`run_external_rules` (#13832) (camc314)
- 3af1e5d linter/no-unsafe-declaration-merging: Always mark first span
as primary (#13830) (camc314)
- 1c43c7c linter: Keep message when merging composite fixes (#13827)
(camc314)
- 26af302 linter/exhaustive-deps: Check stable value is on lhs of
assignment expr (#13815) (camc314)
- 4bc12d0 linter/exhaustive-deps: Remove impossible comparison with
parent kind (#13814) (camc314)
- 12baf5e linter/exhaustive-deps: Respect primary span when identifying
disable directive location (#13781) (camc314)
- fa7400a linter/no-undef: False positive with `arguments` in functions
(#13763) (camc314)
- 50e6e3c editor: Restrict servers paths for `oxc.path.server` (#13740)
(Sysix)
- b45077d editor: Strip leading slash for bin path on windows (#13738)
(Sysix)
- 8fa6227 editor: Don't allow `oxc.path.server` for untrusted workspaces
(#13734) (Sysix)
- 56da114 linter/react/jsx-handler-names: Do not detect the function
name within the inline-function's body block (#13456) (Takuji Shimokawa)
- b2bc5b4 linter/react-perf/jsx-no-new-object-as-prop: Skip as/satisfies
exprs (#13718) (camc314)
- ab51394 raw_transfer: Disable layout assertions on some 32-bit
platforms (#13716) (overlookmotel)
- 09428f6 linter/plugins: Remove outdated comment (#13691)
(overlookmotel)
- a294721 linter/plugins: Exit early if JS plugins enabled on
unsupported platforms (#13689) (overlookmotel)
- 68a2280 linter/plugins: More graceful exit for
`--experimental-js-plugins` CLI option (#13688) (overlookmotel)

### 🚜 Refactor

- 395d40d linter: Derive inmpls for `PartialEq`, `Eq` over manual ones
(#13828) (camc314)
- 8e4cd8f linter/func-names: Use `run_once` over looping over all nodes
(#13798) (camc314)
- 7f4e2fe eslint/func-names: Clean up implementation and improve
documentation (#13601) (Antoine Zanardi)
- 137896a language_server: Split options for linting and formatting
(#13627) (Sysix)
- 7346099 linter: Move `oxlint` application code into separate module
(#13745) (overlookmotel)
- 6dd4107 linter: Remove `#[cfg(test)]` attributes from `tester` module
(#13714) (overlookmotel)
- c40c6ef linter/plugins: Directory for JS plugins-related code (#13701)
(overlookmotel)
- a0022c1 linter/plugins: Improve error messages for JS plugins (#13699)
(overlookmotel)
- 1fd993f napi/oxlint: Rename `napi/oxlint2` to `napi/oxlint` (#13682)
(overlookmotel)

### ⚡ Performance

- 90c8286 linter: Detect node types from `let..else` statements (#13690)
(camchenry)
- 08c05df semantic: Make CFG construction a compile-time feature
(#13678) (Boshen)

### 🎨 Styling

- 99a7638 linter: Add comments + re-organise imports (#13715)
(overlookmotel)

### 🧪 Testing

- 18a1145 linter: Add debug assertions for skipping rules (#13724)
(camc314)
- cb080de linter/no-unused-vars: Add test for non ASCII chars in JSX
components (#13820) (camc314)
- b6eba27 linter/no-undef: Add more test cases for `arguments` (#13764)
(camc314)
- fb2d087 linter: Set CWD for tests (#13722) (overlookmotel)

Co-authored-by: camc314 <18101008+camc314@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 C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants