Skip to content

Conversation

@ulrichstark
Copy link
Contributor

@ulrichstark ulrichstark commented Oct 25, 2025

PR Checklist

Overview

Reports useless default values.

function Bar({ foo = '' }: { foo: string }) {
  return foo;
}

const { foo = '' } = { foo: 'bar' };

[1, 2, 3].map((a = 42) => a + 1);

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @ulrichstark!

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
Copy link

netlify bot commented Oct 25, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit def0e8a
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/690a29413b76e10008715b89
😎 Deploy Preview https://deploy-preview-11720--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 (🟢 up 1 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (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 project configuration.

@nx-cloud
Copy link

nx-cloud bot commented Oct 25, 2025

View your CI Pipeline Execution ↗ for commit def0e8a

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 19s View ↗
nx run-many -t lint ✅ Succeeded 3m 18s View ↗
nx run-many -t typecheck ✅ Succeeded 1m 57s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 4s View ↗
nx run integration-tests:test ✅ Succeeded 3s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 1s View ↗
nx run generate-configs ✅ Succeeded 7s View ↗
nx run types:build ✅ Succeeded 5s View ↗
Additional runs (29) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-11-04 16:39:02 UTC

@codecov
Copy link

codecov bot commented Oct 25, 2025

Codecov Report

❌ Patch coverage is 93.01075% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.67%. Comparing base (ea2ee6b) to head (def0e8a).

Files with missing lines Patch % Lines
...-plugin/src/rules/no-useless-default-assignment.ts 92.69% 13 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #11720    +/-   ##
========================================
  Coverage   90.66%   90.67%            
========================================
  Files         518      519     +1     
  Lines       52435    52621   +186     
  Branches     8686     8721    +35     
========================================
+ Hits        47541    47714   +173     
- Misses       4880     4893    +13     
  Partials       14       14            
Flag Coverage Δ
unittest 90.67% <93.01%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/eslint-plugin/src/configs/eslintrc/all.ts 100.00% <100.00%> (ø)
...lugin/src/configs/eslintrc/disable-type-checked.ts 100.00% <100.00%> (ø)
...n/src/configs/eslintrc/strict-type-checked-only.ts 100.00% <100.00%> (ø)
...plugin/src/configs/eslintrc/strict-type-checked.ts 100.00% <100.00%> (ø)
packages/eslint-plugin/src/configs/flat/all.ts 100.00% <100.00%> (ø)
...nt-plugin/src/configs/flat/disable-type-checked.ts 100.00% <100.00%> (ø)
...lugin/src/configs/flat/strict-type-checked-only.ts 100.00% <100.00%> (ø)
...int-plugin/src/configs/flat/strict-type-checked.ts 100.00% <100.00%> (ø)
...-plugin/src/rules/no-useless-default-assignment.ts 92.69% <92.69%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ulrichstark ulrichstark marked this pull request as draft October 25, 2025 22:13
@ulrichstark ulrichstark marked this pull request as ready for review October 25, 2025 22:59
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

A great start, I love how readable this implementation is! 👏 nicely done.

Requesting changes mostly on getting test coverage up and covering edge cases. I suspect you'll have to tweak the implementation a little to deal with tuples. Cheers!

default:
return null;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

[Non-Actionable] I'm surprised a utility doesn't already exist for this - but I couldn't find one.

  • getStaticValue: doesn't handle identifiers
  • getStringIfConstant: doesn't handle identifiers (it's a small wrapper around getStaticStringValue)
  • getStaticStringValue: didn't handle identifiers properly

Not requesting changes, just noting - maybe I missed one?

Copy link
Member

Choose a reason for hiding this comment

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

[Testing] Some more "fun" cases to check:

Some of those already work, it'd just be good to have more unit tests for them to be safe.

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Nov 3, 2025
@ulrichstark
Copy link
Contributor Author

Thanks Josh for your review! I already made all low effort changes. Do you also want me to turn the suggestion into a fix? I think it's safe in every case the project is properly typed.

@JoshuaKGoldberg
Copy link
Member

Yes let's do that 🚀

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

Labels

awaiting response Issues waiting for a reply from the OP or another party

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rule proposal: Detect useless default in function parameters and object destructuring

2 participants