Support EJS files/tags · Issue #492 · htmlhint/HTMLHint · GitHub
Skip to content

Support EJS files/tags #492

Open

Description

@LightCC

Is your feature request related to a problem? Please describe.
HTMLHint appears to work well on *.ejs (EJS - Embedded JavaScript) files for the HTML parts, but the EJS templates trigger the spec-char-escape rule on the <% open and %> close tags for the embedded JS templating.

Describe the solution you'd like
In *.ejs files, HTMLHint should recognize the EJS start/stop tags and ignore the spec-char-escape tags at the minimum.

It's possible that everything between the tags should also be ignored, although there aren't many tags in EJS (plan <%, <%= for just variables, etc.) and most of it is just plain javascript.

Ideally, all the EJS tags and the javascript itself would all be linted.

Describe alternatives you've considered
I looked for other linters for EJS, at least supported by VS Code, didn't see anything.

I do use .htmlhintrc to disable the spec-char-escape rule:

{
    "spec-char-escape": false
}

but this is a less-than-ideal solution as it disables checking for that rule in all normal HTML code as well.

Additional context
In VS Code, this shows up as follows:
image

image

Activity

  1. Shinigami92 commented on Jul 11, 2020

    @Shinigami92
    Contributor

    Thank you for your feature request
    But let me tell you that we are currently working intensively on the core and configuration structure of HTMLHint
    So it will take some time before we have time to implement such features

  2. added
    coreRelates to HTMLHint's core APIs and features
    triageAn HTMLHint team member will look at this issue
    on Jul 14, 2020
  3. added
    bot:staleIssue marked as stale because there was no activity
    on Sep 12, 2020
  4. hugosaintemarie commented on Nov 9, 2020

    @hugosaintemarie

    I agree with @LightCC. Issues with ejs here as well.

  5. Netgator commented on Jan 21, 2021

    @Netgator

    I am also encountering the same issues.

  6. added
    keep-unstaleThe issue will not be marked as stale by the stale-bot
    and removed
    bot:staleIssue marked as stale because there was no activity
    on Jan 22, 2021
  7. aravindvnair99 commented on Mar 26, 2021

    @aravindvnair99

    @thedaviddias @Shinigami92 Why not keep this issue open?

    As pointed out by @LightCC, @ashugeo and @Netgator, my VS Code is filled with squiggly lines every time I'm working with EJS.

    image

    Coming to a solution, we can maybe have a check condition to see if an EJS file is being inspected instead of an HTML file and in which case ignore the following:

    <% 'Scriptlet' tag, for control-flow, no output
    <%_ 'Whitespace Slurping' Scriptlet tag, strips all whitespace before it
    <%= Outputs the value into the template (HTML escaped)
    <%- Outputs the unescaped value into the template
    <%# Comment tag, no execution, no output
    <%% Outputs a literal '<%'
    %> Plain ending tag
    -%> Trim-mode ('newline slurp') tag, trims following newline
    _%> 'Whitespace Slurping' ending tag, removes all whitespace after it
    

    Reference: EJS Tags

  8. reporter123 commented on Nov 19, 2021

    @reporter123

    This issues needs to be reopened due to being closed by the bot.

  9. tolgahanbora commented on Oct 20, 2022

    @tolgahanbora
  10. added theissue type on Jun 6, 2025
  11. deleted a comment from stale on Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelates to HTMLHint's core APIs and featuresfeature requestFunctionality that introduces a new featurekeep-unstaleThe issue will not be marked as stale by the stale-bottriageAn HTMLHint team member will look at this issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions