Skip to content

Commit bc0559e

Browse files
committedAug 19, 2024··
feat: improve error messages for plugin conflicts, close #450, close #474
1 parent e1471fc commit bc0559e

File tree

5 files changed

+100
-654
lines changed

5 files changed

+100
-654
lines changed
 

‎packages/eslint-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@typescript-eslint/eslint-plugin": "^8.1.0",
5959
"@typescript-eslint/parser": "^8.1.0",
6060
"eslint-config-flat-gitignore": "^0.1.8",
61-
"eslint-flat-config-utils": "^0.3.0",
61+
"eslint-flat-config-utils": "^0.3.1",
6262
"eslint-plugin-import-x": "^3.1.0",
6363
"eslint-plugin-jsdoc": "^50.2.2",
6464
"eslint-plugin-regexp": "^2.6.0",

‎packages/eslint-config/src/flat/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ export function createConfigForNuxt(
8585
c.append(...userConfigs)
8686
}
8787

88+
c
89+
.setPluginConflictsError()
90+
.setPluginConflictsError('import', [
91+
'Different instances of plugin "{{pluginName}}" found in multiple configs:',
92+
'{{configNames}}.',
93+
'You might forget to set `standalone: false`.',
94+
'Please refer to https://eslint.nuxt.com/packages/module#custom-config-presets.',
95+
'',
96+
].join('\n'))
97+
8898
return c
8999
}
90100

‎packages/module/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@nuxt/eslint-plugin": "workspace:*",
5555
"@nuxt/kit": "^3.12.4",
5656
"chokidar": "^3.6.0",
57-
"eslint-flat-config-utils": "^0.3.0",
57+
"eslint-flat-config-utils": "^0.3.1",
5858
"eslint-typegen": "^0.3.1",
5959
"find-up": "^7.0.0",
6060
"get-port-please": "^3.1.2",

‎packages/module/src/modules/config/generate.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ export async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, a
2323
}
2424

2525
importLines.push(
26-
{
27-
from: 'eslint-flat-config-utils',
28-
name: 'composer',
29-
},
3026
{
3127
from: 'eslint-typegen',
3228
name: 'default',
@@ -51,8 +47,6 @@ export async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, a
5147
dirs: getDirs(nuxt),
5248
}
5349

54-
configItems.push(`// Nuxt Configs\ncreateConfigForNuxt(options)`)
55-
5650
for (const addon of addons) {
5751
const resolved = await addon.getConfigs()
5852
if (resolved?.imports)
@@ -83,14 +77,20 @@ export async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, a
8377
'',
8478
'export { defineFlatConfigs }',
8579
'',
86-
`export const configs = composer()`,
87-
'',
8880
`export const options = resolveOptions(${JSON.stringify(basicOptions, null, 2)})`,
89-
``,
90-
`configs.append(`,
91-
configItems.join(',\n\n'),
92-
`)`,
9381
'',
82+
`export const configs = createConfigForNuxt(options)`,
83+
84+
...(configItems.length
85+
? [
86+
'',
87+
`configs.append(`,
88+
configItems.join(',\n\n'),
89+
`)`,
90+
'',
91+
]
92+
: []),
93+
9494
'export function withNuxt(...customs) {',
9595
' return configs',
9696
' .clone()',

‎pnpm-lock.yaml

+76-640
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.