no_script_url

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoScriptUrlRule = rule.Rule{
	Name: "no-script-url",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		const jsScheme = "javascript:"

		check := func(node *ast.Node) {
			value := utils.GetStaticStringValue(node)
			if len(value) >= len(jsScheme) && strings.EqualFold(value[:len(jsScheme)], jsScheme) {
				ctx.ReportNode(node, rule.RuleMessage{
					Id:          "unexpectedScriptURL",
					Description: "Script URL is a form of eval.",
				})
			}
		}

		return rule.RuleListeners{
			ast.KindStringLiteral: func(node *ast.Node) {
				check(node)
			},
			ast.KindNoSubstitutionTemplateLiteral: func(node *ast.Node) {

				if node.Parent != nil && node.Parent.Kind == ast.KindTaggedTemplateExpression {
					return
				}
				check(node)
			},
		}
	},
}

https://eslint.org/docs/latest/rules/no-script-url

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