Skip to content

Files

Latest commit

 

History

History
20 lines (14 loc) · 571 Bytes

no-missing-g-flag.md

File metadata and controls

20 lines (14 loc) · 571 Bytes

Pattern: Missing global flag in String#matchAll/String#replaceAll

Issue: -

Description

When calling String#matchAll() and String#replaceAll() with a RegExp missing the global (g) flag, it will be a runtime error. This rule reports RegExps missing the global (g) flag that cause these errors.

Examples

/* eslint regexp/no-missing-g-flag: "error" */
/* ✓ GOOD */
var m = games.matchAll(/foo/g);
var newText = text.replaceAll(/Dog/ig, 'cat');

/* ✗ BAD */
var m = games.matchAll(/foo/);
var newText = text.replaceAll(/Dog/i, 'cat');