Skip to content

⬅️ Back to Table of Contents

📄 no-duplicate-enum-values.ts

📊 Analysis Summary

Metric Count
🔧 Functions 3
📦 Imports 3
📊 Variables & Constants 3

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts

📦 Imports

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

Variables & Constants

Name Type Kind Value Exported
enumMembers any const node.body.members
seenValues Set<string | number> const new Set<number | string>()
value number | string | undefined let/var *not shown*

Functions

isStringLiteral(node: TSESTree.Expression): node is TSESTree.StringLiteral

Code
function isStringLiteral(
      node: TSESTree.Expression,
    ): node is TSESTree.StringLiteral {
      return (
        node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string'
      );
    }
  • Parameters:
  • node: TSESTree.Expression
  • Return Type: node is TSESTree.StringLiteral

isNumberLiteral(node: TSESTree.Expression): node is TSESTree.NumberLiteral

Code
function isNumberLiteral(
      node: TSESTree.Expression,
    ): node is TSESTree.NumberLiteral {
      return (
        node.type === AST_NODE_TYPES.Literal && typeof node.value === 'number'
      );
    }
  • Parameters:
  • node: TSESTree.Expression
  • Return Type: node is TSESTree.NumberLiteral

isStaticTemplateLiteral(node: TSESTree.Expression): node is TSESTree.TemplateLiteral

Code
function isStaticTemplateLiteral(
      node: TSESTree.Expression,
    ): node is TSESTree.TemplateLiteral {
      return (
        node.type === AST_NODE_TYPES.TemplateLiteral &&
        node.expressions.length === 0 &&
        node.quasis.length === 1
      );
    }
  • Parameters:
  • node: TSESTree.Expression
  • Return Type: node is TSESTree.TemplateLiteral