Shopify / erb_lint

Lint your ERB or HTML files
MIT License
680 stars 122 forks source link

AllowedScriptType should allow "module" for type script tag #384

Open jcoyne opened 1 month ago

jcoyne commented 1 month ago

I don't understand why erb_lint is surfacing this:

Avoid using "module" as type for `<script>` tag. Must be one of: text/javascript (or no type attribute). (not autocorrected)

This is valid HTML: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html

Similarly "application/ld+json" should be an acceptable value. https://docs.parse.ly/metadata-jsonld/

davidstosik commented 1 month ago

Hi there! 👋🏻 It looks like the AllowedScriptType rule only allows text/javascript by default. You can easily customize the rule in your configuration file:

---
linters:
  AllowedScriptType:
    enabled: true
    allowed_types:
      - 'application/json'
      - 'text/javascript'
      - 'text/html'
      - 'application/ld+json' # ⬅️ here
      - 'module' # ⬅️ and here
    allow_blank: false
    disallow_inline_scripts: false

(More details in the link I shared above.)

(This PR in BetterHtml seems to be related by the way: Add module as a type of Githubissues.

  • Githubissues is a development platform for aggregating issues.