Skip to content

Commit

Permalink
feat(eslint-config): support default export and rest arguments for ea…
Browse files Browse the repository at this point in the history
…sier usage
  • Loading branch information
antfu committed Apr 10, 2024
1 parent 10d21e9 commit c75ebf1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/eslint-config/src/flat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ export function defineFlatConfigs(

/**
* Create an array of ESLint flat configs for Nuxt 3, based on the given options.
* Accpets appending user configs as rest arguments from the second argument.
*
* Usually it would be use `@nuxt/eslint` module which will generate the necessary configuration based on your project.
*
* For Nuxt apps, it's recommanded to use `@nuxt/eslint` module instead, which will generate the necessary configuration based on your project.
* @see https://eslint.nuxt.com/packages/module
*/
export function createConfigForNuxt(options: NuxtESLintConfigOptions = {}): FlatConfigComposer<FlatConfigItem> {
export function createConfigForNuxt(
options: NuxtESLintConfigOptions = {},
...userConfigs: ResolvableFlatConfig[]
): FlatConfigComposer<FlatConfigItem> {
const c = composer()

const resolved = resolveOptions(options)
Expand Down Expand Up @@ -73,5 +76,11 @@ export function createConfigForNuxt(options: NuxtESLintConfigOptions = {}): Flat
disables(resolved),
)

if (userConfigs.length > 0) {
c.append(...userConfigs)
}

return c
}

export default createConfigForNuxt

0 comments on commit c75ebf1

Please sign in to comment.