-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(linter): add the eslint/no_duplicate_imports rule #7309
base: main
Are you sure you want to change the base?
feat(linter): add the eslint/no_duplicate_imports rule #7309
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
fn no_duplicate_imports_diagnostic(module_name: &str, span: Span) -> OxcDiagnostic { | ||
OxcDiagnostic::warn(format!("'{}' import is duplicated", module_name)) | ||
.with_help("Merge the duplicated import into a single import statement") | ||
.with_label(span) | ||
} | ||
|
||
fn no_duplicate_exports_diagnostic(module_name: &str, span: Span) -> OxcDiagnostic { | ||
OxcDiagnostic::warn(format!("'{}' export is duplicated", module_name)) | ||
.with_help("Merge the duplicated exports into a single export statement") | ||
.with_label(span) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's probably worth useing with_labels
and proving an array of spans so that we can highlight both of the import stmts
|
||
let mut modules: HashMap<String, Vec<ModuleEntry>> = HashMap::new(); | ||
|
||
for node in nodes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than looping over all nodes here, is it possible to use ctx.module_record().import_entries
?
it has a vec of ImportEntry
which includes both the span of the module specifier and it's name
0bbf025
to
3cdc7fb
Compare
CodSpeed Performance ReportMerging #7309 will not alter performanceComparing Summary
|
Create the rule
Almost all cases are implemented. Already usable