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: check imports and class names in no-shadow-restricted-names #19272

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

mdjermanovic
Copy link
Member

Prerequisites checklist

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

[ ] Documentation update
[x] 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
[ ] Other, please explain:

Fixes #19271

What changes did you make? (Give an overview)

Updated no-shadow-restricted-names rule to also check imports and class names.

Also updated it to report on all defs as that seems to have been the intention according to the tests.

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

@mdjermanovic mdjermanovic requested a review from a team as a code owner December 24, 2024 18:59
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Dec 24, 2024
@github-actions github-actions bot added the rule Relates to ESLint's core rules label Dec 24, 2024
Copy link

netlify bot commented Dec 24, 2024

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit b1be07e
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/676b047905b2bd00080aa5af
😎 Deploy Preview https://deploy-preview-19272--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly accepted There is consensus among the team that this change meets the criteria for inclusion labels Dec 24, 2024
Copy link
Contributor

@Tanujkanti4441 Tanujkanti4441 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

Would like another team member to review this.

@fasttime
Copy link
Member

Thanks! It looks like the rule was never updated to report on imports and classes. The documentation even refers to a paragraph of the ES5 spec, where imports and classes were not yet defined.

As for reporting on all defs, that seems to ensure that the report locations for vars are disjoint rather than overlaid on the first declaration as it is currently the case:

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

