Skip to content
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

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

Closed
1 task
epmatsw opened this issue Apr 18, 2024 · 1 comment · Fixed by #18364
Closed
1 task

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

epmatsw opened this issue Apr 18, 2024 · 1 comment · Fixed by #18364
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly repro:yes

Comments

@epmatsw
Copy link

epmatsw commented Apr 18, 2024

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

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@epmatsw epmatsw added bug ESLint is working incorrectly repro:needed labels Apr 18, 2024
@aladdin-add
Copy link
Member

Thanks for the report, I was able to repro!

aladdin-add added a commit to aladdin-add/eslint that referenced this issue Apr 19, 2024
It replaced {} with `Object.create(null)` to avoid accessing
properties on the Object prototype.

fixes eslint#18363
aladdin-add added a commit to aladdin-add/eslint that referenced this issue Apr 19, 2024
It replaced {} with `Object.create(null)` to avoid accessing
properties on the Object prototype.

fixes eslint#18363
@aladdin-add aladdin-add added the accepted There is consensus among the team that this change meets the criteria for inclusion label Apr 19, 2024
aladdin-add added a commit to aladdin-add/eslint that referenced this issue Apr 22, 2024
It replaced {} with `Object.create(null)` to avoid accessing
properties on the Object prototype.

fixes eslint#18363
aladdin-add added a commit to aladdin-add/eslint that referenced this issue Apr 22, 2024
It replaced {} with `Object.create(null)` to avoid accessing
properties on the Object prototype.

fixes eslint#18363
mdjermanovic pushed a commit that referenced this issue Apr 23, 2024
It replaced {} with `Object.create(null)` to avoid accessing
properties on the Object prototype.

fixes #18363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly repro:yes
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

2 participants