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

Conflict with eslint rule "spaced-comment" #67

Open
ClementMindflow opened this issue Jun 25, 2021 · 6 comments · May be fixed by #68
Open

Conflict with eslint rule "spaced-comment" #67

ClementMindflow opened this issue Jun 25, 2021 · 6 comments · May be fixed by #68

Comments

@ClementMindflow
Copy link

ClementMindflow commented Jun 25, 2021

When a HTML comment is parsed using html-eslint it produce comment node of type comment.
If that node is given to the eslint builtin spaced-comment rule, it will fail with the following error:

TypeError: Cannot read property 'markers' of undefined
Occurred while linting /Users/clement/Dev/mindflow-platform/apps/studio/public/index.html:1
    at checkCommentForSpace (/Users/clement/Dev/mindflow-platform/node_modules/eslint/lib/rules/spaced-comment.js:336:49)
    at /Users/clement/Dev/mindflow-platform/node_modules/eslint/lib/rules/spaced-comment.js:385:19
...

After a quick look at the code, it seems like the spaced-comment rule expect comment node to have the type attribute set to either block or line, and node comment ( see here )

Maybe setting the node type to the appropriate type would fix the issue ...

@ClementMindflow ClementMindflow changed the title Potential conflict with eslint rule "spaced-comment" Conflict with eslint rule "spaced-comment" Jun 25, 2021
@yeonjuan
Copy link
Owner

Hi @ClementMindflow Sorry for being late.

html-eslint does not work with ECMAScript AST, It uses a AST made from html-eslint/parser.
It means we cannot use common eslint rules with html-eslint because the targeting language is different.

  • eslint: ECMAScript, JSX,
  • html-eslint: HTML

I think It would be great if we add a new spaced-comment rule which supporting HTML.
Thanks for the report 👍

@galyfray
Copy link

galyfray commented May 7, 2022

it seems that any rules that has to do with comments cause troubles. I have a similar issue with the capitalized-comments rule

@FatehAK
Copy link

FatehAK commented Dec 6, 2022

I'm facing the same issue as @ClementMindflow. Please let me know if there any plans on incorporating the fix or workarounds available?

@FatehAK
Copy link

FatehAK commented Dec 6, 2022

Fixed it temporarily by turning off the 'space-comments' rule for *.html alone in overrides key. Is there a way to permanently fix this?

@yeonjuan
Copy link
Owner

yeonjuan commented Jan 8, 2023

@FatehAK For permanently fixing it we should create a new rule (ie: @html-eslint/space-comments) which can handle html syntax.

@howieye
Copy link

howieye commented May 4, 2023

This bug still exists today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants