function stateNameExistsInPropNode()

in src/validation/validateStates.ts [41:55]


function stateNameExistsInPropNode(
  nextPropNode: PropertyASTNode,
  stateNames: string[],
  document: TextDocument,
  message: string,
): Diagnostic | void {
  const stateNameExists = (stateNames as unknown[]).includes(nextPropNode?.valueNode?.value)

  if (nextPropNode && nextPropNode.valueNode && !stateNameExists) {
    const { length, offset } = nextPropNode.valueNode
    const range = Range.create(document.positionAt(offset), document.positionAt(offset + length))

    return Diagnostic.create(range, message, DiagnosticSeverity.Error)
  }
}