Skip to content

Commit

Permalink
feat(semantic): cfg prototype (#2019)
Browse files Browse the repository at this point in the history
Co-authored-by: U9G <[email protected]>
  • Loading branch information
Boshen and u9g authored Jan 25, 2024
1 parent 2794064 commit 8898377
Show file tree
Hide file tree
Showing 143 changed files with 4,741 additions and 164 deletions.
45 changes: 43 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,26 @@ impl<'a> MemberExpression<'a> {
}
}

pub fn through_optional_is_specific_member_access(
&'a self,
object: &str,
property: &str,
) -> bool {
let object_matches = match self.object().without_parenthesized() {
Expression::ChainExpression(x) => match &x.expression {
ChainElement::CallExpression(_) => false,
ChainElement::MemberExpression(me) => {
me.object().without_parenthesized().is_specific_id(object)
}
},
x => x.is_specific_id(object),
};

let property_matches = self.static_property_name().is_some_and(|p| p == property);

object_matches && property_matches
}

/// Whether it is a static member access `object.property`
pub fn is_specific_member_access(&'a self, object: &str, property: &str) -> bool {
self.object().is_specific_id(object)
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 @@ -82,6 +82,7 @@ mod eslint {
pub mod no_setter_return;
pub mod no_shadow_restricted_names;
pub mod no_sparse_arrays;
// pub mod no_this_before_super;
pub mod no_undef;
pub mod no_unsafe_finally;
pub mod no_unsafe_negation;
Expand Down Expand Up @@ -326,6 +327,7 @@ oxc_macros::declare_all_lint_rules! {
eslint::eqeqeq,
eslint::for_direction,
eslint::getter_return,
// eslint::no_this_before_super,
eslint::no_array_constructor,
eslint::no_async_promise_executor,
eslint::no_bitwise,
Expand Down
Loading

0 comments on commit 8898377

Please sign in to comment.