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 9494 "eslint-plugin-no-only-tests" : " ^3.1.0" ,
9595 "eslint-plugin-perfectionist" : " ^2.10.0" ,
9696 "eslint-plugin-prettier" : " ^5.1.3" ,
97+ "eslint-plugin-regexp" : " ^2.5.0" ,
9798 "eslint-plugin-tailwindcss" : " ^3.15.1" ,
9899 "eslint-plugin-unicorn" : " ^53.0.0" ,
99100 "eslint-plugin-unused-imports" : " ^3.2.0" ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 perfectionist ,
1414 prettier ,
1515 react ,
16+ regexp ,
1617 sortPackageJson ,
1718 svelte ,
1819 test ,
@@ -49,6 +50,7 @@ const configs = await combine(
4950 unocss ( ) ,
5051 vue ( ) ,
5152 command ( ) ,
53+ regexp ( ) ,
5254)
5355
5456const 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'
1818export * from './svelte'
1919export * from './tailwindcss'
2020export * 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 {
1414 perfectionist ,
1515 prettier ,
1616 react ,
17+ regexp ,
1718 sortPackageJson ,
1819 sortTsconfig ,
1920 svelte ,
@@ -87,6 +88,7 @@ export async function defineConfig(
8788 gitignore : enableGitignore = true ,
8889 isInEditor = defaultIsInEditor ,
8990 react : enableReact = false ,
91+ regexp : enableRegexp = true ,
9092 svelte : enableSvelte = false ,
9193 tailwindcss : enableTailwindCSS = hasTailwindCSS ,
9294 typescript : enableTypeScript = hasTypeScript ,
@@ -144,6 +146,9 @@ export async function defineConfig(
144146 )
145147 }
146148
149+ if ( enableRegexp )
150+ configs . push ( regexp ( typeof enableRegexp === 'boolean' ? { } : enableRegexp ) )
151+
147152 if ( options . test ?? true ) {
148153 configs . push (
149154 test ( {
Original file line number Diff line number Diff line change @@ -95,6 +95,13 @@ export interface OptionsOverrides {
9595 overrides ?: TypedFlatConfigItem [ 'rules' ]
9696}
9797
98+ export interface OptionsRegExp {
99+ /**
100+ * Override rulelevels
101+ */
102+ level ?: 'error' | 'warn'
103+ }
104+
98105export interface OptionsUnoCSS extends OptionsOverrides {
99106 /**
100107 * Enable attributify support.
@@ -209,6 +216,14 @@ export interface OptionsConfig extends OptionsComponentExts {
209216 */
210217 unocss ?: boolean | OptionsUnoCSS
211218
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+
212227 /**
213228 * Whether to use prettierrc
214229 *
You can’t perform that action at this time.
0 commit comments