Skip to content

Commit b7c7a01

Browse files
committedAug 29, 2024
fix!: make the first ignores always global, disallow files in the first arg, fix #594
1 parent 6e7cfe9 commit b7c7a01

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed
 

‎src/configs/ignores.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import type { TypedFlatConfigItem } from '../types'
22
import { GLOB_EXCLUDE } from '../globs'
33

4-
export async function ignores(): Promise<TypedFlatConfigItem[]> {
4+
export async function ignores(userIgnores: string[] = []): Promise<TypedFlatConfigItem[]> {
55
return [
66
{
7-
ignores: GLOB_EXCLUDE,
7+
ignores: [
8+
...GLOB_EXCLUDE,
9+
...userIgnores,
10+
],
811
},
912
]
1013
}

‎src/factory.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@ import { formatters } from './configs/formatters'
3434
import { regexp } from './configs/regexp'
3535
import type { RuleOptions } from './typegen'
3636

37-
const flatConfigProps: (keyof TypedFlatConfigItem)[] = [
37+
const flatConfigProps = [
3838
'name',
39-
'files',
40-
'ignores',
4139
'languageOptions',
4240
'linterOptions',
4341
'processor',
4442
'plugins',
4543
'rules',
4644
'settings',
47-
]
45+
] satisfies (keyof TypedFlatConfigItem)[]
4846

4947
const VuePackages = [
5048
'vue',
@@ -78,7 +76,7 @@ export const defaultPluginRenaming = {
7876
* The merged ESLint configurations.
7977
*/
8078
export function antfu(
81-
options: OptionsConfig & TypedFlatConfigItem = {},
79+
options: OptionsConfig & Omit<TypedFlatConfigItem, 'files'> = {},
8280
...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]
8381
): FlatConfigComposer<TypedFlatConfigItem, ConfigNames> {
8482
const {
@@ -129,7 +127,7 @@ export function antfu(
129127

130128
// Base configs
131129
configs.push(
132-
ignores(),
130+
ignores(options.ignores),
133131
javascript({
134132
isInEditor,
135133
overrides: getOverrides(options, 'javascript'),
@@ -274,6 +272,10 @@ export function antfu(
274272
))
275273
}
276274

275+
if ('files' in options) {
276+
throw new Error('[@antfu/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.')
277+
}
278+
277279
// User can optionally pass a flat config item to the first argument
278280
// We pick the known keys as ESLint would do schema validation
279281
const fusedConfig = flatConfigProps.reduce((acc, key) => {

0 commit comments

Comments
 (0)
Please sign in to comment.