Skip to content

Commit 3b66829

Browse files
committed
Add ESLint support
1 parent eb0fcda commit 3b66829

File tree

5 files changed

+49
-11
lines changed

5 files changed

+49
-11
lines changed

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type Config = {
6767
includeGithubPages: boolean
6868
includePlayground: boolean
6969
includeExamples: boolean
70+
includeEsLint: boolean
7071
}
7172

7273
async function init() {
@@ -125,6 +126,7 @@ async function init() {
125126
process.exit(1)
126127
}
127128

129+
const includeEsLint = await togglePrompt('Include ESLint?', true, 'Yes', 'No')
128130
const includeDocs = await togglePrompt('Include VitePress for documentation?', true)
129131
const includeGithubPages = includeDocs && await togglePrompt('Include GitHub Pages config for documentation?')
130132
const includePlayground = await togglePrompt('Include playground application for development?', true)
@@ -160,7 +162,8 @@ async function init() {
160162
includeDocs,
161163
includeGithubPages,
162164
includePlayground,
163-
includeExamples
165+
includeExamples,
166+
includeEsLint
164167
}
165168

166169
copyTemplate('base', config)
@@ -177,6 +180,10 @@ async function init() {
177180
copyTemplate('playground', config)
178181
}
179182

183+
if (config.includeEsLint) {
184+
copyTemplate('eslint', config)
185+
}
186+
180187
console.log('Project created')
181188
console.log('Note: pnpm must be used as the package manager')
182189
console.log()

src/template/base/config/package.json.ejs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"clean": "pnpm run -r clean",
66
"build": "pnpm run -r build",
77
"type-check": "pnpm run -r type-check",
8-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
8+
<%_ if (config.includeEsLint) { _%>
9+
"lint": "eslint",
10+
"lint:fix": "eslint --fix",
11+
<%_ } _%>
912
<%_ if (config.includePlayground) { _%>
1013
"dev": "pnpm run --filter ./packages/playground -r dev",
1114
<%_ } _%>
@@ -18,18 +21,29 @@
1821
"preinstall": "node scripts/preinstall.js",
1922
"postinstall": "simple-git-hooks"
2023
},
24+
<%_ if (config.includeEsLint) { _%>
2125
"simple-git-hooks": {
2226
"pre-commit": "pnpm run type-check && pnpm exec lint-staged"
2327
},
2428
"lint-staged": {
2529
"*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix"
2630
},
31+
<%_ } else { _%>
32+
"simple-git-hooks": {
33+
"pre-commit": "pnpm run type-check"
34+
},
35+
<%_ } _%>
2736
"devDependencies": {
37+
<%_ if (config.includeEsLint) { _%>
38+
"@eslint/compat": "^1.2.6",
2839
"@typescript-eslint/parser": "^8.23.0",
40+
"@vitest/eslint-plugin": "1.1.25",
2941
"@vue/eslint-config-typescript": "^14.3.0",
3042
"eslint": "^9.18.0",
3143
"eslint-plugin-vue": "^9.32.0",
44+
"jiti": "^2.4.2",
3245
"lint-staged": "^15.4.3",
46+
<%_ } _%>
3347
"simple-git-hooks": "^2.11.1"
3448
}
3549
}

src/template/base/config/packages/@projectName@/package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,7 @@
5050
"vite-plugin-dts": "^4.5.0",
5151
"vitest": "^3.0.2",
5252
"vue": "^3.5.13",
53-
"vue-tsc": "^2.2.0",
54-
55-
"@vitest/eslint-plugin": "1.1.25",
56-
"@vue/eslint-config-typescript": "^14.3.0",
57-
"eslint": "^9.18.0",
58-
"eslint-plugin-vue": "^9.32.0",
59-
"jiti": "^2.4.2",
60-
"vite-plugin-vue-devtools": "^7.7.0"
53+
"vue-tsc": "^2.2.0"
6154
},
6255
"scripts": {
6356
"clean": "rimraf dist coverage",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"files": [".eslintrc.cjs"],
2+
"files": ["eslint.config.mts"],
33
"include": ["scripts/**/*"]
44
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
4+
import { includeIgnoreFile } from '@eslint/compat'
5+
import pluginVue from 'eslint-plugin-vue'
6+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
7+
import pluginVitest from '@vitest/eslint-plugin'
8+
9+
export default defineConfigWithVueTs(
10+
{
11+
name: 'app/files-to-lint',
12+
files: ['**/*.{ts,mts,vue}'],
13+
},
14+
15+
includeIgnoreFile(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '.gitignore')),
16+
17+
pluginVue.configs['flat/essential'],
18+
vueTsConfigs.recommended,
19+
20+
{
21+
...pluginVitest.configs.recommended,
22+
files: ['src/**/__tests__/*'],
23+
},
24+
)

0 commit comments

Comments
 (0)