Skip to content

Commit

Permalink
feat(linter): add statement_span to ModuleRecord/ImportEntry (#8195)
Browse files Browse the repository at this point in the history
Probably a breaking change. 

this is needed for the diagnostic in `no-restricted-imports`:
#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>
  • Loading branch information
Sysix and autofix-ci[bot] authored Dec 31, 2024
1 parent f88acb3 commit bde44a3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/oxc_linter/src/module_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit bde44a3

Please sign in to comment.