diff --git a/index.js b/index.js index 809b91e5..e6c04b4c 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,9 @@ module.exports = { "./rules/core/variables.js", "./rules/core/styles.js", "./rules/core/es6.js", - "./rules/plugins/prettier.js", "./rules/plugins/eslint-comments.js", "./rules/plugins/import.js", + "./rules/plugins/regexp.js", + "./rules/plugins/prettier.js", // must be last ], }; diff --git a/package-lock.json b/package-lock.json index 56ec04f8..dd422971 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,8 @@ "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.25.1", - "eslint-plugin-react-hooks": "^4.2.0" + "eslint-plugin-react-hooks": "^4.2.0", + "eslint-plugin-regexp": "^1.1.0" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "*", @@ -3585,6 +3586,14 @@ "node": ">= 10" } }, + "node_modules/comment-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.2.4.tgz", + "integrity": "sha512-pm0b+qv+CkWNriSTMsfnjChF9kH0kxz55y44Wo5le9qLxMj5xDQAaEd9ZN1ovSuk9CsrncWaFwgpOMg7ClJwkw==", + "engines": { + "node": ">= 12.0.0" + } + }, "node_modules/compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -5084,6 +5093,51 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/eslint-plugin-regexp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-1.1.0.tgz", + "integrity": "sha512-mbDJigs9cAzDx7RDiEYXY0muX+BL8EJIG6wskYktGHFMZsuG8vJRBV4Co2wngeYJpB9S914M64T9reDr2bxTCg==", + "dependencies": { + "comment-parser": "^1.1.2", + "eslint-utils": "^3.0.0", + "jsdoctypeparser": "^9.0.0", + "refa": "^0.9.0", + "regexp-ast-analysis": "^0.2.4", + "regexpp": "^3.2.0", + "scslre": "^0.1.6" + }, + "engines": { + "node": "^12 || >=14" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/eslint-plugin-regexp/node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dependencies": { + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/eslint-plugin-regexp/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "engines": { + "node": ">=10" + } + }, "node_modules/eslint-rule-documentation": { "version": "1.0.23", "resolved": "https://registry.npmjs.org/eslint-rule-documentation/-/eslint-rule-documentation-1.0.23.tgz", @@ -9096,6 +9150,17 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsdoctypeparser": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz", + "integrity": "sha512-jrTA2jJIL6/DAEILBEh2/w9QxCuwmvNXIry39Ay/HVfhE3o2yVV0U44blYkqdHA/OKloJEqvJy0xU+GSdE2SIw==", + "bin": { + "jsdoctypeparser": "bin/jsdoctypeparser" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -11500,11 +11565,28 @@ "node": ">=8" } }, + "node_modules/refa": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/refa/-/refa-0.9.1.tgz", + "integrity": "sha512-egU8LgFq2VXlAfUi8Jcbr5X38wEOadMFf8tCbshgcpVCYlE7k84pJOSlnvXF+muDB4igkdVMq7Z/kiNPqDT9TA==", + "dependencies": { + "regexpp": "^3.2.0" + } + }, "node_modules/regenerator-runtime": { "version": "0.13.7", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" }, + "node_modules/regexp-ast-analysis": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/regexp-ast-analysis/-/regexp-ast-analysis-0.2.4.tgz", + "integrity": "sha512-8L7kOZQaKPxKKAwGuUZxTQtlO3WZ+tiXy4s6G6PKL6trbOXcZoumwC3AOHHFtI/xoSbNxt7jgLvCnP1UADLWqg==", + "dependencies": { + "refa": "^0.9.0", + "regexpp": "^3.2.0" + } + }, "node_modules/regexp.prototype.flags": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz", @@ -11521,11 +11603,14 @@ } }, "node_modules/regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "engines": { "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" } }, "node_modules/remark": { @@ -12663,6 +12748,16 @@ "node": ">=10" } }, + "node_modules/scslre": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/scslre/-/scslre-0.1.6.tgz", + "integrity": "sha512-JORxVRlQTfjvlOAaiQKebgFElyAm5/W8b50lgaZ0OkEnKnagJW2ufDh3xRfU75UD9z3FGIu1gL1IyR3Poa6Qmw==", + "dependencies": { + "refa": "^0.9.0", + "regexp-ast-analysis": "^0.2.3", + "regexpp": "^3.2.0" + } + }, "node_modules/semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -17456,6 +17551,11 @@ "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", "dev": true }, + "comment-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.2.4.tgz", + "integrity": "sha512-pm0b+qv+CkWNriSTMsfnjChF9kH0kxz55y44Wo5le9qLxMj5xDQAaEd9ZN1ovSuk9CsrncWaFwgpOMg7ClJwkw==" + }, "compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -18803,6 +18903,35 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz", "integrity": "sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ==" }, + "eslint-plugin-regexp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-1.1.0.tgz", + "integrity": "sha512-mbDJigs9cAzDx7RDiEYXY0muX+BL8EJIG6wskYktGHFMZsuG8vJRBV4Co2wngeYJpB9S914M64T9reDr2bxTCg==", + "requires": { + "comment-parser": "^1.1.2", + "eslint-utils": "^3.0.0", + "jsdoctypeparser": "^9.0.0", + "refa": "^0.9.0", + "regexp-ast-analysis": "^0.2.4", + "regexpp": "^3.2.0", + "scslre": "^0.1.6" + }, + "dependencies": { + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "requires": { + "eslint-visitor-keys": "^2.0.0" + } + }, + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==" + } + } + }, "eslint-rule-documentation": { "version": "1.0.23", "resolved": "https://registry.npmjs.org/eslint-rule-documentation/-/eslint-rule-documentation-1.0.23.tgz", @@ -21605,6 +21734,11 @@ "esprima": "^4.0.0" } }, + "jsdoctypeparser": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz", + "integrity": "sha512-jrTA2jJIL6/DAEILBEh2/w9QxCuwmvNXIry39Ay/HVfhE3o2yVV0U44blYkqdHA/OKloJEqvJy0xU+GSdE2SIw==" + }, "jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -23430,11 +23564,28 @@ "strip-indent": "^3.0.0" } }, + "refa": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/refa/-/refa-0.9.1.tgz", + "integrity": "sha512-egU8LgFq2VXlAfUi8Jcbr5X38wEOadMFf8tCbshgcpVCYlE7k84pJOSlnvXF+muDB4igkdVMq7Z/kiNPqDT9TA==", + "requires": { + "regexpp": "^3.2.0" + } + }, "regenerator-runtime": { "version": "0.13.7", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" }, + "regexp-ast-analysis": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/regexp-ast-analysis/-/regexp-ast-analysis-0.2.4.tgz", + "integrity": "sha512-8L7kOZQaKPxKKAwGuUZxTQtlO3WZ+tiXy4s6G6PKL6trbOXcZoumwC3AOHHFtI/xoSbNxt7jgLvCnP1UADLWqg==", + "requires": { + "refa": "^0.9.0", + "regexpp": "^3.2.0" + } + }, "regexp.prototype.flags": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz", @@ -23445,9 +23596,9 @@ } }, "regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==" + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==" }, "remark": { "version": "13.0.0", @@ -24328,6 +24479,16 @@ "xmlchars": "^2.2.0" } }, + "scslre": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/scslre/-/scslre-0.1.6.tgz", + "integrity": "sha512-JORxVRlQTfjvlOAaiQKebgFElyAm5/W8b50lgaZ0OkEnKnagJW2ufDh3xRfU75UD9z3FGIu1gL1IyR3Poa6Qmw==", + "requires": { + "refa": "^0.9.0", + "regexp-ast-analysis": "^0.2.3", + "regexpp": "^3.2.0" + } + }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", diff --git a/package.json b/package.json index 07c62c5e..d915bf70 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.25.1", - "eslint-plugin-react-hooks": "^4.2.0" + "eslint-plugin-react-hooks": "^4.2.0", + "eslint-plugin-regexp": "^1.1.0" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "*", @@ -120,6 +121,7 @@ "node", "prettier", "react", + "regexp", "typescript" ] ] diff --git a/rules/plugins/regexp.js b/rules/plugins/regexp.js new file mode 100644 index 00000000..34a76002 --- /dev/null +++ b/rules/plugins/regexp.js @@ -0,0 +1,19 @@ +module.exports = { + extends: ["plugin:regexp/recommended"], + + rules: { + "regexp/hexadecimal-escape": "off", + "regexp/letter-case": "off", + "regexp/no-octal": "error", + "regexp/no-standalone-backslash": "error", + "regexp/no-super-linear-move": "warn", + "regexp/prefer-escape-replacement-dollar-char": "error", + "regexp/prefer-named-backreference": "error", + "regexp/prefer-quantifier": "error", + "regexp/prefer-regexp-exec": "error", + "regexp/prefer-regexp-test": "error", + "regexp/sort-alternatives": "off", + "regexp/sort-character-class-elements": "warn", + "regexp/unicode-escape": "off", + }, +};