typescript-eslint-language-service icon indicating copy to clipboard operation
typescript-eslint-language-service copied to clipboard

Error: use '@typescript-eslint/parser'

Open lkrugertogetr opened this issue 2 years ago • 2 comments

I'm using yarn berry, which does make it more of a pain than it needs to be. Here's some missing dependencies according to yarn:

//.yarnrc.yml
packageExtensions:
  typescript-eslint-language-service@*:
    dependencies:
      '@typescript-eslint/scope-manager': '*'
      '@typescript-eslint/visitor-keys': '*'
      'globby': '^11.0.3'
      'is-glob': '*'
      '@eslint/eslintrc': '*'

yarnPath: .yarn/releases/yarn-berry.cjs

After that I get the following:

Info 33   [14:42:43.011] [typescript-eslint-language-service] config: {"name":"typescript-eslint-language-service"}
Info 34   [14:42:43.012] Plugin activation failed: Error: Qualified path resolution failed - none of those files can be found on the disk.

Source path: i:\<repo path>\.yarn\cache\eslint-npm-7.32.0-e15cc6682f-cc85af9985.zip\node_modules\eslint\lib\cli-engine\cascading-config-array-factory
Not found: i:\<repo path>\.yarn\cache\eslint-npm-7.32.0-e15cc6682f-cc85af9985.zip\node_modules\eslint\lib\cli-engine\cascading-config-array-factory
Not found: i:\<repo path>\.yarn\cache\eslint-npm-7.32.0-e15cc6682f-cc85af9985.zip\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js
Not found: i:\<repo path>\.yarn\cache\eslint-npm-7.32.0-e15cc6682f-cc85af9985.zip\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.json
Not found: i:\<repo path>\.yarn\cache\eslint-npm-7.32.0-e15cc6682f-cc85af9985.zip\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.node

I am using the latest ESLint. After removing the try catch block in eslint-config-provider.ts I'm getting the following:

Plugin activation failed: Error: Missing "./lib/cascading-config-array-factory" export in "@eslint/eslintrc" package
Require stack:
- i:\<repo path>\.yarn\__virtual__\typescript-eslint-language-service-virtual-cb98ba6b40\0\cache\typescript-eslint-language-service-npm-4.1.5-470c7ddaa3-3d4934bac3.zip\node_modules\typescript-eslint-language-service\lib\eslint-config-provider.js
- i:\<repo path>\.yarn\__virtual__\typescript-eslint-language-service-virtual-cb98ba6b40\0\cache\typescript-eslint-language-service-npm-4.1.5-470c7ddaa3-3d4934bac3.zip\node_modules\typescript-eslint-language-service\lib\plugin-module-factory.js
- i:\<repo path>\.yarn\__virtual__\typescript-eslint-language-service-virtual-cb98ba6b40\0\cache\typescript-eslint-language-service-npm-4.1.5-470c7ddaa3-3d4934bac3.zip\node_modules\typescript-eslint-language-service\lib\index.js
- i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js
- i:\<repo path>\.pnp.cjs

Edit: after changing @eslint/eslintrc version from * to ^0.4.3 it loaded correctly.

lkrugertogetr avatar Aug 19 '21 12:08 lkrugertogetr

After getting it loading correctly I'm getting the following:

Info 254  [15:26:13.502] [typescript-eslint-language-service] use '@typescript-eslint/parser'
Info 255  [15:26:13.515] [typescript-eslint-language-service] Error: use '@typescript-eslint/parser'
    at ESLintAdapter.getESLintResult (i:\<repo path>\.yarn\__virtual__\typescript-eslint-language-service-virtual-cb98ba6b40\0\cache\typescript-eslint-language-service-npm-4.1.5-470c7ddaa3-3d4934bac3.zip\node_modules\typescript-eslint-language-service\lib\eslint-adapter.js:92:19)
    at ESLintAdapter.getSemanticDiagnostics (i:\<repo path>\.yarn\__virtual__\typescript-eslint-language-service-virtual-cb98ba6b40\0\cache\typescript-eslint-language-service-npm-4.1.5-470c7ddaa3-3d4934bac3.zip\node_modules\typescript-eslint-language-service\lib\eslint-adapter.js:106:39)
    at IOSession.Session.semanticCheck (i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js:164150:52)
    at i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js:164206:31
    at MultistepOperation.executeAction (i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js:163156:25)
    at i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js:163135:100
    at IOSession.Session.executeWithRequestId (i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js:165473:28)
    at Object.executeWithRequestId (i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js:163918:87)
    at Immediate._onImmediate (i:\<repo path>\.yarn\cache\typescript-patch-bb3b548ba1-bc2c4fdf0f.zip\node_modules\typescript\lib\tsserver.js:163135:41)
    at processImmediate (internal/timers.js:461:21)

Here's my eslint config:

{
  "plugins": ["prettier", "react", "@typescript-eslint"],
  "extends": [
    "airbnb-typescript",
    // "airbnb/hooks",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended"
  ],
  "parserOptions": {
    "project": ["./tsconfig.json"]
  }
}

And ts config:

{
  "compilerOptions": {
    "target": "esnext",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "plugins": [
      {
        "name": "typescript-eslint-language-service"
      }
    ]
  },
  "include": ["src"]
}

Update: this doesn't seem to be related to the package manager either, using good old yarn v1 it happens too.

lkrugertogetr avatar Aug 19 '21 13:08 lkrugertogetr

Update: changing the deprecated CLIEngine to ESLint here solved that issue. However, it is still not working.

The following is happening:

Info 486  [09:07:43.371] request:
    {"seq":80,"type":"request","command":"projectInfo","arguments":{"file":"i:/<repo path>/src/Test.ts","needFileNameList":false}}
Perf 487  [09:07:43.372] 80::projectInfo: elapsed time (in milliseconds) 0.1975
Info 488  [09:07:43.372] response:
    {"seq":0,"type":"response","command":"projectInfo","request_seq":80,"success":true,"body":{"configFileName":"i:/<repo path>/tsconfig.json","languageServiceDisabled":false}}
Info 489  [09:07:43.448] request:
    {"seq":81,"type":"request","command":"encodedSemanticClassifications-full","arguments":{"file":"i:/<repo path>/src/Test.ts","start":0,"length":54,"format":"2020"}}
Perf 490  [09:07:43.448] 81::encodedSemanticClassifications-full: elapsed time (in milliseconds) 0.6382
Info 491  [09:07:43.448] response:
    {"seq":0,"type":"response","command":"encodedSemanticClassifications-full","request_seq":81,"success":true,"body":{"spans":[24,4,2817,29,3,1793,48,3,1792],"endOfLineState":0}}
Info 492  [09:07:43.677] request:
    {"seq":82,"type":"request","command":"geterr","arguments":{"delay":0,"files":["i:/<repo path>/src/Test.ts"]}}
Perf 493  [09:07:43.680] 82::geterr: async elapsed time (in milliseconds) 2.8574
Info 494  [09:07:43.692] event:
    {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"i:/<repo path>/src/Test.ts","diagnostics":[]}}
Info 495  [09:07:43.729] event:
    {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"i:/<repo path>/src/Test.ts","diagnostics":[{"start":{"line":1,"offset":30},"end":{"line":1,"offset":33},"text":"Parameter 'arg' implicitly has an 'any' type.","code":7006,"category":"error"}]}}
Info 496  [09:07:43.730] event:
    {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"i:/<repo path>/src/Test.ts","diagnostics":[]}}
Info 497  [09:07:43.730] event:
    {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":82}}

Resulting in this: image

With this none of the ESLint rules are triggered by the TS language service plugin where they should be while they are by the ESLint plugin for VSCode, at this point I'm starting to get clueless.

lkrugertogetr avatar Aug 20 '21 06:08 lkrugertogetr