-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inline event handler linting #123
Comments
First of all, thank you for the well written issue and sorry for the response delay. This is a popular issue (see previous one #61), even an implementation attempt have been made (#87) but never followed. That said, I'm a bit shy about working on this, as there is a few open questions:
As far as the |
All good, thank you for the reply!
I'd think either disabled, or if there may be some use cases for some questionable rules, leave it to
<body>
<!-- The following won't work with type=module, whether the input is above or below the script,
but the input does work in either position when there is no type=module -->
<input onchange="alert(a);">
<script type="module">
var a = 5;
</script>
<!-- This implicit global can affect the script below, whether it is type=module or not, and
whether the input is below or above; it will be an error until defined -->
<input onchange="b = 8;">
<script type="module">
setInterval(() => {
console.log(b);
}, 3000);
</script>
</body> Perhaps
Cool |
Description
Inline event handlers such as
onload
can contain JavaScript. These may contain errors or one may not want these handlers at all.It would be great if
eslint-plugin-html
:event
as defined (and foronerror
treatsource
,lineno
,colno
, anderror
as defined) (but don't treat them as unused if they are not used).this
Alternatives
Allow bad code within HTML. (A particular concern is the likes of https://github.com/mozilla/eslint-plugin-no-unsanitized not being able to find
innerHTML
usage.)There was at one point a Firefox add-on for detecting inline handlers, but this is not automated.
Additional context
* See -https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers#Event_handlers_parameters_this_binding_and_the_return_value
And thanks for the great plugin!
The text was updated successfully, but these errors were encountered: