no-eval
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-eval": "error",
},
},
];const obj = { x: "foo" },
key = "x",
value = eval("obj." + key);
(0, eval)("const a = 0");
const foo = eval;
foo("const a = 0");
// This `this` is the global object.
this.eval("const a = 0");/*global window*/
window.eval("const a = 0");/*global global*/
global.eval("const a = 0");const obj = { x: "foo" },
key = "x",
value = obj[key];
class A {
foo() {
// This is a user-defined method.
this.eval("const a = 0");
}
eval() {
}
static {
// This is a user-defined static method.
this.eval("const a = 0");
}
static eval() {
}
}Examples from the ESLint documentation.
no-eval
eslint
export default [
{
rules: {
"no-eval": "error",
},
},
];no-eval
eslint plugin · correctness
{
"rules": {
"no-eval": "error"
}
}security/noGlobalEval
security · since 1.5.0
{
"linter": {
"rules": {
"security": {
"noGlobalEval": "error"
}
}
}
}Disallow renaming import, export, and destructured assignments to the same name
Disallow the use of arguments.caller or arguments.callee
Disallow the use of the __iterator__ property
Disallow unused expressions
Disallow comparisons where both sides are exactly the same