Skip to content

Not compatible with @html-eslint/eslint-plugin when language is used instead of languageOptions.parser for parsing #312

@andreww2012

Description

@andreww2012

Description

Hello! @html-eslint/eslint-plugin defines an html language directly on the plugin, allowing to enable HTML parsing by setting

{
  language: '<@html-eslint/eslint-plugin prefix>/html'
}

instead of

import eslintParserHtml from '@html-eslint/parser';

{
  languageOptions: {
    parser: eslintParserHtml,
  },
}

However, if the method 1 is used instead of method 2 and eslint-plugin-html is added, HTML files linting stops completely.

Setup configuration

  • ESLint version: 9.39.2
  • eslint-plugin-html version: 8.1.4
  • NodeJS version: Not relevant
  • Operating System name and version: Not relevant
  • ESLint configuration (.eslintrc/eslint.config.js): in the repro

Reproduction: https://stackblitz.com/edit/vitejs-vite-c35nwdjv

  1. Initially, method 1 is used and both plugins are added to the config. Run pnpm test to run ESLint on index.html and observe no found errors (expected: 1:1 error '!DOCTYPE' is not in lowercase @html-eslint/lowercase)
  2. Comment out html: eslintPluginJsInHtml line and run this script again. The problem will be reported now.
  3. Uncomment the same line again and uncomment languageOptions section. The problem will continue to be correctly reported.

Additional context

Very quickly looking at the source code of this plugin, I'm guessing this is expected, but this problem is quite hard to debug. I wonder if it's possible to somehow work this around or at least mention in the docs that explicitly specifying the parser is necessary? At the very least, do not suppress the reports from other plugins if the parser cannot be found. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions