improvement(linter/nextjs): use root_node method in no_async_client_component rule. (#3087)

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

View file

@ -40,8 +40,8 @@ declare_oxc_lint!(
impl Rule for NoAsyncClientComponent {
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!() };
if program.directives.iter().any(|directive| directive.directive.as_str() == "use client") {
for node in &program.body {