Skip to content

Commit

Permalink
feat(linter): Implement eslint:yoda (#7559)
Browse files Browse the repository at this point in the history
In this PR, implement
[eslint:yoda](https://eslint.org/docs/latest/rules/yoda)

ref: #479
  • Loading branch information
tbashiyy authored Dec 4, 2024
1 parent 690fc54 commit bd9d38a
Show file tree
Hide file tree
Showing 6 changed files with 1,807 additions and 7 deletions.
1 change: 1 addition & 0 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ impl<'a> ComputedMemberExpression<'a> {
{
Some(lit.quasis[0].value.raw.clone())
}
Expression::RegExpLiteral(lit) => Some(Atom::from(lit.raw)),
_ => None,
}
}
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 @@ -148,6 +148,7 @@ mod eslint {
pub mod unicode_bom;
pub mod use_isnan;
pub mod valid_typeof;
pub mod yoda;
}

mod typescript {
Expand Down Expand Up @@ -640,6 +641,7 @@ oxc_macros::declare_all_lint_rules! {
eslint::unicode_bom,
eslint::use_isnan,
eslint::valid_typeof,
eslint::yoda,
import::default,
import::export,
import::first,
Expand Down
Loading

0 comments on commit bd9d38a

Please sign in to comment.