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

Latest commit

 

History

History
35 lines (24 loc) · 951 Bytes

prefer-predefined-quantifiers.md

File metadata and controls

35 lines (24 loc) · 951 Bytes

prefer-predefined-quantifiers 🔧

Prefer predefined quantifiers (+*?) instead of their more verbose form.

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

Source file
Test file

Description

Prefer predefined quantifiers over general quantifiers. E.g. ? instead of {0,1}, * instead of {0,}, and + instead of {1,}.

Predefined use less characters than their verbose counterparts and are therefore easier to read.

Examples

Examples of valid code for this rule:

/a+b*c?/
/a{2,}b{2,6}c{2}/

Examples of invalid code for this rule:

/a{1,}/
/a{0,}/
/a{0,1}/