Skip to content

Commit 1fd58d4

Browse files
committed
chore(deps): eslint v9 with nuxt/eslint
1 parent 5ce0986 commit 1fd58d4

File tree

18 files changed

+861
-708
lines changed

18 files changed

+861
-708
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @ts-check
2+
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
3+
4+
export default createConfigForNuxt({
5+
features: {
6+
tooling: true,
7+
stylistic: true,
8+
},
9+
}, {
10+
rules: {
11+
'vue/multi-word-component-names': 'off',
12+
},
13+
})

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"dev": "nuxt dev playground --tunnel",
4141
"build": "nuxt-module-build build",
4242
"lint": "eslint .",
43+
"lint:fix": "eslint . --fix",
4344
"prepack": "pnpm lint && pnpm build",
4445
"release": "pnpm lint && release-it",
4546
"pre:release": "pnpm lint && release-it --preRelease"
@@ -57,16 +58,15 @@
5758
},
5859
"devDependencies": {
5960
"@nuxt/content": "^2.12.1",
60-
"@nuxt/eslint-config": "^0.2.0",
61+
"@nuxt/eslint": "^0.3.10",
6162
"@nuxt/image": "^1.6.0",
6263
"@nuxt/module-builder": "^0.6.0",
6364
"@nuxt/schema": "^3.11.2",
6465
"@nuxt/ui-pro": "^1.1.0",
65-
"@nuxtjs/eslint-config-typescript": "^12.1.0",
6666
"@types/node": "^20.12.7",
6767
"changelogen": "^0.5.5",
6868
"consola": "^3.2.3",
69-
"eslint": "^8.57.0",
69+
"eslint": "^9.1.1",
7070
"nuxt": "^3.11.2",
7171
"release-it": "^17.2.1",
7272
"typescript": "^5.4.5"

playground/nuxt.config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default defineNuxtConfig({
55
extends: '@nuxt/ui-pro',
66
modules: ['@nuxt/ui', '@nuxt/content', '../src/module', '@nuxt/image'],
77
studio: {
8-
enabled: true
8+
enabled: true,
99
},
1010
hooks: {
1111
// Set all components to global
@@ -16,16 +16,16 @@ export default defineNuxtConfig({
1616
// }
1717
// })
1818
},
19-
listen: async (_, { getURLs }) => {
19+
'listen': async (_, { getURLs }) => {
2020
const urls = await getURLs()
2121
const tunnelURL = urls.find((u: { type: string }) => u.type === 'tunnel')
22-
if (!tunnelURL) { return consola.warn('Could not get Tunnel URL') }
22+
if (!tunnelURL) return consola.warn('Could not get Tunnel URL')
2323
consola.box(
24-
'Nuxt Studio Playground Ready.\n\n' +
25-
'1. Go to https://nuxt.studio/@studio/studio-module\n' +
26-
'2. Paste `' + tunnelURL.url + '` in the Deployed URL field\n' +
27-
'3. Play with the Studio Playground!'
24+
'Nuxt Studio Playground Ready.\n\n'
25+
+ '1. Go to https://nuxt.studio/@studio/studio-module\n'
26+
+ '2. Paste `' + tunnelURL.url + '` in the Deployed URL field\n'
27+
+ '3. Play with the Studio Playground!',
2828
)
29-
}
30-
}
29+
},
30+
},
3131
})

playground/nuxt.schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export default defineNuxtSchema({
55
header: group({
66
title: 'Header',
77
fields: {
8-
title: field({ type: 'string' })
9-
}
10-
})
11-
}
8+
title: field({ type: 'string' }),
9+
},
10+
}),
11+
},
1212
})

pnpm-lock.yaml

Lines changed: 624 additions & 488 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module.ts

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { existsSync } from 'node:fs'
2-
import path from 'path'
2+
import path from 'node:path'
33
import { defu } from 'defu'
44
import { addPrerenderRoutes, installModule, defineNuxtModule, addPlugin, extendViteConfig, createResolver, logger, addComponentsDir, addServerHandler, resolveAlias, addVitePlugin } from '@nuxt/kit'
55
import { findNearestFile } from 'pkg-types'
6-
// @ts-ignore
6+
// @ts-expect-error import does exist
77
import gitUrlParse from 'git-url-parse'
88
import { version } from '../package.json'
99

@@ -13,7 +13,7 @@ export interface ModuleOptions {
1313
/**
1414
* Enable Studio mode
1515
* @default: 'production'
16-
**/
16+
*/
1717
enabled: 'production' | true
1818
}
1919

