BenoitZugmeyer / eslint-plugin-html

An ESLint plugin to extract and lint scripts from HTML files.
ISC License
430 stars 51 forks source link

Add an option for eol-last to apply to the whole file rather than individual scripts. #65

Closed Standard8 closed 4 years ago

Standard8 commented 7 years ago

I think the spirit of eol-last is to ensure there's always a newline at the end of the file. Certainly for Mozilla we tend to ensure it, as it makes diffs simpler.

Therefore, I'd like to request an option so that we can have eol-last apply to the whole html file, rather than individual scripts as I don't think there is much value for the script tag.

BenoitZugmeyer commented 7 years ago

Thank you very much for all the bug reports, I fixed the simple ones, but some require more digging.

In my opinion, all ESLint rules should apply on the script code instead of the HTML. Ideally, we would need an "HTML-lint" project to apply some rules to the HTML. I can think of many solutions:

  1. add a "eol-last" rule in https://github.com/htmllint/htmllint, and use it side by side with ESLint
  2. add a "eol-last" rule in https://github.com/htmllint/htmllint, and integrate it in eslint-plugin-html so it outputs JS lints merged with HTML lints
  3. implement a eslint-plugin-html setting like "check-eol-last" so it checks this particular issue on the whole file

I think 1. and 3. are rather straightforward, 2. needs a bit more work but it's the more appealing solution. What do you think about it? would you mind using a separate command to lint HTML related issues, or do you prefer to stick with ESLint only?

hsxfjames commented 7 years ago

I think 1 is better, since there are already some "HTML-lint" like projects exist. ESLint is not designed for linting HTMLs.

Standard8 commented 7 years ago

I think either 1 or 3 would be fine. 1 seems to make a bit more sense logically, since it seems to fit more with the split between the two (I also now have to go investigate htmllint :-) )