CodeSampleX

샘플

react-refresh 0.17.0: isLikelyComponentType

검증된 샘플 — npm react-refresh 0.17.0: isLikelyComponentType. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: isLikelyComponentType returns true for…

sha256:3864b45b2729f5daf211e4cf1397710648b5356526408e1c507a858b5da790eb

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-04

케이스

HOW
목표
verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.17.0
패키지
심벌
  • react-refresh.isLikelyComponentType
생성일
2026-09-04T18:52:58Z

컨트랙트

  1. isLikelyComponentType returns true for PascalCase function components and arrow functions
  2. isLikelyComponentType returns true for components with uppercase displayName
  3. isLikelyComponentType returns true for class components with isReactComponent on prototype
  4. isLikelyComponentType returns true for React forwardRef and memo objects
  5. isLikelyComponentType returns false for lowercase functions and regular classes
  6. isLikelyComponentType returns false for plain objects, non-component elements, primitives, and nullish values

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.17.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react-refresh@0.17.0
Demonstrate these symbols/APIs:
  - react-refresh.isLikelyComponentType

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:e845f2386faaf115cd0bd9e3efef61028dbbc42c70ba68d70155c18efe9a4ede","contract":["isLikelyComponentType returns true for PascalCase function components and arrow functions","isLikelyComponentType returns true for components with uppercase displayName","isLikelyComponentType returns true for class components with isReactComponent on prototype","isLikelyComponentType returns true for React forwardRef and memo objects","isLikelyComponentType returns false for lowercase functions and regular classes","isLikelyComponentType returns false for plain objects, non-component elements, primitives, and nullish values"],"goal":"verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.17.0","kind":"HOW","packages":["pkg:npm/react-refresh@0.17.0"],"schemaVersion":1,"symbols":["react-refresh.isLikelyComponentType"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react-refresh@0.17.0"],"schemaVersion":1,"subject":"pkg:npm/react-refresh@0.17.0","symbols":["react-refresh.isLikelyComponentType"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-refresh-is-likely-component-type",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-refresh-is-likely-component-type",
      "version": "1.0.0",
      "dependencies": {
        "react-refresh": "0.17.0"
      }
    },
    "node_modules/react-refresh": {
      "version": "0.17.0",
      "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
      "integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "sample-react-refresh-is-likely-component-type",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of react-refresh isLikelyComponentType",
  "type": "module",
  "main": "src/index.js",
  "dependencies": {
    "react-refresh": "0.17.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.17.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-refresh@0.17.0"
  ],
  "symbols": [
    "react-refresh.isLikelyComponentType"
  ]
}
src/index.js
import { isLikelyComponentType } from 'react-refresh';

/**
 * Check if the given value is likely a React component type.
 *
 * @param {*} type - The value to inspect.
 * @returns {boolean} True if the value is likely a component type.
 */
export function checkIsLikelyComponentType(type) {
  return isLikelyComponentType(type);
}

export { isLikelyComponentType };
test/contract.mjs
import assert from 'node:assert/strict';
import {
  isLikelyComponentType,
  checkIsLikelyComponentType,
} from '../src/index.js';

// 1. Export verification
assert.equal(typeof isLikelyComponentType, 'function', 'isLikelyComponentType must be a function');
assert.equal(typeof checkIsLikelyComponentType, 'function', 'checkIsLikelyComponentType helper must be a function');

// 2. PascalCase function components and arrow functions
function ValidComponent() {
  return null;
}
assert.equal(isLikelyComponentType(ValidComponent), true, 'PascalCase function must be recognized as component type');
assert.equal(checkIsLikelyComponentType(ValidComponent), true, 'checkIsLikelyComponentType returns true for PascalCase function');

const ArrowComponent = () => null;
assert.equal(isLikelyComponentType(ArrowComponent), true, 'Arrow function with PascalCase name must be recognized as component type');
assert.equal(checkIsLikelyComponentType(ArrowComponent), true, 'checkIsLikelyComponentType returns true for PascalCase arrow function');

// 3. Components with uppercase displayName
const anonymousFunc = (() => function() {
  return null;
})();
Object.defineProperty(anonymousFunc, 'name', { value: '' });
anonymousFunc.displayName = 'NamedComponent';
assert.equal(isLikelyComponentType(anonymousFunc), true, 'Function with uppercase displayName must be recognized as component type');
assert.equal(checkIsLikelyComponentType(anonymousFunc), true, 'checkIsLikelyComponentType returns true for function with uppercase displayName');

// 4. Class components with isReactComponent on prototype
class MyClassComponent {}
MyClassComponent.prototype.isReactComponent = true;
assert.equal(isLikelyComponentType(MyClassComponent), true, 'Class component with isReactComponent must be recognized as component type');
assert.equal(checkIsLikelyComponentType(MyClassComponent), true, 'checkIsLikelyComponentType returns true for class component');

// 5. React forwardRef and memo objects
const forwardRefComponent = {
  $$typeof: Symbol.for('react.forward_ref'),
  render: () => null,
};
assert.equal(isLikelyComponentType(forwardRefComponent), true, 'React forwardRef object must be recognized as component type');
assert.equal(checkIsLikelyComponentType(forwardRefComponent), true, 'checkIsLikelyComponentType returns true for forwardRef');

const memoComponent = {
  $$typeof: Symbol.for('react.memo'),
  type: ValidComponent,
};
assert.equal(isLikelyComponentType(memoComponent), true, 'React memo object must be recognized as component type');
assert.equal(checkIsLikelyComponentType(memoComponent), true, 'checkIsLikelyComponentType returns true for memo object');

// 6. Lowercase functions and regular classes
function helperFunction() {
  return false;
}
assert.equal(isLikelyComponentType(helperFunction), false, 'lowercase function must not be recognized as component type');
assert.equal(checkIsLikelyComponentType(helperFunction), false, 'checkIsLikelyComponentType returns false for lowercase function');

const lowercaseArrow = () => false;
assert.equal(isLikelyComponentType(lowercaseArrow), false, 'lowercase arrow function must not be recognized as component type');

class RegularClass {
  method() {}
}
assert.equal(isLikelyComponentType(RegularClass), false, 'regular class without isReactComponent must not be recognized as component type');

// 7. Plain objects, non-component elements, primitives, and nullish values
assert.equal(isLikelyComponentType({}), false, 'plain object must not be recognized as component type');
assert.equal(isLikelyComponentType({ $$typeof: Symbol.for('react.element') }), false, 'React element object must not be recognized as component type');
assert.equal(isLikelyComponentType(null), false, 'null must not be recognized as component type');
assert.equal(isLikelyComponentType(undefined), false, 'undefined must not be recognized as component type');
assert.equal(isLikelyComponentType(42), false, 'number primitive must not be recognized as component type');
assert.equal(isLikelyComponentType('MyComponent'), false, 'string primitive must not be recognized as component type');
assert.equal(isLikelyComponentType(true), false, 'boolean primitive must not be recognized as component type');

console.log('Contract tests passed successfully.');

오리진 시더

익명