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

Latest commit

 

History

History
34 lines (23 loc) · 927 Bytes

no-zero-quantifier.md

File metadata and controls

34 lines (23 loc) · 927 Bytes

no-zero-quantifier 🔧

Disallow quantifiers with a maximum of 0.

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

Source file
Test file

Description

Quantifiers with a maximum of zero mean that the quantified element will never be matched. They essentially produce dead code.

Note: The rule will not remove zero-quantified elements if they are or contain a capturing group. In this case, the quantifier and element will simple be reported.

Examples

Examples of valid code for this rule:

/a{0,1}/;

Examples of invalid code for this rule:

/a{0}/;
/a{0,0}/;