no-script-url
禁止 javascript:
网址
有些人认为使用 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)`;
兼容性
¥Compatibility
-
JSHint:该规则对应 JSHint 的
scripturl
规则。¥JSHint: This rule corresponds to
scripturl
rule of JSHint.
版本
此规则是在 ESLint v0.0.9 中引入。