コンテンツにスキップ

noDivRegex

このコンテンツはまだ日本語訳がありません。

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

Disallow equal signs explicitly at the beginning of regular expressions.

This rule forbids equal signs (=) after the slash (/) at the beginning of a regular expression literal, because the characters /= can be confused with a division assignment operator.

function bar() {
return /=foo/;
}
code-block.js:2:10 lint/nursery/noDivRegex  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Avoid using an equal sign directly after the slash at the beginning of a regular expression literal.

1 │ function bar() {
> 2 │ return /=foo/;
^^^^^^
3 │ }
4 │

The characters /= can be confused with a division assignment operator. Replace the equal sign (=) with [=] to prevent confusion.

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.

Safe fix: Replace with [=].

2 │ ··return·/[=]foo/;
+ +
function bar() {
return /[=]foo/;
}