Skip to content

Commit

Permalink
add regexp plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Katkov committed May 18, 2024
1 parent 90f76d6 commit e463bae
Show file tree
Hide file tree
Showing 11 changed files with 494 additions and 13 deletions.
83 changes: 82 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins:
- promise
- array-func
- import
- regexp
parserOptions:
sourceType: module
ecmaVersion: 2021
Expand Down Expand Up @@ -206,6 +207,86 @@ rules:
promise/param-names: error
promise/valid-params: error
radix: error
regexp/confusing-quantifier: error
regexp/control-character-escape: error
regexp/grapheme-string-literal: error
regexp/hexadecimal-escape: error
regexp/letter-case: error
regexp/match-any: error
regexp/negation: error
regexp/no-contradiction-with-assertion: error
regexp/no-control-character: error
regexp/no-dupe-characters-character-class: error
regexp/no-dupe-disjunctions: error
regexp/no-empty-alternative: error
regexp/no-empty-capturing-group: error
regexp/no-empty-character-class: error
regexp/no-empty-group: error
regexp/no-empty-lookarounds-assertion: error
regexp/no-empty-string-literal: error
regexp/no-escape-backspace: error
regexp/no-extra-lookaround-assertions: error
regexp/no-invalid-regexp: error
regexp/no-invisible-character: error
regexp/no-lazy-ends: error
regexp/no-legacy-features: error
regexp/no-misleading-capturing-group: error
regexp/no-misleading-unicode-character: error
regexp/no-missing-g-flag: error
regexp/no-non-standard-flag: error
regexp/no-obscure-range: error
regexp/no-octal: error
regexp/no-optional-assertion: error
regexp/no-potentially-useless-backreference: error
regexp/no-standalone-backslash: error
regexp/no-super-linear-backtracking: error
regexp/no-super-linear-move: error
regexp/no-trivially-nested-assertion: error
regexp/no-trivially-nested-quantifier: error
regexp/no-unused-capturing-group: error
regexp/no-useless-assertions: error
regexp/no-useless-backreference: error
regexp/no-useless-character-class: error
regexp/no-useless-dollar-replacements: error
regexp/no-useless-escape: error
regexp/no-useless-flag: error
regexp/no-useless-lazy: error
regexp/no-useless-non-capturing-group: error
regexp/no-useless-quantifier: error
regexp/no-useless-range: error
regexp/no-useless-set-operand: error
regexp/no-useless-string-literal: error
regexp/no-zero-quantifier: error
regexp/optimal-lookaround-quantifier: error
regexp/optimal-quantifier-concatenation: error
regexp/prefer-character-class: error
regexp/prefer-d:
- error
- insideCharacterClass: range
regexp/prefer-escape-replacement-dollar-char: error
regexp/prefer-lookaround: error
regexp/prefer-named-backreference: error
regexp/prefer-named-replacement: error
regexp/prefer-plus-quantifier: error
regexp/prefer-predefined-assertion: error
regexp/prefer-quantifier: error
regexp/prefer-question-quantifier: error
regexp/prefer-regexp-exec: error
regexp/prefer-regexp-test: error
regexp/prefer-result-array-groups: error
regexp/prefer-set-operation: error
regexp/prefer-star-quantifier: error
regexp/prefer-unicode-codepoint-escapes: error
regexp/prefer-w: error
regexp/require-unicode-regexp: error
regexp/simplify-set-operations: error
regexp/sort-alternatives: error
regexp/sort-character-class-elements: error
regexp/sort-flags: error
regexp/strict: error
regexp/unicode-escape: error
regexp/unicode-property: error
regexp/use-ignore-case: error
require-atomic-updates: error
require-yield: error
simple-import-sort/exports: error
Expand Down Expand Up @@ -238,7 +319,6 @@ rules:
- markers:
- /
symbol-description: error
unicorn/better-regex: error
unicorn/catch-error-name: error
unicorn/consistent-destructuring: error
unicorn/consistent-function-scoping: error
Expand Down Expand Up @@ -399,6 +479,7 @@ overrides:
- '@typescript-eslint'
parserOptions:
project: true
EXPERIMENTAL_useProjectService: true
rules:
'@typescript-eslint/adjacent-overload-signatures': error
'@typescript-eslint/array-type':
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ You can achieve best results running `do-me-lint` once or periodically if you wa

It makes sense to keep `.domelintrc.yml` as part of your git repository.

For monorepos you need to run the script from each project's directory.

## Troubleshooting

If there are too many warnings to fix in one go:
Expand Down Expand Up @@ -117,3 +115,4 @@ relaxedRules:
- [array-func](https://github.com/freaktechnik/eslint-plugin-array-func)
- [import](https://github.com/import-js/eslint-plugin-import)
- [Playwright](https://github.com/playwright-community/eslint-plugin-playwright)
- [eslint-plugin-regexp](https://ota-meshi.github.io/)
79 changes: 79 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-playwright": "^0.9.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^2.5.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-unicorn": "^49.0.0",
Expand Down
2 changes: 2 additions & 0 deletions src/config/rulesets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ruleset as playwright } from './rulesets/ruleset.playwright'
import { ruleset as promise } from './rulesets/ruleset.promise'
import { ruleset as react } from './rulesets/ruleset.react'
import { ruleset as reactHooks } from './rulesets/ruleset.react-hooks'
import { ruleset as regexp } from './rulesets/ruleset.regexp'
import { ruleset as simpleSort } from './rulesets/ruleset.simple-import-sort'
import { ruleset as sonarjs } from './rulesets/ruleset.sonarjs'
import { ruleset as typescript } from './rulesets/ruleset.typescript'
Expand All @@ -29,4 +30,5 @@ export const ruleset: Record<string, Rule> = {
...arrayFunction,
...importPlugin,
...playwright,
...regexp,
}
4 changes: 2 additions & 2 deletions src/config/rulesets/ruleset.eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export const ruleset: Record<string, Rule> = {
enabled: true,
},
'prefer-named-capture-group': {
enabled: false, // in practice most regexps don't need it and migration takes ages
enabled: false, // in practice most regexps don't need it and migration takes ages; also there is better regexp/prefer-named-capture-group
},
'prefer-object-has-own': {
enabled: false, // until Object.hasOwn stops being experimental: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn#browser_compatibility
Expand All @@ -425,7 +425,7 @@ export const ruleset: Record<string, Rule> = {
scope: 'js', // @typescript-eslint/require-await
},
'require-unicode-regexp': {
enabled: false, // reports even for latin-only regexps, annoying in webpack config
enabled: false, // superceded by regexp/require-unicode-regexp and regexp/require-unicode-sets-regexp
},
'vars-on-top': {
enabled: false, // doesn't make sense in ES6 world
Expand Down
Loading

0 comments on commit e463bae

Please sign in to comment.