noDivRegex
Summary
Section titled “Summary”- Rule available since:
v2.3.12 - Diagnostic Category:
lint/nursery/noDivRegex - This rule has a safe fix.
- The default severity of this rule is information.
- Sources:
- Same as
no-div-regex
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noDivRegex": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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/;}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.