CodeSampleX

Ejemplo

@typescript-eslint/types 8.69.0: AST_NODE_TYPES

Muestra verificada para npm @typescript-eslint/types 8.69.0: AST_NODE_TYPES. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:d0b5c726488b53f9ff56203c6fd886fcd0ecf9aa7e90dec45e2e263858ad4227

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-10-11

Caso

HOW
Objetivo
verify @typescript-eslint/types.AST_NODE_TYPES in pkg:npm/%40typescript-eslint/types@8.69.0
Paquetes
Símbolos
  • @typescript-eslint/types.AST_NODE_TYPES
Entorno
node 22.23.2
Creado
2026-10-11T16:46:08Z

Contrato

  1. AST_NODE_TYPES provides canonical string enum mappings for standard ECMAScript AST node types including Identifier, Literal, Program, FunctionDeclaration, and ReturnStatement
  2. AST_NODE_TYPES provides canonical string enum mappings for TypeScript-specific AST node types including TSInterfaceDeclaration, TSTypeAliasDeclaration, TSTypeAnnotation, and TSTypeReference
  3. AST_NODE_TYPES provides canonical string enum mappings for JSX AST node types including JSXElement, JSXAttribute, and JSXOpeningElement
  4. isValidNodeType validates arbitrary strings against known AST_NODE_TYPES enum members
  5. getNodeTypeCategory categorizes AST_NODE_TYPES members into typescript, jsx, declaration, statement, and expression categories
  6. isTypeDeclarationNode identifies TypeScript type and interface declarations using AST_NODE_TYPES

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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 @typescript-eslint/types.AST_NODE_TYPES in pkg:npm/%40typescript-eslint/types@8.69.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40typescript-eslint/types@8.69.0
Demonstrate these symbols/APIs:
  - @typescript-eslint/types.AST_NODE_TYPES

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:beb474d04eb92f545d461c7f1d7d3c6b4afceaabb99397b1003fea241d540378","contract":["AST_NODE_TYPES provides canonical string enum mappings for standard ECMAScript AST node types including Identifier, Literal, Program, FunctionDeclaration, and ReturnStatement","AST_NODE_TYPES provides canonical string enum mappings for TypeScript-specific AST node types including TSInterfaceDeclaration, TSTypeAliasDeclaration, TSTypeAnnotation, and TSTypeReference","AST_NODE_TYPES provides canonical string enum mappings for JSX AST node types including JSXElement, JSXAttribute, and JSXOpeningElement","isValidNodeType validates arbitrary strings against known AST_NODE_TYPES enum members","getNodeTypeCategory categorizes AST_NODE_TYPES members into typescript, jsx, declaration, statement, and expression categories","isTypeDeclarationNode identifies TypeScript type and interface declarations using AST_NODE_TYPES"],"goal":"verify @typescript-eslint/types.AST_NODE_TYPES in pkg:npm/%40typescript-eslint/types@8.69.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/types@8.69.0"],"schemaVersion":1,"symbols":["@typescript-eslint/types.AST_NODE_TYPES"]},"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/%40typescript-eslint/types@8.69.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/types@8.69.0","symbols":["@typescript-eslint/types.AST_NODE_TYPES"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-typescript-eslint-types-ast-node-types",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-typescript-eslint-types-ast-node-types",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@typescript-eslint/types": "8.69.0"
      }
    },
    "node_modules/@typescript-eslint/types": {
      "version": "8.69.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.69.0.tgz",
      "integrity": "sha512-K3VrubUPhlo9VDBS6QdI8YB5j7ClpqLRdefcz6PFrhnwicehBweqQ9Evhl4l+FYz0HdDmMqIiSX0aldGRYtDCA==",
      "license": "MIT",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      }
    }
  }
}
package.json
{
  "name": "sample-typescript-eslint-types-ast-node-types",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of @typescript-eslint/types AST_NODE_TYPES",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "@typescript-eslint/types": "8.69.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @typescript-eslint/types.AST_NODE_TYPES in pkg:npm/%40typescript-eslint/types@8.69.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40typescript-eslint/types@8.69.0"
  ],
  "symbols": [
    "@typescript-eslint/types.AST_NODE_TYPES"
  ]
}
src/index.js
const { AST_NODE_TYPES } = require('@typescript-eslint/types');

/**
 * Validates whether the given string is a known member of AST_NODE_TYPES.
 *
 * @param {string} typeName - The candidate node type name.
 * @returns {boolean} True if typeName exists in AST_NODE_TYPES.
 */
function isValidNodeType(typeName) {
  if (typeof typeName !== 'string') {
    return false;
  }
  return Object.prototype.hasOwnProperty.call(AST_NODE_TYPES, typeName);
}

/**
 * Categorizes an AST node type into a major syntactic group.
 *
 * @param {string} nodeType - The AST node type string to categorize.
 * @returns {string} One of 'statement', 'expression', 'declaration', 'typescript', 'jsx', 'other', or 'unknown'.
 */
function getNodeTypeCategory(nodeType) {
  if (typeof nodeType !== 'string' || !isValidNodeType(nodeType)) {
    return 'unknown';
  }

  if (nodeType.startsWith('TS')) {
    return 'typescript';
  }

  if (nodeType.startsWith('JSX')) {
    return 'jsx';
  }

  if (nodeType.endsWith('Declaration')) {
    return 'declaration';
  }

  if (nodeType.endsWith('Statement')) {
    return 'statement';
  }

  if (nodeType.endsWith('Expression') || nodeType.endsWith('Literal') || nodeType === AST_NODE_TYPES.Identifier) {
    return 'expression';
  }

  return 'other';
}

/**
 * Checks if a given AST node is a TypeScript type declaration node.
 *
 * @param {object} node - The AST node to check.
 * @returns {boolean} True if the node represents a TypeScript interface or type alias declaration.
 */
function isTypeDeclarationNode(node) {
  if (!node || typeof node.type !== 'string') {
    return false;
  }
  return (
    node.type === AST_NODE_TYPES.TSInterfaceDeclaration ||
    node.type === AST_NODE_TYPES.TSTypeAliasDeclaration ||
    node.type === AST_NODE_TYPES.TSEnumDeclaration ||
    node.type === AST_NODE_TYPES.TSModuleDeclaration
  );
}

module.exports = {
  AST_NODE_TYPES,
  getNodeTypeCategory,
  isTypeDeclarationNode,
  isValidNodeType,
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  AST_NODE_TYPES,
  getNodeTypeCategory,
  isTypeDeclarationNode,
  isValidNodeType,
} = require('../src/index.js');

async function runContract() {
  // 1. AST_NODE_TYPES provides canonical string enum mappings for standard ECMAScript AST node types
  assert.strictEqual(typeof AST_NODE_TYPES, 'object');
  assert.strictEqual(AST_NODE_TYPES.Identifier, 'Identifier');
  assert.strictEqual(AST_NODE_TYPES.Literal, 'Literal');
  assert.strictEqual(AST_NODE_TYPES.Program, 'Program');
  assert.strictEqual(AST_NODE_TYPES.FunctionDeclaration, 'FunctionDeclaration');
  assert.strictEqual(AST_NODE_TYPES.VariableDeclaration, 'VariableDeclaration');
  assert.strictEqual(AST_NODE_TYPES.BinaryExpression, 'BinaryExpression');
  assert.strictEqual(AST_NODE_TYPES.ReturnStatement, 'ReturnStatement');

  // 2. AST_NODE_TYPES provides canonical string enum mappings for TypeScript-specific AST node types
  assert.strictEqual(AST_NODE_TYPES.TSInterfaceDeclaration, 'TSInterfaceDeclaration');
  assert.strictEqual(AST_NODE_TYPES.TSTypeAliasDeclaration, 'TSTypeAliasDeclaration');
  assert.strictEqual(AST_NODE_TYPES.TSTypeAnnotation, 'TSTypeAnnotation');
  assert.strictEqual(AST_NODE_TYPES.TSTypeReference, 'TSTypeReference');
  assert.strictEqual(AST_NODE_TYPES.TSUnionType, 'TSUnionType');
  assert.strictEqual(AST_NODE_TYPES.TSIntersectionType, 'TSIntersectionType');
  assert.strictEqual(AST_NODE_TYPES.TSAsExpression, 'TSAsExpression');

  // 3. AST_NODE_TYPES provides canonical string enum mappings for JSX AST node types
  assert.strictEqual(AST_NODE_TYPES.JSXElement, 'JSXElement');
  assert.strictEqual(AST_NODE_TYPES.JSXAttribute, 'JSXAttribute');
  assert.strictEqual(AST_NODE_TYPES.JSXOpeningElement, 'JSXOpeningElement');
  assert.strictEqual(AST_NODE_TYPES.JSXClosingElement, 'JSXClosingElement');
  assert.strictEqual(AST_NODE_TYPES.JSXIdentifier, 'JSXIdentifier');

  // 4. isValidNodeType validates arbitrary strings against known AST_NODE_TYPES enum members
  assert.strictEqual(isValidNodeType('Identifier'), true);
  assert.strictEqual(isValidNodeType('TSInterfaceDeclaration'), true);
  assert.strictEqual(isValidNodeType('JSXElement'), true);
  assert.strictEqual(isValidNodeType('NonExistentNodeType'), false);
  assert.strictEqual(isValidNodeType(''), false);
  assert.strictEqual(isValidNodeType(null), false);
  assert.strictEqual(isValidNodeType(undefined), false);

  // 5. getNodeTypeCategory categorizes AST_NODE_TYPES into typescript, jsx, declaration, statement, expression, and other
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.TSInterfaceDeclaration), 'typescript');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.TSTypeReference), 'typescript');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.JSXElement), 'jsx');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.JSXAttribute), 'jsx');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.FunctionDeclaration), 'declaration');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.VariableDeclaration), 'declaration');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.ReturnStatement), 'statement');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.IfStatement), 'statement');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.BinaryExpression), 'expression');
  assert.strictEqual(getNodeTypeCategory(AST_NODE_TYPES.Identifier), 'expression');
  assert.strictEqual(getNodeTypeCategory('UnknownNode'), 'unknown');

  // 6. isTypeDeclarationNode identifies TypeScript type and interface declarations using AST_NODE_TYPES
  const interfaceNode = { type: AST_NODE_TYPES.TSInterfaceDeclaration, id: { type: AST_NODE_TYPES.Identifier, name: 'Config' } };
  const typeAliasNode = { type: AST_NODE_TYPES.TSTypeAliasDeclaration, id: { type: AST_NODE_TYPES.Identifier, name: 'Id' } };
  const enumNode = { type: AST_NODE_TYPES.TSEnumDeclaration, id: { type: AST_NODE_TYPES.Identifier, name: 'Direction' } };
  const functionNode = { type: AST_NODE_TYPES.FunctionDeclaration, id: { type: AST_NODE_TYPES.Identifier, name: 'run' } };
  const varNode = { type: AST_NODE_TYPES.VariableDeclaration, kind: 'const', declarations: [] };

  assert.strictEqual(isTypeDeclarationNode(interfaceNode), true);
  assert.strictEqual(isTypeDeclarationNode(typeAliasNode), true);
  assert.strictEqual(isTypeDeclarationNode(enumNode), true);
  assert.strictEqual(isTypeDeclarationNode(functionNode), false);
  assert.strictEqual(isTypeDeclarationNode(varNode), false);
  assert.strictEqual(isTypeDeclarationNode(null), false);
  assert.strictEqual(isTypeDeclarationNode({}), false);

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

runContract().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Seeder de origen

anónimo