You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importhtmlfrom"@html-eslint/eslint-plugin";importparserfrom"@html-eslint/parser";exportdefault[// recommended configuration included in the pluginhtml.configs["flat/recommended"],// your own configurations.{files: ["**/*.html"],plugins: {"@html-eslint": html,},languageOptions: {
parser,},rules: {"@html-eslint/indent": "error",},},];
Updated:
importhtmlfrom"@html-eslint/eslint-plugin";importhtmlParserfrom"@html-eslint/parser";// <-- renamed to avoid confusion with other parsersexportdefault[// your own configurations.{// recommended configuration included in the plugin
...html.configs["flat/recommended"],// <-- to limit scope of recommendationsfiles: ["**/*.html"],plugins: {"@html-eslint": html,},languageOptions: {parser: htmlParser,// <-- make explicit assignment},rules: {"@html-eslint/indent": "error"}}];
Also, I'm suggesting to rename the parser name to make it explicit that is for html (useful when there is more than one parser used in the file).
Update:
If rules is defined, html.configs["flat/recommended"].rules must be spread inside it to avoid overriding recommended rules.
If rules is not defined, html.configs["flat/recommended"] can be spread directly at object level
Given that html.configs["flat/recommended"] also have plugins and languageOptions.parser, both are optional when html.configs["flat/recommended"] is spread inside the object wherefilesis defined.
In summary:
This works:
importhtmlfrom"@html-eslint/eslint-plugin";exportdefault[// your own configurations.{files: ["**/*.html"],
...html.configs["flat/recommended"]}];
This, too:
importhtmlfrom"@html-eslint/eslint-plugin";exportdefault[// your own configurations.{files: ["**/*.html"],
...html.configs["flat/recommended"],rules: {
...html.configs["flat/recommended"].rules,// <-- Mandatory. If not, rules are lost"@html-eslint/indent": "error"}}];
Or:
importhtmlfrom"@html-eslint/eslint-plugin";importhtmlParserfrom"@html-eslint/parser";// <-- renamed to avoid confusion with other parsersexportdefault[// your own configurations.{files: ["**/*.html"],plugins: {"@html-eslint": html,},languageOptions: {parser: htmlParser,// <-- make explicit assignment},rules: {
...html.configs["flat/recommended"].rules,// <-- Mandatory. If not, rules are lost"@html-eslint/indent": "error"}}];
The text was updated successfully, but these errors were encountered:
In https://html-eslint.org/docs/getting-started, I think the example for flat config should be adjusted.
Reasoning:
Update:
rules
is defined,html.configs["flat/recommended"].rules
must be spread inside it to avoid overriding recommended rules.rules
is not defined,html.configs["flat/recommended"]
can be spread directly at object levelhtml.configs["flat/recommended"]
also haveplugins
andlanguageOptions.parser
, both are optional whenhtml.configs["flat/recommended"]
is spread inside the object wherefiles
is defined.In summary:
This works:
This, too:
Or:
The text was updated successfully, but these errors were encountered: