linter-htmlhint
linter-htmlhint copied to clipboard
HTMLHint options
On http://htmlhint.com/ you can chose from a lot of options for linting, could these be added to the Package Settings? For example a checkbox if I want to check for tag-self-close
also? Currently I can only configure the path to the executable.
Options would be very usefull indeed.
I'm using the htmlhinter for my html files, but actually each .html file only contains a <template>..</template>
element. So currently, htmlhint is bugging me with a lot of "doctype must be first" errors.
Should be great if we could use something like a .htmlhint
file, so the project settings can be shared trough the project code repository. (just like the .jshintrc file)
Never mind my comment, just found out (by looking at the src) that a .htmlhintrc is actually supported.
@thorade, you can create a file named .htmlhintrc
at the root of your project, with contents like:
{
"tagname-lowercase": true,
"attr-lowercase": true,
"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
}
(restarting atom is required to make it work)
That is good to know, thanks for sharing!
Still I would be interested in the Settings->Options, because I frequently use Atom+Linter+htmlhint to inspect files that were autogenerated and are nor part of any project, they are just dumped into some temporary directory.
For now, I will just always use the same folder and have a .htmlhintrc
file in there...
Two more comments:
I created a more complete .htmlhintrc
file here:
https://gist.github.com/thorade/6988cc4b3df8f3f75f8f
When changing that file, you do not have to restart Atom,
disabling an then re-enabling the linter-htmlhint package is sufficient.
The findFile helper should look up your directory tree till it finds a .htmlhintrc
file. So if you are putting files in a temporary place, you can put the rc file anywhere up from there and it should get picked up.
Hi guys~ Is it possible set the .htmlhintrc
options in config.cson
?
The only setting currently implemented in this package is the path to htmlhint
.
@Arcanemagus thanks~ I think if there is a global configuration will be better .
If you put a .htmlhintrc
file in your root /
, you essentially get a global configuration. The linter plugin looks for a .htmlhintrc
in each directory up from the source file that is being linted, so if you have one anywhere above your source file it will stop at the first one it finds.
Rules and their options change, so it would be difficult to keep the linter config up to date. I use several .htmlhintrc
files in each project, one in my client directory, another in my views directory and one in the server directory, each with different options (like turning off the doctype check in my views, but not in other places).
There's some discussion about restructuring the options over here https://github.com/htmlhint/HTMLHint/issues/279.
Atm, HTMLHint can only support the rules directory via cli
. If we could add an extra config option, then we'd be able to partially mitigate the issue that this directory cannot be set in the .htmlhintrc
config file until the base project catches up. Understandably with the world situation, things are going to be delayed of course...
htmlhint --rulesdir ./rules/ --rules test-rule
- https://github.com/htmlhint/HTMLHint/wiki/Usage#load-custom-rules
- https://github.com/htmlhint/HTMLHint/issues/279
- https://github.com/htmlhint/HTMLHint/issues/356