Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): [no-useless-default-assignment] add rule#11720

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@ulrichstark
Copy link
Contributor

@ulrichstarkulrichstark commentedOct 25, 2025
edited
Loading

PR Checklist

Overview

Reports useless default values.

functionBar({ foo=''}:{foo:string}){returnfoo;}const{ foo=''}={foo:'bar'};const[foo='']=['bar'];[1,2,3].map((a=42)=>a+1);

zanminkian and rivajunior reacted with thumbs up emojilishaduck reacted with heart emoji
@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 onhttps://opencollective.com/typescript-eslint.

@netlify
Copy link

netlifybot commentedOct 25, 2025
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit026fd7f
🔍 Latest deploy loghttps://app.netlify.com/projects/typescript-eslint/deploys/692f5a2de7675f000801ac59
😎 Deploy Previewhttps://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: 93 (🔴 down 2 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 yourNetlify project configuration.

@nx-cloud
Copy link

nx-cloudbot commentedOct 25, 2025
edited
Loading

View yourCI Pipeline Execution ↗ for commit026fd7f

CommandStatusDurationResult
nx test eslint-plugin --coverage=false✅ Succeeded5m 25sView ↗
nx run-many -t lint✅ Succeeded3m 15sView ↗
nx run-many -t typecheck✅ Succeeded2m 1sView ↗
nx run types:build✅ Succeeded1sView ↗
nx run integration-tests:test✅ Succeeded6sView ↗
nx run generate-configs✅ Succeeded8sView ↗
nx test eslint-plugin-internal --coverage=false✅ Succeeded4sView ↗
nx test typescript-estree --coverage=false✅ Succeeded1sView ↗
Additional runs (29)✅ Succeeded...View ↗

☁️Nx Cloud last updated this comment at2025-12-02 21:41:13 UTC

@codecov
Copy link

codecovbot commentedOct 25, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (5ac66a6) to head (026fd7f).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@##             main   #11720      +/-   ##==========================================+ Coverage   90.53%   90.58%   +0.04%==========================================  Files         523      524       +1       Lines       53097    53325     +228       Branches     8838     8892      +54     ==========================================+ Hits        48074    48302     +228  Misses       5010     5010                Partials       13       13
FlagCoverage Δ
unittest90.58% <100.00%> (+0.04%)⬆️

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

Files with missing linesCoverage Δ
packages/eslint-plugin/src/configs/eslintrc/all.ts100.00% <100.00%> (ø)
...lugin/src/configs/eslintrc/disable-type-checked.ts100.00% <100.00%> (ø)
...n/src/configs/eslintrc/strict-type-checked-only.ts100.00% <100.00%> (ø)
...plugin/src/configs/eslintrc/strict-type-checked.ts100.00% <100.00%> (ø)
packages/eslint-plugin/src/configs/flat/all.ts100.00% <100.00%> (ø)
...nt-plugin/src/configs/flat/disable-type-checked.ts100.00% <100.00%> (ø)
...lugin/src/configs/flat/strict-type-checked-only.ts100.00% <100.00%> (ø)
...int-plugin/src/configs/flat/strict-type-checked.ts100.00% <100.00%> (ø)
...-plugin/src/rules/no-useless-default-assignment.ts100.00% <100.00%> (ø)
🚀 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.

@ulrichstarkulrichstark marked this pull request as draftOctober 25, 2025 22:13
@ulrichstarkulrichstark marked this pull request as ready for reviewOctober 25, 2025 22:59
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg 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!

ulrichstark reacted with heart emoji
default:
returnnull;
}
}

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 aroundgetStaticStringValue)
  • getStaticStringValue: didn't handle identifiers properly

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

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelNov 3, 2025
@ulrichstark
Copy link
ContributorAuthor

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 🚀

ulrichstark reacted with rocket emoji

@github-actionsgithub-actionsbot removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelNov 26, 2025
JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesNov 28, 2025
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Lovely work, thanks! 🙌

@ronami had a bunch of good points I'd missed last review cycle, so if they have time it'd be good to hear from them too.

ulrichstark and ronami reacted with thumbs up emoji
@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelNov 28, 2025
bradzacher
bradzacher previously approved these changesNov 30, 2025
Copy link
Member

@ronamironami left a comment

Choose a reason for hiding this comment

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

🚀🚀 Looks amazing!

I've added two comments for bugs around destructuring records/mapped-types.

ulrichstark reacted with heart emoji
@github-actionsgithub-actionsbot removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 1, 2025
Copy link
Member

@ronamironami left a comment
edited
Loading

Choose a reason for hiding this comment

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

Lovely work! 🏆

Requesting one final adjustment for records/mapped-types around thenoUncheckedIndexedAccess compiler option.

ulrichstark reacted with rocket emoji
Copy link
Member

@ronamironami left a comment

Choose a reason for hiding this comment

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

🚀🚀

ulrichstark reacted with heart emoji
@JoshuaKGoldbergJoshuaKGoldberg merged commit1301f79 intotypescript-eslint:mainDec 14, 2025
67 checks passed
@ulrichstarkulrichstark deleted the feat(eslint-plugin)---no-useless-default-assignment]-add-rule branchDecember 14, 2025 20:21
@simPod
Copy link

importtype{TypePolicy}from'@apollo/client';importtype{Foo,Bar}from'@app/gql/graphql';import{replaceArray}from'./helpers';exportconstnetworkPortTypePolicy:TypePolicy={fields:{pduLinks:{merge:(_existing:PduPortLink[]|undefined,incoming:PduPortLink[]=[])=>replaceArray<PduPortLink>(_existing,incoming),},serverLinks:{merge:(_existing:ServerPortLink[]|undefined,incoming:ServerPortLink[]=[])=>replaceArray<ServerPortLink>(_existing,incoming),},},};
ESLint: 8.57.1TypeError: Cannot read properties of undefined (reading 'getParameters')Occurred while linting /builds/myfile.ts:10Rule: "@typescript-eslint/no-useless-default-assignment"    at checkAssignmentPattern (/builds/.yarn/__virtual__/@typescript-eslint-eslint-plugin-virtual-a7bfaa68a3/5/cache/yarn/cache/@typescript-eslint-eslint-plugin-npm-8.50.0-f4ae1c8099-10c0.zip/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-useless-default-assignment.js:114:54)    at ruleErrorHandler (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/linter.js:1076:28)    at /cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/safe-emitter.js:45:58    at Array.forEach (<anonymous>)    at Object.emit (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/safe-emitter.js:45:38)    at NodeEventGenerator.applySelector (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/node-event-generator.js:297:26)    at NodeEventGenerator.applySelectors (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/node-event-generator.js:326:22)    at NodeEventGenerator.enterNode (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/node-event-generator.js:340:14)    at CodePathAnalyzer.enterNode (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:803:23)    at /cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/linter.js:1111:32    at Array.forEach (<anonymous>)    at runRules (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/linter.js:1106:15)    at Linter._verifyWithoutProcessors (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/linter.js:1355:31)    at Linter._verifyWithConfigArray (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/linter.js:1807:21)    at Linter.verify (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/linter.js:1437:65)    at Linter.verifyAndFix (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/linter/linter.js:2068:29)    at verifyText (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/cli-engine/cli-engine.js:254:48)    at CLIEngine.executeOnFiles (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/cli-engine/cli-engine.js:834:28)    at ESLint.lintFiles (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/eslint/eslint.js:551:23)    at Object.execute (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/lib/cli.js:421:36)    at async main (/cache/yarn/cache/eslint-npm-8.57.1-dd20287a5a-10c0.zip/node_modules/eslint/bin/eslint.js:152:22)
ulrichstark reacted with thumbs up emoji

@ulrichstark
Copy link
ContributorAuthor

Hey@simPod, thanks for reporting that crash! It's fixed when#11845 is merged and released.

@kirkwaiblinger
Copy link
Member

@simPod@ulrichstark

Please file a new issue with reproduction for this, thanks! Seehttps://typescript-eslint.io/contributing/issues#commenting

@typescript-eslinttypescript-eslint locked asresolvedand limited conversation to collaboratorsDec 15, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@ronamironamironami approved these changes

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg left review comments

@bradzacherbradzacherbradzacher left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

6 participants

@ulrichstark@JoshuaKGoldberg@simPod@kirkwaiblinger@ronami@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp