-
Notifications
You must be signed in to change notification settings - Fork 110
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
Is there way to lint *.component.html files? #142
Comments
Can you explain the problem clearly? What doesn't work? Please check jsx section for how to configure web-mode and tide. You probably need to change the |
This is an issue with flycheck and tslint (+codelyzer), not tide. You can't see the errors reported by tslint for template files because flycheck doesn't know they're there (in turn because they are reported by linting the corresponding .ts file and not the .html file itself). |
typescript 2.4.1 seems to work with external angular templates too! microsoft/TypeScript#17229 |
@perveziqbal Are you just enabling tide mode with HTML files? If so, how do you handle formatting and all the other "invalid" syntax errors that occur? |
If you are using typescript 2.3 or older, html files will be treated as typescript files when tide is enabled. Update typescript to 2.4.1. Also update angular/language-service. Add the following to tsconfig.json
Enable web-mode and tide in html files. |
So, I've added the language service and web-mode, and enabled web-mode and tide in html files, but I'm still getting a huge amount of syntax errors because tide is checking the whole buffer. I looked at how to use web-mode with tide in the docs, but couldn't find anything except with tsx files which I suppose is not what I'm looking for. Thanks for your help, I'm really excited about this :) |
I have created a repository on github, please see if that works for you. |
@perveziqbal Looking at that repo... If you need to modify |
@everedifice
What do you mean by "lint" in this case? |
@rtm While using Visual Studio Code. I can see that warning of using method that component class file doesn't have. See below example // hello.component.ts @Component({
template: './hello.component.html'
})
export class HelloComponent {
} // hello.component.html <button type="button" (click)="sayHello()">click</button>
~~~~~~~~~~ Visual Studio Code warning using sayHello() method because HelloComponent doesn't have sayHello method. Currently If i use inline template (write template code into |
FWIW I couldn't get There's a wiki entry for this, but this should work: npm install -g vscode-html-languageserver-bin
# the Angular language server isn't yet published on npm--see tracking issue:
# https://github.com/angular/vscode-ng-language-service/issues/377
mkdir -p ~/.angular
curl https://marketplace.visualstudio.com/_apis/public/gallery/publishers/Angular/vsextensions/ng-template/latest/vspackage | \
tar -C ~/.angular -zxf - and then turn on LSP in (after-load 'sgml-mode
(add-hook 'html-mode-hook #'lsp-deferred)) Since LSP now supports multiple language servers per buffer, this all Just Works(TM) (or at least it did for me). Jump to definition, linting, etc, from ng HTML buffers all seems to work as I'd expect, and tide + LSP work together pretty seamlessly.
(use-package lsp-mode
:diminish "LSP"
:ensure-system-package
((html-languageserver . "npm install -g vscode-html-languageserver-bin")
;; workaround until it's published on npm: https://github.com/angular/vscode-ng-language-service/issues/377
("~/.angular/extension/server/server.js" . "mkdir -p ~/.angular && curl https://marketplace.visualstudio.com/_apis/public/gallery/publishers/Angular/vsextensions/ng-template/latest/vspackage | tar -C ~/.angular -zxf -"))
:hook ((html-mode . lsp-deferred))) |
Inline template are lint well.
But when i open *.component.html buffer, it doesn't work.
Is there any way to lint *.component.html files?
The text was updated successfully, but these errors were encountered: