Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7b048f3
First pass at implementing the prefer-const rule.
connorshea Nov 2, 2025
0b0a2e0
Iteration 2, implements some of the options.
connorshea Nov 2, 2025
067f3e6
Enable a few more tests.
connorshea Nov 2, 2025
30a8069
Enable a few more tests.
connorshea Nov 2, 2025
5935501
Enable more tests.
connorshea Nov 2, 2025
f7a2a31
Get a few more tests passing.
connorshea Nov 2, 2025
4d677ac
Format and update snap.
connorshea Nov 2, 2025
1b49bdd
Implement more of the ignoreReadBeforeAssign option.
connorshea Nov 2, 2025
4c539e9
Get more tests passing!
connorshea Nov 2, 2025
d6ec245
Get more tests passing!
connorshea Nov 2, 2025
5aa9e2b
Fix a few more tests related to control flow.
connorshea Nov 2, 2025
4d70cce
Update a weird test.
connorshea Nov 2, 2025
8708527
Get another test passing.
connorshea Nov 2, 2025
c054b3f
This is becoming very complex and I think the AI is doing excessive t…
connorshea Nov 2, 2025
696575b
Re-run lintgen.
connorshea Nov 15, 2025
97f1920
Fix lint failures.
connorshea Nov 15, 2025
1d22e29
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 15, 2025
5588ab6
feat(linter): Enable commented-out test for prefer-const rule.
connorshea Nov 15, 2025
e54480b
Resolve feedback.
connorshea Nov 15, 2025
61e1387
Make comment clearer.
connorshea Nov 15, 2025
d8153c6
refactor(linter): Simplify the code for prefer-const rule implementat…
connorshea Nov 15, 2025
731a14c
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 15, 2025
421e090
Clean up code a bit more.
connorshea Nov 15, 2025
4a77f02
docs(linter): Improve docs for prefer-const rule.
connorshea Nov 15, 2025
34a1991
Update the prefer-const config to deserialize using the config object.
connorshea Nov 15, 2025
3d76cb8
Add basic tests for ensuring comments don't get caught.
connorshea Nov 16, 2025
2dfafa5
Update the diagnostic to use a period at the end of sentences.
connorshea Nov 16, 2025
9845197
Fix prefer-const to not suggest const for cases where it is invalid.
connorshea Nov 16, 2025
087e412
Fix prefer-const to not suggest const for another case where it is in…
connorshea Nov 16, 2025
e3754a5
Add one more test case for commented code.
connorshea Nov 16, 2025
9561ddb
fix(linter): Fix another edge-case for a case where const cannot be u…
connorshea Nov 16, 2025
b6c8f5c
formatting tweaks for tests
connorshea Nov 16, 2025
19c06ad
Resolve feedback on memory usage.
connorshea Nov 16, 2025
328ec56
refactor: Rework the ignoreReadBeforeAssign logic.
connorshea Nov 16, 2025
968d081
Simplify a bit and add tests.
connorshea Nov 17, 2025
59719d0
Add comment
connorshea Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/oxc_linter/src/generated/rule_runner_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,12 @@ impl RuleRunner for crate::rules::eslint::operator_assignment::OperatorAssignmen
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

impl RuleRunner for crate::rules::eslint::prefer_const::PreferConst {
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::VariableDeclaration]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

impl RuleRunner for crate::rules::eslint::prefer_destructuring::PreferDestructuring {
const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[
AstType::AssignmentExpression,
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_linter/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pub(crate) mod eslint {
pub mod no_warning_comments;
pub mod no_with;
pub mod operator_assignment;
pub mod prefer_const;
pub mod prefer_destructuring;
pub mod prefer_exponentiation_operator;
pub mod prefer_numeric_literals;
Expand Down Expand Up @@ -802,6 +803,7 @@ oxc_macros::declare_all_lint_rules! {
eslint::no_warning_comments,
eslint::no_with,
eslint::operator_assignment,
eslint::prefer_const,
eslint::prefer_template,
eslint::prefer_destructuring,
eslint::prefer_promise_reject_errors,
Expand Down
Loading
Loading