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

Latest commit

 

History

History
34 lines (24 loc) · 897 Bytes

sort-flags.md

File metadata and controls

34 lines (24 loc) · 897 Bytes

sort-flags 🔧

Requires the regex flags to be sorted.

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

Source file
Test file

Description

The flags of JavaScript regular expressions should be sorted alphabetically because the flags of the .flags property of RegExp objects are always sorted. Not sorting flags in regex literals misleads readers into thinking that the order may have some purpose which it doesn't.

Examples

Examples of valid code for this rule:

/abc/
/abc/iu
/abc/gimsuy

Examples of invalid code for this rule:

/abc/mi
/abc/us