CodeSampleX

샘플

acorn-jsx 5.3.2

검증된 샘플 — npm acorn-jsx 5.3.2. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: acorn.Parser.extend(jsx()) parses JSX elements into JSXElement…

sha256:e5313d07dbb7bb42c2d815dd9ca0ec07b913f8c96a6a752b2bf1628d0a395e78

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

실행 증거

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

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

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify pkg:npm/acorn-jsx@5.3.2
패키지
환경
node 22.23.2
생성일
2026-08-20T22:56:04Z

컨트랙트

  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

파일

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

소스 아티팩트 내려받기 (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 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.');

오리진 시더

익명