Sample
@babel/generator 7.29.7: generate
Verified sample for npm @babel/generator 7.29.7: generate. The contract ran on node 22 · linux debian/x64 · docker and passed.
sha256:98949f8c0e14804a513daec4f9a8ccf81c1f1627bac76edd4cd31757c3c9beed
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-05 |
Case
HOW- Goal
- verify @babel/generator.generate in pkg:npm/%40babel/generator@7.29.7
- Packages
- Symbols
-
- @babel/generator.generate
- Created
- 2026-09-05T19:01:50Z
Contract
- generate converts BinaryExpression AST into formatted expression code
- generate formats variable declarations with compact formatting without redundant spaces
- generate produces version 3 source maps when sourceMaps option is enabled
- generate strips comments when comments option is false
- generate preserves line breaks when retainLines option is true
- generate returns an object with code string and map property
- generate throws an Error when passed an unknown AST node type
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
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 @babel/generator.generate in pkg:npm/%40babel/generator@7.29.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40babel/generator@7.29.7
Demonstrate these symbols/APIs:
- @babel/generator.generate
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:4bdaf60a624a2f54f8dcb0be22f110643cdef2320ab52d14e61ffa85063d2ce3","contract":["generate converts BinaryExpression AST into formatted expression code","generate formats variable declarations with compact formatting without redundant spaces","generate produces version 3 source maps when sourceMaps option is enabled","generate strips comments when comments option is false","generate preserves line breaks when retainLines option is true","generate returns an object with code string and map property","generate throws an Error when passed an unknown AST node type"],"goal":"verify @babel/generator.generate in pkg:npm/%40babel/generator@7.29.7","kind":"HOW","packages":["pkg:npm/%40babel/generator@7.29.7"],"schemaVersion":1,"symbols":["@babel/generator.generate"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40babel/generator@7.29.7"],"schemaVersion":1,"subject":"pkg:npm/%40babel/generator@7.29.7","symbols":["@babel/generator.generate"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-babel-generator-generate",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-babel-generator-generate",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@babel/generator": "7.29.7"
}
},
"node_modules/@babel/generator": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.7.tgz",
"integrity": "sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.29.7",
"@babel/types": "^7.29.7",
"@jridgewell/gen-mapping": "^0.3.12",
"@jridgewell/trace-mapping": "^0.3.28",
"jsesc": "^3.0.2"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/parser": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz",
"integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/types": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
"integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^7.29.7",
"@babel/helper-validator-identifier": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.0",
"@jridgewell/trace-mapping": "^0.3.24"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"license": "MIT",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
"integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
"license": "MIT"
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.31",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/jsesc": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
"integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==",
"license": "MIT",
"bin": {
"jsesc": "bin/jsesc"
},
"engines": {
"node": ">=6"
}
}
}
}
{
"name": "sample-babel-generator-generate",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"@babel/generator": "7.29.7"
}
}
{
"schemaVersion": 1,
"goal": "verify @babel/generator.generate in pkg:npm/%40babel/generator@7.29.7",
"kind": "HOW",
"packages": [
"pkg:npm/%40babel/generator@7.29.7"
],
"symbols": [
"@babel/generator.generate"
]
}
import generatorPkg, { generate } from "@babel/generator";
const generateFn = typeof generate === "function"
? generate
: (generatorPkg.default?.generate || (typeof generatorPkg.default === "function" ? generatorPkg.default : generatorPkg));
export { generateFn as generate };
export function generateExpression(ast, options = {}) {
return generateFn(ast, options);
}
export function generateCompact(ast) {
return generateFn(ast, { compact: true });
}
export function generateWithSourceMap(ast, sourceFileName) {
return generateFn(ast, {
sourceMaps: true,
sourceFileName
});
}
export function generateWithoutComments(ast) {
return generateFn(ast, { comments: false });
}
export function generateWithRetainedLines(ast) {
return generateFn(ast, { retainLines: true });
}
import assert from "node:assert/strict";
import {
generate,
generateExpression,
generateCompact,
generateWithSourceMap,
generateWithoutComments,
generateWithRetainedLines
} from "../src/index.mjs";
// 1. generate converts BinaryExpression AST into formatted expression code
{
const ast = {
type: "BinaryExpression",
operator: "+",
left: { type: "Identifier", name: "foo" },
right: { type: "Identifier", name: "bar" }
};
const result = generateExpression(ast);
assert.equal(typeof result.code, "string");
assert.equal(result.code, "foo + bar");
}
// 2. generate formats variable declarations with compact formatting without redundant spaces
{
const ast = {
type: "VariableDeclaration",
kind: "const",
declarations: [
{
type: "VariableDeclarator",
id: { type: "Identifier", name: "value" },
init: { type: "NumericLiteral", value: 100 }
}
]
};
const result = generateCompact(ast);
assert.equal(result.code, "const value=100;");
}
// 3. generate produces version 3 source maps when sourceMaps option is enabled
{
const ast = {
type: "Identifier",
name: "variableName",
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 },
filename: "input.js"
}
};
const result = generateWithSourceMap(ast, "input.js");
assert.ok(result.map, "Expected source map to be generated");
assert.equal(result.map.version, 3);
assert.ok(Array.isArray(result.map.sources));
assert.ok(result.map.sources.includes("input.js"));
}
// 4. generate strips comments when comments option is false
{
const ast = {
type: "ExpressionStatement",
expression: { type: "Identifier", name: "target" },
leadingComments: [
{ type: "CommentBlock", value: " comment text " }
]
};
const withComments = generate(ast, { comments: true });
assert.match(withComments.code, /\/\* comment text \*\//);
const withoutComments = generateWithoutComments(ast);
assert.equal(withoutComments.code.trim(), "target;");
assert.equal(withoutComments.code.includes("comment text"), false);
}
// 5. generate preserves line breaks when retainLines option is true
{
const ast = {
type: "Program",
body: [
{
type: "ExpressionStatement",
expression: { type: "Identifier", name: "firstLine" },
loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 9 } }
},
{
type: "ExpressionStatement",
expression: { type: "Identifier", name: "thirdLine" },
loc: { start: { line: 3, column: 0 }, end: { line: 3, column: 9 } }
}
]
};
const result = generateWithRetainedLines(ast);
assert.match(result.code, /firstLine;\n\nthirdLine;/);
}
// 6. generate returns an object with code string and map property
{
const ast = { type: "NumericLiteral", value: 123 };
const result = generate(ast);
assert.equal(typeof result, "object");
assert.equal(typeof result.code, "string");
assert.equal(result.code, "123");
assert.equal(result.map, null);
}
// 7. generate throws an Error when passed an unknown AST node type
{
assert.throws(
() => generate({ type: "InvalidUnknownNodeType" }),
/unknown node of type/
);
}
console.log("All @babel/generator.generate contract tests passed successfully.");
Origin Seeder
anonymous