no_webpack_loader_syntax

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoWebpackLoaderSyntax = rule.Rule{
	Name: "import/no-webpack-loader-syntax",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		return rule.RuleListeners{
			ast.KindImportDeclaration: func(node *ast.Node) {
				specifier := node.ModuleSpecifier()
				if specifier == nil || specifier.Kind != ast.KindStringLiteral {
					return
				}
				modulePath := specifier.AsStringLiteral().Text

				if hasWebpackLoaderSyntax(modulePath) {
					ctx.ReportNode(specifier, buildRuleMessage(modulePath))
				}
			},
			ast.KindCallExpression: func(node *ast.Node) {
				callExpression := node.AsCallExpression()
				expr := callExpression.Expression
				if expr.Kind != ast.KindIdentifier || expr.AsIdentifier().Text != "require" {
					return
				}

				if len(callExpression.Arguments.Nodes) == 0 {
					return
				}
				arg := callExpression.Arguments.Nodes[0]
				if arg.Kind != ast.KindStringLiteral {
					return
				}
				modulePath := arg.AsStringLiteral().Text
				if hasWebpackLoaderSyntax(modulePath) {

					ctx.ReportNode(arg, buildRuleMessage(modulePath))
				}
			},
		}
	},
}

See: https://github.com/import-js/eslint-plugin-import/blob/01c9eb04331d2efa8d63f2d7f4bfec3bc44c94f3/src/rules/no-webpack-loader-syntax.js

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL