Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !37186

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

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Julien Déramond requested to merge main-jd-eslint-plugin-html into main Sep 21, 2022
  • Overview 1
  • Commits 3
  • Pipelines 0
  • Changes 8

Linked to https://github.com/twbs/bootstrap/pull/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

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: main-jd-eslint-plugin-html