Closed salamaashoush closed 1 year ago
First of all, you're using the setting to auto-fix all (both linting and non-ESLint related) problems when saving a file. If you only want to auto-fix ESLint problems, try using:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
Another optimization is to set "eslint.codeActionsOnSave.mode": "problems"
. The setting description says that it will "fix only reported problems that have non-overlapping textual edits. This option runs a lot faster.":
https://github.com/microsoft/vscode-eslint/blob/4b92c12af15d41f76417bde9571cb56f08ec3d0f/package.json#L406-L419
Alternatively, you can also try explicitly listing the linting rules that you want to auto-fix with "eslint.codeActionsOnSave.rules"
. The README has more information about how you can configure this setting.
https://github.com/microsoft/vscode-eslint/blob/4b92c12af15d41f76417bde9571cb56f08ec3d0f/package.json#L420-L433
I tried"eslint.codeActionsOnSave.mode": "problems"
but still no luck, also I was already using "source.fixAll.eslint": true
The slowdown is usually caused by specific Eslint rules and unfortunately there is in most of the times nothing the extension itself can do about it. The recommended way to address this is to:
eslint.debug
setting and inspect the output in the ESLint channel.eslint.codeActionsOnSave.rules
settingIf none of the rules is slow can you please provide us with a GitHub repository we can clone that demos the slowness.
I have the same problem
I guess it may be caused by a combination of:
plugin:vue/vue3-recommended
+ @vue/eslint-config-standard-with-typescript
or @vue/eslint-config-airbnb-with-typescript
)quasar
) "editor.defaultFormatter": "Vue.volar",
"_editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"],
tl;dr 3 passes in 9192ms on save after formatting with Volar
Honestly, being able to see ESlint badge in the bottom bar saying "linting (pass 4)" atfer 2s lag would be good enough solution to one half of a problem
It would easily solve the "why is ESLint does not work", by showing user that the linter is actually working, and that the problem is on the user's side (too many rules, slow rules, etc)
Adding such a status is actually a good idea. I capture it here: https://github.com/microsoft/vscode-eslint/issues/1542
Found out why it is slow in my case, we recently added @typescript-eslint/no-unnecessary-condition
rule, and it required us to set parserOptions.project
in my eslint configs, and when I remove those it works just fine
so I guess this issue is not relevant here, but maybe on https://github.com/typescript-eslint/typescript-eslint, WDYT @dbaeumer @MariaSolOs ?
@salamaashoush I do agree that this doesn't sound like an issue with this extension, but do note that typescript-eslint
has a disclaimer in their docs about performance being affected with type-aware linting, so I wouldn't suggest blaming them either (since they have the performance warning).
@MariaSolOs is right. There are two kinds of eslint problems flaged by typescript-eslint:
I will close the issue since there is little, I can do to fix this besides the rule customizations I already offer.
This maybe could use
^ a useless rule taking up over 50% of time
Also IMO the first suggestion the user should be able to find in this thread should be
Please run
$ TIMING=1 DEBUG=eslint:cli-engine yarn eslint src/components/NewNode.vue --fix
and disable that useless rule which is using 90% of the time
For the user feedback there is https://github.com/microsoft/vscode-eslint/issues/1542. I do have a writeup as well how to tackle it. We could reference it from the user feedback (https://github.com/microsoft/vscode-eslint/issues/1344)
I was having the same issue, and just solved it with configuring eslint.workingDirectories
properly for my monorepo.
I have.eslintrc
and .eslintignore
at my root folder. And each workspace under packages/
folder has it's own .eslintrc
and .eslintignore
. So
// specifying `eslint.workingDirectories` is required to make vscode-eslint work properly with yarn workspaces (monorepo)
// From the docs: If executing ESLint in the terminal requires you to change the working directory in the terminal into a sub folder then it is usually necessary to tweak this setting
// read more: https://github.com/microsoft/vscode-eslint/blob/24d2ac45b2fe1b8cc8639038b724ba48610da8e2/README.md?plain=1#L238
"eslint.workingDirectories": [{ "pattern": "./packages/*/" }],
Try adding this line to your setttings.json
"typescript.tsdk": "./node_modules/typescript/lib"
This is assuming you are using a mac and you have node_modules in your root directory.
Type: Performance Issue
when I add eslint code action on saving, saving files becomes really slow
I ran the Bisect and found that the problem comes from eslint extension
here are my eslint configs
Extension version: 2.2.6 VS Code version: Code 1.72.2 (d045a5eda657f4d7b676dedbfa7aab8207f8a075, 2022-10-12T22:16:30.254Z) OS version: Darwin x64 22.1.0 Modes: Sandboxed: No
System Info
|Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|4, 4, 4| |Memory (System)|16.00GB (3.02GB free)| |Process Argv|--crash-reporter-id 2a886961-8a82-4e90-b3e3-ee50e266bb8a| |Screen Reader|no| |VM|0%|
Process Info
``` CPU % Mem MB PID Process 17 197 71754 code main 0 82 71757 gpu-process 0 16 71760 utility-network-service 0 164 71761 window (player.rs — lp-bevy-tutorial) 0 508 71762 window (settings.json — BY-1933-add-drawer-component) 0 213 71853 extensionHost 0 16 71992 /Users/salamaashoush/.vscode/extensions/rust-lang.rust-analyzer-0.3.1248-darwin-x64/server/rust-analyzer 0 16 72346 /Users/salamaashoush/.rustup/toolchains/nightly-x86_64-apple-darwin/libexec/rust-analyzer-proc-macro-srv 0 33 72489 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node /Users/salamaashoush/.vscode/extensions/streetsidesoftware.code-spell-checker-2.10.1/packages/_server/dist/main.js --node-ipc --clientProcessId=71853 0 246 71855 shared-process 0 49 71856 ptyHost 0 0 72128 /usr/local/bin/fish -l 0 0 72153 /usr/local/bin/fish -l 0 16 71946 fileWatcher 0 49 77530 fileWatcher 0 0 77854 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= 0 82 75421 utility 0 82 77527 issue-reporter 0 573 77528 extensionHost 0 180 77551 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --serverMode partialSemantic --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName /var/folders/q7/z945j8vs7bq29s2zd6qbxdyh0000gn/T/vscode-typescript501/4c6703e1833fef8bf57c/tscancellation-b149849d0c5be99878a4.tmp* --globalPlugins typescript-styled-plugin,typescript-svelte-plugin,@vsintellicode/typescript-intellicode-plugin,ms-vsintellicode-typescript --pluginProbeLocations /Users/salamaashoush/.vscode/extensions/styled-components.vscode-styled-components-1.7.5,/Users/salamaashoush/.vscode/extensions/svelte.svelte-vscode-106.2.0,/Users/salamaashoush/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.2.28,/Users/salamaashoush/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.2.28 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc 1 541 77552 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/q7/z945j8vs7bq29s2zd6qbxdyh0000gn/T/vscode-typescript501/4c6703e1833fef8bf57c/tscancellation-d7029d0136100a47dda5.tmp* --globalPlugins typescript-styled-plugin,typescript-svelte-plugin,@vsintellicode/typescript-intellicode-plugin,ms-vsintellicode-typescript --pluginProbeLocations /Users/salamaashoush/.vscode/extensions/styled-components.vscode-styled-components-1.7.5,/Users/salamaashoush/.vscode/extensions/svelte.svelte-vscode-106.2.0,/Users/salamaashoush/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.2.28,/Users/salamaashoush/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.2.28 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc 0 82 77553 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js --globalTypingsCacheLocation /Users/salamaashoush/Library/Caches/typescript/4.8 --enableTelemetry --typesMapLocation /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typesMap.json --validateDefaultNpmLocation 0 115 77588 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node /Users/salamaashoush/.vscode/extensions/streetsidesoftware.code-spell-checker-2.10.1/packages/_server/dist/main.js --node-ipc --clientProcessId=77528 0 98 77788 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=77528 ```Workspace Info
``` | Window (settings.json — BY-1933-add-drawer-component) | Window (player.rs — lp-bevy-tutorial) | Folder (BY-1933-add-drawer-component): 4336 files | File types: tsx(1323) ts(1085) svg(294) js(145) ttf(104) log(75) | json(70) woff(70) woff2(70) png(32) | Conf files: package.json(20) tsconfig.json(19) settings.json(2) | dockerfile(1) | Folder (lp-bevy-tutorial): 5414 files | File types: o(939) json(551) timestamp(550) d(510) rmeta(456) rlib(240) | bc(141) ll(19) rs(14) dylib(14) | Conf files:; ```A/B Experiments
``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes516:30244333 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 azure-dev_surveyone:30548225 2144e591:30553903 pyindex848cf:30577861 nodejswelcome1:30587005 40g7c324:30573242 ```