CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-eslint-plugin-regexp

ESLint plugin for finding RegExp mistakes and RegExp style guide violations.

82

0.96x
Overview
Eval results
Files

index.mddocs/

ESLint Plugin RegExp

ESLint Plugin RegExp provides a comprehensive suite of 82+ specialized linting rules for detecting regular expression mistakes and enforcing RegExp style guide violations. It helps developers avoid common pitfalls when working with regular expressions, including finding wrong usage patterns, enforcing consistent regular expression styles, and providing optimization hints.

Package Information

  • Package Name: eslint-plugin-regexp
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install eslint-plugin-regexp
  • Node.js: ^18 || >=20
  • ESLint: >=8.44.0

Core Imports

// ES modules
import { configs, rules, meta } from "eslint-plugin-regexp";
// CommonJS
const { configs, rules, meta } = require("eslint-plugin-regexp");

Basic Usage

// ESLint configuration (.eslintrc.js)
module.exports = {
  plugins: ["regexp"],
  extends: ["plugin:regexp/recommended"],
  rules: {
    "regexp/no-unused-capturing-group": "error",
    "regexp/confusing-quantifier": "warn"
  }
};

// ESLint flat config (eslint.config.js)
import regexp from "eslint-plugin-regexp";

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

Architecture

ESLint Plugin RegExp is built around several key components:

  • Rules Engine: 82+ specialized ESLint rules organized by category (possible errors, best practices, stylistic choices)
  • Configuration System: Pre-built configurations for different use cases (recommended, all rules)
  • RegExp Analysis: Deep analysis of regular expression patterns using AST parsing and static analysis
  • Type System: Full TypeScript integration with comprehensive type definitions for all rule interfaces
  • Flat Config Support: Modern ESLint flat configuration format alongside legacy configuration

Capabilities

Plugin Configuration

Core plugin setup and pre-configured rule sets for different use cases. Essential for integrating the plugin into your ESLint workflow.

interface PluginConfigs {
  recommended: ESLintConfig;
  all: ESLintConfig;
  "flat/all": FlatESLintConfig;
  "flat/recommended": FlatESLintConfig;
}

const configs: PluginConfigs;

Configuration

Error Prevention Rules

Critical rules that catch potential errors, bugs, and issues that could cause runtime failures or unexpected behavior in regular expressions.

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

interface RuleMeta {
  type: "problem" | "suggestion" | "layout";
  docs: {
    description: string;
    category: string;
    recommended: boolean;
    url: string;
  };
  fixable?: "code" | "whitespace";
  schema: JSONSchema4;
}

Error Prevention Rules

Best Practice Rules

Rules that enforce coding standards, performance optimizations, and maintainability improvements for regular expressions.

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

interface ReportDescriptor {
  node: ESTree.Node;
  message: string;
  fix?: (fixer: RuleFixer) => Fix | null;
}

Best Practice Rules

Stylistic Rules

Rules that enforce consistent formatting, naming conventions, and stylistic choices for regular expressions to improve code readability.

interface RuleFixer {
  insertTextAfter(node: ESTree.Node, text: string): Fix;
  insertTextBefore(node: ESTree.Node, text: string): Fix;
  remove(node: ESTree.Node): Fix;
  replaceText(node: ESTree.Node, text: string): Fix;
}

interface Fix {
  range: [number, number];
  text: string;
}

Stylistic Rules

Plugin Metadata

Package information and metadata utilities for integrating with build tools and development workflows.

interface Meta {
  name: string;
  version: string;
}

const meta: Meta;

Plugin Metadata

Install with Tessl CLI

npx tessl i tessl/npm-eslint-plugin-regexp

docs

best-practice-rules.md

configuration.md

error-rules.md

index.md

metadata.md

stylistic-rules.md

tile.json