eslint / eslint

Find and fix problems in your JavaScript code.
https://eslint.org
MIT License
24.39k stars 4.4k forks source link

Bug: defining a global named `__defineSetter__` doesn't work #18363

Closed epmatsw closed 3 weeks ago

epmatsw commented 1 month ago

Environment

https://eslint.org/play/#eyJ0ZXh0IjoiLypnbG9iYWwgX19kZWZpbmVTZXR0ZXJfXywgYSovXG5cbl9fZGVmaW5lU2V0dGVyX18gPSA0MjsiLCJvcHRpb25zIjp7InJ1bGVzIjp7Im5vLXVuZGVmIjpbImVycm9yIl19LCJsYW5ndWFnZU9wdGlvbnMiOnsicGFyc2VyT3B0aW9ucyI6eyJlY21hRmVhdHVyZXMiOnt9fX19fQ==

What parser are you using?

Default (Espree)

What did you do?

Defining a global named __defineSetter causes eslint to crash if done in an inline comment. It also seems not to work if done in a config file.

https://eslint.org/play/#eyJ0ZXh0IjoiLypnbG9iYWwgX19kZWZpbmVTZXR0ZXJfXywgYSovXG5cbl9fZGVmaW5lU2V0dGVyX18gPSA0MjsiLCJvcHRpb25zIjp7InJ1bGVzIjp7Im5vLXVuZGVmIjpbImVycm9yIl19LCJsYW5ndWFnZU9wdGlvbnMiOnsicGFyc2VyT3B0aW9ucyI6eyJlY21hRmVhdHVyZXMiOnt9fX19fQ==

Configuration ``` export default [ { "rules": { "no-undef": [ "error" ] } } ]; ```
/*global __defineSetter__, a*/

__defineSetter__ = 42;

What did you expect to happen?

It should treat __defineSetter__ as a valid global.

What actually happened?

ESLint crashes. When specified in the globals object in a config rather than an inline comment, it doesn't crash but it also doesn't seem to respect the global.

Link to Minimal Reproducible Example

https://eslint.org/play/#eyJ0ZXh0IjoiLypnbG9iYWwgX19kZWZpbmVTZXR0ZXJfXywgYSovXG5cbl9fZGVmaW5lU2V0dGVyX18gPSA0MjsiLCJvcHRpb25zIjp7InJ1bGVzIjp7Im5vLXVuZGVmIjpbImVycm9yIl19LCJsYW5ndWFnZU9wdGlvbnMiOnsicGFyc2VyT3B0aW9ucyI6eyJlY21hRmVhdHVyZXMiOnt9fX19fQ==

Participation

Additional comments

No response

aladdin-add commented 1 month ago

Thanks for the report, I was able to repro!