Skip to content

regexUnicodeProperties

Reports inconsistent Unicode property names in regular expressions.

✅ This rule is included in the ts stylistic presets.

Unicode properties may be expressed in several different ways. Including the fully-written out category prefix is a more verbose way that is not necessary.

This rule detects inconsistent Unicode property names in regular expressions and suggests more idiomatic forms for:

  1. Unnecessary gc= / General_Category= prefix: unicode general category properties can be used without the prefix.
  2. Long script names: short script aliases like Grek should use the full name Greek for readability.
const
const pattern: RegExp
pattern
= /\p{gc=L}/u;
const
const pattern2: RegExp
pattern2
= /\p{General_Category=Letter}/u;
const
const pattern: RegExp
pattern
= /\p{sc=Grek}/u;
const
const pattern2: RegExp
pattern2
= /\p{Script=Latn}/u;
const
const pattern: RegExp
pattern
= /\p{scx=Cyrl}/u;
const
const pattern: RegExp
pattern
= new
var RegExp: RegExpConstructor
new (pattern: RegExp | string, flags?: string) => RegExp (+2 overloads)
RegExp
("\\p{gc=L}", "u");
const
const pattern2: RegExp
pattern2
= new
var RegExp: RegExpConstructor
new (pattern: RegExp | string, flags?: string) => RegExp (+2 overloads)
RegExp
("\\p{sc=Grek}", "u");

This rule is not configurable.

If your project has a style guide that prefers explicit gc= prefixes or short script names for consistency with other documentation, you might want to disable this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.