問題の事象
VSCodeでAngularプロジェクトを作成すると、htmlファイルで下記のような警告が出てしまって、邪魔だと思います。
こんなのや
Doctype must be declared first.(doctype-first)
こんなの
The attribute name of [ *ngIf ] must be in lowercase.
解決方法
「.htmlhintrc」ファイルをプロジェクト直下に配置して下記のように設定しましょう。
{ "tagname-lowercase": true, "attr-lowercase": false, "attr-value-double-quotes": true, "doctype-first": false, "tag-pair": true, "spec-char-escape": true, "id-unique": true, "src-not-empty": true, "attr-no-duplication": true, "title-require": true }
これで警告が出なくなります。
観れば分かると思いますが、冒頭で例に出した警告は下記の設定により出なくなります。
"attr-lowercase": false, // 属性に小文字以外を使っても警告を非表示にする "doctype-first": false, // doctypeを最初に書かなくても警告を非表示にする
関係ない設定までしてるのは、このファイルを作成すると全ての設定を書かないと、書かなかったタイプの警告は表示されなくなてしまうからです。
「.htmlhintrc」とは
HTMLHintのルール設定が出来るファイルです。
詳しくは下記を参照してください。
github.com