File tree Expand file tree Collapse file tree 7 files changed +104
-0
lines changed Expand file tree Collapse file tree 7 files changed +104
-0
lines changed Original file line number Diff line number Diff line change 94
94
"eslint-plugin-no-only-tests" : " ^3.1.0" ,
95
95
"eslint-plugin-perfectionist" : " ^2.10.0" ,
96
96
"eslint-plugin-prettier" : " ^5.1.3" ,
97
+ "eslint-plugin-regexp" : " ^2.5.0" ,
97
98
"eslint-plugin-tailwindcss" : " ^3.15.1" ,
98
99
"eslint-plugin-unicorn" : " ^53.0.0" ,
99
100
"eslint-plugin-unused-imports" : " ^3.2.0" ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
perfectionist ,
14
14
prettier ,
15
15
react ,
16
+ regexp ,
16
17
sortPackageJson ,
17
18
svelte ,
18
19
test ,
@@ -49,6 +50,7 @@ const configs = await combine(
49
50
unocss ( ) ,
50
51
vue ( ) ,
51
52
command ( ) ,
53
+ regexp ( ) ,
52
54
)
53
55
54
56
const configNames = configs . map ( i => i . name ) . filter ( Boolean ) as string [ ]
Original file line number Diff line number Diff line change @@ -18,3 +18,4 @@ export * from './formatter'
18
18
export * from './svelte'
19
19
export * from './tailwindcss'
20
20
export * from './command'
21
+ export * from './regexp'
Original file line number Diff line number Diff line change
1
+ import { configs } from 'eslint-plugin-regexp'
2
+ import type {
3
+ OptionsOverrides ,
4
+ OptionsRegExp ,
5
+ TypedFlatConfigItem ,
6
+ } from '../types'
7
+
8
+ export async function regexp (
9
+ options : OptionsRegExp & OptionsOverrides = { } ,
10
+ ) : Promise < TypedFlatConfigItem [ ] > {
11
+ const config = configs [ 'flat/recommended' ] as TypedFlatConfigItem
12
+
13
+ const rules = {
14
+ ...config . rules ,
15
+ }
16
+
17
+ if ( options . level === 'warn' ) {
18
+ Object . keys ( rules ) . forEach ( key => {
19
+ if ( rules [ key ] === 'error' ) rules [ key ] = 'warn'
20
+ } )
21
+ }
22
+
23
+ return [
24
+ {
25
+ ...config ,
26
+ name : 'coderwyd/regexp/rules' ,
27
+ rules : {
28
+ ...rules ,
29
+ ...options . overrides ,
30
+ } ,
31
+ } ,
32
+ ]
33
+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
perfectionist ,
15
15
prettier ,
16
16
react ,
17
+ regexp ,
17
18
sortPackageJson ,
18
19
sortTsconfig ,
19
20
svelte ,
@@ -87,6 +88,7 @@ export async function defineConfig(
87
88
gitignore : enableGitignore = true ,
88
89
isInEditor = defaultIsInEditor ,
89
90
react : enableReact = false ,
91
+ regexp : enableRegexp = true ,
90
92
svelte : enableSvelte = false ,
91
93
tailwindcss : enableTailwindCSS = hasTailwindCSS ,
92
94
typescript : enableTypeScript = hasTypeScript ,
@@ -144,6 +146,9 @@ export async function defineConfig(
144
146
)
145
147
}
146
148
149
+ if ( enableRegexp )
150
+ configs . push ( regexp ( typeof enableRegexp === 'boolean' ? { } : enableRegexp ) )
151
+
147
152
if ( options . test ?? true ) {
148
153
configs . push (
149
154
test ( {
Original file line number Diff line number Diff line change @@ -95,6 +95,13 @@ export interface OptionsOverrides {
95
95
overrides ?: TypedFlatConfigItem [ 'rules' ]
96
96
}
97
97
98
+ export interface OptionsRegExp {
99
+ /**
100
+ * Override rulelevels
101
+ */
102
+ level ?: 'error' | 'warn'
103
+ }
104
+
98
105
export interface OptionsUnoCSS extends OptionsOverrides {
99
106
/**
100
107
* Enable attributify support.
@@ -209,6 +216,14 @@ export interface OptionsConfig extends OptionsComponentExts {
209
216
*/
210
217
unocss ?: boolean | OptionsUnoCSS
211
218
219
+ /**
220
+ * Enable regexp rules.
221
+ *
222
+ * @see https://ota-meshi.github.io/eslint-plugin-regexp/
223
+ * @default true
224
+ */
225
+ regexp ?: boolean | ( OptionsRegExp & OptionsOverrides )
226
+
212
227
/**
213
228
* Whether to use prettierrc
214
229
*
You can’t perform that action at this time.
0 commit comments