Skip to content

Commit 6b59f83

Browse files
authored
Devex: Faster linting (#5611)
* devex: Keep the presubmit from wiping the lint cache * devex: typescript for eslint config * devex: upgrade lint plugins and dedupe lockfile * lint: Fix autofixable rules with updated vue linter * lint: Remove default for required prop * lint: temporarily disable warnings for missing defaults * deps: Update vue-tsc * lint: use the config convenience utility, switch to using projectService * lint: Fix redundant eslint config blocks and misplaced parser * lint: Split up parsing options for typescript vs vue files
1 parent 6a01b08 commit 6b59f83

File tree

22 files changed

+378
-561
lines changed

22 files changed

+378
-561
lines changed

eslint.config.js renamed to eslint.config.ts

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
55
import storybook from 'eslint-plugin-storybook'
66
import unusedImports from 'eslint-plugin-unused-imports'
77
import pluginVue from 'eslint-plugin-vue'
8+
import { defineConfig } from 'eslint/config'
89
import globals from 'globals'
910
import tseslint from 'typescript-eslint'
11+
import vueParser from 'vue-eslint-parser'
1012

11-
export default [
12-
{
13-
files: ['src/**/*.{js,mjs,cjs,ts,vue}']
14-
},
13+
const extraFileExtensions = ['.vue']
14+
15+
export default defineConfig([
1516
{
1617
ignores: [
1718
'src/scripts/*',
@@ -24,35 +25,49 @@ export default [
2425
]
2526
},
2627
{
28+
files: ['./**/*.{ts,mts}'],
2729
languageOptions: {
2830
globals: {
2931
...globals.browser,
3032
__COMFYUI_FRONTEND_VERSION__: 'readonly'
3133
},
32-
parser: tseslint.parser,
3334
parserOptions: {
34-
project: ['./tsconfig.json', './tsconfig.eslint.json'],
35+
parser: tseslint.parser,
36+
projectService: true,
37+
tsConfigRootDir: import.meta.dirname,
3538
ecmaVersion: 2020,
3639
sourceType: 'module',
37-
extraFileExtensions: ['.vue']
40+
extraFileExtensions
3841
}
3942
}
4043
},
41-
pluginJs.configs.recommended,
42-
...tseslint.configs.recommended,
43-
...pluginVue.configs['flat/recommended'],
44-
eslintPluginPrettierRecommended,
4544
{
46-
files: ['src/**/*.vue'],
45+
files: ['./**/*.vue'],
4746
languageOptions: {
47+
globals: {
48+
...globals.browser,
49+
__COMFYUI_FRONTEND_VERSION__: 'readonly'
50+
},
51+
parser: vueParser,
4852
parserOptions: {
49-
parser: tseslint.parser
53+
parser: tseslint.parser,
54+
projectService: true,
55+
tsConfigRootDir: import.meta.dirname,
56+
ecmaVersion: 2020,
57+
sourceType: 'module',
58+
extraFileExtensions
5059
}
5160
}
5261
},
62+
pluginJs.configs.recommended,
63+
tseslint.configs.recommended,
64+
pluginVue.configs['flat/recommended'],
65+
eslintPluginPrettierRecommended,
66+
storybook.configs['flat/recommended'],
5367
{
5468
plugins: {
5569
'unused-imports': unusedImports,
70+
// @ts-expect-error Bad types in the plugin
5671
'@intlify/vue-i18n': pluginI18n
5772
},
5873
rules: {
@@ -67,6 +82,7 @@ export default [
6782
'vue/multi-word-component-names': 'off', // TODO: fix
6883
'vue/no-template-shadow': 'off', // TODO: fix
6984
'vue/one-component-per-file': 'off', // TODO: fix
85+
'vue/require-default-prop': 'off', // TODO: fix -- this one is very worthwhile
7086
// Restrict deprecated PrimeVue components
7187
'no-restricted-imports': [
7288
'error',
@@ -135,6 +151,5 @@ export default [
135151
}
136152
]
137153
}
138-
},
139-
...storybook.configs['flat/recommended']
140-
]
154+
}
155+
])

lint-staged.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ export default {
33

44
'./**/*.{ts,tsx,vue,mts}': (stagedFiles) => [
55
...formatAndEslint(stagedFiles),
6-
'vue-tsc --noEmit'
6+
'pnpm typecheck'
77
]
88
}
99

1010
function formatAndEslint(fileNames) {
1111
return [
12-
`eslint --fix ${fileNames.join(' ')}`,
13-
`prettier --write ${fileNames.join(' ')}`
12+
`pnpm exec eslint --cache --fix ${fileNames.join(' ')}`,
13+
`pnpm exec prettier --cache --write ${fileNames.join(' ')}`
1414
]
1515
}

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
"build-storybook": "storybook build"
3939
},
4040
"devDependencies": {
41-
"@eslint/js": "^9.8.0",
41+
"@eslint/js": "^9.35.0",
4242
"@iconify-json/lucide": "^1.2.66",
4343
"@iconify/tailwind": "^1.2.0",
44-
"@intlify/eslint-plugin-vue-i18n": "^3.2.0",
44+
"@intlify/eslint-plugin-vue-i18n": "^4.1.0",
4545
"@lobehub/i18n-cli": "^1.25.1",
4646
"@nx/eslint": "21.4.1",
4747
"@nx/playwright": "21.4.1",
@@ -64,11 +64,11 @@
6464
"@vitest/ui": "^3.0.0",
6565
"@vue/test-utils": "^2.4.6",
6666
"eslint": "^9.34.0",
67-
"eslint-config-prettier": "^10.1.2",
68-
"eslint-plugin-prettier": "^5.2.6",
69-
"eslint-plugin-storybook": "^9.1.1",
70-
"eslint-plugin-unused-imports": "^4.1.4",
71-
"eslint-plugin-vue": "^9.27.0",
67+
"eslint-config-prettier": "^10.1.8",
68+
"eslint-plugin-prettier": "^5.5.4",
69+
"eslint-plugin-storybook": "^9.1.6",
70+
"eslint-plugin-unused-imports": "^4.2.0",
71+
"eslint-plugin-vue": "^10.4.0",
7272
"fs-extra": "^11.2.0",
7373
"globals": "^15.9.0",
7474
"happy-dom": "^15.11.0",
@@ -79,13 +79,13 @@
7979
"lint-staged": "^15.2.7",
8080
"nx": "21.4.1",
8181
"prettier": "^3.3.2",
82-
"storybook": "^9.1.1",
82+
"storybook": "^9.1.6",
8383
"tailwindcss": "^4.1.12",
8484
"tailwindcss-primeui": "^0.6.1",
8585
"tsx": "^4.15.6",
8686
"tw-animate-css": "^1.3.8",
8787
"typescript": "^5.4.5",
88-
"typescript-eslint": "^8.42.0",
88+
"typescript-eslint": "^8.44.0",
8989
"unplugin-icons": "^0.22.0",
9090
"unplugin-vue-components": "^0.28.0",
9191
"uuid": "^11.1.0",
@@ -94,7 +94,8 @@
9494
"vite-plugin-html": "^3.2.2",
9595
"vite-plugin-vue-devtools": "^7.7.6",
9696
"vitest": "^3.2.4",
97-
"vue-tsc": "^2.1.10",
97+
"vue-eslint-parser": "^10.2.0",
98+
"vue-tsc": "^3.0.7",
9899
"zip-dir": "^2.0.0",
99100
"zod-to-json-schema": "^3.24.1"
100101
},

0 commit comments

Comments
 (0)