or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-9/

JSX Prop Requirements Validator

Utilities for verifying required props on JSX elements while respecting case sensitivity and spread handling preferences.

Capabilities

Ensure all required props are present

  • Returns true when attributes include all required props regardless of casing (default ignoreCase true). @test
  • Returns false when a required prop is missing and only unrelated spreads exist with strict spread handling. @test
  • Returns true when required props appear only in an object spread and loose spread handling is enabled. @test

Ensure at least one prop is present

  • Returns true when any prop from a candidate set is present ignoring case. @test
  • Returns false when none of the candidate props exist and spread handling is strict. @test

Case-sensitive checks

  • When case-sensitive mode is requested, treats differently cased prop names as distinct. @test

Report missing props

  • Returns a list of required prop names that are not satisfied under current options. @test

Implementation

@generates

API

export interface PropCheckOptions {
  /** Defaults to true. When false, comparisons must match case exactly. */
  ignoreCase?: boolean;
  /** Defaults to true. When false, spreads are treated as possibly satisfying required props. */
  spreadStrict?: boolean;
}

/**
 * Returns true when every required prop is present on the JSX attributes.
 */
export function requireAllProps(
  attributes: Array<JSXAttribute | JSXSpreadAttribute>,
  requiredProps: string[],
  options?: PropCheckOptions
): boolean;

/**
 * Returns true when at least one prop from the candidate list is present.
 */
export function requireAnyProp(
  attributes: Array<JSXAttribute | JSXSpreadAttribute>,
  candidateProps: string[],
  options?: PropCheckOptions
): boolean;

/**
 * Returns the required props that are not satisfied by the JSX attributes.
 */
export function listMissingProps(
  attributes: Array<JSXAttribute | JSXSpreadAttribute>,
  requiredProps: string[],
  options?: PropCheckOptions
): string[];

Dependencies { .dependencies }

jsx-ast-utils { .dependency }

Utilities for inspecting JSX attributes and spreads. @satisfied-by