Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

ESLint config is broken for IDE integrations like VS Code #5

Closed
Haprog opened this issue Mar 11, 2019 · 1 comment
Closed

ESLint config is broken for IDE integrations like VS Code #5

Haprog opened this issue Mar 11, 2019 · 1 comment
Assignees

Comments

@Haprog
Copy link

Haprog commented Mar 11, 2019

Description

ESLint config is broken due to used dependency versions of eslint and eslint-plugin-html.

gulp lint does seem to work though. So I guess gulp-eslint is working fine, but directly calling the eslint CLI doesn't currently work in combination with eslint-plugin-html (when linting HTML files) which also breaks IDE integrations (like ESLint extension for VS Code [dbaeumer.vscode-eslint]) which depend on the eslint CLI.

When opening an HTML file with VS Code, the ES Lint extension throws an error (see "Actual outcome" below)

Expected outcome

ES Lint plugin in VS Code should work fine when you open HTML files in the project. Also calling ./node_modules/eslint/bin/eslint.js src/**/*.html should work without errors.

Actual outcome

In both use cases an error is thrown:

TypeError: Cannot read property 'define' of undefined
    at Linter.verifyWithSharedScopes (/Users/haprog/Work/components/vaadin-combo-box/node_modules/eslint-plugin-html/src/index.js:202:16)
    at Linter.verify (/Users/haprog/Work/components/vaadin-combo-box/node_modules/eslint-plugin-html/src/index.js:170:32)
    at Linter.verifyAndFix (/Users/haprog/Work/components/vaadin-combo-box/node_modules/eslint/lib/linter.js:1035:29)
    at processText (/Users/haprog/Work/components/vaadin-combo-box/node_modules/eslint/lib/cli-engine.js:197:32)
    at CLIEngine.executeOnText (/Users/haprog/Work/components/vaadin-combo-box/node_modules/eslint/lib/cli-engine.js:690:40)
    at /Users/haprog/.vscode/extensions/dbaeumer.vscode-eslint-1.8.2/server/out/eslintServer.js:1:35002
    at W.E.get.N.then.n (/Users/haprog/.vscode/extensions/dbaeumer.vscode-eslint-1.8.2/server/out/eslintServer.js:1:35937)

Steps to reproduce

  1. Either make a fresh clone of a component repo (e.g. vaadin-combo-box) or delete node_modules/ directory
  2. Run npm install
  3. Do one of
    a. Run ./node_modules/eslint/bin/eslint.js src/**/*.html
    b. use VS Code to open an HTML file which includes some JS. (e.g. src/vaadin-combo-box.html in vaadin-combo-box)

Cause

This problem seems to be caused by BenoitZugmeyer/eslint-plugin-html#113.

See also: eslint/eslint#11346

Can be fixed by either downgrading eslint to version 5.12.0 (now the dependency is ^5.0.0 which currently resolves to 5.15.1) or by upgrading eslint-plugin-html to 5.0.1 or later (now the dependency is ^4.0.0 which currently resolves to 4.0.5).

Looks like this would be fixed by #3.

Workaround

This can be locally worked around (per clone) by doing one of these (and then reloading VS Code):

  • npm i -D eslint-plugin-html@^5.0.0
  • npm i -D eslint@5.12.0
@web-padawan
Copy link
Member

Release in 2.0.0 due to major dependency version bump

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants