Skip to content

Commit

Permalink
fix(linter/default): ignore unsupported files (e.g. .vue)
Browse files Browse the repository at this point in the history
relates #3157
  • Loading branch information
Boshen committed May 12, 2024
1 parent 36f0094 commit 313fb83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/oxc_linter/fixtures/import/vue/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script setup lang="ts">
import * as vue from 'vue'
</script>
11 changes: 10 additions & 1 deletion crates/oxc_linter/src/rules/import/default.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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")
{
Expand Down Expand Up @@ -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![
Expand Down

0 comments on commit 313fb83

Please sign in to comment.