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>
This commit is contained in:
Alexander S. 2024-12-31 01:47:26 +01:00 committed by GitHub
parent f88acb331b
commit bde44a3720
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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),