Перейти до вмісту

noImpliedEval

Цей контент ще не доступний вашою мовою.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noImpliedEval": "error"
}
}
}
}

Disallow the use of eval()-like methods.

The eval() function evaluates the passed string as a JavaScript code. Calling setTimeout, setInterval, or setImmediate with a string argument is an implied eval() because the string is evaluated as code.

Using implied eval() is considered a bad practice because:

  1. It exposes your code to security risks and performance issues
  2. The code is evaluated in the global scope rather than the local scope
  3. It prevents the JavaScript engine from optimizing the code
setTimeout("alert('Hello world!');", 100);
code-block.js:1:1 lint/nursery/noImpliedEval ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Implied eval() is not allowed.

> 1 │ setTimeout(“alert(‘Hello world!’);”, 100);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Passing strings to functions like setTimeout, setInterval, or setImmediate is a form of implied eval() and can lead to security and performance issues.

Use a function instead of a string.

This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/8735 for more information or to report possible bugs.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

setInterval("alert('Hello world!');", 100);
code-block.js:1:1 lint/nursery/noImpliedEval ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Implied eval() is not allowed.

> 1 │ setInterval(“alert(‘Hello world!’);”, 100);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Passing strings to functions like setTimeout, setInterval, or setImmediate is a form of implied eval() and can lead to security and performance issues.

Use a function instead of a string.

This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/8735 for more information or to report possible bugs.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

setImmediate("alert('Hello world!');");
code-block.js:1:1 lint/nursery/noImpliedEval ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Implied eval() is not allowed.

> 1 │ setImmediate(“alert(‘Hello world!’);”);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Passing strings to functions like setTimeout, setInterval, or setImmediate is a form of implied eval() and can lead to security and performance issues.

Use a function instead of a string.

This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/8735 for more information or to report possible bugs.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

window.setTimeout("count = 5", 10);
code-block.js:1:1 lint/nursery/noImpliedEval ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Implied eval() is not allowed.

> 1 │ window.setTimeout(“count = 5”, 10);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Passing strings to functions like setTimeout, setInterval, or setImmediate is a form of implied eval() and can lead to security and performance issues.

Use a function instead of a string.

This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/8735 for more information or to report possible bugs.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

window.setInterval("foo = bar", 10);
code-block.js:1:1 lint/nursery/noImpliedEval ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Implied eval() is not allowed.

> 1 │ window.setInterval(“foo = bar”, 10);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Passing strings to functions like setTimeout, setInterval, or setImmediate is a form of implied eval() and can lead to security and performance issues.

Use a function instead of a string.

This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/8735 for more information or to report possible bugs.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

setTimeout(function() {
alert('Hello world!');
}, 100);
setInterval(() => {
alert('Hello world!');
}, 100);
// setTimeout is shadowed by a local variable
function foo(setTimeout) {
setTimeout("alert('Hello world!');", 100);
}