CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-react-display-name

Babel plugin that automatically adds displayName properties to React class components created with createClass

Overall
score

96%

Overview
Eval results
Files

task.mdevals/scenario-6/

Display Name Preservation Helper

Create a small transform helper that processes JavaScript/TypeScript source containing React createClass usages and ensures that missing displayName properties are injected while existing displayName definitions remain untouched.

Capabilities

Leaves explicit display names untouched

  • When a createClass call includes a displayName property, the transformed output keeps the original value without adding or changing anything else. @test

Adds missing display names from identifiers

  • For a createClass call assigned to an identifier (e.g., const Card = createClass({...})) that lacks displayName, the transformed output injects a single displayName matching the identifier. @test

Avoids duplicate injections in nested structures

  • When createClass calls appear inside object properties or nested expressions, only those lacking displayName get one; any call that already declares displayName is left unchanged, and no duplicates appear. @test

Implementation

@generates

API

export interface TransformOptions {
  filename?: string;
  parserPlugins?: string[];
}

export function annotateDisplayNames(source: string, options?: TransformOptions): string;

Dependencies { .dependencies }

@babel/core { .dependency }

Runs the source transform pipeline.

@babel/plugin-transform-react-display-name { .dependency }

Injects display names for React createClass components only when missing.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-react-display-name

tile.json