Skip to content

fix(eslint-plugin): [no-unnecessary-type-assertion] should report readonly class properties with a literal initializer - #10618

Merged
JoshuaKGoldberg merged 9 commits into
typescript-eslint:mainfrom
y-hsgw:fix/no-unnecessary-type-assertion
Jan 28, 2025
Merged

JoshuaKGoldberg merged 9 commits into
typescript-eslint:mainfrom
y-hsgw:fix/no-unnecessary-type-assertion

Conversation

@y-hsgw

@y-hsgw y-hsgw commented Jan 6, 2025 •

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

Fixed the bug described in the title.

🐛

@typescript-eslint

Copy link
Copy Markdown
Contributor

Thanks for the PR, @y-hsgw!

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.

@netlify

netlify Bot commented Jan 6, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit a320eaf
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6798161e60e6ae000848e567
😎 Deploy Preview https://deploy-preview-10618--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: 97 (🔴 down 1 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.

@nx-cloud

nx-cloud Bot commented Jan 6, 2025 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a320eaf.

Command Status Duration Result
nx run-many --target=build --exclude website --... ✅ Succeeded 3s View ↗
nx run-many --target=clean ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-27 23:42:03 UTC

@codecov

codecov Bot commented Jan 6, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.26%. Comparing base (a175189) to head (a320eaf).
Report is 43 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10618      +/-   ##
==========================================
+ Coverage   87.00%   87.26%   +0.26%     
==========================================
  Files         447      450       +3     
  Lines       15586    15715     +129     
  Branches     4542     4601      +59     
==========================================
+ Hits        13560    13714     +154     
+ Misses       1671     1645      -26     
- Partials      355      356       +1     
Flag Coverage Δ
unittest 87.26% <100.00%> (+0.26%) ⬆️

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

Files with missing lines Coverage Δ
...-plugin/src/rules/no-unnecessary-type-assertion.ts 98.01% <100.00%> (+0.06%) ⬆️

... and 104 files with indirect coverage changes

@y-hsgw y-hsgw changed the title fix: [no-unnecessary-type-assertion] should report readonly class properties with a literal initializer fix(eslint-plugin): [no-unnecessary-type-assertion] should report readonly class properties with a literal initializer Jan 6, 2025

@ronami ronami left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just minor changes requested. Looks great! 🚀

Comment thread packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts Outdated
Comment thread packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts Outdated
@y-hsgw
y-hsgw requested a review from ronami January 17, 2025 14:49
@github-actions github-actions Bot removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 17, 2025

@ronami ronami left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The implementation looks great to me, nice! 👍

Requesting changes a bit on tests and potentially checking template literals just once, thanks!

Comment thread packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts Outdated
Comment thread packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts Outdated
@ronami ronami added the awaiting response Issues waiting for a reply from the OP or another party label Jan 21, 2025
@y-hsgw
y-hsgw requested a review from ronami January 21, 2025 23:14
@github-actions github-actions Bot removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 21, 2025

@ronami ronami left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍👍 Thanks! looking really good! Requesting small adjustments around testing.

Comment thread packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts Outdated
@ronami ronami added the awaiting response Issues waiting for a reply from the OP or another party label Jan 23, 2025
@y-hsgw
y-hsgw requested a review from ronami January 24, 2025 12:20
@github-actions github-actions Bot removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 24, 2025

@ronami ronami left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just one small change I missed previously, other than that this looks fantastic 🏆

Comment thread packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts Outdated
@ronami ronami added the awaiting response Issues waiting for a reply from the OP or another party label Jan 27, 2025
@y-hsgw
y-hsgw requested a review from ronami January 27, 2025 23:26
@github-actions github-actions Bot removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 27, 2025

@ronami ronami left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for pushing this 🚀

@ronami ronami added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jan 28, 2025

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚀

@JoshuaKGoldberg
JoshuaKGoldberg merged commit 1c73754 into typescript-eslint:main Jan 28, 2025
@y-hsgw
y-hsgw deleted the fix/no-unnecessary-type-assertion branch January 28, 2025 23:46
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 5, 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: [no-unnecessary-type-assertion] should report readonly class properties with a literal initializer

3 participants