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

docs(eslint-plugin): [no-extraneous-class] overhaul rule docs#5059

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

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Expands the rule's docs to include a more complete explanation of the points against namespace-y classes.

Esqarrouth reacted with thumbs up emoji
@nx-cloud
Copy link

nx-cloudbot commentedMay 23, 2022
edited
Loading

☁️ Nx Cloud Report

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

📂 See all runs for this branch


✅ Successfully ran 46 targets

Sent with 💌 fromNxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@JoshuaKGoldberg!

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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitorsper day.

@netlify
Copy link

netlifybot commentedMay 23, 2022
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commita1a5b17
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/6298cb1561de3100080f7652
😎 Deploy Previewhttps://deploy-preview-5059--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify site settings.

@bradzacherbradzacher added the documentationDocumentation ("docs") that needs adding/updating labelMay 23, 2022
@bradzacherbradzacher changed the titledocs: overhauled no-extraneous-class rule docsdocs(eslint-plugin): [no-extraneous-class] overhaul rule docsMay 23, 2022
@JoshuaKGoldbergJoshuaKGoldberg marked this pull request as ready for reviewMay 23, 2022 19:36
@codecov
Copy link

codecovbot commentedMay 23, 2022
edited
Loading

Codecov Report

Merging#5059 (a1a5b17) intomain (ce3083e) willincrease coverage by2.50%.
The diff coverage isn/a.

@@            Coverage Diff             @@##             main    #5059      +/-   ##==========================================+ Coverage   91.32%   93.83%   +2.50%==========================================  Files         132      286     +154       Lines        1487     9839    +8352       Branches      224     2939    +2715     ==========================================+ Hits         1358     9232    +7874- Misses         65      328     +263- Partials       64      279     +215
FlagCoverage Δ
unittest93.83% <ø> (+2.50%)⬆️

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

Impacted FilesCoverage Δ
...kages/eslint-plugin/src/rules/func-call-spacing.ts96.87% <0.00%> (ø)
...es/eslint-plugin/src/rules/prefer-function-type.ts97.18% <0.00%> (ø)
...n/src/rules/no-non-null-asserted-optional-chain.ts46.66% <0.00%> (ø)
...t-plugin/src/rules/no-meaningless-void-operator.ts100.00% <0.00%> (ø)
...plugin/src/rules/explicit-module-boundary-types.ts91.04% <0.00%> (ø)
...c/rules/no-non-null-asserted-nullish-coalescing.ts91.66% <0.00%> (ø)
...t-plugin/src/rules/adjacent-overload-signatures.ts95.34% <0.00%> (ø)
...eslint-plugin/src/rules/consistent-type-imports.ts94.26% <0.00%> (ø)
.../eslint-plugin/src/rules/no-useless-constructor.ts95.23% <0.00%> (ø)
...t-plugin/src/rules/prefer-reduce-type-parameter.ts100.00% <0.00%> (ø)
... and144 more

Esqarrouth
Esqarrouth previously approved these changesMay 23, 2022
bradzacher
bradzacher previously approved these changesMay 25, 2022
Copy link
Member

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

I think we need to add a clear example to the docs saying what you should do instead of a static class.

For example:


Instead of using a static utility class you should individually export the utilities from your module.

❌ Incorrect

exportdefaultclassUtilities{staticutil1(){returnUtilities.util3();}staticutil2(){ ...}staticutil3(){ ...}}

✅ Correct

exportfunctionutil1(){returnutil3();}exportfunctionutil2(){ ...}exportfunctionutil3(){ ...}

:::note
One case you need to be careful of is exporting mutable variables.
A class property can be mutated externally, however exported variables are always constant. This means that importers can only ever read the first value they are assigned and importers cannot write to the variables.
This case is very rare and is generally considered a code smell, but if you do need it you can still accomplish it using getters and setter functions as seen below.
:::

❌ Incorrect

exportdefaultclassUtilities{staticmutableField=1;staticutil1(){Utilities.mutableField+=1;}}

✅ Correct

letmutableField=1;exportfunctiongetMutableField(){returnmutableField;}exportfunctionsetMutableField(value:number){mutableField=value;}exportfunctionutil1(){mutableField+=1;}}

JoshuaKGoldberg reacted with thumbs up emoji
@JoshuaKGoldberg
Copy link
MemberAuthor

I'm still planning on getting to this, btw - likely on my Twitch stream tomorrow.

bradzacher, armano2, crutchcorn, and Esqarrouth reacted with thumbs up emoji

bradzacher
bradzacher previously approved these changesJun 1, 2022
@bradzacher
Copy link
Member

200

@bradzacherbradzacher merged commit8698e80 intotypescript-eslint:mainJun 4, 2022
@JoshuaKGoldbergJoshuaKGoldberg deleted the no-extraneous-class-docs branchJune 4, 2022 19:52
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJul 5, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EsqarrouthEsqarrouthEsqarrouth left review comments

@Josh-CenaJosh-CenaJosh-Cena left review comments

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
documentationDocumentation ("docs") that needs adding/updating
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Docs: [no-extraneous-class] Explain why the rule is useful
4 participants
@JoshuaKGoldberg@bradzacher@Esqarrouth@Josh-Cena

[8]ページ先頭

©2009-2025 Movatter.jp