vuejs / eslint-config-typescript

ESLint configuration for Vue 3 + TypeScript projects
MIT License
128 stars 30 forks source link

[14.0.0-rc0] very slow compared to v13 #82

Closed chrisnruud closed 1 month ago

chrisnruud commented 1 month ago

Hello. We are in the early proess of migrating our common eslint libraries to eslint 9 and when using the rc - version of v14 to consolidate our config, it works like expected, but the execution is several magnitudes slower than the same configuration on v13 / eslint 8 - unless we are doing something wrong in our implementation (just a bare - bones configuration setup is significantly slower) - then we hope that we can be able to either debug or that this is fixed in the release :)

https://github.com/dsb-norge/eslint-config-dsb-vue3-ts/tree/eslint9 for reference

haoqunjiang commented 1 month ago

Would you happen to have an example project for me to benchmark?

One possible problem is that I missed a performance tweak that could improve the parsing speed of SFCs with no <script> blocks. It's fixed in 14.0.0-rc.1. Could you check it out and see if the fix works?

chrisnruud commented 1 month ago

Hi and thanks for the reply. All of our lager projects are not open source so I cannot share their code, I can probably get eslint --debug logs for runs using the eslint 8 and eslint 9 implementations , if not, I'll see what I can do to fork some of the internal code and clean it up for debug purposes

chrisnruud commented 1 month ago

I have released a pre-release of our shared config over at https://www.npmjs.com/package/@dsb-norge/eslint-config-dsb-vue3-ts as well

chrisnruud commented 1 month ago

Attached are the debug logs on a project using the same codebase running eslint 8 using the config from https://github.com/dsb-norge/eslint-config-dsb-vue3-ts/releases/tag/v2.2.0 and eslint 9 using the config from https://github.com/dsb-norge/eslint-config-dsb-vue3-ts/releases/tag/v3.0.0-0

eslint8.debug.txt eslint9.debug.txt

haoqunjiang commented 1 month ago

This .map call should be removed. Because not all configs returned from the ConfigArray can be applied to all .ts files. There's already a global ignore pattern so the ignores field here is redundant too. https://github.com/dsb-norge/eslint-config-dsb-vue3-ts/blob/29cf9b8fc7f0de57adb74746a47d8906996331ad/index.js#L9-L13

haoqunjiang commented 1 month ago

I read the debug logs and found a few anomalies.

Most notably, src/main.ts and vite.config.ts took way too long to parse and fix. You can try running lint on the two files with the DEBUG=typescript-eslint:*environment variable to see what's taking so much time. (https://typescript-eslint.io/troubleshooting/typed-linting/performance#slow-eslint-rules)

Vue files like src/components/applications/production/ProductionAttachmentsStep.vue also took longer to parse/fix than ESLint 8. But I suppose part of that can be attributed to the same reason as src/main.ts, so let's look into them first.

chrisnruud commented 1 month ago

added debug for main.ts and [vite.config.ts] using the commands main.ts.debug.txt vite.config.ts.debug.txt

DEBUG=typescript-eslint:* npx eslint ./vite.config.ts and DEBUG=typescript-eslint:* npx eslint ./src/main.ts

haoqunjiang commented 1 month ago

Thanks for the debug log! I found that I accidentally enabled projectService by default for all Vue files (should be off by default) 😅 And that incorrect configuration spread to normal .ts files due to the abovementioned .map call. So typescript-eslint was trying to get the type info of all the files, significantly slowing down the whole process…

It's fixed in 14.0.0-rc.2. Could you try it out?

robtesch commented 1 month ago

@haoqunjiang I was also having issues with 14.0.0-rc.0 and 14.0.0-rc.1 being incredibly slow on my project (5 - 10 min vs 10 - 30 sec on eslint 8). I've just tried 14.0.0-rc.2 and it's much much faster. I haven't done the detailed testing to check if it's as fast as 13.x with eslint 8, but it's definitely useable again. Thanks!

chrisnruud commented 1 month ago

@haoqunjiang Building our sharable config using rc2 is significantly faster than rc0 through 1 👍 I cannot say if it is _as_fast as using v13, but its definitely usable on even our largest application as - is!