CodeSampleX

Beispiel

acorn-jsx 5.3.2

Verifiziertes Beispiel für npm acorn-jsx 5.3.2. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: acorn.Parser.extend(jsx()) parses JSX…

sha256:e5313d07dbb7bb42c2d815dd9ca0ec07b913f8c96a6a752b2bf1628d0a395e78

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
2
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20
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

Fall

HOW
Ziel
verify pkg:npm/acorn-jsx@5.3.2
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-20T22:56:04Z

Contract

  1. acorn.Parser.extend(jsx()) parses JSX elements into JSXElement, JSXOpeningElement, and JSXClosingElement AST nodes
  2. acorn.Parser.extend(jsx()) parses self-closing JSX elements with attributes
  3. acorn.Parser.extend(jsx()) parses JSX fragments (<>...</>)
  4. acorn.Parser.extend(jsx()) parses JSX member expressions (<UI.Button />)
  5. acorn.Parser.extend(jsx()) parses JSX expression containers in attributes and child nodes
  6. jsx({ allowNamespaces: true }) parses XML namespaced tags like <svg:path /> into JSXNamespacedName
  7. jsx({ allowNamespaces: false }) rejects XML namespaced tags with a SyntaxError

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 pkg:npm/acorn-jsx@5.3.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/acorn-jsx@5.3.2
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - 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.
csx.json
{"case":{"caseId":"case:sha256:cd26cf6f8ec467a8a10e307d7340eae41dd25248d351b81787c4950013a4f462","constraints":{"executionContext":"node"},"contract":["acorn.Parser.extend(jsx()) parses JSX elements into JSXElement, JSXOpeningElement, and JSXClosingElement AST nodes","acorn.Parser.extend(jsx()) parses self-closing JSX elements with attributes","acorn.Parser.extend(jsx()) parses JSX fragments (\u003c\u003e...\u003c/\u003e)","acorn.Parser.extend(jsx()) parses JSX member expressions (\u003cUI.Button /\u003e)","acorn.Parser.extend(jsx()) parses JSX expression containers in attributes and child nodes","jsx({ allowNamespaces: true }) parses XML namespaced tags like \u003csvg:path /\u003e into JSXNamespacedName","jsx({ allowNamespaces: false }) rejects XML namespaced tags with a SyntaxError"],"goal":"verify pkg:npm/acorn-jsx@5.3.2","kind":"HOW","packages":["pkg:npm/acorn-jsx@5.3.2"],"schemaVersion":1},"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","verifierAdapter":"node-typescript@1"}
index.js
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',
  });
}

module.exports = {
  createJSXParser,
  parseJSX,
};
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/acorn-jsx@5.3.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/acorn-jsx@5.3.2"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
const assert = require('node:assert');
const acorn = require('acorn');
const jsx = require('acorn-jsx');
const { parseJSX } = require('../index.js');

// 1. Basic JSX Element parsing with default jsx plugin
{
  const parser = acorn.Parser.extend(jsx());
  const code = '<div className="container">Hello World</div>';
  const ast = parser.parse(code, { ecmaVersion: 'latest' });

  assert.strictEqual(ast.type, 'Program');
  assert.strictEqual(ast.body.length, 1);

  const expr = ast.body[0].expression;
  assert.strictEqual(expr.type, 'JSXElement');
  assert.strictEqual(expr.openingElement.type, 'JSXOpeningElement');
  assert.strictEqual(expr.openingElement.name.type, 'JSXIdentifier');
  assert.strictEqual(expr.openingElement.name.name, 'div');
  assert.strictEqual(expr.openingElement.selfClosing, false);

  assert.strictEqual(expr.openingElement.attributes.length, 1);
  const attr = expr.openingElement.attributes[0];
  assert.strictEqual(attr.type, 'JSXAttribute');
  assert.strictEqual(attr.name.type, 'JSXIdentifier');
  assert.strictEqual(attr.name.name, 'className');
  assert.strictEqual(attr.value.type, 'Literal');
  assert.strictEqual(attr.value.value, 'container');

  assert.strictEqual(expr.children.length, 1);
  assert.strictEqual(expr.children[0].type, 'JSXText');
  assert.strictEqual(expr.children[0].value, 'Hello World');

  assert.strictEqual(expr.closingElement.type, 'JSXClosingElement');
  assert.strictEqual(expr.closingElement.name.name, 'div');
}

// 2. Self-closing JSX elements
{
  const parser = acorn.Parser.extend(jsx());
  const code = '<img src="icon.png" alt="icon" />';
  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.closingElement, null);
  assert.strictEqual(expr.openingElement.attributes.length, 2);
}

// 3. JSX Fragments
{
  const parser = acorn.Parser.extend(jsx());
  const code = '<><span>A</span><span>B</span></>';
  const ast = parser.parse(code, { ecmaVersion: 'latest' });

  const expr = ast.body[0].expression;
  assert.strictEqual(expr.type, 'JSXFragment');
  assert.strictEqual(expr.openingFragment.type, 'JSXOpeningFragment');
  assert.strictEqual(expr.closingFragment.type, 'JSXClosingFragment');
  assert.strictEqual(expr.children.length, 2);
}

// 4. JSX Member Expressions (e.g. <UI.Button />)
{
  const parser = acorn.Parser.extend(jsx());
  const code = '<UI.Button label="Submit" />';
  const ast = parser.parse(code, { ecmaVersion: 'latest' });

  const expr = ast.body[0].expression;
  assert.strictEqual(expr.openingElement.name.type, 'JSXMemberExpression');
  assert.strictEqual(expr.openingElement.name.object.type, 'JSXIdentifier');
  assert.strictEqual(expr.openingElement.name.object.name, 'UI');
  assert.strictEqual(expr.openingElement.name.property.type, 'JSXIdentifier');
  assert.strictEqual(expr.openingElement.name.property.name, 'Button');
}

// 5. JSX Expressions in attributes and children
{
  const parser = acorn.Parser.extend(jsx());
  const code = '<Counter count={10 + 2}>{"count is: " + 12}</Counter>';
  const ast = parser.parse(code, { ecmaVersion: 'latest' });

  const expr = ast.body[0].expression;
  const attr = expr.openingElement.attributes[0];
  assert.strictEqual(attr.value.type, 'JSXExpressionContainer');
  assert.strictEqual(attr.value.expression.type, 'BinaryExpression');

  assert.strictEqual(expr.children[0].type, 'JSXExpressionContainer');
  assert.strictEqual(expr.children[0].expression.type, 'BinaryExpression');
}

// 6. Namespaces option: allowNamespaces: false vs allowNamespaces: true
{
  const parserWithNs = acorn.Parser.extend(jsx({ allowNamespaces: true }));
  const astWithNs = parserWithNs.parse('<svg:path d="M0 0" />', { ecmaVersion: 'latest' });
  const expr = astWithNs.body[0].expression;
  assert.strictEqual(expr.openingElement.name.type, 'JSXNamespacedName');
  assert.strictEqual(expr.openingElement.name.namespace.name, 'svg');
  assert.strictEqual(expr.openingElement.name.name.name, 'path');

  const parserNoNs = acorn.Parser.extend(jsx({ allowNamespaces: false }));
  assert.throws(() => {
    parserNoNs.parse('<svg:path d="M0 0" />', { ecmaVersion: 'latest' });
  }, /Unexpected token/);
}

// 7. Helper wrapper function verification
{
  const ast = parseJSX('<header id="main-header">Title</header>');
  assert.strictEqual(ast.type, 'Program');
  assert.strictEqual(ast.body[0].expression.type, 'JSXElement');
}

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

Ursprungs-Seeder

anonym