Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_analyze): Implement noStaticOnlyClass #4514

Merged
merged 21 commits into from
Jun 12, 2023

Conversation

nikeee
Copy link
Contributor

@nikeee nikeee commented May 20, 2023

Summary

This is a WIP PR. Things need to be done better (for example, that match block with a lot of repeated code). I'm takign suggestions here. :)

Things to clarify:

Notes:

  • The diagnostic is located at the class name, not the entire class (for less visual noise).
  • In case the class is anonymous, the diagnostic is located at the class keyword. This may be removed, if we decide to exclude anonymous classes from this rule.

Resolves #4482

Test Plan

Some tests are there. We need to check whether this is everything needed.

Changelog

  • The PR requires a changelog line - I'll do one if the PR gets in a more finished state

Documentation

  • The PR requires documentation
  • I will create a new PR to update the documentation (if necessary, please comment)

@netlify
Copy link

netlify bot commented May 20, 2023

Deploy Preview for docs-rometools ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d6744cf
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/64871e5b09b4df0008e23ab4
😎 Deploy Preview https://deploy-preview-4514--docs-rometools.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 your Netlify site settings.

@github-actions github-actions bot added A-Diagnostic Area: errors and diagnostics A-Linter Area: linter A-Project Area: project configuration and loading labels May 20, 2023
Copy link
Contributor

@Conaclos Conaclos left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution :)

What about private-static fields (static #foo)?

What about TsConstructorSignatureClassMember? It seems as if we can return false here (and thus, treat it as non-static).

I think you got them right: we should treat them like other constructs.

Does this rule match on class expressions or default class exports?

Both.

The disuccsion that I had with ematipico in #4482 has certainly confused you: The rule will be in style once stabilized (in several versions from teh current one). Any new rules should be a nursery rule.

Your rule should be placed in analyzers/nursery (semantic_analyzers is reserved for rules that use the semantic model).

@nikeee
Copy link
Contributor Author

nikeee commented May 20, 2023

I just noticed that the rule also matches on empty classes. I've decided to skip empty classes, since it might be the case that the user is currently typing out a new class. If this doesn't match the intentions of this rule, feel free to comment.

Any Idea on how to get rid of the code duplication? I don't think it's that bad, but it doesn't seem right.

@nikeee nikeee marked this pull request as ready for review May 20, 2023 20:20
@nikeee nikeee marked this pull request as draft May 21, 2023 13:43
@nikeee nikeee marked this pull request as ready for review May 29, 2023 20:06
Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you for you contribution!

@ematipico
Copy link
Contributor

@Conaclos could you review the PR please? I believe we can merge it?

@nikeee Would you mind rebasing your branch? So we can merge it ;)

@nikeee
Copy link
Contributor Author

nikeee commented Jun 12, 2023

@ematipico done and ready for squash :)

@Conaclos Conaclos merged commit 8fc4c6f into rome:main Jun 12, 2023
16 checks passed
@Conaclos
Copy link
Contributor

Thanks for your contribution :)

@nikeee nikeee deleted the feature/noStaticOnlyClass branch June 12, 2023 18:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Diagnostic Area: errors and diagnostics A-Linter Area: linter A-Project Area: project configuration and loading
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📎 Implement noStaticOnlyClass, @typescript-eslint/no-extraneous-class, unicorn/no-static-only-class
3 participants