BenoitZugmeyer / eslint-plugin-html

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

Work with multiple script tags which have a src #110

Closed AlexMcDermott closed 4 years ago

AlexMcDermott commented 5 years ago

Description

It would be nice to have a HTML file with multiple script tags with src attributes and have them all be linted under the same global scope. Such as:

image

This would be useful when creating web apps with multiple classes across different files and being able to lint them without having to define globals for each file and stop ESLint complaint about undefined classes and classes being defined but not used. Such as in the image bellow:

loo14

I have an open question on Stack Overflow where we came to the consensus that it is not the current functionally of this plugin but nether the less details my situation. Thank you for your time :)

EDIT: This seems like a feature you may have remove for performance reasons when working with a large number of files? See here. If so would it be possible to add it back as an option?

BenoitZugmeyer commented 5 years ago

Thanks for your issue. This could be a nice addition indeed, with some limitations (ex: defered script loading may not define variables when the inline scripts are executed). We'd need a path declaration like jest, typescript or webpack.

My plugin never implemented such feature. The issue #102 was about <script> tags with no inline content (whether having a src attribute or not).

BenoitZugmeyer commented 4 years ago

Since files will be linted separately anyway (ex: by feeding the whole directory toeslint, or when editin the file via a code editor), this kind of errors will appear no matter how the HTML plugin handles scripts referenced in HTML files. I'm going to close this, as this feature would be hard to implement and offer limited advantages anyway.