Skip to content

⬅️ Back to Table of Contents

📄 no-extraneous-class.ts

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 3
📊 Variables & Constants 4
📑 Type Aliases 2

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/src/rules/no-extraneous-class.ts

📦 Imports

Name Source
TSESTree @typescript-eslint/utils
AST_NODE_TYPES @typescript-eslint/utils
createRule ../util

Variables & Constants

Name Type Kind Value Exported
parent any const node.parent
reportNode any const `parent.type === AST_NODE_TYPES.ClassDeclaration && parent.id
? parent.id
: parent`
onlyStatic boolean let/var true
onlyConstructor boolean let/var true

Functions

isAllowWithDecorator(node: TSESTree.ClassDeclaration | TSESTree.ClassExpression | undefined): boolean

Code
(
      node: TSESTree.ClassDeclaration | TSESTree.ClassExpression | undefined,
    ): boolean => {
      return !!(
        allowWithDecorator &&
        node?.decorators &&
        node.decorators.length !== 0
      );
    }
  • Parameters:
  • node: TSESTree.ClassDeclaration | TSESTree.ClassExpression | undefined
  • Return Type: boolean

Type Aliases

Options

type Options = [
  {
    allowConstructorOnly?: boolean;
    allowEmpty?: boolean;
    allowStaticOnly?: boolean;
    allowWithDecorator?: boolean;
  },
];

MessageIds

type MessageIds = 'empty' | 'onlyConstructor' | 'onlyStatic';