Skip to content

fix(eslint-plugin): [dot-notation] handle noPropertyAccessFromIndexSignature true #10644

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

Merged
merged 7 commits into from
Feb 3, 2025

Conversation

yeonjuan
Copy link
Contributor

@yeonjuan yeonjuan commented Jan 13, 2025

PR Checklist

Overview

It addresses #10627 in the way mentioned in #10627 (comment)

We might have to change strategy to inspect the node's indexInfos and look for indexers with keyType.flags & TypeFlags.StringLike?

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @yeonjuan!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 2894e85
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/67a00c00aad5b800085715e9
😎 Deploy Preview https://deploy-preview-10644--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 89 (🔴 down 9 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

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

Copy link

nx-cloud bot commented Jan 13, 2025

View your CI Pipeline Execution ↗ for commit 2894e85.

Command Status Duration Result
nx test eslint-plugin ✅ Succeeded 5m 55s View ↗
nx test eslint-plugin --coverage=false ✅ Succeeded 7m 35s View ↗
nx test type-utils ✅ Succeeded <1s View ↗
nx run types:build ✅ Succeeded <1s View ↗
nx run-many --target=build --exclude website --... ✅ Succeeded 27s View ↗
nx test typescript-eslint ✅ Succeeded 5s View ↗
nx test visitor-keys ✅ Succeeded <1s View ↗
nx test utils ✅ Succeeded <1s View ↗
Additional runs (24) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-02-03 00:40:42 UTC

@yeonjuan yeonjuan force-pushed the fix/10627 branch 2 times, most recently from 4a69ff9 to 39e76a9 Compare January 13, 2025 17:14
@yeonjuan yeonjuan marked this pull request as ready for review January 14, 2025 13:43
@kirkwaiblinger kirkwaiblinger added the awaiting response Issues waiting for a reply from the OP or another party label Jan 19, 2025
@yeonjuan
Copy link
Contributor Author

@kirkwaiblinger Thanks! I've fixed! 41025ca

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.26%. Comparing base (31be053) to head (2894e85).
Report is 45 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10644      +/-   ##
==========================================
+ Coverage   87.15%   87.26%   +0.11%     
==========================================
  Files         448      450       +2     
  Lines       15576    15718     +142     
  Branches     4551     4601      +50     
==========================================
+ Hits        13575    13717     +142     
  Misses       1645     1645              
  Partials      356      356              
Flag Coverage Δ
unittest 87.26% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/eslint-plugin/src/rules/dot-notation.ts 96.77% <100.00%> (+0.22%) ⬆️

... and 20 files with indirect coverage changes

@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Feb 2, 2025
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

one testing request but looks good to me!

Copy link
Member

Choose a reason for hiding this comment

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

(testing)

Let's add a test case that involves generics as well. I was playing with

type ExtraKey = `extra${string}`;

type StructureWithExtras = {
  foo: string;
  bar: boolean;
  [extraKey: ExtraKey]: number;
}

function f<T extends StructureWithExtras>(x: T) {
  console.log(x['extraAbc']);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks for sending this in! 🙂

@kirkwaiblinger kirkwaiblinger added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Feb 3, 2025
@JoshuaKGoldberg JoshuaKGoldberg merged commit 3e44913 into typescript-eslint:main Feb 3, 2025
64 of 65 checks passed
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 5, 2025
| datasource | package                          | from   | to     |
| ---------- | -------------------------------- | ------ | ------ |
| npm        | @typescript-eslint/eslint-plugin | 8.22.0 | 8.23.0 |
| npm        | @typescript-eslint/parser        | 8.22.0 | 8.23.0 |


## [v8.23.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8230-2025-02-03)

##### 🚀 Features

-   **eslint-plugin:** \[no-unnecessary-boolean-literal-compare] enforce strictNullChecks ([#10712](typescript-eslint/typescript-eslint#10712))

##### 🩹 Fixes

-   **eslint-plugin:** \[no-shadow] ignore declare variables in definition files shadowing global variables ([#10710](typescript-eslint/typescript-eslint#10710))
-   **eslint-plugin:** \[no-restricted-imports] support regex option ([#10699](typescript-eslint/typescript-eslint#10699))
-   **eslint-plugin:** \[dot-notation] handle noPropertyAccessFromIndexSignature true ([#10644](typescript-eslint/typescript-eslint#10644))
-   **eslint-plugin:** \[prefer-nullish-coalescing] fix missing return ([#10732](typescript-eslint/typescript-eslint#10732))
-   bump ts-api-utils to ^2.0.1 ([#10761](typescript-eslint/typescript-eslint#10761))
-   **eslint-plugin:** \[no-unnecessary-template-expression] allow interpolating type parameter in type context ([#10739](typescript-eslint/typescript-eslint#10739))
-   **eslint-plugin:** \[switch-exhaustiveness-check] suggest with qualified name ([#10697](typescript-eslint/typescript-eslint#10697))
-   **eslint-plugin:** \[no-unnecessary-type-assertion] should report readonly class properties with a literal initializer ([#10618](typescript-eslint/typescript-eslint#10618))

##### ❤️ Thank You

-   Josh Goldberg ✨
-   Olivier Zalmanski [@OlivierZal](https://github.com/OlivierZal)
-   Ryan Poon [@sopa301](https://github.com/sopa301)
-   YeonJuan [@yeonjuan](https://github.com/yeonjuan)
-   Yukihiro Hasegawa [@y-hsgw](https://github.com/y-hsgw)

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 5, 2025
| datasource | package                          | from   | to     |
| ---------- | -------------------------------- | ------ | ------ |
| npm        | @typescript-eslint/eslint-plugin | 8.22.0 | 8.23.0 |
| npm        | @typescript-eslint/parser        | 8.22.0 | 8.23.0 |


## [v8.23.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8230-2025-02-03)

##### 🚀 Features

-   **eslint-plugin:** \[no-unnecessary-boolean-literal-compare] enforce strictNullChecks ([#10712](typescript-eslint/typescript-eslint#10712))

##### 🩹 Fixes

-   **eslint-plugin:** \[no-shadow] ignore declare variables in definition files shadowing global variables ([#10710](typescript-eslint/typescript-eslint#10710))
-   **eslint-plugin:** \[no-restricted-imports] support regex option ([#10699](typescript-eslint/typescript-eslint#10699))
-   **eslint-plugin:** \[dot-notation] handle noPropertyAccessFromIndexSignature true ([#10644](typescript-eslint/typescript-eslint#10644))
-   **eslint-plugin:** \[prefer-nullish-coalescing] fix missing return ([#10732](typescript-eslint/typescript-eslint#10732))
-   bump ts-api-utils to ^2.0.1 ([#10761](typescript-eslint/typescript-eslint#10761))
-   **eslint-plugin:** \[no-unnecessary-template-expression] allow interpolating type parameter in type context ([#10739](typescript-eslint/typescript-eslint#10739))
-   **eslint-plugin:** \[switch-exhaustiveness-check] suggest with qualified name ([#10697](typescript-eslint/typescript-eslint#10697))
-   **eslint-plugin:** \[no-unnecessary-type-assertion] should report readonly class properties with a literal initializer ([#10618](typescript-eslint/typescript-eslint#10618))

##### ❤️ Thank You

-   Josh Goldberg ✨
-   Olivier Zalmanski [@OlivierZal](https://github.com/OlivierZal)
-   Ryan Poon [@sopa301](https://github.com/sopa301)
-   YeonJuan [@yeonjuan](https://github.com/yeonjuan)
-   Yukihiro Hasegawa [@y-hsgw](https://github.com/y-hsgw)

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [dot-notation] Conflict between noPropertyAccessFromIndexSignature and extra (constrained) object keys
3 participants