Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.12 KB

prefer-question-quantifier.md

File metadata and controls

47 lines (30 loc) · 1.12 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/prefer-question-quantifier
enforce using `?` quantifier
v0.1.0

regexp/prefer-question-quantifier

💼 This rule is enabled in the ✅ plugin:regexp/recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

enforce using ? quantifier

📖 Rule Details

This rule is aimed at using ? quantifier instead of {0,1} in regular expressions.

/* eslint regexp/prefer-question-quantifier: "error" */

/* ✓ GOOD */
var foo = /a?/;

/* ✗ BAD */
var foo = /a{0,1}/;

🔧 Options

Nothing.

🚀 Version

This rule was introduced in eslint-plugin-regexp v0.1.0

🔍 Implementation