Skip to content

Files

Latest commit

 

History

History
27 lines (19 loc) · 484 Bytes

no-div-regex.md

File metadata and controls

27 lines (19 loc) · 484 Bytes

Pattern: Regular expression starting with =

Issue: -

Description

Using = at the beginning of a regular expression can be mistaken for a division assignment operator (e.g., /=). This confusion can lead to bugs and reduced code readability.

Examples

Example of incorrect code:

function bar() {
  return /=foo/;
}

const regex = /=test/;

Example of correct code:

function bar() {
  return /[=]foo/;
}

const regex = /\=test/;