From 06e5140131e479435860b9fa1a07b9605930067f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 20 Feb 2026 15:32:57 -0500 Subject: [PATCH] tools: add eslint-plugin-regexp --- eslint.config.mjs | 38 +++++++++++++++++++ tools/eslint/package-lock.json | 69 ++++++++++++++++++++++++++++++++-- tools/eslint/package.json | 1 + 3 files changed, 104 insertions(+), 4 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index cd66c1392b68c7..fb6f9623587583 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,6 +20,7 @@ const { default: js } = await importEslintTool('@eslint/js'); const { default: babelEslintParser } = await importEslintTool('@babel/eslint-parser'); const babelPluginSyntaxImportSource = resolveEslintTool('@babel/plugin-syntax-import-source'); const { default: jsdoc } = await importEslintTool('eslint-plugin-jsdoc'); +const { default: regexpPlugin } = await importEslintTool('eslint-plugin-regexp'); const { default: markdown } = await importEslintTool('@eslint/markdown'); const { default: stylisticJs } = await importEslintTool('@stylistic/eslint-plugin'); @@ -84,6 +85,7 @@ export default [ // #region general config js.configs.recommended, jsdoc.configs['flat/recommended'], + regexpPlugin.configs.recommended, { files: ['**/*.js'], languageOptions: { @@ -275,6 +277,42 @@ export default [ 'jsdoc/reject-any-type': 'off', 'jsdoc/reject-function-type': 'off', + // RegExp recommended rules that we disable. + // Todo: Investigate which rules should be enabled. + 'prefer-regex-literals': 'off', + 'regexp/control-character-escape': 'off', + 'regexp/match-any': 'off', + 'regexp/negation': 'off', + 'regexp/no-contradiction-with-assertion': 'off', + 'regexp/no-dupe-characters-character-class': 'off', + 'regexp/no-dupe-disjunctions': 'off', + 'regexp/no-empty-alternative': 'off', + 'regexp/no-legacy-features': 'off', + 'regexp/no-misleading-capturing-group': 'off', + 'regexp/no-obscure-range': 'off', + 'regexp/no-potentially-useless-backreference': 'off', + 'regexp/no-super-linear-backtracking': 'off', + 'regexp/no-trivially-nested-quantifier': 'off', + 'regexp/no-unused-capturing-group': 'off', + 'regexp/no-useless-assertions': 'off', + 'regexp/no-useless-character-class': 'off', + 'regexp/no-useless-escape': 'off', + 'regexp/no-useless-flag': 'off', + 'regexp/no-useless-lazy': 'off', + 'regexp/no-useless-non-capturing-group': 'off', + 'regexp/no-useless-quantifier': 'off', + 'regexp/no-useless-range': 'off', + 'regexp/optimal-lookaround-quantifier': 'off', + 'regexp/optimal-quantifier-concatenation': 'off', + 'regexp/prefer-character-class': 'off', + 'regexp/prefer-d': 'off', + 'regexp/prefer-question-quantifier': 'off', + 'regexp/prefer-star-quantifier': 'off', + 'regexp/prefer-w': 'off', + 'regexp/sort-flags': 'off', + 'regexp/strict': 'off', + 'regexp/use-ignore-case': 'off', + // Stylistic rules. '@stylistic/js/arrow-parens': 'error', '@stylistic/js/arrow-spacing': 'error', diff --git a/tools/eslint/package-lock.json b/tools/eslint/package-lock.json index 515dfae3335769..411800e9284d5f 100644 --- a/tools/eslint/package-lock.json +++ b/tools/eslint/package-lock.json @@ -17,6 +17,7 @@ "eslint": "^10.0.1", "eslint-formatter-tap": "^9.0.1", "eslint-plugin-jsdoc": "^62.7.0", + "eslint-plugin-regexp": "^3.0.0", "globals": "^17.3.0" } }, @@ -933,9 +934,9 @@ } }, "node_modules/eslint": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.0.1.tgz", - "integrity": "sha512-20MV9SUdeN6Jd84xESsKhRly+/vxI+hwvpBMA93s+9dAcjdCuCojn4IqUGS3lvVaqjVYGYHSRMCpeFtF2rQYxQ==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.0.2.tgz", + "integrity": "sha512-uYixubwmqJZH+KLVYIVKY1JQt7tysXhtj21WSvjcSmU5SVNzMus1bgLe+pAt816yQ8opKfheVVoPLqvVMGejYw==", "license": "MIT", "peer": true, "dependencies": { @@ -949,7 +950,7 @@ "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", - "ajv": "^6.12.4", + "ajv": "^6.14.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", @@ -1045,6 +1046,27 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-plugin-regexp": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-3.0.0.tgz", + "integrity": "sha512-iW7hgAV8NOG6E2dz+VeKpq67YLQ9jaajOKYpoOSic2/q8y9BMdXBKkSR9gcMtbqEhNQzdW41E3wWzvhp8ExYwQ==", + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.11.0", + "comment-parser": "^1.4.0", + "jsdoc-type-pratt-parser": "^7.0.0", + "refa": "^0.12.1", + "regexp-ast-analysis": "^0.7.1", + "scslre": "^0.3.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "peerDependencies": { + "eslint": ">=9.38.0" + } + }, "node_modules/eslint-scope": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.1.tgz", @@ -2494,6 +2516,31 @@ "node": ">=6" } }, + "node_modules/refa": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/refa/-/refa-0.12.1.tgz", + "integrity": "sha512-J8rn6v4DBb2nnFqkqwy6/NnTYMcgLA+sLr0iIO41qpv0n+ngb7ksag2tMRl0inb1bbO/esUwzW1vbJi7K0sI0g==", + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.8.0" + }, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/regexp-ast-analysis": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/regexp-ast-analysis/-/regexp-ast-analysis-0.7.1.tgz", + "integrity": "sha512-sZuz1dYW/ZsfG17WSAG7eS85r5a0dDsvg+7BiiYR5o6lKCAtUrEwdmRmaGF6rwVj3LcmAeYkOWKEPlbPzN3Y3A==", + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.8.0", + "refa": "^0.12.1" + }, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/reserved-identifiers": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/reserved-identifiers/-/reserved-identifiers-1.2.0.tgz", @@ -2506,6 +2553,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/scslre": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/scslre/-/scslre-0.3.0.tgz", + "integrity": "sha512-3A6sD0WYP7+QrjbfNA2FN3FsOaGGFoekCVgTyypy53gPxhbkCIjtO6YWgdrfM+n/8sI8JeXZOIxsHjMTNxQ4nQ==", + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.8.0", + "refa": "^0.12.0", + "regexp-ast-analysis": "^0.7.0" + }, + "engines": { + "node": "^14.0.0 || >=16.0.0" + } + }, "node_modules/semver": { "version": "7.7.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", diff --git a/tools/eslint/package.json b/tools/eslint/package.json index 72de28a5bb8080..434e6f6b7cf73f 100644 --- a/tools/eslint/package.json +++ b/tools/eslint/package.json @@ -12,6 +12,7 @@ "eslint": "^10.0.1", "eslint-formatter-tap": "^9.0.1", "eslint-plugin-jsdoc": "^62.7.0", + "eslint-plugin-regexp": "^3.0.0", "globals": "^17.3.0" } }