]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-script-url.js
41479006ee92737eb1f282e6124ffcc07ecdfe75
2 * @fileoverview Rule to flag when using javascript: urls
5 /* eslint no-script-url: 0 -- Code is checking to report such URLs */
9 const astUtils
= require("./utils/ast-utils");
11 //------------------------------------------------------------------------------
13 //------------------------------------------------------------------------------
15 /** @type {import('../shared/types').Rule} */
21 description
: "Disallow `javascript:` urls",
23 url
: "https://eslint.org/docs/rules/no-script-url"
29 unexpectedScriptURL
: "Script URL is a form of eval."
36 * Check whether a node's static value starts with "javascript:" or not.
37 * And report an error for unexpected script URL.
38 * @param {ASTNode} node node to check
41 function check(node
) {
42 const value
= astUtils
.getStaticStringValue(node
);
44 if (typeof value
=== "string" && value
.toLowerCase().indexOf("javascript:") === 0) {
45 context
.report({ node
, messageId
: "unexpectedScriptURL" });
50 if (node
.value
&& typeof node
.value
=== "string") {
54 TemplateLiteral(node
) {
55 if (!(node
.parent
&& node
.parent
.type
=== "TaggedTemplateExpression")) {