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-unnecessary-parameter-property-assignment] add new rule#8903

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

Merged

Conversation

yeonjuan
Copy link
Contributor

@yeonjuanyeonjuan commentedApr 11, 2024
edited
Loading

PR Checklist

Overview

kirkwaiblinger reacted with thumbs up emojicamsteffen reacted with rocket emoji
@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 onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedApr 11, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitb2690e4
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/66813ec59074a1000808408a
😎 Deploy Previewhttps://deploy-preview-8903--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: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (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 site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedApr 11, 2024
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitb2690e4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 fromNxCloud.

@yeonjuanyeonjuanforce-pushed thenew-rule/7045 branch 4 times, most recently fromf10ba89 to95cbd19CompareApril 13, 2024 15:17
@yeonjuanyeonjuan marked this pull request as ready for reviewApril 13, 2024 16:10
@bradzacherbradzacher added the enhancement: new plugin ruleNew rule request for eslint-plugin labelMay 28, 2024
@JoshuaKGoldbergJoshuaKGoldberg changed the titlefeat(eslint-plugin): [no-unnecessary-property-assignment] add new rulefeat(eslint-plugin): [no-unnecessary-parameter-property-assignment] add new ruleJun 2, 2024
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.

This is looking great! Sorry for the long review time on it. It looked more intimidating from the outside to me than it ended up being 😅. A testament to the nice clean code on the inside!

Because scope analysis tends to be tricky, I went with a little more scrutiny than average on granular code nitpicking.

Brown cartoon cat ("Goma") nodding with sunglasses and crossed arms. Caption: "YES"

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelJun 2, 2024
@yeonjuan
Copy link
ContributorAuthor

@JoshuaKGoldberg Thank you for your review. I fixed it.

JoshuaKGoldberg reacted with rocket emoji

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelJun 12, 2024
Copy link
Contributor

Choose a reason for hiding this comment

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

More test cases I have in mind:

  1. this.foo = this.foo

  2. setTimeout(() => this.foo = foo, 0)

  3. bitwise/shifting operators?

declareconstkey:'foo';classFoo{constructor(privatefoo:string){this[key]=foo;}}

Choose a reason for hiding this comment

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

setTimeout(() => this.foo = foo, 0)

That's covered enough by the(() => {})() IMO. This just generally needs to check a call expression.

bitwise/shifting operators`

I think we're fine with the existing set of operators. They're similar enough in the AST that we don't need to be exhaustive.

declare const key: 'foo'

Covered bydeclare const name: string IMO

JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesJun 29, 2024
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.

This looks lovely, thanks! 🧹

I only have small nitpicks left - happy to apply these before our Monday release.

</TabItem>
</Tabs>

{/* Intentionally Omitted: When Not To Use It */}

Choose a reason for hiding this comment

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

[Docs] To mention: if you don't use parameter properties, you can ignore this rule.

yeonjuan reacted with thumbs up emoji
>
> See **https://typescript-eslint.io/rules/no-unnecessary-parameter-property-assignment** for documentation.

Parameter properties let you create and initialize a member in one place.

Choose a reason for hiding this comment

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

[Docs] This explanation is pretty sparse. We've been trying to flesh out our docs to be more useful. How about linking to the TypeScript docs?https://www.typescriptlang.org/docs/handbook/2/classes.html#parameter-properties

Suggested change
Parameterproperties let you createandinitialize a member in one place.
[TypeScript's parameterproperties](https://www.typescriptlang.org/docs/handbook/2/classes.html#parameter-properties) allow creatingandinitializing a member in one place.

yeonjuan reacted with thumbs up emoji
Comment on lines 7 to 11
type MessageIds = 'unnecessaryAssign';

const UNNECESSARY_OPERATORS = new Set(['=', '&&=', '||=', '??=']);

export default createRule<[], MessageIds>({

Choose a reason for hiding this comment

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

[Style] No need to explicitly declare those type arguments ✨

Suggested change
typeMessageIds='unnecessaryAssign';
constUNNECESSARY_OPERATORS=newSet(['=','&&=','||=','??=']);
exportdefaultcreateRule<[],MessageIds>({
constUNNECESSARY_OPERATORS=newSet(['=','&&=','||=','??=']);
exportdefaultcreateRule({

yeonjuan reacted with thumbs up emoji
docs: {
description:
'Disallow unnecessary assignment of constructor property parameter',
requiresTypeChecking: false,

Choose a reason for hiding this comment

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

[Style] TIL three existing rules declare this explicitly ... but they don't need to:

Suggested change
requiresTypeChecking: false,

yeonjuan reacted with thumbs up emoji

Choose a reason for hiding this comment

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

setTimeout(() => this.foo = foo, 0)

That's covered enough by the(() => {})() IMO. This just generally needs to check a call expression.

bitwise/shifting operators`

I think we're fine with the existing set of operators. They're similar enough in the AST that we don't need to be exhaustive.

declare const key: 'foo'

Covered bydeclare const name: string IMO

@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelJun 29, 2024
@yeonjuan
Copy link
ContributorAuthor

@JoshuaKGoldberg Thanks! I fixed!d22cb8b

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.

🚀 thanks!

@JoshuaKGoldbergJoshuaKGoldberg merged commit451e738 intotypescript-eslint:mainJul 6, 2024
61 checks passed
description:
'Disallow unnecessary assignment of constructor property parameter',
},
fixable: 'code',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this true? I'm not able to get it to fix my code, and I don't see where a fixer is passed tocontext.report.

Choose a reason for hiding this comment

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

Aha! You're right - this was an oversight.eslint/eslint#18008 would have caught it.

Are you up for filing an issue and/or sending a PR@dasa? It'd be a great contribution 😁

JoshuaKGoldberg pushed a commit that referenced this pull requestJul 9, 2024
…remove `fixable` from `meta` (#9527)chore: remove `fixable` from `meta`No fixer is actually present.Ref:#8903 (comment)
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJul 18, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dasadasadasa left review comments

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

@StyleShitStyleShitStyleShit requested changes

Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we mergeenhancement: new plugin ruleNew rule request for eslint-plugin
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Rule proposal: forbid unnecessary assignment of parameter properties
5 participants
@yeonjuan@dasa@JoshuaKGoldberg@StyleShit@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp