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

feat: update eslint-scope to ignore "use strict" directives in ES3 #15595

Merged
merged 2 commits into from Feb 12, 2022

Conversation

mdjermanovic
Copy link
Member

@mdjermanovic mdjermanovic commented Feb 9, 2022

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:

Updates eslint-scope to include eslint/eslint-scope#87.

What changes did you make? (Give an overview)

Updated package.json, and added tests for two core rules that will be affected by this change:

  • no-invalid-this will have fewer warnings.
  • no-eval will have more warnings.

Is there anything you'd like reviewers to focus on?

Marked as draft as it currently uses eslint-scope from GitHub.

@mdjermanovic mdjermanovic added accepted upgrade labels Feb 9, 2022
@eslint-github-bot eslint-github-bot bot added the feature label Feb 9, 2022
@mdjermanovic mdjermanovic marked this pull request as ready for review Feb 12, 2022
@ljharb
Copy link
Sponsor Contributor

ljharb commented Feb 12, 2022

I think this should be considered a breaking change; there exists no workaround to enforce ES3 syntax and also that it will parse in ES5+ with strict mode in the same eslint run.

@mdjermanovic
Copy link
Member Author

mdjermanovic commented Feb 12, 2022

@ljharb eslint-scope is already released with this change, this PR only updates dependency requirements to ensure consistent behavior with ESLint v8.9.0.

This change is only related to scope analysis, and now it will work correctly for ES3. In particular, this in functions in ES3 environments refers to the global object regardless of "use strict".

@mdjermanovic mdjermanovic merged commit 68f64a9 into main Feb 12, 2022
14 checks passed
@mdjermanovic mdjermanovic deleted the eslint-scope-es3-strict branch Feb 12, 2022
@ljharb
Copy link
Sponsor Contributor

ljharb commented Feb 12, 2022

@mdjermanovic right. but it won't work correctly for ES3 code that runs in an ES5+ engine, which is what actually matters. ecmaVersion: 3 means "ES3 syntax", it doesn't mean "i am only running code in an ES3 engine", because precisely zero people are doing that.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Feb 12, 2022

At any rate, it's clear the decision is made, but what this means is that I have to pin my shared eslint config forever at v8.8.0, since with v8.9.0+, i will run the risk of breaking over 10% of npm's download traffic, because eslint will allow code that runs in IE 6-8 but breaks in every other browser.

@mdjermanovic
Copy link
Member Author

mdjermanovic commented Feb 12, 2022

I understand that, but this is a case where same code works differently in ES3 and ES5 engines. This change fixes analysis for ES3, and brings a possibility to correctly analyze code for both ES3 and ES5 (albeit, with two runs).

@ljharb
Copy link
Sponsor Contributor

ljharb commented Feb 12, 2022

Before, strict code that works in ES5+ would always work in ES3.

In other words, this change allows code patterns that break in every modern browser from now until the end of time, and will only ever work in ancient ES3 engines.

crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Feb 17, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`8.8.0` -> `8.9.0`](https://renovatebot.com/diffs/npm/eslint/8.8.0/8.9.0) |

---

### Release Notes

<details>
<summary>eslint/eslint</summary>

### [`v8.9.0`](https://github.com/eslint/eslint/releases/v8.9.0)

[Compare Source](eslint/eslint@v8.8.0...v8.9.0)

#### Features

-   [`68f64a9`](eslint/eslint@68f64a9) feat: update eslint-scope to ignore `"use strict"` directives in ES3 ([#&#8203;15595](eslint/eslint#15595)) (Milos Djermanovic)
-   [`db57639`](eslint/eslint@db57639) feat: add `es2016`, `es2018`, `es2019`, and `es2022` environments ([#&#8203;15587](eslint/eslint#15587)) (Milos Djermanovic)
-   [`2dc38aa`](eslint/eslint@2dc38aa) feat: fix bug with arrow function return types in function-paren-newline ([#&#8203;15541](eslint/eslint#15541)) (Milos Djermanovic)
-   [`6f940c3`](eslint/eslint@6f940c3) feat: Implement FlatRuleTester ([#&#8203;15519](eslint/eslint#15519)) (Nicholas C. Zakas)

#### Documentation

-   [`570a036`](eslint/eslint@570a036) docs: add `one-var` example with `for-loop` initializer ([#&#8203;15596](eslint/eslint#15596)) (Milos Djermanovic)
-   [`417191d`](eslint/eslint@417191d) docs: Remove the $ prefix in terminal commands ([#&#8203;15565](eslint/eslint#15565)) (Andreas Lewis)
-   [`389ff34`](eslint/eslint@389ff34) docs: add missing `Variable#scope` property in the scope manager docs ([#&#8203;15571](eslint/eslint#15571)) (Milos Djermanovic)
-   [`f63795d`](eslint/eslint@f63795d) docs: no-eval replace dead link with working one ([#&#8203;15568](eslint/eslint#15568)) (rasenplanscher)
-   [`0383591`](eslint/eslint@0383591) docs: Remove old Markdown issue template ([#&#8203;15556](eslint/eslint#15556)) (Brandon Mills)
-   [`a8dd5a2`](eslint/eslint@a8dd5a2) docs: add 'when not to use it' section in no-duplicate-case docs ([#&#8203;15563](eslint/eslint#15563)) (Milos Djermanovic)
-   [`1ad439e`](eslint/eslint@1ad439e) docs: add missed verb in docs ([#&#8203;15550](eslint/eslint#15550)) (Jeff Mosawy)

#### Chores

-   [`586d45c`](eslint/eslint@586d45c) chore: Upgrade to espree@9.3.1 ([#&#8203;15600](eslint/eslint#15600)) (Milos Djermanovic)
-   [`623e1e2`](eslint/eslint@623e1e2) chore: Upgrade to eslint-visitor-keys@3.3.0 ([#&#8203;15599](eslint/eslint#15599)) (Milos Djermanovic)
-   [`355b23d`](eslint/eslint@355b23d) chore: fix outdated link to Code of Conduct in PR template ([#&#8203;15578](eslint/eslint#15578)) (Rich Trott)
-   [`b10fef2`](eslint/eslint@b10fef2) ci: use Node 16 for browser test ([#&#8203;15569](eslint/eslint#15569)) (Milos Djermanovic)
-   [`92f89fb`](eslint/eslint@92f89fb) chore: suggest demo link in bug report template ([#&#8203;15557](eslint/eslint#15557)) (Brandon Mills)

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

 **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1173
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
srijan-deepsource pushed a commit to deepsourcelabs/eslint that referenced this issue May 30, 2022
…slint#15595)

* feat: update eslint-scope to ignore `"use strict"` directives in ES3

* update package.json with eslint-scope@7.1.1
srijan-deepsource added a commit to deepsourcelabs/eslint that referenced this issue May 30, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Aug 12, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age label Aug 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted archived due to age feature upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants