no-misleading-character-class
What it does
Section titled “What it does”Reports a character class in the constant string given to new Regex(...) and the static methods of Regex, in which a combining mark follows another character.
Why it matters
Section titled “Why it matters”A combining mark is a separate code point that attaches to the character before it. In a character class each code point is its own member, so the class matches the base letter or the mark alone and never the combined character the author sees.
To fix, write the combined character as a group outside the class, or as a single precomposed character.
Example
Section titled “Example”... void f(String s) {... Pattern.matches("[a" + "\u0301]", s); Pattern.compile("a b"); Other.compile("a b"); Pattern.compile(s);...Configuration
Section titled “Configuration”csharp: lint: rules: no-misleading-character-class: warn # off (default), warn, errorjava: lint: rules: no-misleading-character-class: warn # off (default), warn, errorjs: lint: rules: no-misleading-character-class: warn # off (default), warn, errorphp: lint: rules: no-misleading-character-class: warn # off (default), warn, errorpython: lint: rules: no-misleading-character-class: warn # off (default), warn, errorEnabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.
Suppress one line with sudsy-disable-next-line no-misleading-character-class in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| eslint | no-misleading-character-class |
partial | the surrogate pair, emoji modifier, flag and joined-sequence checks are not made |