Skip to content

Commit fba5a1f

Browse files
committed
Align the project's own configuration with the configuration it generates
1 parent c092330 commit fba5a1f

File tree

14 files changed

+1061
-22
lines changed

14 files changed

+1061
-22
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
root = true
2+
13
[*]
24
charset = utf-8
35
indent_style = space
46
indent_size = 2
57
end_of_line = lf
68
insert_final_newline = true
79
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
indent_size = 4
13+
trim_trailing_whitespace = false

eslint.config.mts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 stylistic from '@stylistic/eslint-plugin'
7+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
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+
stylistic.configs.customize({
21+
commaDangle: 'never'
22+
})
23+
)

package.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,31 @@
66
"node": ">=v18.3.0"
77
},
88
"devDependencies": {
9+
"@eslint/compat": "^1.2.6",
10+
"@stylistic/eslint-plugin": "^4.0.0",
11+
"@typescript-eslint/parser": "^8.23.0",
12+
"@vue/eslint-config-typescript": "^14.3.0",
13+
"eslint": "^9.18.0",
14+
"eslint-plugin-vue": "^9.32.0",
15+
"jiti": "^2.4.2",
916
"lint-staged": "^15.4.3",
1017
"simple-git-hooks": "^2.11.1"
1118
},
1219
"scripts": {
1320
"clean": "pnpm run -r clean",
1421
"docs:dev": "pnpm run --filter ./packages/docs -r dev",
1522
"docs:build": "pnpm run --filter ./packages/docs -r build",
23+
"type-check": "pnpm run -r type-check",
24+
"lint": "eslint",
25+
"lint:fix": "eslint --fix",
1626
"build": "pnpm run -r build",
17-
"preinstall": "npx only-allow pnpm"
27+
"preinstall": "node scripts/preinstall.js",
28+
"postinstall": "simple-git-hooks"
29+
},
30+
"simple-git-hooks": {
31+
"pre-commit": "pnpm run type-check && pnpm exec lint-staged"
32+
},
33+
"lint-staged": {
34+
"*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint"
1835
}
1936
}

packages/create-vue-lib/src/index.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ async function prompt(options: Omit<PromptObject, 'name'>) {
2222
)
2323

2424
return result.name
25-
} catch (cancelled) {
25+
}
26+
catch (cancelled) {
2627
console.log(cancelled.message)
2728
process.exit(1)
2829
}
@@ -125,13 +126,15 @@ function processArgs(): Args {
125126
})
126127

127128
argValues = args.values
128-
} catch (err) {
129+
}
130+
catch (err) {
129131
if (err.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION') {
130132
console.log('Error:')
131133
console.log(err.message)
132134
console.log('See --help for valid options')
133135
process.exit(1)
134-
} else {
136+
}
137+
else {
135138
throw err
136139
}
137140
}
@@ -201,7 +204,8 @@ async function init() {
201204
if (fs.existsSync(path.join(targetDirPath, 'package.json'))) {
202205
console.log('Target directory already contains package.json')
203206
}
204-
} else {
207+
}
208+
else {
205209
if (fs.existsSync(targetDirPath)) {
206210
console.log('Target directory already exists')
207211
}
@@ -399,14 +403,16 @@ function copyFiles(templateFile: string, config: Config) {
399403
}
400404

401405
fs.writeFileSync(target, content)
402-
} else if (['package.json', 'vite.config.mts', 'config.mts', 'index.md', 'introduction.md', 'App.vue', 'tsconfig.app.json', 'env.d.ts'].includes(filename)) {
406+
}
407+
else if (['package.json', 'vite.config.mts', 'config.mts', 'index.md', 'introduction.md', 'App.vue', 'tsconfig.app.json', 'env.d.ts'].includes(filename)) {
403408
const template = fs.readFileSync(templatePath, 'utf-8')
404409
const content = template
405410
.replace(/@projectName@/g, config.mainPackageDirName)
406411
.replace(new RegExp(`@(${Object.keys(config).join('|')})@`, 'g'), (all, setting) => config[setting] ?? all)
407412

408413
fs.writeFileSync(targetPath, content)
409-
} else {
414+
}
415+
else {
410416
fs.copyFileSync(templatePath, targetPath)
411417
}
412418
}

packages/docs/.vitepress/config.mts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { resolve } from 'node:path'
2-
31
import { defineConfigWithTheme } from 'vitepress'
42

53
export default defineConfigWithTheme({

packages/docs/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

packages/docs/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
"scripts": {
44
"clean": "rimraf dist .vitepress/cache",
55
"dev": "vitepress dev .",
6-
"build": "vitepress build .",
7-
"preview": "vitepress preview ."
6+
"type-check:code": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
7+
"type-check:config": "vue-tsc --noEmit -p tsconfig.node.json --composite false",
8+
"type-check": "run-p -c type-check:*",
9+
"build:only": "vitepress build .",
10+
"build": "run-p -c type-check \"build:only {@}\" --",
11+
"preview": "vitepress preview .",
12+
"preinstall": "node ../../scripts/preinstall.js"
813
},
914
"dependencies": {
1015
"vue": "^3.5.13"

packages/docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup>
1+
<script setup lang="ts">
22
import { useRouter, withBase } from 'vitepress'
33
import { onMounted } from 'vue'
44

packages/docs/tsconfig.app.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "@vue/tsconfig/tsconfig.dom.json",
3+
"include": [
4+
"env.d.ts",
5+
"src/**/*",
6+
"src/**/*.vue",
7+
".vitepress/theme/**/*",
8+
".vitepress/theme/**/*.vue",
9+
"src/**/*.md"
10+
],
11+
"vueCompilerOptions": {
12+
"vitePressExtensions": [".md"]
13+
}
14+
}

packages/docs/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files": [],
3+
"references": [
4+
{
5+
"path": "./tsconfig.node.json"
6+
},
7+
{
8+
"path": "./tsconfig.app.json"
9+
}
10+
]
11+
}

0 commit comments

Comments
 (0)