百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

eslint-plugin-regexp

> 后端框架
开源

用于查找正则表达式错误和风格指南违规的 ESLint 插件。

769 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于查找正则表达式错误和风格指南违规的 ESLint 插件。

Introduction

eslint-plugin-regexp is ESLint plugin for finding RegExp mistakes and RegExp style guide violations.

:name_badge: Features

This ESLint plugin provides linting rules relate to better ways to help you avoid problems when using RegExp.

  • Find the wrong usage of regular expressions, and their hints.
  • Enforces a consistent style of regular expressions.
  • Find hints for writing optimized regular expressions.
  • 80 plugin rules for regular expression syntax and features.

You can check on the Online DEMO.

:book: Documentation

See documents.

:cd: Installation

bash
npm install --save-dev eslint eslint-plugin-regexp

Requirements

  • ESLint v9.38.0 and above
  • Node.js v20.19.0, v22.13.0, v24 and above

:book: Usage

Add regexp to the plugins section of your eslint.config.js configuration file (you can omit the eslint-plugin- prefix) and either use one of the two configurations available (recommended or all) or configure the rules you want:

The recommended configuration

The plugin.configs.recommended config enables a subset of the rules that should be most useful to most users. See lib/configs/rules/recommended.ts for more details.

javascript
// eslint.config.js
import regexpPlugin from "eslint-plugin-regexp"

export default [
    regexpPlugin.configs.recommended,
];

Advanced Configuration

Override/add specific rules configurations. See also: http://eslint.org/docs/user-guide/configuring.

javascript
// eslint.config.js
import regexpPlugin from "eslint-plugin-regexp"

export default [
    {
        plugins: { regexp: regexpPlugin },
        rules: {
            // Override/add rules settings here, such as:
            "regexp/rule-name": "error"
        }
    }
];

Using the all configuration

The plugin.configs.all config enables all rules. It's meant for testing, not for production use because it changes with every minor and major version of the plugin. Use it at your own risk. See lib/configs/rules/all.ts for more details.

:white_check_mark: Rules

Configurations enabled in.
⚠️ Configurations set to warn in.
Set in the flat/recommended configuration.
Set in the recommended configuration.
Automatically fixable by the --fix CLI option.
Manually fixable by editor suggestions.

Possible Errors

Name Description ⚠️
no-contradiction-with-assertion disallow elements that contradict assertions
no-control-character disallow control characters
no-dupe-disjunctions disallow duplicate disjunctions
no-empty-alternative disallow alternatives without elements
no-empty-capturing-group disallow capturing group that captures empty.
no-empty-character-class disallow character classes that match no characters
no-empty-group disallow empty group
no-empty-lookarounds-assertion disallow empty lookahead assertion or empty lookbehind assertion
no-escape-backspace disallow escape backspace ([\b])
no-invalid-regexp disallow invalid regular expression strings in RegExp constructors
no-lazy-ends disallow lazy quantifiers at the end of an expression
no-misleading-capturing-group disallow capturing groups that do not behave as one would expect
no-misleading-unicode-character disallow multi-code-point characters in character classes and quantifiers
no-missing-g-flag disallow missing g flag in patterns used in String#matchAll and String#replaceAll
no-optional-assertion disallow optional assertions
no-potentially-useless-backreference disallow backreferences that reference a group that might not be matched
no-super-linear-backtracking disallow exponential and polynomial backtracking
no-super-linear-move disallow quantifiers that cause quadratic moves
no-useless-assertions disallow assertions that are known to always accept (or reject)
no-useless-backreference disallow useless backreferences in regular expressions
no-useless-dollar-replacements disallow useless $ replacements in replacement string
strict disallow not strictly valid regular expressions

Best Practices

Name Description ⚠️
confusing-quantifier disallow confusing quantifiers
control-character-escape enforce consistent escaping of control characters
negation enforce use of escapes on negation
no-dupe-characters-character-class disallow duplicate characters in the RegExp character class
no-empty-string-literal disallow empty string literals in character classes
no-extra-lookaround-assertions disallow unnecessary nested lookaround assertions
no-invisible-character disallow invisible raw character
no-legacy-features disallow legacy RegExp features
no-non-standard-flag disallow non-standard flags
[no-obscure-ra

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScripteslint-plugineslintpluginregexregexp

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架