Exemple
react-refresh 0.18.0: isLikelyComponentType
Échantillon vérifié pour npm react-refresh 0.18.0: isLikelyComponentType. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:72cf2def3b6b06a9b2cd6c434db4f6d68b0524490dd22787d5f09e014b067eb8
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-06 |
Cas
HOW- Objectif
- verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.18.0
- Paquets
- Symboles
-
- react-refresh.isLikelyComponentType
- Environnement
- node 22.23.2
- Créé
- 2026-09-06T15:04:47Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Code source
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.18.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-refresh@0.18.0
Demonstrate these symbols/APIs:
- react-refresh.isLikelyComponentType
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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.
{"case":{"caseId":"case:sha256:61e8c1b415c3d25be9f41d731aa5cfc9aadcab701d88a6535418c7d202e52a59","constraints":{"executionContext":"node"},"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.18.0","kind":"HOW","packages":["pkg:npm/react-refresh@0.18.0"],"schemaVersion":1,"symbols":["react-refresh.isLikelyComponentType"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react-refresh@0.18.0"],"schemaVersion":1,"subject":"pkg:npm/react-refresh@0.18.0","symbols":["react-refresh.isLikelyComponentType"],"verifierAdapter":"node-typescript@1"}
{
"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",
"license": "MIT-0",
"dependencies": {
"react-refresh": "0.18.0"
}
},
"node_modules/react-refresh": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.18.0.tgz",
"integrity": "sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
}
}
}
{
"name": "sample-react-refresh-is-likely-component-type",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"react-refresh": "0.18.0"
}
}
{
"schemaVersion": 1,
"goal": "verify react-refresh.isLikelyComponentType in pkg:npm/react-refresh@0.18.0",
"kind": "HOW",
"packages": [
"pkg:npm/react-refresh@0.18.0"
],
"symbols": [
"react-refresh.isLikelyComponentType"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import refreshRuntimeModule from "react-refresh/runtime";
export const RefreshRuntime =
refreshRuntimeModule && typeof refreshRuntimeModule === "object" && "default" in refreshRuntimeModule
? refreshRuntimeModule.default
: refreshRuntimeModule;
export const isLikelyComponentType = RefreshRuntime.isLikelyComponentType;
/**
* 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 RefreshRuntime.isLikelyComponentType(type);
}
import assert from "node:assert/strict";
import refreshRuntimeModule from "react-refresh/runtime";
import {
isLikelyComponentType,
checkIsLikelyComponentType,
} from "../src/index.mjs";
const rawRuntime =
refreshRuntimeModule && typeof refreshRuntimeModule === "object" && "default" in refreshRuntimeModule
? refreshRuntimeModule.default
: refreshRuntimeModule;
// 1. Export verification
assert.equal(typeof isLikelyComponentType, "function", "isLikelyComponentType must be a function");
assert.equal(typeof checkIsLikelyComponentType, "function", "checkIsLikelyComponentType helper must be a function");
assert.equal(typeof rawRuntime.isLikelyComponentType, "function", "raw runtime isLikelyComponentType must be a function");
// Contract 1: isLikelyComponentType returns true for 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");
assert.equal(rawRuntime.isLikelyComponentType(ValidComponent), true);
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");
assert.equal(rawRuntime.isLikelyComponentType(ArrowComponent), true);
}
// Contract 2: isLikelyComponentType returns true for 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");
assert.equal(rawRuntime.isLikelyComponentType(anonymousFunc), true);
}
// Contract 3: isLikelyComponentType returns true for 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");
assert.equal(rawRuntime.isLikelyComponentType(MyClassComponent), true);
}
// Contract 4: isLikelyComponentType returns true for 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");
assert.equal(rawRuntime.isLikelyComponentType(forwardRefComponent), true);
function BaseComponent() {
return null;
}
const memoComponent = {
$$typeof: Symbol.for("react.memo"),
type: BaseComponent,
};
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");
assert.equal(rawRuntime.isLikelyComponentType(memoComponent), true);
}
// Contract 5: isLikelyComponentType returns false for 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");
assert.equal(rawRuntime.isLikelyComponentType(helperFunction), false);
const lowercaseArrow = () => false;
assert.equal(isLikelyComponentType(lowercaseArrow), false, "lowercase arrow function must not be recognized as component type");
assert.equal(rawRuntime.isLikelyComponentType(lowercaseArrow), false);
class RegularClass {
method() {}
}
assert.equal(isLikelyComponentType(RegularClass), false, "regular class without isReactComponent must not be recognized as component type");
assert.equal(checkIsLikelyComponentType(RegularClass), false, "checkIsLikelyComponentType returns false for regular class");
assert.equal(rawRuntime.isLikelyComponentType(RegularClass), false);
}
// Contract 6: isLikelyComponentType returns false for 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");
assert.equal(rawRuntime.isLikelyComponentType({}), false);
assert.equal(rawRuntime.isLikelyComponentType(null), false);
}
console.log("All react-refresh.isLikelyComponentType contract tests passed successfully.");
Seeder d'origine
anonyme