Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint-plugin-html to lint JS in HTML files #37186

Merged
merged 3 commits into from Sep 27, 2022

Conversation

julien-deramond
Copy link
Member

@julien-deramond julien-deramond commented Sep 21, 2022

Linked to #36915

Description

This PR introduces the use of eslint-plugin-html to lint JavaScript within HTML files in <script>s.

It seemed to be the best and recommended tool to do it. Feel free to double check if this choice is valid :)

Some extra info:

  • Only the matching rules from /site/.eslintrc.json have been reused (thanks @GeoSot for pointing out these rules)
  • "no-console": "off" has been added since it is useful for debugging these standalone pages that never will be in production

I wasn't a big fan of --ext .html,.js as I'd prefer to target only the HTML files we want to parse but it seems that there's no other way to do it:

By default, when executing the eslint command on a directory, only .js files will be linted. You will have to specify extra extensions with the --ext option. Example: eslint --ext .html,.js src will lint both .html and .js files in the src directory.

Source: https://www.npmjs.com/package/eslint-plugin-html#troubleshooting

@julien-deramond julien-deramond marked this pull request as ready for review September 23, 2022 19:55
@XhmikosR XhmikosR removed the js label Sep 27, 2022
@XhmikosR XhmikosR merged commit abb1cf5 into main Sep 27, 2022
@XhmikosR XhmikosR deleted the main-jd-eslint-plugin-html branch September 27, 2022 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants