eslint/no-script-url 样式
它的作用
禁止 javascript: URL。
为什么这不好?
使用 javascript: URL 被一些人视为一种 eval 形式。通过 javascript: URL 传入的代码必须像处理 eval 一样,由浏览器进行解析和求值。这可能会导致安全和性能问题。
示例
此规则的错误代码示例:
javascript
location.href = "javascript:void(0)";
location.href = `javascript:void(0)`;如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-script-url": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-script-url": "error",
},
});bash
oxlint --deny no-script-url版本
此规则于 v0.2.15 中添加。
