Skip to content

Commit 53ac15b

Browse files
authored
chore: use eslint-config-vuetify v4 (#74)
1 parent e9167b8 commit 53ac15b

File tree

30 files changed

+1164
-231
lines changed

30 files changed

+1164
-231
lines changed

eslint.config.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
export { default } from 'eslint-config-vuetify/index.ts.mjs'
1+
import vuetify from 'eslint-config-vuetify'
2+
3+
export default vuetify({
4+
vue: true,
5+
perfectionist: {
6+
import: false,
7+
},
8+
}, {
9+
rules: {
10+
'unicorn/no-process-exit': 'off',
11+
},
12+
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@types/validate-npm-package-name": "^4.0.2",
4444
"esbuild": "^0.25.1",
4545
"eslint": "^9.23.0",
46-
"eslint-config-vuetify": "^3.0.3",
46+
"eslint-config-vuetify": "4.0.0",
4747
"nypm": "^0.6.0",
4848
"release-it": "^18.1.2",
4949
"typescript": "^5.8.2"

pnpm-lock.yaml

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

scripts/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function bundle () {
1717
}
1818

1919
bundle()
20-
.catch(err => {
21-
console.error(err)
20+
.catch(error => {
21+
console.error(error)
2222
process.exit(1)
2323
})

src/index.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Node
2-
import { dirname, join, resolve } from 'path'
3-
import { fileURLToPath } from 'url'
4-
import { mkdirSync, rmSync, writeFileSync } from 'fs'
2+
import { dirname, join, resolve } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import { mkdirSync, rmSync, writeFileSync } from 'node:fs'
55

66
// Types
77
import type { ContextState } from './utils/prompts'
@@ -19,7 +19,7 @@ const validPresets = ['base', 'custom', 'default', 'essentials']
1919
async function run () {
2020
const argv = minimist(process.argv.slice(2), {
2121
alias: {
22-
'typescript': ['ts'],
22+
typescript: ['ts'],
2323
},
2424
})
2525

@@ -50,8 +50,6 @@ async function run () {
5050
usePackageManager,
5151
installDependencies: installDeps,
5252
usePreset,
53-
useStore,
54-
useEslint,
5553
useNuxtV4Compat,
5654
useNuxtModule,
5755
useNuxtSSR,
@@ -83,8 +81,7 @@ async function run () {
8381
useNuxtSSR,
8482
useNuxtSSRClientHints,
8583
})
86-
}
87-
else {
84+
} else {
8885
// Create project directory
8986
mkdirSync(projectRoot)
9087

@@ -122,7 +119,7 @@ run()
122119
console.log('Support Vuetify: https://github.com/sponsors/johnleider')
123120
process.exit(0)
124121
})
125-
.catch(err => {
126-
console.error(`\n${red('✖')} ${err}\n`)
122+
.catch(error => {
123+
console.error(`\n${red('✖')} ${error}\n`)
127124
process.exit(1)
128125
})

src/utils/cli/postinstall/pnpm.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ export async function pnpmIgnored (root: string) {
55
const [major] = pnpmVersion.split('.').map(Number)
66
if (major && major >= 10) {
77
const detect = (await x('pnpm', ['ignored-builds'], { nodeOptions: { cwd: root } })).stdout
8-
if (detect.startsWith('Automatically ignored builds during installation:\n None')) return
8+
if (detect.startsWith('Automatically ignored builds during installation:\n None')) {
9+
return
10+
}
911
return detect
1012
}
1113
}
1214

1315
export default async function pnpm (root: string) {
1416
const detect = await pnpmIgnored(root)
15-
if (detect) console.warn(detect)
17+
if (detect) {
18+
console.warn(detect)
19+
}
1620
}

src/utils/deepMerge.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ interface DeepMerge {
55

66
const isObject: { (key: any): boolean } = (v: unknown): boolean => {
77
return (
8-
v === Object(v) &&
9-
v !== null &&
10-
!Array.isArray(v)
8+
v === Object(v)
9+
&& v !== null
10+
&& !Array.isArray(v)
1111
)
1212
}
1313

1414
const deepMerge: DeepMerge = <T extends GenericObject[]>(...sources: T): GenericObject =>
1515
sources.reduce((acc, curr) => {
16-
Object.keys(curr).forEach(key => {
16+
for (const key of Object.keys(curr)) {
1717
if (Array.isArray(acc[key]) && Array.isArray(curr[key])) {
1818
acc[key] = Array.from(new Set((acc[key]).concat(curr[key])))
1919
} else if (isObject(acc[key]) && isObject(curr[key])) {
2020
acc[key] = deepMerge(acc[key], curr[key])
2121
} else {
2222
acc[key] = curr[key]
2323
}
24-
})
24+
}
2525

2626
return acc
2727
}, {})

src/utils/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import { installDependencies } from './installDependencies'
2-
import { renderTemplate } from './renderTemplate'
1+
export { installDependencies } from './installDependencies'
32

4-
export {
5-
installDependencies,
6-
renderTemplate,
7-
}
3+
export { renderTemplate } from './renderTemplate'

src/utils/installDependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function installDependencies (root: string = process.cwd(), manager
1919
})
2020
.catch(() => {
2121
console.error(
22-
`Failed to install dependencies using ${manager}.`
22+
`Failed to install dependencies using ${manager}.`,
2323
)
2424
})
2525
if (manager === 'pnpm') {

src/utils/nuxt/renderNuxtTemplate.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Node
2-
import fs from 'fs'
3-
import path from 'path'
4-
import { spawnSync } from 'child_process'
2+
import fs from 'node:fs'
3+
import path from 'node:path'
4+
import { spawnSync } from 'node:child_process'
55

66
// Types
77
import type { NuxtContext, PackageJsonEntry } from './types'
@@ -35,14 +35,17 @@ export async function renderNuxtTemplate (ctx: NuxtContext) {
3535
.replace('@latest', () => (isYarn1 ? '' : '@latest'))
3636
.replace(/^npm exec/, () => {
3737
// Prefer `pnpm dlx`, `yarn dlx`, or `bun x`
38-
if (pkgManager === 'pnpm')
38+
if (pkgManager === 'pnpm') {
3939
return 'pnpm dlx'
40+
}
4041

41-
if (pkgManager === 'yarn' && !isYarn1)
42+
if (pkgManager === 'yarn' && !isYarn1) {
4243
return 'yarn dlx'
44+
}
4345

44-
if (pkgManager === 'bun')
46+
if (pkgManager === 'bun') {
4547
return 'bun x'
48+
}
4649

4750
// Use `npm exec` in all other cases,
4851
// including Yarn 1.x and other custom npm clients.
@@ -87,7 +90,7 @@ function configurePackageJson ({
8790
nuxtPreset,
8891
}: NuxtContext) {
8992
const packageJson = path.join(projectRoot, 'package.json')
90-
const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf-8'))
93+
const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
9194
pkg.name = projectName
9295

9396
// prepare scripts
@@ -104,7 +107,7 @@ function configurePackageJson ({
104107
const dependencies: PackageJsonEntry[] = [
105108
['vuetify', versions.vuetify],
106109
]
107-
if (dependencies.length) {
110+
if (dependencies.length > 0) {
108111
addPackageObject('dependencies', dependencies, pkg)
109112
}
110113

@@ -118,21 +121,20 @@ function configurePackageJson ({
118121
]
119122
if (useNuxtModule) {
120123
devDependencies.push(['vuetify-nuxt-module', versions['vuetify-nuxt-module']])
121-
}
122-
else {
124+
} else {
123125
devDependencies.push(['upath', versions['upath']])
124126
devDependencies.push(['@vuetify/loader-shared', versions['@vuetify/loader-shared']])
125127
devDependencies.push(['vite-plugin-vuetify', versions['vite-plugin-vuetify']])
126128
}
127-
if (devDependencies.length) {
129+
if (devDependencies.length > 0) {
128130
addPackageObject('devDependencies', devDependencies, pkg)
129131
}
130132

131133
// add scripts
132134
addPackageObject('scripts', scripts, pkg, false)
133135

134136
// save package.json
135-
fs.writeFileSync(packageJson, JSON.stringify(pkg, null, 2), 'utf-8')
137+
fs.writeFileSync(packageJson, JSON.stringify(pkg, null, 2), 'utf8')
136138
}
137139

138140
function configureVuetify (ctx: NuxtContext, nuxtConfig: ReturnType<typeof parseModule>) {
@@ -283,9 +285,11 @@ function prepareNuxtModule (
283285
useBrowserThemeOnly: false,
284286
},
285287
},
286-
styles: ctx.nuxtPreset === 'nuxt-default' ? true : {
287-
configFile: 'assets/settings.scss',
288-
},
288+
styles: ctx.nuxtPreset === 'nuxt-default'
289+
? true
290+
: {
291+
configFile: 'assets/settings.scss',
292+
},
289293
}
290294
configureVuetify(ctx, nuxtConfig)
291295
addNuxtModule(
@@ -304,9 +308,11 @@ function prepareVuetifyModule (
304308
const config = configureVuetify(ctx, nuxtConfig)
305309

306310
// enable auto import and include styles
307-
const styles = ctx.nuxtPreset !== 'nuxt-essentials' ? true : {
308-
configFile: 'assets/settings.scss',
309-
}
311+
const styles = ctx.nuxtPreset === 'nuxt-essentials'
312+
? {
313+
configFile: 'assets/settings.scss',
314+
}
315+
: true
310316
config.vuetify = { autoImport: true, styles }
311317
}
312318

@@ -323,13 +329,12 @@ function prepareProject (ctx: NuxtContext) {
323329
// v4 compat: rootPath is `${rootPath}/app`
324330
// https://nuxt.com/docs/getting-started/upgrade#migrating-to-nuxt-4
325331
const nuxtConfigFile = path.join(rootPath, useNuxtV4Compat ? '../nuxt.config.ts' : 'nuxt.config.ts')
326-
const nuxtConfig = parseModule(fs.readFileSync(nuxtConfigFile, 'utf-8'))
332+
const nuxtConfig = parseModule(fs.readFileSync(nuxtConfigFile, 'utf8'))
327333

328334
// prepare nuxt config
329335
if (useNuxtModule) {
330336
prepareNuxtModule(ctx, nuxtConfig)
331-
}
332-
else {
337+
} else {
333338
prepareVuetifyModule(ctx, nuxtConfig)
334339
}
335340

@@ -368,7 +373,7 @@ function prepareProject (ctx: NuxtContext) {
368373
fs.writeFileSync(
369374
nuxtConfigFile,
370375
code,
371-
'utf-8',
376+
'utf8',
372377
)
373378

374379
// prepare resources

0 commit comments

Comments
 (0)