-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Linting support for typescript #170
Comments
Do you have an example project where I can test it? If you can get linting to work on CLI I should be able to surface the errors to VSCode. |
I created a repo based on vue-cli's official webpack-simple template and replaced javascript with typescript using the To re-produce:
You also need typescrpt and tslint installed globally. Hope this helps |
I'm not sure if this is supported by tslint. Not yet I guess. |
@ppasieka: tslint works fine for .vue files in the command line with this setup. The problem is that those lint errors are not surfaced/displayed in visual studio code. |
@timeu, do you have TSLint |
@romandragan yeah I have the same issue with |
Actually I'm planning to have better integration between vetur and eslint/tslint by just sending the js/ts region to eslint/tslint and add padding to the errors position. vetur already divides Vue SFC into multiple regions so it has this info. |
I'll build a |
Well tslint doesn't support plugins yet :( |
I created a VSCode extension for linting TypeScript in .vue files: TSLint Vue Just make sure you set the language attribute on your script tags: Cheers! |
Latest version (v1.1.0) of TSLint Vue now includes linting at typechecker level. You can turn on linting at the typechecker level by setting the // .vscode/settings.json
{
"tslint.typeCheck": true,
} I'm also working on a PR in the excellent & fast fork-ts-checker-webpack-plugin to work with |
@prograhammer Thanks, I'll look into your plugin to see how I can integrate it (great work!) If I understand correctly, TSLint Vue is for editor and fork-ts-checker-webpack-plugin is for webpack config so it emits lint error at dev environment, right? We already surface all TS errors so we only need TSLint, but it would be good if the error in editor can be consistent with the error on CLI. |
@octref The screencapture gif in my previous post shows And yes, Feel free to ping me on any more questions as you decide on what you want to do in Vetur. Thanks! |
Alright, for anyone following this thread... I have got TSLint Vue v1.3.0 working fully for |
Also, if you are looking for a Webpack solution: TypeStrong/fork-ts-checker-webpack-plugin#77 (Check the top of that PR and you can npm install and try it out right away). |
I didn't test it within vue files, but tslint-language-service works well on typescript files. |
TypeScript in vue files loses many features compared to pure TypeScript files, like toggling TypeScript server between the one shipped with VSCode and the one installed locally, restarting TypeScript Server, linting, etc. It would be great if vetur can integrate tslint-language-services due to low overhead in comparison with vscode-tslint. |
How about build a |
Is there a way to disable eslint for |
@bbugh same problem here. I currently have my Typescript Vue files in my eslintignore, and my Javascript Vue files in my tslintignore. This way the linting of the script works, but I have no linting of the HTML template for my components using Typescript. |
@bbugh @MaartenStaa I was having this same issue. Not sure what your build set-up is but with the vue-eslint-parser I was able to set up two different parsers for the script section using the eslint glob overrides. I do have to name all my
Not sure how this effects the HTML since I'm using Pug and don't get any linting there anyhow. |
@acacia314 that's a nice idea. I don't mind naming our files |
There is a typescript-tslint-plugin made by Microsoft, it works well with .ts file, vetur should try this. |
Dunno if you heard about it, but TSLint is going to be deprecated in favor of an ESLint plugin. I'll leave here some links I found to help setup ESLint with TS support. https://github.com/typescript-eslint/typescript-eslint |
@IlCallo Were you able to get your script blocks (and potentially even template blocks) to catch type errors? I can’t seem to get that working, even though the type errors are shown at compile time from the cli. I have an example here. If you clone the repo and try passing a number or multiple params to EDIT: I answered my own question, it was a configuration option in VSCode. Make sure |
Not yet, but I'm not that expert actually, I'm just scratching the surface of linting in these weeks |
I got this working too with vue-cli project.
|
Thanks @samlof, I followed your checklist and got it working too! |
Any movement on this, now that Eslint support for typescript is solid is there a way to just continue using prettier-eslint for typescript? |
@josh-hemphill I believe TSLint is to be deprecated, so it's better only to rely on ESLint, not TSLint. |
@mesqueeb Yep, that's what I meant. Also I just saw that Eslint introduced "eslint.format.enable": true,
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}, |
I am not sure, if this issue belongs here or rather in vscode-tslint, but is there any way to add support for linting typescript script blocks (
<script lang="ts">
) in single file vue components (similar to what is possible with eslint?) or is there any workaround ?In my current webpack setup, I managed to get linting to work from the command line when I run the build step (can be done with vue-loader and ts-loader).
However VSCode does not display the linting errors and warnings.
The text was updated successfully, but these errors were encountered: