Files
oxc-project__oxc/tasks/linter_codegen/Cargo.toml
Boshen f424ac675a refactor(linter): replace declare_all_lint_rules! macro with codegen (#18076)
## Summary

- Replace the `declare_all_lint_rules\!` proc-macro with checked-in codegen
- The generated `rules_enum.rs` file (~16K lines) provides better IDE support since the code is visible to rust-analyzer
- Run `cargo run -p oxc_linter_codegen` to regenerate
- Uses `quote\!` macro for clean, maintainable code generation

### Changes

- **New**: `tasks/linter_codegen/src/rules_enum.rs` - generates `RuleEnum` using `quote\!` macro
- **Modified**: `tasks/linter_codegen/src/main.rs` - added `generate_rules_enum_file()`
- **Modified**: `tasks/linter_codegen/src/rules.rs` - updated parser to scan module declarations
- **Modified**: `tasks/linter_codegen/Cargo.toml` - added `quote` and `proc-macro2` dependencies
- **Modified**: `crates/oxc_linter/src/rules.rs` - replaced macro invocation with re-exports, updated module docs
- **Modified**: `crates/oxc_linter/src/lib.rs` - added `pub mod rules_enum` to generated module, added clippy expects
- **Deleted**: `crates/oxc_macros/src/declare_all_lint_rules.rs` - removed proc-macro

### Adding new rules

1. Add the rule module to `crates/oxc_linter/src/rules.rs`
2. Run `cargo run -p oxc_linter_codegen` to regenerate `RuleEnum`

### Build time comparison

| Mode | main | this PR | Change |
|------|------|---------|--------|
| Dev | 26.80s | 31.39s | +17% |
| Release | 3m 32s | 3m 37s | +2% |

The slight increase is expected since rustc now parses the 1.1MB generated file instead of expanding a proc-macro. The tradeoff is better IDE support.

## Test plan

- [x] All 916 linter tests pass
- [x] `just lint` passes
- [x] `just ready` passes
- [x] Verified codegen works: `cargo run -p oxc_linter_codegen`

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-01-21 02:48:30 +00:00

23 lines
468 B
TOML

[package]
name = "oxc_linter_codegen"
version = "0.0.0"
edition.workspace = true
license.workspace = true
publish = false
[lints]
workspace = true
[[bin]]
name = "oxc_linter_codegen"
test = false
doctest = false
[dependencies]
convert_case = { workspace = true }
proc-macro2 = { workspace = true }
project-root = { workspace = true }
quote = { workspace = true }
rustc-hash = { workspace = true }
syn = { workspace = true, features = ["full", "visit", "parsing"] }