eslint-plugin-html icon indicating copy to clipboard operation
eslint-plugin-html copied to clipboard

ESLint v9.28, extends, defineConfig - Is this plugin compatible or have I made a mistake in my config

Open shoulders opened this issue 6 months ago • 10 comments

the background

I have tried to get eslint-plugin-html working, but I just keep getting errors.

As you can see I am using the latest version of ESLint which uses the la Config with extends.

I used htmlscripts instead of html when defining this plugin because I already have added eslint-html as html. perhaps the demo code should use a different keyword if what I have done is correct.

the question

Please can someone tell me what mistakes I have made or if the current version is not compatible with my setup.

The error shown in VSCode

Could not find a declaration file for module 'eslint-plugin-html'. 'c:/Users/shoulders/Desktop/thetemp/node_modules/eslint-plugin-html/src/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/eslint-plugin-html if it exists or add a new declaration (.d.ts) file containing declare module 'eslint-plugin-html';ts(7016)

Image

the terminal error - when i load a .html file

[Error - 3:21:48 PM] An unexpected error occurred:
[Error - 3:21:48 PM] TypeError: context.getScope is not a function
Occurred while linting C:\Users\shoulders\Desktop\thetemp\index.html:1
Rule: "__eslint-plugin-html-prepare/__eslint-plugin-html-prepare"
    at getGlobalScope (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint-plugin-html\src\verifyWithSharedScopes.js:80:18)
    at prepare (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint-plugin-html\src\verifyWithSharedScopes.js:12:29)
    at Program (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint-plugin-html\src\verifyWithFlatConfigPatch.js:70:21)
    at ruleErrorHandler (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint\lib\linter\linter.js:1307:33)
    at C:\Users\shoulders\Desktop\thetemp\node_modules\eslint\lib\linter\safe-emitter.js:45:46
    at Array.forEach (<anonymous>)
    at Object.emit (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint\lib\linter\safe-emitter.js:45:26)
    at #applySelector (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint\lib\linter\source-code-traverser.js:148:17)
    at ESQueryHelper.applySelectors (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint\lib\linter\source-code-traverser.js:206:24)
    at SourceCodeTraverser.traverseSync (C:\Users\shoulders\Desktop\thetemp\node_modules\eslint\lib\linter\source-code-traverser.js:277:16)

My Environment

VSCode: v 1.101.0 ESLint: v9.28.0 node: v22.16.0 npm ls ├── @eslint/[email protected] ├── @eslint/[email protected] ├── @eslint/[email protected] ├── @eslint/[email protected] ├── @html-eslint/[email protected] ├── @html-eslint/[email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]

My eslint.config.mjs

import js from "@eslint/js";
import globals from "globals";
import json from "@eslint/json";
import markdown from "@eslint/markdown";
import css from "@eslint/css";
import html from "@html-eslint/eslint-plugin";
import htmlscripts from "eslint-plugin-html";
import { defineConfig } from "eslint/config";


export default defineConfig([
  { files: ["**/*.{js,mjs,cjs}"], plugins: { js }, extends: ["js/recommended"] },
  { files: ["**/*.{js,mjs,cjs}"], languageOptions: { globals: globals.browser } },
  { files: ["**/*.json"], plugins: { json }, language: "json/json", extends: ["json/recommended"] },
  { files: ["**/*.jsonc"], plugins: { json }, language: "json/jsonc", extends: ["json/recommended"] },
  { files: ["**/*.json5"], plugins: { json }, language: "json/json5", extends: ["json/recommended"] },
  { files: ["**/*.md"], plugins: { markdown }, language: "markdown/gfm", extends: ["markdown/recommended"] },
  { files: ["**/*.css"], plugins: { css }, language: "css/css", extends: ["css/recommended"] },
  { files: ["**/*.html"], plugins: { html }, language: "html/html", extends: [html.configs["flat/recommended"]] },
  { files: ["**/*.html"], plugins: { htmlscripts } },
]);

shoulders avatar Jun 13 '25 14:06 shoulders