Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving files with eslint code action is really slow #1538

Closed
salamaashoush opened this issue Oct 17, 2022 · 16 comments
Closed

Saving files with eslint code action is really slow #1538

salamaashoush opened this issue Oct 17, 2022 · 16 comments
Labels
info-needed Issue requires more information from poster

Comments

@salamaashoush
Copy link

salamaashoush commented Oct 17, 2022

Type: Performance Issue

when I add eslint code action on saving, saving files becomes really slow

"editor.codeActionsOnSave": {
    "source.fixAll": true,
}

I ran the Bisect and found that the problem comes from eslint extension

here are my eslint configs

module.exports = {
  parser: '@typescript-eslint/parser',
  extends: [
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:prettier/recommended',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:import/typescript',
    'plugin:storybook/recommended',
  ],
  plugins: ['simple-import-sort', 'react-hooks'],
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
    },
  },
  overrides: [
    {
      files: ['*.js', '*.jsx'],
      rules: {
        '@typescript-eslint/explicit-function-return-type': 0,
        '@typescript-eslint/explicit-member-accessibility': 0,
        '@typescript-eslint/no-var-requires': 0,
      },
    },
  ],
  rules: {
    'react/jsx-uses-react': 'off',
    'react/react-in-jsx-scope': 'off',
    'no-console': 2,
    'react/prop-types': 0,
    'simple-import-sort/imports': 'error',
    '@typescript-eslint/no-use-before-define': [2, { variables: false }],
    '@typescript-eslint/interface-name-prefix': 0,
    '@typescript-eslint/explicit-function-return-type': 0,
    '@typescript-eslint/explicit-module-boundary-types': 0,
    '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'warn',
    '@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
  },
  ignorePatterns: ['**/generated'],
  settings: {
    react: {
      version: 'detect',
    },
    'import/resolver': {
      node: {
        extensions: ['.ts', '.tsx', '.js', '.jsx'],
      },
    },
  },
};

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: enabled
canvas_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

@MariaSolOs
Copy link
Contributor

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.":

vscode-eslint/package.json

Lines 406 to 419 in 4b92c12

"eslint.codeActionsOnSave.mode": {
"scope": "resource",
"type": "string",
"enum": [
"all",
"problems"
],
"enumDescriptions": [
"Fixes all possible problems in the file. This option might take some time.",
"Fixes only reported problems that have non-overlapping textual edits. This option runs a lot faster."
],
"default": "all",
"markdownDescription": "Specifies the code action mode. Possible values are 'all' and 'problems'."
},

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.

vscode-eslint/package.json

Lines 420 to 433 in 4b92c12

"eslint.codeActionsOnSave.rules": {
"scope": "resource",
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
}, {
"type": "null"
}
],
"default": null,
"markdownDescription": "The rules that should be executed when computing the code actions on save or formatting a file. Defaults to the rules configured via the ESLint configuration"

@salamaashoush
Copy link
Author

I tried"eslint.codeActionsOnSave.mode": "problems" but still no luck, also I was already using "source.fixAll.eslint": true

@dbaeumer
Copy link
Member

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:

  • enable debugging to see which rule is slow. You can do this by using the eslint.debug setting and inspect the output in the ESLint channel.
  • exclude the rule using the eslint.codeActionsOnSave.rules setting

If none of the rules is slow can you please provide us with a GitHub repository we can clone that demos the slowness.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Oct 21, 2022
@Dimava
Copy link

Dimava commented Oct 21, 2022

I have the same problem

I guess it may be caused by a combination of:

  • a big .vue file, ~300 lines
  • heavy rules ( plugin:vue/vue3-recommended + @vue/eslint-config-standard-with-typescript or @vue/eslint-config-airbnb-with-typescript )
  • big typescript libraries in global (quasar)
  • slow processor (because discharged laptop battery)
  • causing long formatting times (~3000ms per pass)
  • with big amount of fixes, requiring 10 passes, causing 30 seconds for first fix
  • with another formatter on top of that, requiring more then one pass for every save
       "editor.defaultFormatter": "Vue.volar",
       "_editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"],
    

@Dimava
Copy link

Dimava commented Oct 21, 2022

ESlint trace
[Trace - 19:39:51] Received notification 'textDocument/publishDiagnostics'.
[Trace - 19:39:51] Received notification 'eslint/status'.
[Trace - 19:40:19] Sending notification 'textDocument/didOpen'.
[Trace - 19:40:19] Received request 'workspace/configuration - (5)'.
[Trace - 19:40:19] Sending response 'workspace/configuration - (5)'. Processing request took 4ms
[Trace - 19:40:19] NODE_PATH value is: C:\Users\Dimava\AppData\Local\nvs\default\node_modules;C:\Users\Dimava\AppData\Local\nvs\default\node_modules
2022-10-21T16:40:20.176Z eslint:cli-engine Linting complete in: 19ms
[Trace - 19:40:20] Received notification 'textDocument/publishDiagnostics'.
[Trace - 19:40:20] Received notification 'eslint/status'.
[Trace - 19:52:27] Sending notification 'textDocument/didOpen'.
[Trace - 19:52:27] Received request 'workspace/configuration - (6)'.
[Trace - 19:52:27] Sending response 'workspace/configuration - (6)'. Processing request took 5ms
[Trace - 19:55:58] Sending request 'textDocument/codeAction - (14)'.
[Trace - 19:55:58] Received response 'textDocument/codeAction - (14)' in 14ms.
[Trace - 19:56:00] Sending notification 'textDocument/didChange'.
2022-10-21T16:56:00.556Z eslint:cli-engine Lint D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:00.556Z eslint:linter Linting code for D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue (pass 1)
2022-10-21T16:56:00.556Z eslint:linter Verify
2022-10-21T16:56:00.556Z eslint:linter With ConfigArray: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:00.556Z eslint:linter Apply the processor: 'vue/.vue'
2022-10-21T16:56:00.557Z eslint:linter A code block was found: '(unnamed)'
2022-10-21T16:56:00.558Z eslint:linter Parsing: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
[Trace - 19:56:02] Sending notification 'textDocument/didChange'.
2022-10-21T16:56:02.297Z eslint:linter Parsing successful: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:02.297Z eslint:linter Scope analysis: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:02.297Z eslint:linter Scope analysis successful: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
[Trace - 19:56:02] Sending request 'textDocument/codeAction - (15)'.
[Trace - 19:56:02] Sending notification '$/cancelRequest'.
[Trace - 19:56:02] Sending request 'textDocument/codeAction - (16)'.
2022-10-21T16:56:02.913Z eslint:linter Generating fixed text for D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue (pass 1)
2022-10-21T16:56:02.913Z eslint:source-code-fixer Applying fixes
2022-10-21T16:56:02.913Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes
2022-10-21T16:56:02.914Z eslint:cli-engine Linting complete in: 2393ms
[Trace - 19:56:02] Received notification 'textDocument/publishDiagnostics'.
[Trace - 19:56:02] Received notification 'eslint/status'.
[Trace - 19:56:02] Received response 'textDocument/codeAction - (15)' in 532ms.
2022-10-21T16:56:02.944Z eslint:cli-engine Lint D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:02.944Z eslint:linter Linting code for D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue (pass 1)
2022-10-21T16:56:02.944Z eslint:linter Verify
2022-10-21T16:56:02.944Z eslint:linter With ConfigArray: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:02.944Z eslint:linter Apply the processor: 'vue/.vue'
2022-10-21T16:56:02.944Z eslint:linter A code block was found: '(unnamed)'
2022-10-21T16:56:02.946Z eslint:linter Parsing: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
[Trace - 19:56:03] Sending notification '$/cancelRequest'.
[Trace - 19:56:03] Sending request 'textDocument/codeAction - (17)'.
[Trace - 19:56:03] Sending notification '$/cancelRequest'.
2022-10-21T16:56:04.734Z eslint:linter Parsing successful: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:04.734Z eslint:linter Scope analysis: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:04.734Z eslint:linter Scope analysis successful: D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue
2022-10-21T16:56:05.056Z eslint:linter Generating fixed text for D:\xyz\xyzvite\src\components\passport\xyzNewNode.vue (pass 1)
2022-10-21T16:56:05.056Z eslint:source-code-fixer Applying fixes
2022-10-21T16:56:05.056Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes
2022-10-21T16:56:05.056Z eslint:cli-engine Linting complete in: 2135ms
[Trace - 19:56:05] Received notification 'textDocument/publishDiagnostics'.
[Trace - 19:56:05] Received notification 'eslint/status'.
[Trace - 19:56:05] Received response 'textDocument/codeAction - (16)' in 2380ms.
[Trace - 19:56:05] Received response 'textDocument/codeAction - (17)' in 1876ms.
[Trace - 19:56:11] Sending request 'textDocument/codeAction - (18)'.
[Trace - 19:56:11] Received response 'textDocument/codeAction - (18)' in 1ms.
[Trace - 19:56:17] Sending notification 'textDocument/didSave'.
[Trace - 19:56:54] Sending request 'workspace/executeCommand - (19)'.
2022-10-21T16:56:54.643Z eslint:cli-engine Lint D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:56:54.643Z eslint:linter Linting code for D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue (pass 1)
2022-10-21T16:56:54.644Z eslint:linter Verify
2022-10-21T16:56:54.644Z eslint:linter With ConfigArray: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:56:54.644Z eslint:linter Apply the processor: 'vue/.vue'
2022-10-21T16:56:54.644Z eslint:linter A code block was found: '(unnamed)'
2022-10-21T16:56:54.645Z eslint:linter Parsing: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
[Trace - 19:56:56] Sending request 'textDocument/codeAction - (20)'.
2022-10-21T16:56:57.254Z eslint:linter Parsing successful: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:56:57.254Z eslint:linter Scope analysis: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:56:57.254Z eslint:linter Scope analysis successful: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:56:57.794Z eslint:linter Generating fixed text for D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue (pass 1)
2022-10-21T16:56:57.794Z eslint:source-code-fixer Applying fixes
2022-10-21T16:56:57.794Z eslint:source-code-fixer Found fixes to apply
2022-10-21T16:56:57.795Z eslint:linter Linting code for D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue (pass 2)
2022-10-21T16:56:57.795Z eslint:linter Verify
2022-10-21T16:56:57.795Z eslint:linter With ConfigArray: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:56:57.796Z eslint:linter Apply the processor: 'vue/.vue'
2022-10-21T16:56:57.796Z eslint:linter A code block was found: '(unnamed)'
2022-10-21T16:56:57.796Z eslint:linter Parsing: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:00.229Z eslint:linter Parsing successful: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:00.229Z eslint:linter Scope analysis: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:00.229Z eslint:linter Scope analysis successful: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:00.626Z eslint:linter Generating fixed text for D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue (pass 2)
2022-10-21T16:57:00.626Z eslint:source-code-fixer Applying fixes
2022-10-21T16:57:00.626Z eslint:source-code-fixer Found fixes to apply
2022-10-21T16:57:00.626Z eslint:linter Linting code for D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue (pass 3)
2022-10-21T16:57:00.626Z eslint:linter Verify
2022-10-21T16:57:00.626Z eslint:linter With ConfigArray: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:00.626Z eslint:linter Apply the processor: 'vue/.vue'
2022-10-21T16:57:00.626Z eslint:linter A code block was found: '(unnamed)'
2022-10-21T16:57:00.627Z eslint:linter Parsing: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:03.190Z eslint:linter Parsing successful: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:03.190Z eslint:linter Scope analysis: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:03.190Z eslint:linter Scope analysis successful: D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue
2022-10-21T16:57:03.711Z eslint:linter Generating fixed text for D:\xyz\xyzvite\src\components\passport\consumer\xyzConsumer.vue (pass 3)
2022-10-21T16:57:03.711Z eslint:source-code-fixer Applying fixes
2022-10-21T16:57:03.711Z eslint:source-code-fixer No fixes to apply
2022-10-21T16:57:03.711Z eslint:cli-engine Linting complete in: 9084ms
[Trace - 19:57:03] Computing all fixes took: 9090 ms.
[Trace - 19:57:03] Computing minimal edits took: 6 ms.
[Trace - 19:57:03] Received request 'workspace/applyEdit - (7)'.
[Trace - 19:57:03] Received response 'textDocument/codeAction - (20)' in 7409ms.
[Trace - 19:57:03] Sending response 'workspace/applyEdit - (7)'. Processing request took 91ms
[Trace - 19:57:03] Sending notification 'textDocument/didChange'.
[Trace - 19:57:03] Received response 'workspace/executeCommand - (19)' in 9192ms.
tl;dr 3 passes in 9192ms on save after formatting with Volar

