HTML editor linting is aggressive for HTML 5

Hi!

This is my first time using this! I noticed though that the editor is pretty “aggressive” with linting HTML 5-- marking things that are valid HTML5 files as invalid.

A quick example is:

<!DOCTYPE html>
<title>hi!</title>
<body>
   <script src="/path/to/something.js"></script>

It complains about about the </body> being missing, but HTML 5 doesn’t require <body> be closed.

I mean, completely minor thing! Keep up the awesome work!

Hi toddself,

thanks for posting, and we are glad you like it :slight_smile:

you can customize the linter :slight_smile: at the top of your html file, you can add the following:

<!--htmlhint tag-pair:false --> 

to get the linter less aggressive against unmatched tags :slight_smile: The full list of options is here.

I hope this helps!

Thank you! That does help. Turning off tag matching though is bad since it will then ignore actually broken HTML!

The gist is that <body>, under most cases does not require a closing tag, but <div> always does. Turning off tag matching doesn’t flag unclosed <div>.

I just filed a bug on HTMLHint though since this stems from that :).

https://github.com/yaniswang/HTMLHint/issues/197

1 Like

I’ll continue on this thread but the html linter is also aggressive of wanting double quotes around attribute values.

The value of attribute [ binding-info ] must be in double quotes.

I can understand enforcing lack of quotes or mismatched single and double quotes but saying usage of single quotes is an error seems more like enforcement of a style choice than preventing errors.

I have some small chunks of json in data-* attributes that are a lot easier to read when using single-quoted html attribute values. It looks like the corresponding linter rule is attr-value-double-quotes.

+1 for a minor thing and thanks for your awesome work!

1 Like

Right now we inherit our tag rules from codemirror, and a lot of them are indeed archaic. It’s on our backlog to customize those rules, and/or find a way to open them up to user config (ie through a lint config file or something)

1 Like