Skip to content

Commit

Permalink
fix: deno_ast 0.34 (#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Feb 21, 2024
1 parent 937fd58 commit b84fc49
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 70 deletions.
35 changes: 23 additions & 12 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ default = []
docs = []

[dependencies]
deno_ast = { version = "0.33.0", features = ["scopes", "transforms", "utils", "visit", "view"] }
deno_ast = { version = "0.34.0", features = ["scopes", "transforms", "utils", "visit", "view"] }
log = "0.4.20"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111"
Expand Down
12 changes: 6 additions & 6 deletions src/rules/adjacent_overload_signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,39 @@ struct AdjacentOverloadSignaturesHandler;

impl Handler for AdjacentOverloadSignaturesHandler {
fn script(&mut self, script: &ast_view::Script, ctx: &mut Context) {
check(&script.body, ctx);
check(script.body, ctx);
}

fn module(&mut self, module: &ast_view::Module, ctx: &mut Context) {
check(&module.body, ctx);
check(module.body, ctx);
}

fn ts_module_block(
&mut self,
ts_module_block: &ast_view::TsModuleBlock,
ctx: &mut Context,
) {
check(&ts_module_block.body, ctx);
check(ts_module_block.body, ctx);
}

fn class(&mut self, class: &ast_view::Class, ctx: &mut Context) {
check(&class.body, ctx);
check(class.body, ctx);
}

fn ts_type_lit(
&mut self,
ts_type_lit: &ast_view::TsTypeLit,
ctx: &mut Context,
) {
check(&ts_type_lit.members, ctx);
check(ts_type_lit.members, ctx);
}

fn ts_interface_body(
&mut self,
ts_interface_body: &ast_view::TsInterfaceBody,
ctx: &mut Context,
) {
check(&ts_interface_body.body, ctx);
check(ts_interface_body.body, ctx);
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/rules/camelcase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl CamelcaseHandler {

fn check_ts_type(&mut self, ty: &ast_view::TsType) {
if let ast_view::TsType::TsTypeLit(type_lit) = ty {
for member in &type_lit.members {
for member in type_lit.members {
self.check_ts_type_element(member);
}
}
Expand Down Expand Up @@ -417,16 +417,16 @@ impl CamelcaseHandler {
ast_view::Pat::Ident(ident) => {
self.check_ident(ident, IdentToCheck::variable(ident.id.inner));
}
ast_view::Pat::Array(ast_view::ArrayPat { ref elems, .. }) => {
ast_view::Pat::Array(ast_view::ArrayPat { elems, .. }) => {
for pat in elems.iter().flatten() {
self.check_pat(pat);
}
}
ast_view::Pat::Rest(ast_view::RestPat { ref arg, .. }) => {
self.check_pat(arg);
}
ast_view::Pat::Object(ast_view::ObjectPat { ref props, .. }) => {
for prop in props {
ast_view::Pat::Object(ast_view::ObjectPat { props, .. }) => {
for prop in *props {
match prop {
ast_view::ObjectPatProp::KeyValue(ast_view::KeyValuePatProp {
ref key,
Expand Down Expand Up @@ -536,13 +536,13 @@ impl Handler for CamelcaseHandler {
return;
}

for decl in &var_decl.decls {
for decl in var_decl.decls {
self.check_pat(&decl.name);

if let Some(expr) = &decl.init {
match expr {
ast_view::Expr::Object(ast_view::ObjectLit { ref props, .. }) => {
for prop in props {
ast_view::Expr::Object(ast_view::ObjectLit { props, .. }) => {
for prop in *props {
if let ast_view::PropOrSpread::Prop(prop) = prop {
match prop {
ast_view::Prop::Shorthand(ident) => self.check_ident(
Expand Down Expand Up @@ -684,7 +684,7 @@ impl Handler for CamelcaseHandler {
IdentToCheck::interface(interface_decl.id.inner),
);

for ty_el in &interface_decl.body.body {
for ty_el in interface_decl.body.body {
self.check_ts_type_element(ty_el);
}
}
Expand Down Expand Up @@ -732,7 +732,7 @@ impl Handler for CamelcaseHandler {

self
.check_ident(&enum_decl.id, IdentToCheck::enum_name(enum_decl.id.inner));
for variant in &enum_decl.members {
for variant in enum_decl.members {
if let ast_view::TsEnumMemberId::Ident(id) = &variant.id {
self.check_ident(id, IdentToCheck::enum_variant(id.inner));
}
Expand Down
4 changes: 2 additions & 2 deletions src/rules/constructor_super.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn return_before_super<'a, 'view>(
constructor: &'a ast_view::Constructor<'view>,
) -> Option<&'a ast_view::ReturnStmt<'view>> {
if let Some(block_stmt) = &constructor.body {
for stmt in &block_stmt.stmts {
for stmt in block_stmt.stmts {
if extract_super_range(stmt).is_some() {
return None;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ struct ConstructorSuperHandler;

impl Handler for ConstructorSuperHandler {
fn class(&mut self, class: &ast_view::Class, ctx: &mut Context) {
for member in &class.body {
for member in class.body {
if let ast_view::ClassMember::Constructor(cons) = member {
check_constructor(cons, class, ctx);
}
Expand Down
8 changes: 4 additions & 4 deletions src/rules/explicit_module_boundary_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Handler for ExplicitModuleBoundaryTypesHandler {
}

fn check_class(class: &ast_view::Class, ctx: &mut Context) {
for member in &class.body {
for member in class.body {
if let ast_view::ClassMember::Method(method) = member {
let is_setter = method.inner.kind == ast_view::MethodKind::Setter;
check_fn(method.function, ctx, is_setter);
Expand All @@ -109,7 +109,7 @@ fn check_fn(function: &ast_view::Function, ctx: &mut Context, is_setter: bool) {
ExplicitModuleBoundaryTypesHint::AddRetType,
);
}
for param in &function.params {
for param in function.params {
check_pat(&param.pat, ctx);
}
}
Expand All @@ -123,7 +123,7 @@ fn check_arrow(arrow: &ast_view::ArrowExpr, ctx: &mut Context) {
ExplicitModuleBoundaryTypesHint::AddRetType,
);
}
for pat in &arrow.params {
for pat in arrow.params {
check_pat(pat, ctx);
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ fn check_expr(expr: &ast_view::Expr, ctx: &mut Context) {
}

fn check_var_decl(var: &ast_view::VarDecl, ctx: &mut Context) {
for declarator in &var.decls {
for declarator in var.decls {
if let Some(expr) = &declarator.init {
check_expr(expr, ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no_case_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct NoCaseDeclarationsHandler;

impl Handler for NoCaseDeclarationsHandler {
fn switch_case(&mut self, switch_case: &SwitchCase, context: &mut Context) {
for stmt in &switch_case.cons {
for stmt in switch_case.cons {
let is_lexical_decl = match stmt {
Stmt::Decl(decl) => match &decl {
Decl::Fn(_) => true,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no_control_regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl Handler for NoControlRegexHandler {

fn call_expr(&mut self, call_expr: &CallExpr, ctx: &mut Context) {
if let Callee::Expr(Expr::Ident(ident)) = &call_expr.callee {
if let Some(regex) = extract_regex(ctx.scope(), ident, &call_expr.args) {
if let Some(regex) = extract_regex(ctx.scope(), ident, call_expr.args) {
check_regex(regex.as_str(), call_expr.range(), ctx);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/rules/no_deprecated_deno_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ fn extract_symbol<'a>(
MemberProp::Computed(prop) => match &prop.expr {
Expr::Lit(Lit::Str(s)) => Some(s.value()),
Expr::Ident(ident) => Some(ident.sym()),
Expr::Tpl(Tpl {
ref exprs,
ref quasis,
..
}) if exprs.is_empty() && quasis.len() == 1 => Some(quasis[0].raw()),
Expr::Tpl(Tpl { exprs, quasis, .. })
if exprs.is_empty() && quasis.len() == 1 =>
{
Some(quasis[0].raw())
}
_ => None,
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no_dupe_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Handler for NoDupeKeysHandler {
let range = obj_lit.range();
let mut keys: HashMap<String, PropertyInfo> = HashMap::new();

for prop in &obj_lit.props {
for prop in obj_lit.props {
if let PropOrSpread::Prop(prop) = prop {
match prop {
Prop::Shorthand(ident) => {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl NoEvalHandler {
}
// Multiple arguments callee: (0, eval)('var foo = 0;')
Expr::Seq(seq) => {
for expr in &seq.exprs {
for expr in seq.exprs {
if let Expr::Ident(ident) = expr {
self.maybe_add_diagnostic(*ident, ident.range(), ctx)
}
Expand Down
3 changes: 1 addition & 2 deletions src/rules/no_implicit_declare_namespace_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Handler for NoImplicitDeclareNamespaceExportHandler {
module_decl.body
{
if !block.body.is_empty() {
let has_named_export = block.body.as_slice().iter().any(|item| {
let has_named_export = block.body.iter().any(|item| {
matches!(
item,
ast_view::ModuleItem::ModuleDecl(
Expand All @@ -60,7 +60,6 @@ impl Handler for NoImplicitDeclareNamespaceExportHandler {
});
let has_non_exported_member = block
.body
.as_slice()
.iter()
.any(|item| matches!(item, ast_view::ModuleItem::Stmt(_)));
if !has_named_export && has_non_exported_member {
Expand Down
6 changes: 3 additions & 3 deletions src/rules/no_misused_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn is_constructor_keyword(ident: &Ident) -> bool {
impl Handler for NoMisusedNewHandler {
fn ts_type_alias_decl(&mut self, t: &TsTypeAliasDecl, ctx: &mut Context) {
if let TsType::TsTypeLit(lit) = t.type_ann {
for member in &lit.members {
for member in lit.members {
if let TsMethodSignature(signature) = &member {
if let Expr::Ident(ident) = signature.key {
if is_constructor_keyword(ident) {
Expand All @@ -96,7 +96,7 @@ impl Handler for NoMisusedNewHandler {
}

fn ts_interface_decl(&mut self, n: &TsInterfaceDecl, ctx: &mut Context) {
for member in &n.body.body {
for member in n.body.body {
match &member {
TsMethodSignature(signature) => {
if let Expr::Ident(ident) = signature.key {
Expand Down Expand Up @@ -129,7 +129,7 @@ impl Handler for NoMisusedNewHandler {
}

fn class_decl(&mut self, expr: &ClassDecl, ctx: &mut Context) {
for member in &expr.class.body {
for member in expr.class.body {
if let ClassMember::Method(method) = member {
let method_name = match &method.key {
PropName::Ident(ident) => ident.sym().as_ref(),
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no_regex_spaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Handler for NoRegexSpacesHandler {

fn call_expr(&mut self, call_expr: &CallExpr, ctx: &mut Context) {
if let Callee::Expr(Expr::Ident(ident)) = &call_expr.callee {
if let Some(regex) = extract_regex(ctx.scope(), ident, &call_expr.args) {
if let Some(regex) = extract_regex(ctx.scope(), ident, call_expr.args) {
check_regex(regex.as_str(), call_expr.range(), ctx);
}
}
Expand Down
Loading

0 comments on commit b84fc49

Please sign in to comment.