fix(linter/default): ignore unsupported files (e.g. .vue)

relates #3157
This commit is contained in:
Boshen 2024-05-12 13:32:26 +08:00
parent 36f0094400
commit 313fb839b5
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1
2 changed files with 13 additions and 1 deletions

View file

@ -0,0 +1,3 @@
<script setup lang="ts">
import * as vue from 'vue'
</script>

View file

@ -1,7 +1,7 @@
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use oxc_span::{Span, VALID_EXTENSIONS};
use oxc_syntax::module_record::ImportImportName;
use crate::{context::LintContext, rule::Rule};
@ -51,6 +51,14 @@ impl Rule for Default {
if remote_module_record_ref.not_esm {
continue;
}
if !remote_module_record_ref
.resolved_absolute_path
.extension()
.and_then(|ext| ext.to_str())
.is_some_and(|ext| VALID_EXTENSIONS.contains(&ext))
{
continue;
}
if remote_module_record_ref.export_default.is_none()
&& !remote_module_record_ref.exported_bindings.contains_key("default")
{
@ -104,6 +112,7 @@ fn test() {
// r#"import foobar from "./typescript-export-assign-property""#,
// r#"import foobar from "./typescript-export-assign-default-reexport""#,
// r#"import React from "./typescript-export-assign-default-namespace"#,
r#"import Foo from "./vue/main.vue""#,
];
let fail = vec![