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
3 changes: 2 additions & 1 deletion crates/oxc_linter/src/generated/rule_runner_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,8 @@ impl RuleRunner for crate::rules::import::no_unassigned_import::NoUnassignedImpo
}

impl RuleRunner for crate::rules::import::no_webpack_loader_syntax::NoWebpackLoaderSyntax {
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::CallExpression, AstType::ImportDeclaration]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

Expand Down
15 changes: 10 additions & 5 deletions crates/oxc_linter/src/rules/import/no_webpack_loader_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ declare_oxc_lint!(

impl Rule for NoWebpackLoaderSyntax {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
// not in top level
if node.scope_id() != ctx.scoping().root_scope_id() {
return;
}

match node.kind() {
AstKind::CallExpression(call_expr) => {
if let Expression::Identifier(identifier) = &call_expr.callee {
Expand All @@ -74,6 +69,11 @@ impl Rule for NoWebpackLoaderSyntax {
return;
};

// not in top level
if node.scope_id() != ctx.scoping().root_scope_id() {
return;
}

if ident.value.contains('!') {
ctx.diagnostic(no_named_as_default_diagnostic(
ident.value.as_str(),
Expand All @@ -83,6 +83,11 @@ impl Rule for NoWebpackLoaderSyntax {
}
}
AstKind::ImportDeclaration(import_decl) => {
// not in top level
if node.scope_id() != ctx.scoping().root_scope_id() {
return;
}

if import_decl.source.value.contains('!') {
ctx.diagnostic(no_named_as_default_diagnostic(
&import_decl.source.value,
Expand Down
Loading