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

Can't lint .ts files when use vue-eslint-parser #864

Closed
odanado opened this issue Dec 25, 2019 · 10 comments
Closed

Can't lint .ts files when use vue-eslint-parser #864

odanado opened this issue Dec 25, 2019 · 10 comments
Labels
info-needed Issue requires more information from poster
Milestone

Comments

@odanado
Copy link

odanado commented Dec 25, 2019

eslint-plugin-vue uses vue-eslint-parser as a parser.
https://github.com/vuejs/eslint-plugin-vue/blob/e8f130c20c0ba6213009e1230a294b0f091e57bb/lib/configs/base.js#L7

I need configure @typescript-eslint/parser in parserOptions.parser so as to lint .ts files.
https://eslint.vuejs.org/user-guide/#usage

.ts files aren't linted, because @typescript-eslint/parser isn't configured in parser options.
 2019-12-25 22 51 20
reproduction repository: https://github.com/odan-sandbox/vscode-eslint-vue-typescript-reproduction

I suggest that include "typescript" in eslint.validate by checking @ typescript-eslint in plugins or parserOptions.parser.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 6, 2020

@odanado this is what is happening now since version 2.x.

I cloned your project but it is unclear to me what you think is not working correctly. Can you please provide steps to reproduce the problem.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Jan 6, 2020
@odanado
Copy link
Author

odanado commented Jan 7, 2020

reproduction steps

  • Run git clone https://github.com/odan-sandbox/vscode-eslint-vue-typescript-reproduction
  • Run cd vscode-eslint-vue-typescript-reproduction
  • Run yarn install
  • Run code .
  • Open code/code.js, code/code.ts and code/code.vue in VSCode

captures

code/code.js and code/code.vue have a warning (Replace = with ·=·eslint(prettier/prettier)). But, code/code.ts doesn't have a warning.

code/code.js

 2020-01-07 8 52 32

code/code.vue

 2020-01-07 8 52 39

code/code.ts

 2020-01-07 8 50 13

@dbaeumer
Copy link
Member

dbaeumer commented Jan 7, 2020

The reason for this is that although the .eslintrc.js tells to use the @typescript-eslint/parser the eslint npm module tells me that it uses the vue-eslint-parser. Need to understand why this is the case.

capture

@dbaeumer
Copy link
Member

dbaeumer commented Jan 7, 2020

The problem is that the parser property is outside the parserOptions. So a correct parser configuration looks like this:

  parser: "@typescript-eslint/parser",
  parserOptions: {
  }

However that doesn't help since vue configuration require the vue-eslint-parser.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 7, 2020

Actually in your setup parser seems to be a valid option for the vue-eslint-parser.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 7, 2020

@ozum
Copy link

ozum commented Jan 7, 2020

@dbaeumer, I have same problem with same configuration as @odanado.

VS did not show and/or fix eslint problems for .ts files in Vue project. However

$ node_modules/.bin/eslint src/some.ts

lists errors as expected:

image

@dbaeumer dbaeumer added this to the 2.0.12 milestone Jan 7, 2020
@dbaeumer
Copy link
Member

dbaeumer commented Jan 7, 2020

Fixed for 2.0.12

@dbaeumer dbaeumer closed this as completed Jan 7, 2020
@ozum
Copy link

ozum commented Jan 8, 2020

Until 2.0.12 is published as a vs code extension, I would like to share my workaround.

I usually put .ts files in a directory in vue projects. I added a separate .eslintrc.js config file into that directory which is specific to .ts files. It works as expected with vscode-eslint 2.0.11. Hope helps.

@odanado
Copy link
Author

odanado commented Jan 8, 2020

I also would like to share my workaround.

Add eslint.validate option in .vscode/settings.json

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "eslint.validate": [
    "typescript"
  ]
}

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants