Given this code:
export default class {
bar () {
event.foo()
arguments.foo()
foo.foo()
}
}
When you run the no-undef eslint rule, you get this back:
test_controller.js
5:5 error 'foo' is not defined no-undef
foo
isn't defined, so that error makes sense.
arguments
is implicit (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments) so the lack of error makes sense.
But where is event
defined? I'm not aware of it being an implicit variable the way arguments
is. I thought this was a bug in no-undef
, but I extracted this example from some Stimulus code that works fine without the event
parameter. So I want to understand if there's some general JS behavior I'm not aware of here.
For the record (though I'm not sure it matters here), Stimulus calls the function here and does pass an event
parameter. But only the name event
works "magically" and that's what's really doing my head in. Note that my simplified example doesn't reference Stimulus at all.