mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
perf(linter): Check file path after checking node kind for nextjs/no-head-element (#5868)
This commit is contained in:
parent
0c8733df23
commit
3148d4b654
1 changed files with 9 additions and 8 deletions
|
|
@ -30,19 +30,20 @@ declare_oxc_lint!(
|
|||
|
||||
impl Rule for NoHeadElement {
|
||||
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
|
||||
let Some(full_file_path) = ctx.file_path().to_str() else {
|
||||
return;
|
||||
};
|
||||
if is_in_app_dir(full_file_path) {
|
||||
return;
|
||||
}
|
||||
if let AstKind::JSXOpeningElement(elem) = node.kind() {
|
||||
let JSXElementName::Identifier(id) = &elem.name else {
|
||||
return;
|
||||
};
|
||||
if id.name == "head" {
|
||||
ctx.diagnostic(no_head_element_diagnostic(elem.span));
|
||||
if id.name != "head" {
|
||||
return;
|
||||
}
|
||||
let Some(full_file_path) = ctx.file_path().to_str() else {
|
||||
return;
|
||||
};
|
||||
if is_in_app_dir(full_file_path) {
|
||||
return;
|
||||
}
|
||||
ctx.diagnostic(no_head_element_diagnostic(elem.span));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue