yeonjuan / html-eslint

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

Error from rule require-li-container since version 0.21.0 #217

Closed mpohl closed 2 months ago

mpohl commented 2 months ago

Version 0.21.0 causes the following error with my setup. Maybe somebody has a hint how to fix it

Oops! Something went wrong! :(

ESLint: 8.57.0

TypeError: Cannot read properties of undefined (reading 'Program')
Occurred while linting test.html:3
Rule: "@html-eslint/require-li-container"
    at Tag (/node_modules/@html-eslint/eslint-plugin/lib/rules/require-li-container.js:37:61)
    at ruleErrorHandler (/node_modules/eslint/lib/linter/linter.js:1076:28)
    at /node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:803:23)
    at /node_modules/eslint/lib/linter/linter.js:1111:32

eslintrc.js:

module.exports = {
  plugins: ['@html-eslint'],
  parser: '@html-eslint/parser',
  extends: ['plugin:@html-eslint/recommended'],
};

test.html :

<html lang="de">
    <ul>
        <li>something</li>
    </ul>
</html>

Environment Info:


Node version: v21.3.0
npm version: v10.2.4
Local ESLint version: v8.57.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 23.6.0
RobertAKARobin commented 2 months ago

@mpohl Can you update to the latest version (0.26.0) and see if that helps?

mpohl commented 2 months ago

Same with 0.26.0. It is working up to 0.20.0

RobertAKARobin commented 2 months ago

Seems to work OK for me? I had to add <!DOCTYPE html>, but with that added it lints fine. See https://stackblitz.com/edit/stackblitz-starters-kawm2t?file=test.html

mpohl commented 2 months ago

The problem was an outdated @html-eslint/parser It is working now with "@html-eslint/parser": "0.26.0" Thanks for your time!