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

task.mdevals/scenario-10/

Range-Limited Regex Linting

Build an ESLint helper that enforces regex character class ranges while respecting configurable allowed character ranges.

Capabilities

Build range-aware lint configs

  • createRangeLintConfig() returns both legacy and flat ESLint config objects that attach the regex linting plugin, set settings.regexp.allowedCharacterRanges to ["alphanumeric"] when not provided, and enable character-class range optimization plus disallowed-range detection as errors. @test

Optimize allowed contiguous sets

  • lintPatterns("const rx = /[ABCDE]/;") with default options reports a single range-optimization issue, applies the autofix to [A-E], leaves zero disallowed-range issues, and returns the rewritten source in output. @test

Block disallowed ranges cleanly

  • lintPatterns("const rx = /[😀😁😂😃]/u;", { allowedRanges: "alphanumeric" }) leaves the input unchanged, reports at least one disallowed-range issue for characters outside the allowed ranges, and reports zero range-optimization fixes because the forbidden characters prevent range creation. @test

Implementation

@generates

API

export type AllowedRanges = string | readonly string[];

export interface RangeConfigShape {
  plugins: unknown;
  rules: Record<string, unknown>;
  settings: { regexp: { allowedCharacterRanges: AllowedRanges } };
}

export interface RangeConfig {
  legacy: RangeConfigShape;
  flat: RangeConfigShape;
}

export interface LintSummary {
  errorCount: number;
  warningCount: number;
  rangeIssues: number;
  disallowedRangeIssues: number;
  output: string;
}

export function createRangeLintConfig(options?: { allowedRanges?: AllowedRanges }): RangeConfig;

export function lintPatterns(
  code: string,
  options?: { allowedRanges?: AllowedRanges; autofix?: boolean }
): Promise<LintSummary>;

Dependencies { .dependencies }

eslint-plugin-regexp { .dependency }

Regex-focused ESLint plugin that optimizes character sets and respects allowedCharacterRanges.

eslint { .dependency }

ESLint engine used to apply the plugin and autofixes.

Install with Tessl CLI

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

tile.json