improvement(linter/ts): use root_node method in the triple_slash_reference rule. (#3088)

This commit is contained in:
Ali Rezvani 2024-04-25 04:25:29 +03:30 committed by GitHub
parent c49f6922c2
commit 69e464b19a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -103,8 +103,8 @@ impl Rule for TripleSlashReference {
}))
}
fn run_once(&self, ctx: &LintContext) {
let Some(root) = ctx.nodes().iter().next() else { return };
let AstKind::Program(program) = root.kind() else { return };
let Some(root) = ctx.nodes().root_node() else { return };
let AstKind::Program(program) = root.kind() else { unreachable!() };
// We don't need to iterate over all comments since Triple-slash directives are only valid at the top of their containing file.
// We are trying to get the first statement start potioin, falling back to the program end if statement does not exist