From bde44a37209f4986e04307c248fffbb170f9c4b1 Mon Sep 17 00:00:00 2001 From: "Alexander S." Date: Tue, 31 Dec 2024 01:47:26 +0100 Subject: [PATCH] feat(linter): add `statement_span` to `ModuleRecord/ImportEntry` (#8195) Probably a breaking change. this is needed for the diagnostic in `no-restricted-imports`: https://github.com/oxc-project/oxc/pull/8113 you can see the eslint expection here: https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-restricted-imports.js#L487-L517 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- crates/oxc_linter/src/module_record.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/oxc_linter/src/module_record.rs b/crates/oxc_linter/src/module_record.rs index 996032d5f..5918b7b17 100644 --- a/crates/oxc_linter/src/module_record.rs +++ b/crates/oxc_linter/src/module_record.rs @@ -156,6 +156,16 @@ impl<'a> From<&oxc_syntax::module_record::NameSpan<'a>> for NameSpan { /// ``` #[derive(Debug, Clone, PartialEq, Eq)] pub struct ImportEntry { + /// Span of the import statement. + /// + /// ## Examples + /// + /// ```ts + /// import { foo } from "mod"; + /// ^^^^^^^^^^^^^^^^^^^^^^^^^ + /// ``` + pub statement_span: Span, + /// String value of the ModuleSpecifier of the ImportDeclaration. /// /// ## Examples @@ -212,6 +222,7 @@ pub struct ImportEntry { impl<'a> From<&oxc_syntax::module_record::ImportEntry<'a>> for ImportEntry { fn from(other: &oxc_syntax::module_record::ImportEntry<'a>) -> Self { Self { + statement_span: other.statement_span, module_request: NameSpan::from(&other.module_request), import_name: ImportImportName::from(&other.import_name), local_name: NameSpan::from(&other.local_name),