@Dimava
Copy link

Dimava commented Oct 25, 2022

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)

@dbaeumer
Copy link
Member

Adding such a status is actually a good idea. I capture it here: #1542

@salamaashoush
Copy link
Author

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

@salamaashoush
Copy link
Author

salamaashoush commented Nov 1, 2022

so I guess this issue is not relevant here, but maybe on https://github.com/typescript-eslint/typescript-eslint, WDYT @dbaeumer @MariaSolOs ?

@MariaSolOs
Copy link
Contributor

@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).

@dbaeumer
Copy link
Member

dbaeumer commented Nov 2, 2022

@MariaSolOs is right. There are two kinds of eslint problems flaged by typescript-eslint:

  • one that only require examining the current file. These are usually fast.
  • one that need a project configuration and always parse all files in the project (at least on initial use). These are usually slower and have performance problems when running code fix on save.

@dbaeumer
Copy link
Member

dbaeumer commented Nov 2, 2022

I will close the issue since there is little, I can do to fix this besides the rule customizations I already offer.

@dbaeumer dbaeumer closed this as completed Nov 2, 2022
@Dimava
Copy link

Dimava commented Nov 2, 2022

This maybe could use

  • some user-visible warnings "ESLint taking too long"
  • disabling non-autofix rules on non-last iteration
  • suggesting to profile ESLint rules

image
^ 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

@dbaeumer
Copy link
Member

dbaeumer commented Nov 3, 2022

For the user feedback there is #1542. I do have a writeup as well how to tackle it. We could reference it from the user feedback (#1344)

@yusufkinatas
Copy link

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/*/" }],

@denny-sam-sahaj
Copy link

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.

@jclaveau jclaveau mentioned this issue Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

6 participants