Index

no-script-url

禁止 javascript: URL

使用 javascript: URL 被一些人认为是一种 eval。传递在 javascript: URL 中的代码必须由浏览器以处理 eval 的相同方式进行解析和评估。

🌐 Using javascript: URLs is considered by some as a form of eval. Code passed in javascript: URLs has to be parsed and evaluated by the browser in the same way that eval is processed.

规则详情

🌐 Rule Details

此规则的错误代码示例:

🌐 Examples of incorrect code for this rule:

在线运行
/*eslint no-script-url: "error"*/

location.href = "javascript:void(0)";

location.href = `javascript:void(0)`;

选项

🌐 Options

此规则没有选项。

🌐 This rule has no options.

兼容性

🌐 Compatibility

  • JSHint:此规则对应于 JSHint 的 scripturl 规则。

版本

此规则是在 ESLint v0.0.9 中引入。

进阶读物

资源