BenoitZugmeyer / eslint-plugin-html

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

Linting non-inline scripts #135

Closed KTibow closed 7 months ago

KTibow commented 3 years ago

Description

Right now, you can only lint non-inline scripts. It'd be good if you could lint stuff using the syntax of

<script src="/confetti.js"></script>

Ideally it would use the syntax of **/confetti.js, because projects might have it in a different place than the root or the same dir.

Alternatives

Use some kind of plugin to replace it with an inline script.

Additional context

brettz9 commented 3 years ago

Just to suggest another alternative. With my project es-file-traverse, you can point to an HTML file (or a file with import or require) to extract the script file names to be linted. The CLI currently has no option for base directory, but you should be able to use the programmatic API to adapt it.

BenoitZugmeyer commented 7 months ago

ESLint works on a per-file basis. Linting JS files referenced in HTML files is out of scope for this plugin. The alternative pointed by @brettz9 looks like a fine alternative.