Skip to content
This repository has been archived by the owner on Oct 11, 2021. It is now read-only.

Latest commit

 

History

History
33 lines (23 loc) · 883 Bytes

no-empty-alternative.md

File metadata and controls

33 lines (23 loc) · 883 Bytes

no-empty-alternative

Disallow alternatives without elements.

configuration in plugin:clean-regex/recommended: "warn"

Source file
Test file

Description

While (re-)writing long regular expressions, it can happen that one forgets to remove the | character of a former alternative. This rule tries to point out these potential mistakes by reporting all empty alternatives.

Examples

Examples of valid code for this rule:

/(?:)/
/a+|b*/

Examples of invalid code for this rule:

/a+|b+|/
/\|\||\|||\|\|\|/
/a(?:a|bc|def|h||ij|k)/