BenoitZugmeyer / eslint-plugin-html

An ESLint plugin to extract and lint scripts from HTML files.
ISC License
436 stars 51 forks source link

fix: prevent patching linter verify funtion multiple times #89

Closed noe132 closed 6 years ago

noe132 commented 6 years ago

Hi. I was using atom as main editor to code file, using linter-eslint to get eslint working in atom.

I got a strange behavior while linting vue files, after digging in I find that the reason that this is happening is because linter-eslint import eslint to create eslint.CLIEngine from both project to lint files independently (but in one worker process) https://github.com/AtomLinter/linter-eslint/blob/master/src/worker.js#L16 https://github.com/AtomLinter/linter-eslint/blob/master/src/worker-helpers.js#L111

while eslint-plugin-html patch the every linter it found when init itself, where we have 2 eslint imported, means that 2 eslint-plugin-html was imported too. This lead to some linter was patched more than 1 time, and it cause the fail linting. it could be easy reproduce by init 2 project with installed with eslint and eslint-plugin-html, and require both eslint in one node process, and try to lint vue files using those 2 eslint instances.

I think that tag the Linter as patched to prevent multiple patch should be good to fix this

noe132 commented 6 years ago

this issue reproduce step video here code using in this video check https://github.com/noe132/eslint-plugin-html-test-case

BenoitZugmeyer commented 6 years ago

Sorry for the wait, thank you very much for your PR!