Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions crates/oxc_linter/src/module_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl fmt::Debug for ModuleRecord {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NameSpan {
pub name: CompactStr,
span: Span,
pub span: Span,
}

impl NameSpan {
Expand All @@ -127,10 +127,6 @@ impl NameSpan {
pub fn name(&self) -> &str {
self.name.as_str()
}

pub fn span(&self) -> Span {
self.span
}
}

impl<'a> From<&oxc_syntax::module_record::NameSpan<'a>> for NameSpan {
Expand Down Expand Up @@ -392,7 +388,7 @@ impl ExportExportName {
/// Attempt to get the [`Span`] of this export name.
pub fn span(&self) -> Option<Span> {
match self {
Self::Name(name) => Some(name.span()),
Self::Name(name) => Some(name.span),
Self::Default(span) => Some(*span),
Self::Null => None,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Rule for NoDuplicateImports {

for entry in &module_record.import_entries {
let source = &entry.module_request.name;
let span = entry.module_request.span();
let span = entry.module_request.span;

let same_statement = if let Some(curr_span) = current_span {
curr_span == span
Expand Down
10 changes: 5 additions & 5 deletions crates/oxc_linter/src/rules/eslint/no_restricted_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,14 +1295,14 @@ fn get_diagnostic_from_import_name_result_path(
},
ImportNameResult::NameDisallowed(name_span) => match &path.allow_import_names {
Some(allow_import_names) => diagnostic_allowed_import_name(
name_span.clone().span(),
name_span.span,
path.message.clone(),
name_span.name(),
source,
allow_import_names.join(", ").as_str(),
),
_ => diagnostic_import_name(
name_span.clone().span(),
name_span.span,
path.message.clone(),
name_span.name(),
source,
Expand Down Expand Up @@ -1363,22 +1363,22 @@ fn get_diagnostic_from_import_name_result_pattern(
}
ImportNameResult::NameDisallowed(name_span) => match &pattern.allow_import_names {
Some(allow_import_names) => diagnostic_allowed_import_name(
name_span.clone().span(),
name_span.span,
pattern.message.clone(),
name_span.name(),
source,
allow_import_names.join(", ").as_str(),
),
_ => match &pattern.allow_import_name_pattern {
Some(allow_import_name_pattern) => diagnostic_allowed_import_name_pattern(
name_span.clone().span(),
name_span.span,
pattern.message.clone(),
name_span.name(),
source,
allow_import_name_pattern.as_str(),
),
_ => diagnostic_pattern_and_import_name(
name_span.clone().span(),
name_span.span,
pattern.message.clone(),
name_span.name(),
source,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Rule for Export {
walk_exported_recursive(remote_module_record, &mut export_names, &mut visited);

if export_names.is_empty() {
ctx.diagnostic(no_named_export(module_request.name(), module_request.span()));
ctx.diagnostic(no_named_export(module_request.name(), module_request.span));
} else {
all_export_names.insert(star_export_entry.span, export_names);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/max_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Rule for MaxDependencies {
"File has too many dependencies ({}). Maximum allowed is {}.",
module_count, self.max,
);
ctx.diagnostic(max_dependencies_diagnostic(error, entry.module_request.span()));
ctx.diagnostic(max_dependencies_diagnostic(error, entry.module_request.span));
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/import/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Rule for Named {
if !remote_module_record.has_module_syntax {
continue;
}
let import_span = import_name.span();
let import_span = import_name.span;
let name = import_name.name();
// Check `import { default as foo } from 'bar'`
if name == "default" && remote_module_record.export_default.is_some() {
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Rule for Named {
if remote_module_record.exported_bindings.contains_key(name) {
continue;
}
ctx.diagnostic(named_diagnostic(name, specifier, import_name.span()));
ctx.diagnostic(named_diagnostic(name, specifier, import_name.span));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/no_duplicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Rule for NoDuplicates {
let imports = module_record
.import_entries
.iter()
.filter(|entry| entry.module_request.span() == requested_module.span)
.filter(|entry| entry.module_request.span == requested_module.span)
.collect::<Vec<_>>();
if imports.is_empty() {
import_entries_maps.entry(0).or_default().push(requested_module);
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/no_named_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Rule for NoNamedDefault {
return;
};
if import_name.name() == "default" && !entry.is_type {
ctx.diagnostic(no_named_default_diagnostic(import_name.span()));
ctx.diagnostic(no_named_default_diagnostic(import_name.span));
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/import/no_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Rule for NoNamespace {
let source = entry.module_request.name();

if self.ignore.is_empty() {
ctx.diagnostic(no_namespace_diagnostic(entry.local_name.span()));
ctx.diagnostic(no_namespace_diagnostic(entry.local_name.span));
} else {
if !source.contains('.') {
return;
Expand All @@ -120,7 +120,7 @@ impl Rule for NoNamespace {
return;
}

ctx.diagnostic(no_namespace_diagnostic(entry.local_name.span()));
ctx.diagnostic(no_namespace_diagnostic(entry.local_name.span));
}
}
ImportImportName::Name(_) | ImportImportName::Default(_) => {}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jest/no_mocks_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Rule for NoMocksImport {
for import_entry in &module_records.import_entries {
let module_specifier = import_entry.module_request.name();
if contains_mocks_dir(module_specifier) {
ctx.diagnostic(no_mocks_import_diagnostic(import_entry.module_request.span()));
ctx.diagnostic(no_mocks_import_diagnostic(import_entry.module_request.span));
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/oxc/no_barrel_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Rule for NoBarrelFile {
{
if let Some(count) = count_loaded_modules(remote_module) {
total += count;
labels.push(module_request.span().label(format!("{count} modules")));
labels.push(module_request.span.label(format!("{count} modules")));
}
}
}
Expand Down
Loading