Skip to content

Commit fe4d69f

Browse files
committed
add eslint option
1 parent 31cef1a commit fe4d69f

File tree

7 files changed

+74
-17
lines changed

7 files changed

+74
-17
lines changed

eslint.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import antfu from '@antfu/eslint-config'
2+
23
export default antfu({
34
type: 'lib',
45
stylistic: {

eslint/eslint.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import antfu from '@antfu/eslint-config'
2+
3+
export default antfu({
4+
stylistic: {
5+
indent: 2,
6+
quotes: 'single',
7+
},
8+
typescript: true,
9+
vue: true,
10+
jsonc: false,
11+
yaml: false,
12+
})

index.cjs

+21-1
Original file line numberDiff line numberDiff line change
@@ -7866,6 +7866,7 @@ async function init() {
78667866
const vueuse = argv2.vueuse;
78677867
const iconpark = argv2.iconpark;
78687868
const githubPage = argv2.githubPage;
7869+
const eslintConfig = argv2.eslintConfig;
78697870
const cwd2 = process2.cwd();
78707871
let result = {};
78717872
result = await (0, import_prompts.default)(
@@ -7912,6 +7913,13 @@ async function init() {
79127913
message: () => {
79137914
return `Use GitHub Page to deploy your project?`;
79147915
}
7916+
},
7917+
{
7918+
name: "useEslintConfig",
7919+
type: () => eslintConfig ? null : "confirm",
7920+
message: () => {
7921+
return `Use @antfu/eslint-config (Anthony's ESLint config preset)?`;
7922+
}
79157923
}
79167924
],
79177925
{
@@ -7926,7 +7934,8 @@ async function init() {
79267934
useVueUse = argv2.vueuse,
79277935
useUnoCss = argv2.unocss,
79287936
useIconPark = argv2.iconpark,
7929-
useGithubPage = argv2.githubPage
7937+
useGithubPage = argv2.githubPage,
7938+
useEslintConfig = argv2.eslintConfig
79307939
} = result;
79317940
const root = import_node_path.default.join(cwd2, targetDir);
79327941
if (import_node_fs.default.existsSync(root) && shouldOverwrite) {
@@ -7951,6 +7960,17 @@ Scaffolding project in ${root}...`);
79517960
if (useIconPark) {
79527961
packageJson.dependencies["@icon-park/vue-next"] = "latest";
79537962
}
7963+
if (useEslintConfig) {
7964+
packageJson.devDependencies["@antfu/eslint-config"] = "latest";
7965+
packageJson.devDependencies.eslint = "latest";
7966+
packageJson.scripts = {
7967+
...packageJson.scripts,
7968+
"lint": "eslint .",
7969+
"lint:fix": "eslint . --fix"
7970+
};
7971+
const eslintTemplateRoot = import_node_path.default.join(__dirname, "./eslint");
7972+
await FileUtils.copyFolderRecursive(eslintTemplateRoot, root);
7973+
}
79547974
import_node_fs.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
79557975
if (useGithubPage) {
79567976
const githubPageTemplateRoot = import_node_path.default.join(__dirname, "./github-page");

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-widget",
3-
"version": "24.1.1-beta.43",
3+
"version": "24.1.1-beta.45",
44
"private": false,
55
"description": "An easy way to start a Widget project",
66
"author": "Neo Fu <[email protected]>",
@@ -12,7 +12,9 @@
1212
"files": [
1313
"index.cjs",
1414
"template",
15-
"unocss"
15+
"unocss",
16+
"github-page",
17+
"eslint"
1618
],
1719
"engines": {
1820
"node": ">=v16.20.0"
@@ -24,6 +26,7 @@
2426
"test": "node index.cjs",
2527
"update:version": "esno scripts/updateVersion.ts",
2628
"pnpm:publish": "npm run build && pnpm publish --no-git-checks",
29+
"link": "pnpm link --global",
2730
"lint:fix": "eslint"
2831
},
2932
"publishConfig": {

scripts/updateVersion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'node:fs'
2-
import packageJson from 'package-json'
32
import ora from 'ora'
3+
import packageJson from 'package-json'
44

55
const spinner = ora('Loading unicorns').start()
66
async function run() {

src/index.ts

+21
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ async function init() {
6868
const vueuse = argv.vueuse
6969
const iconpark = argv.iconpark
7070
const githubPage = argv.githubPage
71+
const eslintConfig = argv.eslintConfig
7172

7273
const cwd = process.cwd()
7374
let result: {
@@ -77,6 +78,7 @@ async function init() {
7778
useUnoCss?: boolean
7879
useIconPark?: boolean
7980
useGithubPage?: boolean
81+
useEslintConfig?: boolean
8082
} = {}
8183
result = await prompts(
8284
[
@@ -128,6 +130,13 @@ async function init() {
128130
return `Use GitHub Page to deploy your project?`
129131
},
130132
},
133+
{
134+
name: 'useEslintConfig',
135+
type: () => (eslintConfig ? null : 'confirm'),
136+
message: () => {
137+
return `Use @antfu/eslint-config (Anthony's ESLint config preset)?`
138+
},
139+
},
131140
],
132141
{
133142
onCancel: () => {
@@ -145,6 +154,7 @@ async function init() {
145154
useUnoCss = argv.unocss,
146155
useIconPark = argv.iconpark,
147156
useGithubPage = argv.githubPage,
157+
useEslintConfig = argv.eslintConfig,
148158
} = result
149159

150160
const root = path.join(cwd, targetDir)
@@ -175,6 +185,17 @@ async function init() {
175185
if (useIconPark) {
176186
packageJson.dependencies['@icon-park/vue-next'] = 'latest'
177187
}
188+
if (useEslintConfig) {
189+
packageJson.devDependencies['@antfu/eslint-config'] = 'latest'
190+
packageJson.devDependencies.eslint = 'latest'
191+
packageJson.scripts = {
192+
...packageJson.scripts,
193+
'lint': 'eslint .',
194+
'lint:fix': 'eslint . --fix',
195+
}
196+
const eslintTemplateRoot = path.join(__dirname, './eslint')
197+
await FileUtils.copyFolderRecursive(eslintTemplateRoot, root)
198+
}
178199
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
179200
if (useGithubPage) {
180201
const githubPageTemplateRoot = path.join(__dirname, './github-page')

template/package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
"update:widgetjs": "widget dependencies -t remote"
1111
},
1212
"dependencies": {
13-
"@vueuse/core": "^11.0.1",
13+
"@vueuse/core": "latest",
1414
"@widget-js/core": "latest",
1515
"@widget-js/vue3": "latest",
16-
"element-plus": "^2.8.1",
17-
"vue": "^3.3.11",
18-
"vue-router": "^4.2.5"
16+
"element-plus": "latest",
17+
"vue": "latest",
18+
"vue-router": "latest"
1919
},
2020
"devDependencies": {
21-
"@tsconfig/node18": "^18.2.2",
22-
"@types/node": "^18.19.3",
23-
"@vitejs/plugin-vue": "^4.5.2",
24-
"@vue/tsconfig": "^0.5.0",
21+
"@tsconfig/node18": "latest",
22+
"@types/node": "latest",
23+
"@vitejs/plugin-vue": "latest",
24+
"@vue/tsconfig": "latest",
2525
"@widget-js/cli": "latest",
2626
"@widget-js/vite-plugin-widget": "latest",
27-
"typescript": "~5.3.0",
28-
"unplugin-auto-import": "^0.11.4",
29-
"unplugin-vue-components": "^0.22.9",
30-
"vite": "^5.0.10",
31-
"vue-tsc": "^1.8.25"
27+
"typescript": "latest",
28+
"unplugin-auto-import": "latest",
29+
"unplugin-vue-components": "latest",
30+
"vite": "latest",
31+
"vue-tsc": "latest"
3232
}
3333
}

0 commit comments

Comments
 (0)