diff --git a/examples/dlint/testdata/issue1145_no_trailing_newline.out b/examples/dlint/testdata/issue1145_no_trailing_newline.out index 6fda401d8..45fe04a25 100644 --- a/examples/dlint/testdata/issue1145_no_trailing_newline.out +++ b/examples/dlint/testdata/issue1145_no_trailing_newline.out @@ -15,7 +15,7 @@ no-var ,-[issue1145_no_trailing_newline.ts:3:1] 3 | ---*/ 4 | var base - : ^^^^^^^^ + : ^^^ `---- help: https://lint.deno.land/#no-var diff --git a/src/rules/no_var.rs b/src/rules/no_var.rs index 9bac22ece..4110f18cd 100644 --- a/src/rules/no_var.rs +++ b/src/rules/no_var.rs @@ -2,8 +2,8 @@ use super::{Context, LintRule}; use crate::handler::{Handler, Traverse}; use crate::Program; -use deno_ast::view::{VarDecl, VarDeclKind}; -use deno_ast::SourceRanged; +use deno_ast::view::{NodeTrait, VarDecl, VarDeclKind}; +use deno_ast::SourceRangedForSpanned; #[derive(Debug)] pub struct NoVar; @@ -39,7 +39,8 @@ struct NoVarHandler; impl Handler for NoVarHandler { fn var_decl(&mut self, var_decl: &VarDecl, ctx: &mut Context) { if var_decl.decl_kind() == VarDeclKind::Var { - ctx.add_diagnostic(var_decl.range(), CODE, MESSAGE); + let range = var_decl.tokens().first().unwrap().range(); + ctx.add_diagnostic(range, CODE, MESSAGE); } } }