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: [no-extraneous-class] Explain why the rule is useful #5040

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updatingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Right now the rule just quotes TSLint's old docs as evidence:

Users who come from a Java-style OO language may wrap their utility functions in an extra class, instead of putting them at the top level.

...but it doesn't explainwhy wrapping utility functions in an extra class is unnecessary or even bad.

In summary:

  • Wrapper classes add extra runtime bloat and cognitive complexity to code without adding any structural improvements
    • Whatever would be put on them, such as utility functions, is already organized by virtue of the module it's in.
    • You can alwaysimport * as ... the module to get all of them in a single object.
  • IDEs can't provide as good autocompletions when you start typing the names of the helpers, since they're on a class instead of freely available to import
  • It's harder to statically analyze code for unused variables, etc. when they're all on the class (see:ts-prune).

IME, this kind of class structure often comes up and is later regretted with teams that are used to adhering to OOP principles but then work in a runtime (e.g. Node) and project type (e.g. Express) that don't need them. They eventually get used to using ECMAScript modules as their form of organization, and find the extra classes to be unnecessary bloat.

Affected URL(s)

https://typescript-eslint.io/rules/no-extraneous-class

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updatingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp