Skip to content

Commit 42aeded

Browse files
committedAug 29, 2024··
feat(config): support Nuxt 4 convention by default, resolve #487
1 parent b776e3a commit 42aeded

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed
 

Diff for: ‎packages/eslint-config/src/flat/configs/disables.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function disables(options: NuxtESLintConfigOptions): Linter.Confi
2424
...(dirs.components.map(componentsDir => join(componentsDir, '*', nestedGlobPattern)) || []),
2525
// Prefixed components can have one-word names in file
2626
...(dirs.componentsPrefixed.map(componentsDir => join(componentsDir, nestedGlobPattern)) || []),
27-
])]
27+
])].sort()
2828

2929
const configs: Linter.Config[] = []
3030

Diff for: ‎packages/eslint-config/src/flat/configs/nuxt.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function nuxt(options: NuxtESLintConfigOptions): Linter.Config[]
1313
...(dirs.layouts?.map(layoutsDir => join(layoutsDir, `**/*.${GLOB_EXTS}`)) || []),
1414
...(dirs.pages?.map(pagesDir => join(pagesDir, `**/*.${GLOB_EXTS}`)) || []),
1515
...(dirs.components?.map(componentsDir => join(componentsDir, `**/*.server.${GLOB_EXTS}`)) || []),
16-
]
16+
].sort()
1717

1818
const configs: Linter.Config[] = []
1919

Diff for: ‎packages/eslint-config/src/flat/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function resolveOptions(
1616
...config.dirs,
1717
} as NuxtESLintConfigOptionsResolved['dirs']
1818

19-
dirs.root ||= ['.']
19+
dirs.root ||= ['.', './app'] // Support both Nuxt 3 and 4 conventions by default
2020
dirs.src ||= dirs.root
2121
dirs.pages ||= dirs.src.map(src => `${src}/pages`)
2222
dirs.layouts ||= dirs.src.map(src => `${src}/layouts`)

Diff for: ‎packages/eslint-config/test/__snapshots__/flat-compose.test.ts.snap

+43-43
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@ exports[`flat config composition > custom src dirs 1`] = `
44
[
55
{
66
"ignores": [
7-
"node_modules",
8-
"**/node_modules/**",
9-
"*.iml",
10-
"**/*.iml/**",
11-
".idea",
12-
"**/.idea/**",
13-
"*.log",
14-
"**/*.log/**",
15-
".nuxt",
16-
"**/.nuxt/**",
17-
".output",
18-
"**/.output/**",
7+
"**/node_modules",
8+
"**/*.iml",
9+
"**/.idea",
10+
"**/*.log",
11+
"**/.nuxt",
12+
"**/.output",
1913
"**/.yarn/cache",
2014
"**/.yarn/*state*",
21-
"dist",
22-
"**/dist/**",
23-
".eslintcache",
24-
"**/.eslintcache/**",
15+
"**/dist",
16+
"**/.eslintcache",
2517
],
2618
},
2719
{
@@ -68,12 +60,12 @@ exports[`flat config composition > custom src dirs 1`] = `
6860
},
6961
{
7062
"files": [
63+
"src1/components/**/*.server.{js,ts,jsx,tsx,vue}",
7164
"src1/layouts/**/*.{js,ts,jsx,tsx,vue}",
72-
"src2/layouts/**/*.{js,ts,jsx,tsx,vue}",
7365
"src1/pages/**/*.{js,ts,jsx,tsx,vue}",
74-
"src2/pages/**/*.{js,ts,jsx,tsx,vue}",
75-
"src1/components/**/*.server.{js,ts,jsx,tsx,vue}",
7666
"src2/components/**/*.server.{js,ts,jsx,tsx,vue}",
67+
"src2/layouts/**/*.{js,ts,jsx,tsx,vue}",
68+
"src2/pages/**/*.{js,ts,jsx,tsx,vue}",
7769
],
7870
"name": "nuxt/vue/single-root",
7971
},
@@ -83,15 +75,15 @@ exports[`flat config composition > custom src dirs 1`] = `
8375
{
8476
"files": [
8577
"src1/app.{js,ts,jsx,tsx,vue}",
78+
"src1/components/*/**/*.{js,ts,jsx,tsx,vue}",
8679
"src1/error.{js,ts,jsx,tsx,vue}",
80+
"src1/layouts/**/*.{js,ts,jsx,tsx,vue}",
81+
"src1/pages/**/*.{js,ts,jsx,tsx,vue}",
8782
"src2/app.{js,ts,jsx,tsx,vue}",
83+
"src2/components/*/**/*.{js,ts,jsx,tsx,vue}",
8884
"src2/error.{js,ts,jsx,tsx,vue}",
89-
"src1/layouts/**/*.{js,ts,jsx,tsx,vue}",
9085
"src2/layouts/**/*.{js,ts,jsx,tsx,vue}",
91-
"src1/pages/**/*.{js,ts,jsx,tsx,vue}",
9286
"src2/pages/**/*.{js,ts,jsx,tsx,vue}",
93-
"src1/components/*/**/*.{js,ts,jsx,tsx,vue}",
94-
"src2/components/*/**/*.{js,ts,jsx,tsx,vue}",
9587
],
9688
"name": "nuxt/disables/routes",
9789
},
@@ -102,24 +94,16 @@ exports[`flat config composition > empty 1`] = `
10294
[
10395
{
10496
"ignores": [
105-
"node_modules",
106-
"**/node_modules/**",
107-
"*.iml",
108-
"**/*.iml/**",
109-
".idea",
110-
"**/.idea/**",
111-
"*.log",
112-
"**/*.log/**",
113-
".nuxt",
114-
"**/.nuxt/**",
115-
".output",
116-
"**/.output/**",
97+
"**/node_modules",
98+
"**/*.iml",
99+
"**/.idea",
100+
"**/*.log",
101+
"**/.nuxt",
102+
"**/.output",
117103
"**/.yarn/cache",
118104
"**/.yarn/*state*",
119-
"dist",
120-
"**/dist/**",
121-
".eslintcache",
122-
"**/.eslintcache/**",
105+
"**/dist",
106+
"**/.eslintcache",
123107
],
124108
},
125109
{
@@ -166,9 +150,12 @@ exports[`flat config composition > empty 1`] = `
166150
},
167151
{
168152
"files": [
153+
"app/components/**/*.server.{js,ts,jsx,tsx,vue}",
154+
"app/layouts/**/*.{js,ts,jsx,tsx,vue}",
155+
"app/pages/**/*.{js,ts,jsx,tsx,vue}",
156+
"components/**/*.server.{js,ts,jsx,tsx,vue}",
169157
"layouts/**/*.{js,ts,jsx,tsx,vue}",
170158
"pages/**/*.{js,ts,jsx,tsx,vue}",
171-
"components/**/*.server.{js,ts,jsx,tsx,vue}",
172159
],
173160
"name": "nuxt/vue/single-root",
174161
},
@@ -178,10 +165,15 @@ exports[`flat config composition > empty 1`] = `
178165
{
179166
"files": [
180167
"app.{js,ts,jsx,tsx,vue}",
168+
"app/app.{js,ts,jsx,tsx,vue}",
169+
"app/components/*/**/*.{js,ts,jsx,tsx,vue}",
170+
"app/error.{js,ts,jsx,tsx,vue}",
171+
"app/layouts/**/*.{js,ts,jsx,tsx,vue}",
172+
"app/pages/**/*.{js,ts,jsx,tsx,vue}",
173+
"components/*/**/*.{js,ts,jsx,tsx,vue}",
181174
"error.{js,ts,jsx,tsx,vue}",
182175
"layouts/**/*.{js,ts,jsx,tsx,vue}",
183176
"pages/**/*.{js,ts,jsx,tsx,vue}",
184-
"components/*/**/*.{js,ts,jsx,tsx,vue}",
185177
],
186178
"name": "nuxt/disables/routes",
187179
},
@@ -195,9 +187,12 @@ exports[`flat config composition > non-standalone 1`] = `
195187
},
196188
{
197189
"files": [
190+
"app/components/**/*.server.{js,ts,jsx,tsx,vue}",
191+
"app/layouts/**/*.{js,ts,jsx,tsx,vue}",
192+
"app/pages/**/*.{js,ts,jsx,tsx,vue}",
193+
"components/**/*.server.{js,ts,jsx,tsx,vue}",
198194
"layouts/**/*.{js,ts,jsx,tsx,vue}",
199195
"pages/**/*.{js,ts,jsx,tsx,vue}",
200-
"components/**/*.server.{js,ts,jsx,tsx,vue}",
201196
],
202197
"name": "nuxt/vue/single-root",
203198
},
@@ -207,10 +202,15 @@ exports[`flat config composition > non-standalone 1`] = `
207202
{
208203
"files": [
209204
"app.{js,ts,jsx,tsx,vue}",
205+
"app/app.{js,ts,jsx,tsx,vue}",
206+
"app/components/*/**/*.{js,ts,jsx,tsx,vue}",
207+
"app/error.{js,ts,jsx,tsx,vue}",
208+
"app/layouts/**/*.{js,ts,jsx,tsx,vue}",
209+
"app/pages/**/*.{js,ts,jsx,tsx,vue}",
210+
"components/*/**/*.{js,ts,jsx,tsx,vue}",
210211
"error.{js,ts,jsx,tsx,vue}",
211212
"layouts/**/*.{js,ts,jsx,tsx,vue}",
212213
"pages/**/*.{js,ts,jsx,tsx,vue}",
213-
"components/*/**/*.{js,ts,jsx,tsx,vue}",
214214
],
215215
"name": "nuxt/disables/routes",
216216
},

0 commit comments

Comments
 (0)
Please sign in to comment.