BenoitZugmeyer / eslint-plugin-html

An ESLint plugin to extract and lint scripts from HTML files.
ISC License
430 stars 51 forks source link

Incompatibility issue between `eslint-plugin-html` and `@html-eslint` #293

Closed m1rn closed 1 week ago

m1rn commented 1 week ago

Description

According to the documentation, eslint-plugin-html should be compatible with @html-eslint. However, when I tried using both in my project, I noticed that eslint-plugin-html stops working. It seems like the issue is caused by @html-eslint/parser.

Here are the details:

I’d like to know if this is a known issue or if there's any way to make these two plugins work together.

Thanks!

Setup configuration

import html from "eslint-plugin-html"
import PARSER_HTML from '@html-eslint/parser'

export default [
  {
    files: ["**/*.html"],
    plugins: {
      html
    },
    languageOptions: {
      parser: PARSER_HTML
    },
    rules: {
      'no-console': 2
    }
  }
]
BenoitZugmeyer commented 1 week ago

You need both the @html-eslint/parser and @html-eslint/eslint-plugin to make it work. Ex:

import html from "eslint-plugin-html"
import htmlEslint from '@html-eslint/eslint-plugin'
import PARSER_HTML from '@html-eslint/parser'

export default [
  {
    files: ["**/*.html"],
    plugins: {
      html,
      "@html-eslint": htmlEslint,
    },
    languageOptions: {
      parser: PARSER_HTML
    },
    rules: {
      'no-console': 2
    }
  }
]

See the @html-eslint default config: https://github.com/yeonjuan/html-eslint/blob/main/packages/eslint-plugin/lib/index.js#L18-L24