Skip to content

Files

Latest commit

 

History

History
28 lines (21 loc) · 511 Bytes

no-dupe-disjunctions.md

File metadata and controls

28 lines (21 loc) · 511 Bytes

Pattern: Duplicate disjunction

Issue: -

Description

This rule disallows duplicate disjunctions. Duplicate disjunctions make the pattern less efficient and may indicate a mistake in the pattern.

Examples

/* eslint regexp/no-dupe-disjunctions: "error" */

/* ✓ GOOD */
var foo = /a|b/
var foo = /(a|b)/
var foo = /(?:a|b)/

/* ✗ BAD */
var foo = /a|a/
var foo = /(a|a)/
var foo = /(?:a|a)/
var foo = /abc|abc/
var foo = /[ab]|[ba]/
var foo = /a|abc/
var foo = /.|abc/
var foo = /.|a|b|c/