AtomLinter / linter-htmlhint

Linter plugin for html, using htmlhint
40 stars 19 forks source link

HTMLHint options #5

Open thorade opened 9 years ago

thorade commented 9 years ago

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.

smeijer commented 9 years ago

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 commented 9 years ago

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)

thorade commented 9 years ago

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 commented 9 years ago

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.

johnwebbcole commented 9 years ago

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.

twxia commented 8 years ago

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

Arcanemagus commented 8 years ago

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

twxia commented 8 years ago

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

johnwebbcole commented 8 years ago

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

dreamalligator commented 4 years ago

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

dreamalligator commented 4 years ago

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