yeonjuan / html-eslint

ESLint plugin for linting HTML
https://html-eslint.org
MIT License
161 stars 28 forks source link

Add support for eslint flat config #174

Closed TheElegantCoding closed 9 months ago

TheElegantCoding commented 10 months ago
yeonjuan commented 10 months ago

Hi @TheElegantCoding, Thanks for the report!. Is there anything else we need to do to support flat config?

I've tested the config below and it seems to be working fine, did you run into any issues?

const Plugin = require("@html-eslint/eslint-plugin");
const Parser = require("@html-eslint/parser");

module.exports = [
  {
    plugins: { "@html-eslint": Plugin },
    languageOptions: {
      parser: Parser,
    },
    files: ["*.html"],
    rules: {
      //...
    },
  },
];
TheElegantCoding commented 10 months ago

thanks that work and also i find an error in my config, in order to work inside all the repo i have to put files: [ '**/*.html' ]

Other problem i have with eslint flat config is the type in typescript my config is in typescript

import { htmlDisabledRule } from '@module/html/rule/html_disabled_rule';
import { htmlGeneralRule } from '@module/html/rule/html_general_rule';
import pluginHtml from "@html-eslint/eslint-plugin";
import parserHtml from "@html-eslint/parser";

const html =
{
  files: [ '**/*.html' ],
  languageOptions:
  {
    parser: parserHtml
  },
  plugins:
  {
    html: pluginHtml
  },
  rules: {
    ...htmlGeneralRule,
    ...htmlDisabledRule
  }
};
export { html };

in the pluginHtml import i get this error Could not find a declaration file for module '@html-eslint/eslint-plugin'.

yeonjuan commented 10 months ago

in the pluginHtml import i get this error Could not find a declaration file for module '@html-eslint/eslint-plugin'.

@TheElegantCoding Thank you. I think this should be fixed..!

LatenPath commented 10 months ago

@yeonjuan Dear sir, I got this warning when import recommended setting. image

Hi @TheElegantCoding, Thanks for the report!. Is there anything else we need to do to support flat config?

I've tested the config below and it seems to be working fine, did you run into any issues?

const Plugin = require("@html-eslint/eslint-plugin");
const Parser = require("@html-eslint/parser");

module.exports = [
  {
    plugins: { "@html-eslint": Plugin },
    languageOptions: {
      parser: Parser,
    },
    files: ["*.html"],
    rules: {
      //...
    },
  },
];

Please help me 😢

yeonjuan commented 10 months ago

Hi @LatenPath , Could you try pluginHtml.configs.recommended.rules instead of pluginHtml.configs.recommended?

const pluginHtml = require("@html-eslint/eslint-plugin");
const parserHtml = require("@html-eslint/parser");

module.exports = [
  {
    files: ["**/*.html"],
    languageOptions: {
      parser: parserHtml,
    },
    plugins: {
      "@html-eslint": pluginHtml,
    },
    rules: pluginHtml.configs.recommended.rules,
  },
];
LatenPath commented 10 months ago

@yeonjuan It's work, sir! image

Disable rule/ Auto-fix,... also work fine!

image

Thank you so much!

But I have a small question, as you can see, other plugin which support Flat config have parser/env built-in so it simpler when setup: image

So I hope we will have one in future too ❤️

yeonjuan commented 10 months ago

@LatenPath

But I have a small question, as you can see, other plugin which support Flat config have parser/env built-in so it simpler

HTML-ESLint does not yet support flat config, we will update it to support flat config :)

yeonjuan commented 9 months ago

Hi @TheElegantCoding @LatenPath The new version is released (v0.23.0). html-eslint supports flat config now! Thanks for the reporting issue!