1
1
import type { ESLint , Linter } from "eslint" ;
2
+ import { isPackageExists } from "local-pkg" ;
2
3
4
+ import { GLOB_SRC_EXT } from "../globs" ;
3
5
import type {
4
6
FlatConfigItem ,
5
7
OptionsFiles ,
@@ -25,6 +27,8 @@ type PluginVue = ESLint.Plugin & {
25
27
} ;
26
28
/* eslint-enable ts/naming-convention */
27
29
30
+ const NuxtPackages = [ "nuxt" ] ;
31
+
28
32
export async function vue (
29
33
options : Readonly <
30
34
Required <
@@ -43,6 +47,8 @@ export async function vue(
43
47
44
48
const { indent = 2 } = typeof stylistic === "boolean" ? { } : stylistic ;
45
49
50
+ const isUsingNuxt = NuxtPackages . some ( ( i ) => isPackageExists ( i ) ) ;
51
+
46
52
const [ pluginVue , pluginVueI18n , parserVue , processorVueBlocks , { mergeProcessors } ] = ( await loadPackages ( [
47
53
"eslint-plugin-vue" ,
48
54
"@intlify/eslint-plugin-vue-i18n" ,
@@ -255,5 +261,43 @@ export async function vue(
255
261
...overrides ,
256
262
} ,
257
263
} ,
264
+
265
+ ...( ( isUsingNuxt
266
+ ? [
267
+ {
268
+ name : "rs:nuxt:rules:off" ,
269
+ files,
270
+ rules : {
271
+ "import/default" : "off" ,
272
+ "import/named" : "off" ,
273
+ "import/namespace" : "off" ,
274
+ "import/no-unresolved" : "off" ,
275
+ } ,
276
+ } ,
277
+ {
278
+ name : "rs:nuxt:rules" ,
279
+ files : [
280
+ // These pages are not used directly by users so they can have one-word names.
281
+ `**/pages/**/*.{${ GLOB_SRC_EXT } ,vue}` ,
282
+ `**/layouts/**/*.{${ GLOB_SRC_EXT } ,vue}` ,
283
+ `**/app.{${ GLOB_SRC_EXT } ,vue}` ,
284
+ `**/error.{${ GLOB_SRC_EXT } ,vue}` ,
285
+
286
+ // These files shouldn't have multiple words in their names as they are within subdirectories.
287
+ `**/components/*/**/*.{${ GLOB_SRC_EXT } ,vue}` ,
288
+ ] ,
289
+ rules : {
290
+ "vue/multi-word-component-names" : "off" ,
291
+ } ,
292
+ } ,
293
+ {
294
+ // Pages and layouts are required to have a single root element if transitions are enabled.
295
+ files : [ `**/pages/**/*.{${ GLOB_SRC_EXT } ,vue}` , `**/layouts/**/*.{${ GLOB_SRC_EXT } ,vue}` ] ,
296
+ rules : {
297
+ "vue/no-multiple-template-root" : "error" ,
298
+ } ,
299
+ } ,
300
+ ]
301
+ : [ ] ) satisfies FlatConfigItem [ ] ) ,
258
302
] ;
259
303
}
0 commit comments