Skip to content

Commit 9ef5975

Browse files
committed
feat: update to eslint v9 & flat config
1 parent df16ed3 commit 9ef5975

File tree

3 files changed

+99
-60
lines changed

3 files changed

+99
-60
lines changed

template/base/package.json.ejs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"format": "prettier --write \"**/*.{js<% if (needsEslint) { %>,cjs<% } %><% if (needsTypeScript) { %>,ts<% } %>,json,css,html,md}\"",
1515
<%_ } _%>
1616
<%_ if (needsEslint) { _%>
17-
"lint<% if (needsStylelint) { %>:script<% } %>": "eslint --ext .js,.cjs<% if (needsTypeScript) { %>,.ts<% } %> .",
17+
"lint<% if (needsStylelint) { %>:script<% } %>": "eslint .",
1818
<%_ } _%>
1919
<%_ if (needsStylelint) { _%>
2020
"lint<% if (needsEslint) { %>:style<% } %>": "stylelint \"src/**/*.css\"",
@@ -30,62 +30,64 @@
3030
},
3131
"dependencies": {
3232
"@babel/runtime": "^7.25.0",
33-
"@vue-mini/core": "^1.0.1",
33+
"@vue-mini/core": "^1.0.2",
3434
"promise-polyfill": "^8.3.0"
3535
},
3636
"devDependencies": {
37-
"@babel/core": "^7.24.9",
37+
"@babel/core": "^7.25.2",
3838
"@babel/plugin-transform-runtime": "^7.24.7",
39-
"@babel/preset-env": "^7.25.0",
39+
"@babel/preset-env": "^7.25.3",
4040
<%_ if (needsTypeScript) { _%>
4141
"@babel/preset-typescript": "^7.24.7",
4242
<%_ } _%>
43-
"@babel/traverse": "^7.25.0",
44-
"@babel/types": "^7.25.0",
43+
"@babel/traverse": "^7.25.3",
44+
"@babel/types": "^7.25.2",
4545
"@rollup/plugin-commonjs": "^26.0.1",
4646
"@rollup/plugin-node-resolve": "^15.2.3",
4747
"@rollup/plugin-replace": "^5.0.7",
4848
"@rollup/plugin-terser": "^0.4.4",
4949
<%_ if (needsTypeScript && needsVitest) { _%>
50-
"@types/node": "^20.14.12",
51-
<%_ } _%>
52-
<%_ if (needsTypeScript && needsEslint) { _%>
53-
"@typescript-eslint/eslint-plugin": "^7.17.0",
54-
"@typescript-eslint/parser": "^7.17.0",
50+
"@types/node": "^22.0.2",
5551
<%_ } _%>
5652
<%_ if (needsVitest) { _%>
57-
"@vitest/coverage-v8": "^2.0.4",
53+
"@vitest/coverage-v8": "^2.0.5",
5854
<%_ } _%>
5955
"babel-plugin-autocomplete-index": "^0.2.0",
6056
"babel-plugin-module-resolver": "^5.0.2",
6157
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
6258
"chokidar": "^3.6.0",
6359
"cross-env": "^7.0.3",
6460
<%_ if (needsEslint) { _%>
65-
"eslint": "^8.57.0",
61+
"eslint": "^9.8.0",
6662
<%_ if (needsPrettier) { _%>
6763
"eslint-config-prettier": "^9.1.0",
6864
<%_ } _%>
6965
<%_ } _%>
7066
"fs-extra": "^11.2.0",
67+
<%_ if (needsEslint) { _%>
68+
"globals": "^15.9.0",
69+
<%_ } _%>
7170
"kolorist": "^1.8.0",
7271
"postcss": "^8.4.40",
7372
"postcss-load-config": "^6.0.1",
7473
"postcss-pxtorpx-pro": "^2.0.0",
7574
<%_ if (needsPrettier) { _%>
7675
"prettier": "^3.3.3",
7776
<%_ } _%>
78-
"rollup": "^4.19.1",
77+
"rollup": "^4.19.2",
7978
<%_ if (needsStylelint) { _%>
80-
"stylelint": "^16.7.0",
79+
"stylelint": "^16.8.1",
8180
"stylelint-config-standard": "^36.0.1",
8281
<%_ } _%>
8382
"terser": "^5.31.3",
8483
<%_ if (needsTypeScript) { _%>
8584
"typescript": "^5.5.4",
8685
<%_ } _%>
86+
<%_ if (needsTypeScript && needsEslint) { _%>
87+
"typescript-eslint": "^8.0.0",
88+
<%_ } _%>
8789
<%_ if (needsVitest) { _%>
88-
"vitest": "^2.0.4",
90+
"vitest": "^2.0.5",
8991
<%_ } _%>
9092
trailing-comma
9193
},

template/eslint/_eslintrc.cjs.ejs

Lines changed: 0 additions & 44 deletions
This file was deleted.

template/eslint/eslint.config.js.ejs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import globals from 'globals';
2+
import eslint from '@eslint/js';
3+
<%_ if (needsTypeScript) { _%>
4+
import tseslint from 'typescript-eslint';
5+
<%_ } _%>
6+
<%_ if (needsPrettier) { _%>
7+
import prettier from 'eslint-config-prettier';
8+
<%_ } _%>
9+
10+
<%_ if (needsTypeScript) { _%>
11+
const config = [
12+
{
13+
files: ['**/*.js', '**/*.ts'],
14+
<%_ if (needsVitest) { _%>
15+
ignores: ['dist/**/*', 'coverage/**/*'],
16+
<%_ } else { _%>
17+
ignores: ['dist/**/*'],
18+
<%_ } _%>
19+
linterOptions: {
20+
reportUnusedDisableDirectives: true,
21+
},
22+
...eslint.configs.recommended,
23+
},
24+
{
25+
files: ['**/*.js'],
26+
languageOptions: {
27+
globals: {
28+
...globals.node,
29+
},
30+
},
31+
<%_ if (needsPrettier) { _%>
32+
...prettier,
33+
<%_ } _%>
34+
},
35+
...tseslint.configs.recommendedTypeChecked.map((c) => ({
36+
...c,
37+
files: ['**/*.ts'],
38+
})),
39+
{
40+
files: ['**/*.ts'],
41+
languageOptions: {
42+
parserOptions: {
43+
projectService: true,
44+
tsconfigRootDir: import.meta.dirname,
45+
},
46+
},
47+
<%_ if (needsPrettier) { _%>
48+
...prettier,
49+
<%_ } _%>
50+
},
51+
];
52+
<%_ } else { _%>
53+
const config = [
54+
{
55+
files: ['**/*.js'],
56+
<%_ if (needsVitest) { _%>
57+
ignores: ['dist/**/*', 'coverage/**/*'],
58+
<%_ } else { _%>
59+
ignores: ['dist/**/*'],
60+
<%_ } _%>
61+
linterOptions: {
62+
reportUnusedDisableDirectives: true,
63+
},
64+
languageOptions: {
65+
globals: {
66+
...globals.node,
67+
},
68+
},
69+
<%_ if (needsPrettier) { _%>
70+
rules: {
71+
...eslint.configs.recommended.rules,
72+
...prettier.rules,
73+
},
74+
<%_ } else { _%>
75+
...eslint.configs.recommended,
76+
<%_ } _%>
77+
},
78+
];
79+
<%_ } _%>
80+
81+
export default config;

0 commit comments

Comments
 (0)