CodeSampleX

Ejemplo

@eslint/plugin-kit 0.7.3

Muestra verificada para npm @eslint/plugin-kit 0.7.3. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó: assert TextSourceCodeBase…

sha256:95aca397d3764434d9111a0f266d6150f26a6d25e2eed0772fe1fbd4c9a7ce5f

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify pkg:npm/%40eslint/plugin-kit@0.7.3
Paquetes
Entorno
node 22.23.2
Creado
2026-09-05T16:33:57Z

Contrato

  1. assert TextSourceCodeBase subclass implements traverse generator yielding VisitNodeStep and CallMethodStep
  2. assert TextSourceCodeBase supports position-style AST nodes for getLoc and getRange
  3. assert TextSourceCodeBase constructor accepts custom lineEndingPattern for CRLF line splitting
  4. assert TextSourceCodeBase default traverse and getParent methods throw Not implemented Error
  5. assert TextSourceCodeBase getLocFromIndex and getIndexFromLoc throw RangeError on out-of-range coordinates
  6. assert TextSourceCodeBase.getAncestors throws TypeError when node argument is missing

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/%40eslint/plugin-kit@0.7.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40eslint/plugin-kit@0.7.3

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:aa22afeae0a8c8d841931c50b337b704be8f30636ff10a45ffb00dad2e90911d","contract":["assert TextSourceCodeBase subclass implements traverse generator yielding VisitNodeStep and CallMethodStep","assert TextSourceCodeBase supports position-style AST nodes for getLoc and getRange","assert TextSourceCodeBase constructor accepts custom lineEndingPattern for CRLF line splitting","assert TextSourceCodeBase default traverse and getParent methods throw Not implemented Error","assert TextSourceCodeBase getLocFromIndex and getIndexFromLoc throw RangeError on out-of-range coordinates","assert TextSourceCodeBase.getAncestors throws TypeError when node argument is missing"],"goal":"verify pkg:npm/%40eslint/plugin-kit@0.7.3","kind":"HOW","packages":["pkg:npm/%40eslint/plugin-kit@0.7.3"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40eslint/plugin-kit@0.7.3"],"schemaVersion":1,"subject":"pkg:npm/%40eslint/plugin-kit@0.7.3","verifierAdapter":"node-typescript@1"}
index.js
const {
  TextSourceCodeBase,
  VisitNodeStep,
  CallMethodStep,
} = require('@eslint/plugin-kit');

/**
 * Custom SourceCode class supporting custom AST traversal and position-style AST nodes.
 */
class MarkdownSourceCode extends TextSourceCodeBase {
  #parents = new Map();

  /**
   * Returns the parent of the given AST node.
   * @param {object} node - AST node.
   * @returns {object|undefined} Parent node.
   */
  getParent(node) {
    return this.#parents.get(node);
  }

  /**
   * Sets the parent of a node.
   * @param {object} node - Child node.
   * @param {object} parent - Parent node.
   */
  setParent(node, parent) {
    this.#parents.set(node, parent);
  }

  /**
   * Traverses the AST in document order yielding VisitNodeStep and CallMethodStep steps.
   * @returns {Iterable<import('@eslint/plugin-kit').TraversalStep>} Traversal steps.
   */
  *traverse() {
    // Visit root node (enter)
    yield new VisitNodeStep({
      target: this.ast,
      phase: 1,
      args: [this.ast, null],
    });

    if (Array.isArray(this.ast.children)) {
      for (const child of this.ast.children) {
        this.setParent(child, this.ast);

        // Visit child node (enter)
        yield new VisitNodeStep({
          target: child,
          phase: 1,
          args: [child, this.ast],
        });

        // Call visitor method for child type
        yield new CallMethodStep({
          target: `on${child.type}`,
          args: [child],
        });

        // Visit child node (exit)
        yield new VisitNodeStep({
          target: child,
          phase: 2,
          args: [child, this.ast],
        });
      }
    }

    // Visit root node (exit)
    yield new VisitNodeStep({
      target: this.ast,
      phase: 2,
      args: [this.ast, null],
    });
  }
}

/**
 * Default SourceCode class without overrides to verify base class default contracts.
 */
class DefaultSourceCode extends TextSourceCodeBase {}

module.exports = {
  TextSourceCodeBase,
  VisitNodeStep,
  CallMethodStep,
  MarkdownSourceCode,
  DefaultSourceCode,
};
package-lock.json
{
  "name": "sample-eslint-plugin-kit",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-eslint-plugin-kit",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@eslint/plugin-kit": "0.7.3"
      }
    },
    "node_modules/@eslint/core": {
      "version": "1.2.1",
      "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.2.1.tgz",
      "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==",
      "license": "Apache-2.0",
      "dependencies": {
        "@types/json-schema": "^7.0.15"
      },
      "engines": {
        "node": "^20.19.0 || ^22.13.0 || >=24"
      }
    },
    "node_modules/@eslint/plugin-kit": {
      "version": "0.7.3",
      "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz",
      "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==",
      "license": "Apache-2.0",
      "dependencies": {
        "@eslint/core": "^1.2.1",
        "levn": "^0.4.1"
      },
      "engines": {
        "node": "^20.19.0 || ^22.13.0 || >=24"
      }
    },
    "node_modules/@types/json-schema": {
      "version": "7.0.15",
      "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
      "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
      "license": "MIT"
    },
    "node_modules/levn": {
      "version": "0.4.1",
      "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
      "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
      "license": "MIT",
      "dependencies": {
        "prelude-ls": "^1.2.1",
        "type-check": "~0.4.0"
      },
      "engines": {
        "node": ">= 0.8.0"
      }
    },
    "node_modules/prelude-ls": {
      "version": "1.2.1",
      "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
      "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.8.0"
      }
    },
    "node_modules/type-check": {
      "version": "0.4.0",
      "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
      "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
      "license": "MIT",
      "dependencies": {
        "prelude-ls": "^1.2.1"
      },
      "engines": {
        "node": ">= 0.8.0"
      }
    }
  }
}
package.json
{
  "name": "sample-eslint-plugin-kit",
  "version": "1.0.0",
  "description": "Clean-room sample verifying @eslint/plugin-kit traversal and position-style AST source code",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "@eslint/plugin-kit": "0.7.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40eslint/plugin-kit@0.7.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40eslint/plugin-kit@0.7.3"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import {
  TextSourceCodeBase,
  VisitNodeStep,
  CallMethodStep,
  MarkdownSourceCode,
  DefaultSourceCode,
} from '../index.js';

// 1. Verify TextSourceCodeBase subclass implements traverse generator yielding VisitNodeStep and CallMethodStep
const headingNode = {
  type: 'Heading',
  position: {
    start: { line: 1, column: 1, offset: 0 },
    end: { line: 1, column: 14, offset: 13 },
  },
};
const paragraphNode = {
  type: 'Paragraph',
  position: {
    start: { line: 3, column: 1, offset: 15 },
    end: { line: 3, column: 16, offset: 30 },
  },
};
const docAst = {
  type: 'Document',
  position: {
    start: { line: 1, column: 1, offset: 0 },
    end: { line: 3, column: 16, offset: 30 },
  },
  children: [headingNode, paragraphNode],
};
const docText = '# Hello World\n\nParagraph text.\n';

const markdownSource = new MarkdownSourceCode({
  ast: docAst,
  text: docText,
});

const steps = Array.from(markdownSource.traverse());
assert.strictEqual(steps.length, 8);

// Root node enter
assert.strictEqual(steps[0].type, 'visit');
assert.strictEqual(steps[0].kind, 1);
assert.strictEqual(steps[0].phase, 1);
assert.strictEqual(steps[0].target, docAst);

// First child enter
assert.strictEqual(steps[1].type, 'visit');
assert.strictEqual(steps[1].kind, 1);
assert.strictEqual(steps[1].phase, 1);
assert.strictEqual(steps[1].target, headingNode);

// First child visitor method call
assert.strictEqual(steps[2].type, 'call');
assert.strictEqual(steps[2].kind, 2);
assert.strictEqual(steps[2].target, 'onHeading');
assert.deepStrictEqual(steps[2].args, [headingNode]);

// First child exit
assert.strictEqual(steps[3].type, 'visit');
assert.strictEqual(steps[3].phase, 2);
assert.strictEqual(steps[3].target, headingNode);

// Parent links established during traversal
assert.strictEqual(markdownSource.getParent(headingNode), docAst);
assert.strictEqual(markdownSource.getParent(paragraphNode), docAst);

// 2. Verify TextSourceCodeBase supports position-style AST nodes for getLoc and getRange
const headingLoc = markdownSource.getLoc(headingNode);
assert.deepStrictEqual(headingLoc, {
  start: { line: 1, column: 1, offset: 0 },
  end: { line: 1, column: 14, offset: 13 },
});

const headingRange = markdownSource.getRange(headingNode);
assert.deepStrictEqual(headingRange, [0, 13]);
assert.strictEqual(markdownSource.getText(headingNode), '# Hello World');

const paragraphRange = markdownSource.getRange(paragraphNode);
assert.deepStrictEqual(paragraphRange, [15, 30]);
assert.strictEqual(markdownSource.getText(paragraphNode), 'Paragraph text.');

// 3. Verify TextSourceCodeBase constructor accepts custom lineEndingPattern for CRLF line splitting
const crlfDocText = 'alpha\r\nbeta\r\ngamma';
const crlfSource = new DefaultSourceCode({
  text: crlfDocText,
  ast: {
    type: 'Program',
    loc: {
      start: { line: 1, column: 0 },
      end: { line: 3, column: 5 },
    },
  },
  lineEndingPattern: /\r\n/u,
});
assert.strictEqual(crlfSource.lines.length, 3);
assert.strictEqual(crlfSource.lines[0], 'alpha');
assert.strictEqual(crlfSource.lines[1], 'beta');
assert.strictEqual(crlfSource.lines[2], 'gamma');

// 4. Verify TextSourceCodeBase default traverse and getParent methods throw Not implemented Error
const defaultSource = new DefaultSourceCode({
  text: 'sample text',
  ast: {
    type: 'Program',
    loc: {
      start: { line: 1, column: 0 },
      end: { line: 1, column: 11 },
    },
  },
});
assert.throws(() => defaultSource.getParent({}), {
  name: 'Error',
  message: 'Not implemented.',
});
assert.throws(() => defaultSource.traverse(), {
  name: 'Error',
  message: 'Not implemented.',
});

// 5. Verify TextSourceCodeBase getLocFromIndex and getIndexFromLoc throw RangeError on out-of-range coordinates
assert.throws(() => defaultSource.getLocFromIndex(-1), {
  name: 'RangeError',
});
assert.throws(() => defaultSource.getLocFromIndex(999), {
  name: 'RangeError',
});
assert.throws(() => defaultSource.getIndexFromLoc({ line: 0, column: 0 }), {
  name: 'RangeError',
});
assert.throws(() => defaultSource.getIndexFromLoc({ line: 5, column: 0 }), {
  name: 'RangeError',
});

// 6. Verify TextSourceCodeBase.getAncestors throws TypeError when node argument is missing
assert.throws(() => defaultSource.getAncestors(), {
  name: 'TypeError',
  message: 'Missing required argument: node.',
});

console.log('All @eslint/plugin-kit contract assertions passed successfully.');

Seeder de origen

anónimo