linter-htmlhint icon indicating copy to clipboard operation
linter-htmlhint copied to clipboard

HTMLHint options

Open thorade opened this issue 10 years ago • 11 comments

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.

thorade avatar Feb 10 '15 10:02 thorade

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)

smeijer avatar Feb 10 '15 12:02 smeijer

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)

smeijer avatar Feb 10 '15 12:02 smeijer

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...

thorade avatar Feb 10 '15 13:02 thorade

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.

thorade avatar Mar 05 '15 09:03 thorade

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.

johnwebbcole avatar Jul 23 '15 14:07 johnwebbcole

Hi guys~ Is it possible set the .htmlhintrc options in config.cson?

twxia avatar Dec 04 '15 08:12 twxia

The only setting currently implemented in this package is the path to htmlhint.

Arcanemagus avatar Dec 04 '15 17:12 Arcanemagus

@Arcanemagus thanks~ I think if there is a global configuration will be better .

twxia avatar Dec 05 '15 04:12 twxia

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).

johnwebbcole avatar Dec 05 '15 05:12 johnwebbcole

There's some discussion about restructuring the options over here https://github.com/htmlhint/HTMLHint/issues/279.

dreamalligator avatar May 03 '20 03:05 dreamalligator

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

dreamalligator avatar May 04 '20 00:05 dreamalligator