or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

best-practice-rules.mdconfiguration.mderror-rules.mdindex.mdmetadata.mdstylistic-rules.md
tile.json

error-rules.mddocs/

Error Prevention Rules

Rules that catch potential errors, bugs, and issues that could cause runtime failures or unexpected behavior in regular expressions. These 25 rules focus on preventing problematic patterns that might not work as intended.

Rule Interface

All error prevention rules implement the standard ESLint rule interface:

interface RuleModule {
  meta: RuleMeta;
  create: (context: RuleContext) => RuleListener;
}

interface RuleMeta {
  type: "problem";
  docs: {
    description: string;
    category: "Possible Errors";
    recommended: boolean;
    url: string;
    ruleName: string;
  };
  fixable?: "code" | "whitespace";
  schema: JSONSchema4;
  messages: Record<string, string>;
}

interface RuleContext {
  getSourceCode(): SourceCode;
  report(descriptor: ReportDescriptor): void;
  options: any[];
  settings: { [name: string]: any };
}

Character and Syntax Errors

confusing-quantifier

Disallows confusing quantifiers that may not behave as expected.

// Rule: regexp/confusing-quantifier
// Type: problem
// Fixable: no
// Recommended: true

control-character-escape

Enforces consistent escaping of control characters to prevent unintended behavior.

// Rule: regexp/control-character-escape  
// Type: problem
// Fixable: code
// Recommended: true

grapheme-string-literal

Enforces consistent use of grapheme string literals to handle Unicode properly.

// Rule: regexp/grapheme-string-literal
// Type: problem
// Fixable: code
// Recommended: false

hexadecimal-escape

Enforces consistent hexadecimal escape sequences to prevent encoding issues.

// Rule: regexp/hexadecimal-escape
// Type: problem
// Fixable: code
// Recommended: false

letter-case

Enforces consistent letter case in character classes to prevent case sensitivity bugs.

// Rule: regexp/letter-case
// Type: problem
// Fixable: code
// Recommended: false

Pattern Structure Errors

match-any

Enforces consistent match-any syntax to prevent ambiguous patterns.

// Rule: regexp/match-any
// Type: problem
// Fixable: code
// Recommended: true

negation

Enforces proper use of escapes on negation to prevent logical errors.

// Rule: regexp/negation
// Type: problem
// Fixable: code
// Recommended: true

no-contradiction-with-assertion

Disallows elements that contradict assertions, which always fail.

// Rule: regexp/no-contradiction-with-assertion
// Type: problem
// Fixable: no
// Recommended: true

no-control-character

Disallows control characters that may cause unexpected behavior.

// Rule: regexp/no-control-character
// Type: problem
// Fixable: no
// Recommended: false

no-dupe-characters-character-class

Disallows duplicate characters in character classes that are redundant.

// Rule: regexp/no-dupe-characters-character-class
// Type: problem
// Fixable: code
// Recommended: true

no-dupe-disjunctions

Disallows duplicate disjunctions that make patterns redundant.

// Rule: regexp/no-dupe-disjunctions
// Type: problem
// Fixable: no
// Recommended: true

Empty Pattern Errors

no-empty-alternative

Disallows alternatives without elements that may not work as expected.

// Rule: regexp/no-empty-alternative
// Type: problem
// Fixable: code
// Recommended: true

no-empty-capturing-group

Disallows capturing groups that capture empty strings, often unintentional.

// Rule: regexp/no-empty-capturing-group
// Type: problem
// Fixable: no
// Recommended: true

no-empty-character-class

Disallows character classes that match no characters, which always fail.

// Rule: regexp/no-empty-character-class
// Type: problem
// Fixable: no
// Recommended: true

no-empty-group

Disallows empty groups that serve no purpose and may indicate errors.

// Rule: regexp/no-empty-group
// Type: problem
// Fixable: code
// Recommended: true

no-empty-lookarounds-assertion

Disallows empty lookaround assertions that always succeed or fail.

// Rule: regexp/no-empty-lookarounds-assertion
// Type: problem
// Fixable: no
// Recommended: true

no-empty-string-literal

Disallows empty string literals in character classes.

// Rule: regexp/no-empty-string-literal
// Type: problem
// Fixable: code
// Recommended: true

Escape and Character Errors

no-escape-backspace

Disallows escape backspace ([\b]) which is often confused with word boundary \b.

// Rule: regexp/no-escape-backspace
// Type: problem
// Fixable: no
// Recommended: true

no-extra-lookaround-assertions

Disallows unnecessary nested lookaround assertions that are redundant.

// Rule: regexp/no-extra-lookaround-assertions
// Type: problem
// Fixable: code
// Recommended: true

no-invalid-regexp

Disallows invalid regular expression strings in RegExp constructors.

// Rule: regexp/no-invalid-regexp
// Type: problem
// Fixable: no
// Recommended: true

no-invisible-character

Disallows invisible raw characters that may cause confusion.

// Rule: regexp/no-invisible-character
// Type: problem
// Fixable: code
// Recommended: false

Quantifier and Performance Errors

no-lazy-ends

Disallows lazy quantifiers at the end of expressions where they have no effect.

// Rule: regexp/no-lazy-ends
// Type: problem
// Fixable: code
// Recommended: true

no-legacy-features

Disallows legacy RegExp features that may not be supported across environments.

// Rule: regexp/no-legacy-features
// Type: problem
// Fixable: no
// Recommended: false

no-misleading-capturing-group

Disallows capturing groups that do not behave as expected.

// Rule: regexp/no-misleading-capturing-group
// Type: problem
// Fixable: no
// Recommended: true

no-misleading-unicode-character

Disallows multi-code-point characters in character classes that may not work as expected.

// Rule: regexp/no-misleading-unicode-character
// Type: problem
// Fixable: no
// Recommended: true

Usage Examples

Common Error Patterns

// ❌ Confusing quantifier
/a{1,1}/  // Should be just /a/

// ❌ Empty character class  
/[]/  // Will never match anything

// ❌ Duplicate characters
/[abbc]/  // The 'b' is duplicated

// ❌ Empty capturing group
/()/  // Captures empty string

// ❌ Contradictory assertion
/\b\B/  // Can never match (word boundary AND non-word boundary)

Corrected Patterns

// ✅ Clear quantifier
/a/

// ✅ Valid character class
/[abc]/

// ✅ No duplicate characters  
/[abc]/

// ✅ Meaningful capturing group
/(abc)/

// ✅ Non-contradictory assertion
/\b/  // or /\B/ but not both