I think this is a useful change.

Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@fasttime fasttime merged commit 87a9352 into main Dec 27, 2024
30 checks passed
@fasttime fasttime deleted the issue19271 branch December 27, 2024 06:23
cswimr pushed a commit to cswimr/gauntlet-cswimr-plugins that referenced this pull request Jan 11, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@eslint/js](https://eslint.org) ([source](https://github.com/eslint/eslint/tree/HEAD/packages/js)) | devDependencies | minor | [`9.17.0` -> `9.18.0`](https://renovatebot.com/diffs/npm/@eslint%2fjs/9.17.0/9.18.0) |
| [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`9.17.0` -> `9.18.0`](https://renovatebot.com/diffs/npm/eslint/9.17.0/9.18.0) |

---

### Release Notes

<details>
<summary>eslint/eslint (@&#8203;eslint/js)</summary>

### [`v9.18.0`](https://github.com/eslint/eslint/releases/tag/v9.18.0)

[Compare Source](eslint/eslint@v9.17.0...v9.18.0)

##### Features

-   [`e84e6e2`](eslint/eslint@e84e6e2) feat: Report allowed methods for `no-console` rule ([#&#8203;19306](eslint/eslint#19306)) (Anna Bocharova)
-   [`8efc2d0`](eslint/eslint@8efc2d0) feat: unflag TypeScript config files ([#&#8203;19266](eslint/eslint#19266)) (Francesco Trotta)
-   [`87a9352`](eslint/eslint@87a9352) feat: check imports and class names in `no-shadow-restricted-names` ([#&#8203;19272](eslint/eslint#19272)) (Milos Djermanovic)

##### Bug Fixes

-   [`da768d4`](eslint/eslint@da768d4) fix: correct `overrideConfigFile` type ([#&#8203;19289](eslint/eslint#19289)) (Francesco Trotta)

##### Documentation

-   [`d9c23c5`](eslint/eslint@d9c23c5) docs: replace `var` with `const` in rule examples ([#&#8203;19325](eslint/eslint#19325)) (Tanuj Kanti)
-   [`8e1a898`](eslint/eslint@8e1a898) docs: add tabs to cli code blocks ([#&#8203;18784](eslint/eslint#18784)) (Jay)
-   [`f3aeefb`](eslint/eslint@f3aeefb) docs: rewrite using let and const in rule examples ([#&#8203;19320](eslint/eslint#19320)) (PoloSpark)
-   [`0b680b3`](eslint/eslint@0b680b3) docs: Update README (GitHub Actions Bot)
-   [`98c86a9`](eslint/eslint@98c86a9) docs: `Edit this page` button link to different branches ([#&#8203;19228](eslint/eslint#19228)) (Tanuj Kanti)
-   [`6947901`](eslint/eslint@6947901) docs: remove hardcoded edit link ([#&#8203;19323](eslint/eslint#19323)) (Milos Djermanovic)
-   [`03f2f44`](eslint/eslint@03f2f44) docs: rewrite var with const in rules examples ([#&#8203;19317](eslint/eslint#19317)) (Thiago)
-   [`26c3003`](eslint/eslint@26c3003) docs: Clarify dangers of eslint:all ([#&#8203;19318](eslint/eslint#19318)) (Nicholas C. Zakas)
-   [`c038257`](eslint/eslint@c038257) docs: add `eqeqeq` in related rules to `no-eq-null` ([#&#8203;19310](eslint/eslint#19310)) (루밀LuMir)
-   [`89c8fc5`](eslint/eslint@89c8fc5) docs: rewrite examples with var using let and const ([#&#8203;19315](eslint/eslint#19315)) (Amaresh  S M)
-   [`db574c4`](eslint/eslint@db574c4) docs: add missing backticks to `no-void` ([#&#8203;19313](eslint/eslint#19313)) (루밀LuMir)
-   [`8d943c3`](eslint/eslint@8d943c3) docs: add missing backticks to `default-case-last` ([#&#8203;19311](eslint/eslint#19311)) (루밀LuMir)
-   [`36ef8bb`](eslint/eslint@36ef8bb) docs: rewrite examples with var using let and const ([#&#8203;19298](eslint/eslint#19298)) (Amaresh  S M)
-   [`1610c9e`](eslint/eslint@1610c9e) docs: add missing backticks to `no-else-return` ([#&#8203;19309](eslint/eslint#19309)) (루밀LuMir)
-   [`df409d8`](eslint/eslint@df409d8) docs: Update README (GitHub Actions Bot)
-   [`2e84213`](eslint/eslint@2e84213) docs: Fix Horizontal Scroll Overflow in Rule Description on Mobile View ([#&#8203;19304](eslint/eslint#19304)) (Amaresh  S M)
-   [`6e7361b`](eslint/eslint@6e7361b) docs: replace `var` with `let` and `const` in rule example ([#&#8203;19302](eslint/eslint#19302)) (Tanuj Kanti)
-   [`069af5e`](eslint/eslint@069af5e) docs: rewrite `var` using `const` in rule examples ([#&#8203;19303](eslint/eslint#19303)) (Kim GyeonWon)
-   [`064e35d`](eslint/eslint@064e35d) docs: remove 'I hope to' comments from scope-manager-interface ([#&#8203;19300](eslint/eslint#19300)) (Josh Goldberg ✨)
-   [`8e00305`](eslint/eslint@8e00305) docs: replace `var` with `const` in rule examples ([#&#8203;19299](eslint/eslint#19299)) (Tanuj Kanti)
-   [`a559009`](eslint/eslint@a559009) docs: Add warning about extending core rules ([#&#8203;19295](eslint/eslint#19295)) (Nicholas C. Zakas)
-   [`0bfdf6c`](eslint/eslint@0bfdf6c) docs: Update README (GitHub Actions Bot)
-   [`ce0b9ff`](eslint/eslint@ce0b9ff) docs: add navigation link for `code explorer` ([#&#8203;19285](eslint/eslint#19285)) (Tanuj Kanti)
-   [`e255cc9`](eslint/eslint@e255cc9) docs: add bluesky icon to footer ([#&#8203;19290](eslint/eslint#19290)) (Tanuj Kanti)
-   [`5d64851`](eslint/eslint@5d64851) docs: remove outdated info about environments ([#&#8203;19296](eslint/eslint#19296)) (Francesco Trotta)
-   [`eec01f0`](eslint/eslint@eec01f0) docs: switch rule examples config format to `languageOptions` ([#&#8203;19277](eslint/eslint#19277)) (Milos Djermanovic)
-   [`b36ca0a`](eslint/eslint@b36ca0a) docs: Fixing Focus Order by Rearranging Element Sequence ([#&#8203;19241](eslint/eslint#19241)) (Amaresh  S M)
-   [`d122c8a`](eslint/eslint@d122c8a) docs: add missing backticks to `sort-imports` ([#&#8203;19282](eslint/eslint#19282)) (루밀LuMir)
-   [`0367a70`](eslint/eslint@0367a70) docs: update custom parser docs ([#&#8203;19288](eslint/eslint#19288)) (Francesco Trotta)
-   [`8c07ebb`](eslint/eslint@8c07ebb) docs: add `border-radius` to `hX:target` selector styles ([#&#8203;19270](eslint/eslint#19270)) (루밀LuMir)
-   [`eff7c57`](eslint/eslint@eff7c57) docs: add limitation section in `no-loop-func` ([#&#8203;19287](eslint/eslint#19287)) (Tanuj Kanti)
-   [`5db226f`](eslint/eslint@5db226f) docs: add missing backticks in various parts of the documentation ([#&#8203;19269](eslint/eslint#19269)) (루밀LuMir)
-   [`789edbb`](eslint/eslint@789edbb) docs: Update README (GitHub Actions Bot)
-   [`613c06a`](eslint/eslint@613c06a) docs: mark rules that are frozen with ❄️ ([#&#8203;19231](eslint/eslint#19231)) (Amaresh  S M)
-   [`43172ec`](eslint/eslint@43172ec) docs: Update README (GitHub Actions Bot)
-   [`ac8b3c4`](eslint/eslint@ac8b3c4) docs: fix description of `overrideConfigFile` option ([#&#8203;19262](eslint/eslint#19262)) (Milos Djermanovic)
-   [`bbb9b46`](eslint/eslint@bbb9b46) docs: Update README (GitHub Actions Bot)
-   [`995b492`](eslint/eslint@995b492) docs: fix inconsistent divider in rule categories box ([#&#8203;19249](eslint/eslint#19249)) (Tanuj Kanti)
-   [`f76d05d`](eslint/eslint@f76d05d) docs: Refactor search result handling with better event listener cleanup ([#&#8203;19252](eslint/eslint#19252)) (Amaresh  S M)
-   [`c5f3d7d`](eslint/eslint@c5f3d7d) docs: Update README (GitHub Actions Bot)

##### Chores

-   [`c52be85`](eslint/eslint@c52be85) chore: upgrade to `@eslint/js@9.18.0` ([#&#8203;19330](eslint/eslint#19330)) (Francesco Trotta)
-   [`362099c`](eslint/eslint@362099c) chore: package.json update for [@&#8203;eslint/js](https://github.com/eslint/js) release (Jenkins)
-   [`495aa49`](eslint/eslint@495aa49) chore: extract package `name` from `package.json` for public interface ([#&#8203;19314](eslint/eslint#19314)) (루밀LuMir)
-   [`6fe0e72`](eslint/eslint@6fe0e72) chore: update dependency [@&#8203;eslint/json](https://github.com/eslint/json) to ^0.9.0 ([#&#8203;19263](eslint/eslint#19263)) (renovate\[bot])

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - 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 these updates again.

---

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

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44Ny4wIiwidXBkYXRlZEluVmVyIjoiMzkuODcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://www.coastalcommits.com/cswimr/gauntlet-cswimr-plugins/pulls/21
Reviewed-by: cswimr <seaswimmerthefsh@gmail.com>
Co-authored-by: Renovate <renovate@coastalcommits.com>
Co-committed-by: Renovate <renovate@coastalcommits.com>
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 feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Bug: no-shadow-restricted-names doesn't flag shadowing caused by imports
3 participants