close

no-div-regex

Added in v0.8.1

Configuration

rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-div-regex': 'error',
    },
  },
]);

Rule Details

Disallows equal signs explicitly at the beginning of regular expression literals, since /= at the start of a regular expression can be visually confused with a division-assignment operator.

Examples of incorrect code for this rule:

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

Examples of correct code for this rule:

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

Original Documentation