improvement(linter/unicorn): use root_node method in the no_empty_file rule. (#3090)

This commit is contained in:
Ali Rezvani 2024-04-25 04:37:40 +03:30 committed by GitHub
parent 71da1a1d72
commit a43054bec5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,8 +47,8 @@ impl Rule for NoEmptyFile {
{
return;
}
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!() };
if program.body.iter().any(|node| !is_empty_stmt(node)) {
return;