Skip to content

Commit af93c10

Browse files
authored
feat: allow unicorn and svelte to overrides rules (#701)
* Allow overriding `unicorn`'s rules * Allow overriding `svelte`'s rules
1 parent 7c24ce7 commit af93c10

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/configs/unicorn.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import type { OptionsUnicorn, TypedFlatConfigItem } from '../types'
33
import { pluginUnicorn } from '../plugins'
44

55
export async function unicorn(options: OptionsUnicorn = {}): Promise<TypedFlatConfigItem[]> {
6+
const {
7+
allRecommended = false,
8+
overrides = {},
9+
} = options
610
return [
711
{
812
name: 'antfu/unicorn/rules',
913
plugins: {
1014
unicorn: pluginUnicorn,
1115
},
1216
rules: {
13-
...(options.allRecommended
17+
...(allRecommended
1418
? pluginUnicorn.configs.recommended.rules
1519
: {
1620
'unicorn/consistent-empty-array-spread': 'error',
@@ -29,6 +33,7 @@ export async function unicorn(options: OptionsUnicorn = {}): Promise<TypedFlatCo
2933
'unicorn/prefer-type-error': 'error',
3034
'unicorn/throw-new-error': 'error',
3135
}),
36+
...overrides,
3237
},
3338
},
3439
]

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export interface OptionsComponentExts {
142142
componentExts?: string[]
143143
}
144144

145-
export interface OptionsUnicorn {
145+
export interface OptionsUnicorn extends OptionsOverrides {
146146
/**
147147
* Include all rules recommended by `eslint-plugin-unicorn`, instead of only ones picked by Anthony.
148148
*
@@ -386,7 +386,7 @@ export interface OptionsConfig extends OptionsComponentExts, OptionsProjectType
386386
*
387387
* @default false
388388
*/
389-
svelte?: boolean
389+
svelte?: boolean | OptionsOverrides
390390

391391
/**
392392
* Enable unocss rules.

0 commit comments

Comments
 (0)