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

configuration.mddocs/

Configuration

ESLint Plugin RegExp provides pre-configured rule sets for different use cases, supporting both legacy ESLint configuration and modern flat configuration formats.

Available Configurations

Recommended Configuration

The recommended configuration enables a curated set of rules that catch common errors and enforce best practices without being overly strict.

interface RecommendedConfig {
  plugins: string[];
  rules: Record<string, SeverityString>;
}

interface FlatRecommendedConfig {
  plugins: { regexp: typeof plugin };
  rules: Record<string, SeverityString>;
}

Legacy ESLint configuration:

module.exports = {
  extends: ["plugin:regexp/recommended"],
  plugins: ["regexp"]
};

Flat ESLint configuration:

import regexp from "eslint-plugin-regexp";

export default [
  {
    ...regexp.configs["flat/recommended"]
  }
];

All Rules Configuration

The all configuration enables every available rule in the plugin. Use with caution as it may be overly strict for some codebases.

interface AllConfig {
  plugins: string[];
  rules: Record<string, SeverityString>;
}

interface FlatAllConfig {
  plugins: { regexp: typeof plugin };
  rules: Record<string, SeverityString>;
}

Legacy ESLint configuration:

module.exports = {
  extends: ["plugin:regexp/all"],
  plugins: ["regexp"]
};

Flat ESLint configuration:

import regexp from "eslint-plugin-regexp";

export default [
  {
    ...regexp.configs["flat/all"]
  }
];

Configuration Structure

Severity Levels

type SeverityString = "error" | "warn" | "off";

Rules can be configured with different severity levels:

  • "error": Rule violations will cause ESLint to exit with code 1
  • "warn": Rule violations will be reported but won't cause ESLint to exit with non-zero code
  • "off": Rule is disabled

Rule Configuration

Individual rules can be configured with options:

interface RuleConfig {
  [ruleName: string]: SeverityString | [SeverityString, ...any[]];
}

Examples:

{
  "rules": {
    "regexp/no-unused-capturing-group": "error",
    "regexp/confusing-quantifier": "warn",
    "regexp/letter-case": ["error", { "caseInsensitive": "ignore" }]
  }
}

Core ESLint Rule Overrides

The plugin configurations also modify some core ESLint rules to avoid conflicts:

Disabled Core Rules

The following core ESLint rules are disabled because the plugin provides better alternatives:

interface CoreRuleOverrides {
  "no-invalid-regexp": "off";
  "no-useless-backreference": "off";
  "no-empty-character-class": "off";
}

Enhanced Core Rules

These core ESLint rules are kept enabled and work alongside plugin rules:

interface EnhancedCoreRules {
  "no-control-regex": "error";
  "no-misleading-character-class": "error";
  "no-regex-spaces": "error";
  "prefer-regex-literals": "error";
}

Usage Examples

Custom Configuration

You can create a custom configuration by extending the recommended config and overriding specific rules:

// Legacy format
module.exports = {
  extends: ["plugin:regexp/recommended"],
  plugins: ["regexp"],
  rules: {
    // Override recommended settings
    "regexp/confusing-quantifier": "error",
    "regexp/letter-case": "off",
    
    // Add additional rules not in recommended
    "regexp/prefer-lookaround": "warn"
  }
};

// Flat format
import regexp from "eslint-plugin-regexp";

export default [
  {
    ...regexp.configs["flat/recommended"],
    rules: {
      ...regexp.configs["flat/recommended"].rules,
      "regexp/confusing-quantifier": "error",
      "regexp/letter-case": "off",
      "regexp/prefer-lookaround": "warn"
    }
  }
];

Plugin Settings

The plugin supports settings that can be configured to customize behavior:

interface RegexpSettings {
  allowedCharacterRanges?: string | readonly string[];
}

Configure plugin settings in your ESLint configuration:

// Legacy format
module.exports = {
  extends: ["plugin:regexp/recommended"],
  plugins: ["regexp"],
  settings: {
    regexp: {
      allowedCharacterRanges: ["a-z", "A-Z", "0-9"]
    }
  }
};

// Flat format
export default [
  {
    ...regexp.configs["flat/recommended"],
    settings: {
      regexp: {
        allowedCharacterRanges: ["a-z", "A-Z", "0-9"]
      }
    }
  }
];

File-specific Configuration

Configure rules differently for specific file patterns:

// Flat format only
export default [
  {
    ...regexp.configs["flat/recommended"]
  },
  {
    files: ["**/*.test.js"],
    rules: {
      // More lenient rules for test files
      "regexp/confusing-quantifier": "off",
      "regexp/prefer-escape": "off"
    }
  }
];