Skip to content

build: Add @typescript-eslint/no-unnecessary-type-assertion rule - #17728

Merged
mydea merged 3 commits into
developfrom
fn/type-assertions
Sep 23, 2025
Merged

mydea merged 3 commits into
developfrom
fn/type-assertions

Conversation

@mydea

@mydea mydea commented Sep 22, 2025

Copy link
Copy Markdown
Member

This PR adds the no-unnecessary-type-assertion eslint rule.

This rule captures unneeded type assertions/conversions. E.g. the following code will be raised:

const thing = { name: 'string' };

// no need for !, this def. exists
thing!.name

// no need to cast to string, as this is already the type
thing.name as string; 

note that this also expects you to use generics where possible instead of casting types, which is nicer anyhow (e.g. getIntegrationByName<IntegrationType>(..) vs getIntegrationByName(..) as IntegrationType).

@mydea
mydea requested review from RulaKhaled and s1gr1d September 22, 2025 11:57
@mydea mydea self-assigned this Sep 22, 2025
@mydea
mydea requested review from a team as code owners September 22, 2025 11:57
@github-actions

github-actions Bot commented Sep 22, 2025 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 24.23 kB - -
@sentry/browser - with treeshaking flags 22.74 kB - -
@sentry/browser (incl. Tracing) 40.34 kB - -
@sentry/browser (incl. Tracing, Replay) 78.72 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.38 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 83.39 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 95.59 kB - -
@sentry/browser (incl. Feedback) 40.95 kB - -
@sentry/browser (incl. sendFeedback) 28.88 kB - -
@sentry/browser (incl. FeedbackAsync) 33.8 kB - -
@sentry/react 25.94 kB - -
@sentry/react (incl. Tracing) 42.32 kB - -
@sentry/vue 28.72 kB - -
@sentry/vue (incl. Tracing) 42.14 kB - -
@sentry/svelte 24.25 kB - -
CDN Bundle 25.74 kB - -
CDN Bundle (incl. Tracing) 40.16 kB - -
CDN Bundle (incl. Tracing, Replay) 76.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 81.88 kB - -
CDN Bundle - uncompressed 75.23 kB - -
CDN Bundle (incl. Tracing) - uncompressed 118.89 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 234.01 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 246.78 kB - -
@sentry/nextjs (client) 44.34 kB - -
@sentry/sveltekit (client) 40.76 kB - -
@sentry/node-core 49.98 kB +0.01% +1 B 🔺
@sentry/node 152.26 kB +0.05% +72 B 🔺
@sentry/node - without tracing 91.88 kB - -
@sentry/aws-serverless 105.33 kB +0.01% +1 B 🔺

View base workflow run

@github-actions

github-actions Bot commented Sep 22, 2025 •

Copy link
Copy Markdown
Contributor

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,292 - 9,098 +2%
GET With Sentry 1,378 15% 1,377 +0%
GET With Sentry (error only) 5,994 65% 5,959 +1%
POST Baseline 1,194 - 1,184 +1%
POST With Sentry 508 43% 499 +2%
POST With Sentry (error only) 1,040 87% 1,030 +1%
MYSQL Baseline 3,304 - 3,317 -0%
MYSQL With Sentry 456 14% 408 +12%
MYSQL With Sentry (error only) 2,675 81% 2,665 +0%

View base workflow run

@s1gr1d s1gr1d 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.

Nice rule!

cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants