CodeSampleX

샘플

acorn-jsx 5.3.2: jsx

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

sha256:98a00cd4dc2b07200b9af76b34e4776d206707388cd6a3360cd5ed9cf424b9a6

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

케이스

HOW
목표
verify pkg:npm/acorn-jsx@5.3.2
패키지
심벌
  • jsx
환경
node 22.23.2
생성일
2026-08-26T09:29:18Z

컨트랙트

  1. acorn.Parser.extend(jsx()) parses JSXElement, JSXOpeningElement, and JSXClosingElement with boolean, string, and JSXExpressionContainer attributes
  2. acorn.Parser.extend(jsx()) parses JSXSpreadAttribute ({...props}) inside JSXOpeningElement attributes
  3. acorn.Parser.extend(jsx()) parses JSXFragment (<>...</>) and nested JSXMemberExpression (<UI.Header />, <UI.Body.Section />)
  4. acorn.Parser.extend(jsx()) parses and decodes named and numeric XML/HTML character entities in JSXText
  5. acorn.Parser.extend(jsx()) parses JSXExpressionContainer with JSXEmptyExpression ({/* comment */}) as child
  6. jsx({ allowNamespaces: true }) parses JSXNamespacedName on element tags and attributes, while allowNamespaces: false throws a SyntaxError on colons
  7. jsx({ allowNamespaces: true, allowNamespacedObjects: true }) parses JSXMemberExpression on namespaced objects (<svg:path.element />), while allowNamespacedObjects: false throws a SyntaxError
  8. acorn.Parser.extend(jsx()) throws a SyntaxError for mismatched JSX closing tags and unparented adjacent JSX elements

파일

  • 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
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.
csx.json
{"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"}
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',
    locations: options.locations || false,
    ranges: options.ranges || false,
  });
}

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"
  ],
  "symbols": [
    "jsx"
  ]
}
test/contract.js
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>&lt;hello &amp; &quot;world&quot; &#39; &#x2F;&gt;</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.');

오리진 시더

익명