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 pattern = /\p{gc=L}/u;
const pattern2 = /\p{General_Category=Letter}/u;
const pattern = /\p{sc=Grek}/u;
const pattern2 = /\p{Script=Latn}/u;
const pattern = /\p{scx=Cyrl}/u;
const pattern = new RegExp("\\p{gc=L}", "u");
const pattern2 = new 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 ❤️‍🔥 in Boston by Josh Goldberg and contributors.