Skip to content

[BUG] parser crashes when encountering unquoted attribute value containing at least one or more = #372

@Galimede

Description

@Galimede

Describe the bug

The parser crashes when encountering unquoted attribute value containing at least one or more =.

> html-eslint-minimal-repro@1.0.0 lint
> eslint


Oops! Something went wrong! :(

ESLint: 9.28.0

TypeError: Cannot read properties of undefined (reading 'value')
Occurred while linting /home/mathieu/dev/experiment/html-eslint-minimal-repro/index.js:5
Rule: "@html-eslint/attrs-newline"
    at Object.fix (/home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/@html-eslint/eslint-plugin/lib/rules/attrs-newline.js:80:39)
    at normalizeFixes (/home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/eslint/lib/linter/report-translator.js:205:25)
    at /home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/eslint/lib/linter/report-translator.js:407:7
    at FileContext.report (/home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/eslint/lib/linter/linter.js:1249:21)
    at Tag (/home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/@html-eslint/eslint-plugin/lib/rules/attrs-newline.js:104:28)
    at ruleErrorHandler (/home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/eslint/lib/linter/linter.js:1307:33)
    at /home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/eslint/lib/linter/safe-emitter.js:45:46
    at Array.forEach (<anonymous>)
    at Object.emit (/home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/eslint/lib/linter/safe-emitter.js:45:26)
    at #applySelector (/home/mathieu/dev/experiment/html-eslint-minimal-repro/node_modules/eslint/lib/linter/source-code-traverser.js:148:17)

To Reproduce

Link to minimal repro: https://github.com/Galimede/html-eslint-minimal-repro

Expected behavior

It shouldn't be mandatory to add quotes around an attribute value (in a template literal).

Activity

yeonjuan

yeonjuan commented on Jun 9, 2025

@yeonjuan
Owner

Hi. @Galimede
The flat/recommend contains settings for HTML files. (**/*.html)
It contains languageOptions for html file so it was recognizing your JS code as HTML that was causing the problem.

When parsing JS or TS that uses html in template literal, you need to apply the settings as follows.
I think this should be added to our documentation. :) Thanks!

import html from "@html-eslint/eslint-plugin";

export default [
  {
    plugins: {
      "@html-eslint" :html,
    },
    rules: html.configs["flat/recommended"].rules,
    // or manually
   //  rules: { "@html-eslint/attrs-newline": "error" },
    files: ["**/*.js"],
  },
];
added
documentationImprovements or additions to documentation
questionFurther information is requested
and removed
bugSomething isn't working
documentationImprovements or additions to documentation
on Jun 9, 2025
Galimede

Galimede commented on Jun 9, 2025

@Galimede
Author

Hi,
Oh I didn't know about that, indeed it works fine now, thanks for the quick answer! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Galimede@yeonjuan

      Issue actions

        [BUG] parser crashes when encountering unquoted attribute value containing at least one or more `=` · Issue #372 · yeonjuan/html-eslint