Exemple
acorn-jsx 5.3.2: jsx
Échantillon vérifié pour npm acorn-jsx 5.3.2: jsx. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:98a00cd4dc2b07200b9af76b34e4776d206707388cd6a3360cd5ed9cf424b9a6
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
- 2
- 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
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
| 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-07 |
Cas
HOW- Objectif
- verify pkg:npm/acorn-jsx@5.3.2
- Paquets
- Symboles
-
- jsx
- Environnement
- node 22.23.2
- Créé
- 2026-08-26T09:29:18Z
Contrat
- acorn.Parser.extend(jsx()) parses JSXElement, JSXOpeningElement, and JSXClosingElement with boolean, string, and JSXExpressionContainer attributes
- acorn.Parser.extend(jsx()) parses JSXSpreadAttribute ({...props}) inside JSXOpeningElement attributes
- acorn.Parser.extend(jsx()) parses JSXFragment (<>...</>) and nested JSXMemberExpression (<UI.Header />, <UI.Body.Section />)
- acorn.Parser.extend(jsx()) parses and decodes named and numeric XML/HTML character entities in JSXText
- acorn.Parser.extend(jsx()) parses JSXExpressionContainer with JSXEmptyExpression ({/* comment */}) as child
- jsx({ allowNamespaces: true }) parses JSXNamespacedName on element tags and attributes, while allowNamespaces: false throws a SyntaxError on colons
- jsx({ allowNamespaces: true, allowNamespacedObjects: true }) parses JSXMemberExpression on namespaced objects (<svg:path.element />), while allowNamespacedObjects: false throws a SyntaxError
- acorn.Parser.extend(jsx()) throws a SyntaxError for mismatched JSX closing tags and unparented adjacent JSX elements
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
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 pkg:npm/acorn-jsx@5.3.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/acorn-jsx@5.3.2
Demonstrate these symbols/APIs:
- jsx
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:a79e018530c6da0372d776cf65409f673b05d791d0aed180770e8e27ea55fb29","contract":["acorn.Parser.extend(jsx()) parses JSXElement, JSXOpeningElement, and JSXClosingElement with boolean, string, and JSXExpressionContainer attributes","acorn.Parser.extend(jsx()) parses JSXSpreadAttribute ({...props}) inside JSXOpeningElement attributes","acorn.Parser.extend(jsx()) parses JSXFragment (\u003c\u003e...\u003c/\u003e) and nested JSXMemberExpression (\u003cUI.Header /\u003e, \u003cUI.Body.Section /\u003e)","acorn.Parser.extend(jsx()) parses and decodes named and numeric XML/HTML character entities in JSXText","acorn.Parser.extend(jsx()) parses JSXExpressionContainer with JSXEmptyExpression ({/* comment */}) as child","jsx({ allowNamespaces: true }) parses JSXNamespacedName on element tags and attributes, while allowNamespaces: false throws a SyntaxError on colons","jsx({ allowNamespaces: true, allowNamespacedObjects: true }) parses JSXMemberExpression on namespaced objects (\u003csvg:path.element /\u003e), while allowNamespacedObjects: false throws a SyntaxError","acorn.Parser.extend(jsx()) throws a SyntaxError for mismatched JSX closing tags and unparented adjacent JSX elements"],"goal":"verify pkg:npm/acorn-jsx@5.3.2","kind":"HOW","packages":["pkg:npm/acorn-jsx@5.3.2"],"schemaVersion":1,"symbols":["jsx"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/acorn-jsx@5.3.2"],"schemaVersion":1,"subject":"pkg:npm/acorn-jsx@5.3.2","symbols":["jsx"],"verifierAdapter":"node-typescript@1"}
const acorn = require('acorn');
const jsx = require('acorn-jsx');
function createJSXParser(options) {
return acorn.Parser.extend(jsx(options));
}
function parseJSX(code, options = {}) {
const parser = createJSXParser(options.jsxOptions);
return parser.parse(code, {
ecmaVersion: options.ecmaVersion || 'latest',
sourceType: options.sourceType || 'module',
locations: options.locations || false,
ranges: options.ranges || false,
});
}
module.exports = {
createJSXParser,
parseJSX,
};
{
"name": "acorn-jsx-verify",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "acorn-jsx-verify",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"acorn": "^8.18.0",
"acorn-jsx": "5.3.2"
}
},
"node_modules/acorn": {
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/acorn-jsx": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
"license": "MIT",
"peerDependencies": {
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
}
}
}
{
"name": "acorn-jsx-verify",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for acorn-jsx",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"acorn": "^8.18.0",
"acorn-jsx": "5.3.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/acorn-jsx@5.3.2",
"kind": "HOW",
"packages": [
"pkg:npm/acorn-jsx@5.3.2"
],
"symbols": [
"jsx"
]
}
const assert = require('node:assert');
const acorn = require('acorn');
const jsx = require('acorn-jsx');
const { createJSXParser, parseJSX } = require('../index.js');
// 1. Basic JSX Element and attribute parsing
{
const parser = createJSXParser();
const code = '<button disabled className="btn" tabIndex={1}>Click</button>';
const ast = parser.parse(code, { ecmaVersion: 'latest' });
assert.strictEqual(ast.type, 'Program');
const expr = ast.body[0].expression;
assert.strictEqual(expr.type, 'JSXElement');
assert.strictEqual(expr.openingElement.name.name, 'button');
assert.strictEqual(expr.openingElement.selfClosing, false);
assert.strictEqual(expr.openingElement.attributes.length, 3);
// boolean attribute (value is null)
assert.strictEqual(expr.openingElement.attributes[0].name.name, 'disabled');
assert.strictEqual(expr.openingElement.attributes[0].value, null);
// string attribute
assert.strictEqual(expr.openingElement.attributes[1].name.name, 'className');
assert.strictEqual(expr.openingElement.attributes[1].value.value, 'btn');
// expression container attribute
assert.strictEqual(expr.openingElement.attributes[2].name.name, 'tabIndex');
assert.strictEqual(expr.openingElement.attributes[2].value.type, 'JSXExpressionContainer');
assert.strictEqual(expr.openingElement.attributes[2].value.expression.value, 1);
assert.strictEqual(expr.children.length, 1);
assert.strictEqual(expr.children[0].type, 'JSXText');
assert.strictEqual(expr.children[0].value, 'Click');
assert.strictEqual(expr.closingElement.name.name, 'button');
}
// 2. JSX Spread Attributes (<Component {...props} />)
{
const parser = createJSXParser();
const code = '<Widget id="w1" {...props} extra={true} />';
const ast = parser.parse(code, { ecmaVersion: 'latest' });
const expr = ast.body[0].expression;
assert.strictEqual(expr.type, 'JSXElement');
assert.strictEqual(expr.openingElement.selfClosing, true);
assert.strictEqual(expr.openingElement.attributes.length, 3);
const spreadAttr = expr.openingElement.attributes[1];
assert.strictEqual(spreadAttr.type, 'JSXSpreadAttribute');
assert.strictEqual(spreadAttr.argument.type, 'Identifier');
assert.strictEqual(spreadAttr.argument.name, 'props');
}
// 3. JSX Fragments (<>...</>) and Member Expressions (<UI.Button />)
{
const parser = createJSXParser();
const code = '<><UI.Header title="Main" /><UI.Body.Section /></>';
const ast = parser.parse(code, { ecmaVersion: 'latest' });
const fragment = ast.body[0].expression;
assert.strictEqual(fragment.type, 'JSXFragment');
assert.strictEqual(fragment.children.length, 2);
const member1 = fragment.children[0];
assert.strictEqual(member1.openingElement.name.type, 'JSXMemberExpression');
assert.strictEqual(member1.openingElement.name.object.name, 'UI');
assert.strictEqual(member1.openingElement.name.property.name, 'Header');
const member2 = fragment.children[1];
assert.strictEqual(member2.openingElement.name.type, 'JSXMemberExpression');
assert.strictEqual(member2.openingElement.name.object.type, 'JSXMemberExpression');
assert.strictEqual(member2.openingElement.name.object.object.name, 'UI');
assert.strictEqual(member2.openingElement.name.object.property.name, 'Body');
assert.strictEqual(member2.openingElement.name.property.name, 'Section');
}
// 4. HTML / XML Character Entity decoding in JSXText
{
const parser = createJSXParser();
const code = '<div><hello & "world" ' /></div>';
const ast = parser.parse(code, { ecmaVersion: 'latest' });
const expr = ast.body[0].expression;
assert.strictEqual(expr.children.length, 1);
assert.strictEqual(expr.children[0].type, 'JSXText');
assert.strictEqual(expr.children[0].value, '<hello & "world" \' />');
}
// 5. JSX Empty Expressions in child containers
{
const parser = createJSXParser();
const code = '<div>{/* comment */}</div>';
const ast = parser.parse(code, { ecmaVersion: 'latest' });
const expr = ast.body[0].expression;
assert.strictEqual(expr.children.length, 1);
assert.strictEqual(expr.children[0].type, 'JSXExpressionContainer');
assert.strictEqual(expr.children[0].expression.type, 'JSXEmptyExpression');
}
// 6. allowNamespaces option: XML namespaced tags
{
const parserWithNs = createJSXParser({ allowNamespaces: true });
const ast = parserWithNs.parse('<xml:tag prefix:attr="val" />', { ecmaVersion: 'latest' });
const expr = ast.body[0].expression;
assert.strictEqual(expr.openingElement.name.type, 'JSXNamespacedName');
assert.strictEqual(expr.openingElement.name.namespace.name, 'xml');
assert.strictEqual(expr.openingElement.name.name.name, 'tag');
assert.strictEqual(expr.openingElement.attributes[0].name.type, 'JSXNamespacedName');
assert.strictEqual(expr.openingElement.attributes[0].name.namespace.name, 'prefix');
assert.strictEqual(expr.openingElement.attributes[0].name.name.name, 'attr');
const parserNoNs = createJSXParser({ allowNamespaces: false });
assert.throws(() => {
parserNoNs.parse('<xml:tag />', { ecmaVersion: 'latest' });
}, /Unexpected token/);
}
// 7. allowNamespacedObjects option
{
const parserWithNsObj = createJSXParser({ allowNamespaces: true, allowNamespacedObjects: true });
const ast = parserWithNsObj.parse('<svg:path.element />', { ecmaVersion: 'latest' });
const expr = ast.body[0].expression;
assert.strictEqual(expr.openingElement.name.type, 'JSXMemberExpression');
assert.strictEqual(expr.openingElement.name.object.type, 'JSXNamespacedName');
assert.strictEqual(expr.openingElement.name.object.namespace.name, 'svg');
assert.strictEqual(expr.openingElement.name.object.name.name, 'path');
assert.strictEqual(expr.openingElement.name.property.name, 'element');
const parserNoNsObj = createJSXParser({ allowNamespaces: true, allowNamespacedObjects: false });
assert.throws(() => {
parserNoNsObj.parse('<svg:path.element />', { ecmaVersion: 'latest' });
}, /Unexpected token/);
}
// 8. Syntax error validation for mismatched closing tags and adjacent elements
{
const parser = createJSXParser();
assert.throws(() => {
parser.parse('<div></span>', { ecmaVersion: 'latest' });
}, /Expected corresponding JSX closing tag for <div>/);
assert.throws(() => {
parser.parse('<div /><span />', { ecmaVersion: 'latest' });
}, /Adjacent JSX elements must be wrapped in an enclosing tag/);
}
// 9. parseJSX helper verification
{
const ast = parseJSX('<header id="main">Title</header>');
assert.strictEqual(ast.type, 'Program');
assert.strictEqual(ast.body[0].expression.type, 'JSXElement');
}
console.log('Contract assertions passed successfully.');
Seeder d'origine
anonyme