@@ -22,17 +22,17 @@ export interface ModuleHooks {}
2222
export default defineNuxtModule<ModuleOptions>({
2323
meta: {
2424
name: 'studio',
25-
configKey: 'studio'
25+
configKey: 'studio',
2626
},
2727
defaults: {
28-
enabled: 'production'
28+
enabled: 'production',
2929
},
30-
async setup (options, nuxt) {
31-
// @ts-ignore
30+
async setup(options, nuxt) {
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3232
nuxt.hook('schema:resolved', (schema: any) => {
3333
nuxt.options.runtimeConfig.appConfigSchema = {
3434
properties: schema.properties?.appConfig,
35-
default: schema.default?.appConfig
35+
default: schema.default?.appConfig,
3636
}
3737
nuxt.options.runtimeConfig.contentSchema = schema.properties?.content || {}
3838
})
@@ -53,25 +53,24 @@ export default defineNuxtModule<ModuleOptions>({
5353
const contentModule = '@nuxt/content'
5454
// Check Content module is installed
5555
if (
56-
!nuxt.options.runtimeConfig.content &&
57-
!nuxt.options.modules.includes(contentModule)
56+
!nuxt.options.runtimeConfig.content
57+
&& !nuxt.options.modules.includes(contentModule)
5858
) {
5959
log.warn('Could not find `@nuxt/content` module. Please install it to enable preview mode.')
6060
return
6161
}
6262
// Check Content module version
6363
const contentModuleVersion = await import(contentModule)
6464
.then(m => m.default || m)
65-
.then((m: any) => m.getMeta())
65+
.then(m => m.getMeta())
6666
.then(m => m.version)
6767
.catch(() => '0')
6868
if (contentModuleVersion < '2.1.1') {
6969
log.warn('Please update `@nuxt/content` to version 2.1.1 or higher to enable preview mode.')
7070
return
7171
}
7272

73-
// Check Pinceau module activated
74-
// @ts-ignore
73+
// @ts-expect-error Check Pinceau module activated
7574
nuxt.hook('pinceau:options', (options) => {
7675
options.studio = true
7776
})
@@ -82,34 +81,34 @@ export default defineNuxtModule<ModuleOptions>({
8281
const publicToken = process.env.NUXT_PUBLIC_STUDIO_TOKENS
8382
const iframeMessagingAllowedOrigins = process.env.IFRAME_MESSAGING_ALLOWED_ORIGINS
8483
const gitInfo = await _getLocalGitInfo(nuxt.options.rootDir) || _getGitEnv() || {}
85-
nuxt.options.runtimeConfig.studio = defu(nuxt.options.runtimeConfig.studio as any, {
84+
nuxt.options.runtimeConfig.studio = defu(nuxt.options.runtimeConfig.studio, {
8685
version,
8786
publicToken,
88-
gitInfo
87+
gitInfo,
8988
})
90-
nuxt.options.runtimeConfig.public.studio = defu(nuxt.options.runtimeConfig.public.studio as any, { apiURL, iframeMessagingAllowedOrigins })
89+
nuxt.options.runtimeConfig.public.studio = defu(nuxt.options.runtimeConfig.public.studio, { apiURL, iframeMessagingAllowedOrigins })
9190

9291
extendViteConfig((config) => {
9392
config.optimizeDeps = config.optimizeDeps || {}
9493
config.optimizeDeps.include = config.optimizeDeps.include || []
9594
config.optimizeDeps.include.push(
96-
'socket.io-client', 'slugify'
95+
'socket.io-client', 'slugify',
9796
)
9897
})
9998

10099
if (contentModuleVersion === '2.10.0') {
101100
addVitePlugin({
102101
name: 'content-resolver',
103102
enforce: 'pre',
104-
resolveId (id, importer) {
103+
resolveId(id, importer) {
105104
if (id.endsWith('.mjs') && ((importer || '').includes('@nuxt/content/dist') || id.includes('@nuxt/content/dist'))) {
106105
id = id
107106
.replace('.mjs', '.js')
108107
.replace(/^\/node_modules/, './node_modules/')
109108

110109
return path.resolve(path.dirname(importer || __dirname), id.replace('.mjs', '.js'))
111110
}
112-
}
111+
},
113112
})
114113
}
115114

@@ -123,29 +122,29 @@ export default defineNuxtModule<ModuleOptions>({
123122
addServerHandler({
124123
method: 'get',
125124
route: '/__studio.json',
126-
handler: resolve('./runtime/server/routes/studio')
125+
handler: resolve('./runtime/server/routes/studio'),
127126
})
128127
addPrerenderRoutes('/__studio.json')
129128

130129
// Install dependencies
131130
await installModule('nuxt-component-meta', {
132-
globalsOnly: true
131+
globalsOnly: true,
133132
})
134-
}
133+
},
135134
})
136135

137136
// --- Utilities to get git info ---
138137

139138
interface GitInfo {
140139
// Repository name
141-
name: string,
140+
name: string
142141
// Repository owner/organization
143-
owner: string,
142+
owner: string
144143
// Repository URL
145-
url: string,
144+
url: string
146145
}
147146

148-
async function _getLocalGitInfo (rootDir: string): Promise<GitInfo | void> {
147+
async function _getLocalGitInfo(rootDir: string): Promise<GitInfo | undefined> {
149148
const remote = await _getLocalGitRemote(rootDir)
150149
if (!remote) {
151150
return
@@ -158,15 +157,15 @@ async function _getLocalGitInfo (rootDir: string): Promise<GitInfo | void> {
158157
return {
159158
name,
160159
owner,
161-
url
160+
url,
162161
}
163162
}
164163

165-
async function _getLocalGitRemote (dir: string) {
164+
async function _getLocalGitRemote(dir: string) {
166165
try {
167166
// https://www.npmjs.com/package/parse-git-config#options
168167
const parseGitConfig = await import('parse-git-config' as string).then(
169-
m => m.promise || m.default || m
168+
m => m.promise || m.default || m,
170169
) as (opts: { path: string }) => Promise<Record<string, Record<string, string>>>
171170
const gitDir = await findNearestFile('.git/config', { startingFrom: dir })
172171
const parsed = await parseGitConfig({ path: gitDir })
@@ -175,30 +174,31 @@ async function _getLocalGitRemote (dir: string) {
175174
}
176175
const gitRemote = parsed['remote "origin"'].url
177176
return gitRemote
178-
} catch (err) {
179-
177+
}
178+
catch {
179+
// Ignore error
180180
}
181181
}
182182

183-
function _getGitEnv (): GitInfo {
183+
function _getGitEnv(): GitInfo {
184184
// https://github.com/unjs/std-env/issues/59
185185
const envInfo = {
186186
// Provider
187-
provider: process.env.VERCEL_GIT_PROVIDER || // vercel
188-
(process.env.GITHUB_SERVER_URL ? 'github' : undefined) || // github
189-
'',
187+
provider: process.env.VERCEL_GIT_PROVIDER // vercel
188+
|| (process.env.GITHUB_SERVER_URL ? 'github' : undefined) // github
189+
|| '',
190190
// Owner
191-
owner: process.env.VERCEL_GIT_REPO_OWNER || // vercel
192-
process.env.GITHUB_REPOSITORY_OWNER || // github
193-
process.env.CI_PROJECT_PATH?.split('/').shift() || // gitlab
194-
'',
191+
owner: process.env.VERCEL_GIT_REPO_OWNER // vercel
192+
|| process.env.GITHUB_REPOSITORY_OWNER // github
193+
|| process.env.CI_PROJECT_PATH?.split('/').shift() // gitlab
194+
|| '',
195195
// Name
196-
name: process.env.VERCEL_GIT_REPO_SLUG ||
197-
process.env.GITHUB_REPOSITORY?.split('/').pop() || // github
198-
process.env.CI_PROJECT_PATH?.split('/').splice(1).join('/') || // gitlab
199-
'',
196+
name: process.env.VERCEL_GIT_REPO_SLUG
197+
|| process.env.GITHUB_REPOSITORY?.split('/').pop() // github
198+
|| process.env.CI_PROJECT_PATH?.split('/').splice(1).join('/') // gitlab
199+
|| '',
200200
// Url
201-
url: process.env.REPOSITORY_URL || '' // netlify
201+
url: process.env.REPOSITORY_URL || '', // netlify
202202
}
203203

204204
if (!envInfo.url && envInfo.provider && envInfo.owner && envInfo.name) {
@@ -211,12 +211,15 @@ function _getGitEnv (): GitInfo {
211211
const { name, owner } = gitUrlParse(envInfo.url) as Record<string, string>
212212
envInfo.name = name
213213
envInfo.owner = owner
214-
} catch {}
214+
}
215+
catch {
216+
// Ignore error
217+
}
215218
}
216219

217220
return {
218221
name: envInfo.name,
219222
owner: envInfo.owner,
220-
url: envInfo.url
223+
url: envInfo.url,
221224
}
222225
}

0 commit comments

Comments
 (0)