Skip to content

Commit 5983d48

Browse files
committed
feat: also modify project scripts for easier setup
1 parent 37c4dcb commit 5983d48

File tree

4 files changed

+92
-5
lines changed

4 files changed

+92
-5
lines changed

bin/create-eslint-config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ const { pkg: pkgToExtend, files } = createConfig({
191191
needsOxlint,
192192
})
193193

194-
// TODO:
195-
// Add `lint` command to package.json
196-
// Add a `format` command to package.json when prettier is used
197-
198194
deepMerge(pkg, pkgToExtend)
199195

200196
// Write `package.json` back

index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default function createConfig({
2020

2121
const pkg = {
2222
devDependencies: pickDependencies(['eslint', 'eslint-plugin-vue']),
23+
scripts: {}
2324
}
2425

2526
const fileExtensions = ['vue']
@@ -54,14 +55,19 @@ export default function createConfig({
5455

5556
if (needsOxlint) {
5657
additionalConfigs.push({
57-
devDependencies: pickDependencies(['oxlint', 'eslint-plugin-oxlint']),
58+
devDependencies: pickDependencies(['oxlint', 'eslint-plugin-oxlint', 'npm-run-all2']),
5859
afterVuePlugin: [
5960
{
6061
importer: "import oxlint from 'eslint-plugin-oxlint'",
6162
content: "oxlint.configs['flat/recommended'],",
6263
},
6364
],
6465
})
66+
pkg.scripts['lint:eslint'] = 'eslint . --fix'
67+
pkg.scripts['lint:oxlint'] = 'oxlint . --fix'
68+
pkg.scripts.lint = 'run-s lint:*'
69+
} else {
70+
pkg.scripts.lint = 'eslint . --fix'
6571
}
6672

6773
if (needsPrettier) {
@@ -78,6 +84,7 @@ export default function createConfig({
7884
},
7985
],
8086
})
87+
pkg.scripts.format = 'prettier --write src/'
8188
}
8289

8390
const configsBeforeVuePlugin = [],
@@ -115,6 +122,10 @@ export default function createConfig({
115122
)
116123
}
117124

125+
// TODO:
126+
// Add `lint` command to package.json
127+
// Add a `format` command to package.json when prettier is used
128+
118129
return {
119130
pkg,
120131
files,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"eslint": "^9.13.0",
4646
"eslint-plugin-oxlint": "^0.11.0",
4747
"eslint-plugin-vue": "^9.30.0",
48+
"npm-run-all2": "^7.0.1",
4849
"oxlint": "^0.11.0",
4950
"prettier": "^3.3.3",
5051
"typescript": "~5.6.0"

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)