CodeSampleX

샘플

@typescript-eslint/types 8.69.0: AST_TOKEN_TYPES

검증된 샘플 — npm @typescript-eslint/types 8.69.0: AST_TOKEN_TYPES. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: AST_TOKEN_TYPES provides canonical…

sha256:385662e542f26a1bbf4004bfad7acdf834d34cf546c118a8d0999a247b04881a

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

실행 증거

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

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

검증 실행 환경

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

케이스

HOW
목표
verify @typescript-eslint/types.AST_TOKEN_TYPES in pkg:npm/%40typescript-eslint/types@8.69.0
패키지
심벌
  • @typescript-eslint/types.AST_TOKEN_TYPES
환경
node 22.23.2
생성일
2026-10-11T17:29:27Z

컨트랙트

  1. AST_TOKEN_TYPES provides canonical string enum mappings for tokenizer token types including Boolean, Identifier, JSXIdentifier, JSXText, Keyword, Null, Numeric, Punctuator, RegularExpression, String, Template, Block, Line, and PrivateIdentifier
  2. isCommentToken utility identifies comment tokens using AST_TOKEN_TYPES Block and Line definitions
  3. isLiteralToken utility classifies literal values using AST_TOKEN_TYPES Boolean, Null, Numeric, String, and RegularExpression
  4. isIdentifierToken utility categorizes identifier tokens using AST_TOKEN_TYPES Identifier, JSXIdentifier, and PrivateIdentifier
  5. classifyToken categorizes tokens into structural groups based on AST_TOKEN_TYPES
  6. isValidTokenType and getTokenTypeName validate known token type strings against AST_TOKEN_TYPES
  7. TSESTree namespace exports AST_TOKEN_TYPES with identical references to the top-level AST_TOKEN_TYPES export

파일

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

소스 아티팩트 내려받기 (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 @typescript-eslint/types.AST_TOKEN_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_TOKEN_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:48fea730b19770f663f9eff614eabc73908f4a9e784d02e2708f4b10f34c6531","contract":["AST_TOKEN_TYPES provides canonical string enum mappings for tokenizer token types including Boolean, Identifier, JSXIdentifier, JSXText, Keyword, Null, Numeric, Punctuator, RegularExpression, String, Template, Block, Line, and PrivateIdentifier","isCommentToken utility identifies comment tokens using AST_TOKEN_TYPES Block and Line definitions","isLiteralToken utility classifies literal values using AST_TOKEN_TYPES Boolean, Null, Numeric, String, and RegularExpression","isIdentifierToken utility categorizes identifier tokens using AST_TOKEN_TYPES Identifier, JSXIdentifier, and PrivateIdentifier","classifyToken categorizes tokens into structural groups based on AST_TOKEN_TYPES","isValidTokenType and getTokenTypeName validate known token type strings against AST_TOKEN_TYPES","TSESTree namespace exports AST_TOKEN_TYPES with identical references to the top-level AST_TOKEN_TYPES export"],"goal":"verify @typescript-eslint/types.AST_TOKEN_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_TOKEN_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_TOKEN_TYPES"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-typescript-eslint-types",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-typescript-eslint-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",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of @typescript-eslint/types AST_TOKEN_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_TOKEN_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_TOKEN_TYPES"
  ]
}
src/index.js
const { AST_TOKEN_TYPES, TSESTree } = require('@typescript-eslint/types');

/**
 * All valid AST_TOKEN_TYPES string values.
 */
const VALID_TOKEN_TYPES = new Set(Object.values(AST_TOKEN_TYPES));

/**
 * Checks whether a value is a valid AST_TOKEN_TYPES token type string.
 *
 * @param {unknown} type - The token type candidate.
 * @returns {boolean} True if the type is a recognized AST_TOKEN_TYPES value.
 */
function isValidTokenType(type) {
  return typeof type === 'string' && VALID_TOKEN_TYPES.has(type);
}

/**
 * Resolves the canonical token type name for a given type name or value.
 *
 * @param {string} tokenType - The name or value of the token type.
 * @returns {string|null} The canonical token type or null if not found.
 */
function getTokenTypeName(tokenType) {
  if (typeof tokenType === 'string' && Object.prototype.hasOwnProperty.call(AST_TOKEN_TYPES, tokenType)) {
    return AST_TOKEN_TYPES[tokenType];
  }
  return null;
}

/**
 * Checks whether a token represents a comment (Block or Line).
 *
 * @param {object} token - The token object to inspect.
 * @returns {boolean} True if the token is a Block or Line comment.
 */
function isCommentToken(token) {
  if (!token || typeof token.type !== 'string') {
    return false;
  }
  return token.type === AST_TOKEN_TYPES.Block || token.type === AST_TOKEN_TYPES.Line;
}

/**
 * Checks whether a token represents a literal (Boolean, Null, Numeric, String, RegularExpression).
 *
 * @param {object} token - The token object to inspect.
 * @returns {boolean} True if the token is a literal.
 */
function isLiteralToken(token) {
  if (!token || typeof token.type !== 'string') {
    return false;
  }
  return (
    token.type === AST_TOKEN_TYPES.Boolean ||
    token.type === AST_TOKEN_TYPES.Null ||
    token.type === AST_TOKEN_TYPES.Numeric ||
    token.type === AST_TOKEN_TYPES.String ||
    token.type === AST_TOKEN_TYPES.RegularExpression
  );
}

/**
 * Checks whether a token represents an identifier (Identifier, JSXIdentifier, PrivateIdentifier).
 *
 * @param {object} token - The token object to inspect.
 * @returns {boolean} True if the token is an identifier token.
 */
function isIdentifierToken(token) {
  if (!token || typeof token.type !== 'string') {
    return false;
  }
  return (
    token.type === AST_TOKEN_TYPES.Identifier ||
    token.type === AST_TOKEN_TYPES.JSXIdentifier ||
    token.type === AST_TOKEN_TYPES.PrivateIdentifier
  );
}

/**
 * Checks whether a token represents a punctuator.
 *
 * @param {object} token - The token object to inspect.
 * @returns {boolean} True if the token is a punctuator token.
 */
function isPunctuatorToken(token) {
  if (!token || typeof token.type !== 'string') {
    return false;
  }
  return token.type === AST_TOKEN_TYPES.Punctuator;
}

/**
 * Checks whether a token represents a keyword.
 *
 * @param {object} token - The token object to inspect.
 * @returns {boolean} True if the token is a keyword token.
 */
function isKeywordToken(token) {
  if (!token || typeof token.type !== 'string') {
    return false;
  }
  return token.type === AST_TOKEN_TYPES.Keyword;
}

/**
 * Checks whether a token represents a template token.
 *
 * @param {object} token - The token object to inspect.
 * @returns {boolean} True if the token is a template token.
 */
function isTemplateToken(token) {
  if (!token || typeof token.type !== 'string') {
    return false;
  }
  return token.type === AST_TOKEN_TYPES.Template;
}

/**
 * Categorizes an AST token into high-level token families.
 *
 * @param {object} token - The token to categorize.
 * @returns {string} The category name.
 */
function classifyToken(token) {
  if (!token || typeof token.type !== 'string') {
    return 'unknown';
  }
  if (isCommentToken(token)) {
    return 'comment';
  }
  if (isLiteralToken(token)) {
    return 'literal';
  }
  if (isIdentifierToken(token)) {
    return 'identifier';
  }
  if (token.type === AST_TOKEN_TYPES.Punctuator) {
    return 'punctuator';
  }
  if (token.type === AST_TOKEN_TYPES.Keyword) {
    return 'keyword';
  }
  if (token.type === AST_TOKEN_TYPES.Template) {
    return 'template';
  }
  if (token.type === AST_TOKEN_TYPES.JSXText) {
    return 'jsx-text';
  }
  return 'unknown';
}

module.exports = {
  AST_TOKEN_TYPES,
  TSESTree,
  isValidTokenType,
  getTokenTypeName,
  isCommentToken,
  isLiteralToken,
  isIdentifierToken,
  isPunctuatorToken,
  isKeywordToken,
  isTemplateToken,
  classifyToken,
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  AST_TOKEN_TYPES,
  TSESTree,
  isValidTokenType,
  getTokenTypeName,
  isCommentToken,
  isLiteralToken,
  isIdentifierToken,
  isPunctuatorToken,
  isKeywordToken,
  isTemplateToken,
  classifyToken,
} = require('../src/index.js');

async function runContract() {
  // 1. AST_TOKEN_TYPES provides canonical string enum mappings for tokenizer token types including Boolean, Identifier, JSXIdentifier, JSXText, Keyword, Null, Numeric, Punctuator, RegularExpression, String, Template, Block, Line, and PrivateIdentifier
  assert.strictEqual(typeof AST_TOKEN_TYPES, 'object');
  assert.strictEqual(AST_TOKEN_TYPES.Boolean, 'Boolean');
  assert.strictEqual(AST_TOKEN_TYPES.Identifier, 'Identifier');
  assert.strictEqual(AST_TOKEN_TYPES.JSXIdentifier, 'JSXIdentifier');
  assert.strictEqual(AST_TOKEN_TYPES.JSXText, 'JSXText');
  assert.strictEqual(AST_TOKEN_TYPES.Keyword, 'Keyword');
  assert.strictEqual(AST_TOKEN_TYPES.Null, 'Null');
  assert.strictEqual(AST_TOKEN_TYPES.Numeric, 'Numeric');
  assert.strictEqual(AST_TOKEN_TYPES.Punctuator, 'Punctuator');
  assert.strictEqual(AST_TOKEN_TYPES.RegularExpression, 'RegularExpression');
  assert.strictEqual(AST_TOKEN_TYPES.String, 'String');
  assert.strictEqual(AST_TOKEN_TYPES.Template, 'Template');
  assert.strictEqual(AST_TOKEN_TYPES.Block, 'Block');
  assert.strictEqual(AST_TOKEN_TYPES.Line, 'Line');
  assert.strictEqual(AST_TOKEN_TYPES.PrivateIdentifier, 'PrivateIdentifier');

  // Verify full set of known enum keys
  const expectedKeys = [
    'Block',
    'Boolean',
    'Identifier',
    'JSXIdentifier',
    'JSXText',
    'Keyword',
    'Line',
    'Null',
    'Numeric',
    'PrivateIdentifier',
    'Punctuator',
    'RegularExpression',
    'String',
    'Template',
  ];
  assert.deepStrictEqual(Object.keys(AST_TOKEN_TYPES).sort(), expectedKeys.sort());

  // 2. isCommentToken utility identifies comment tokens using AST_TOKEN_TYPES Block and Line definitions
  assert.strictEqual(isCommentToken({ type: AST_TOKEN_TYPES.Block, value: '/* comment */' }), true);
  assert.strictEqual(isCommentToken({ type: AST_TOKEN_TYPES.Line, value: '// line' }), true);
  assert.strictEqual(isCommentToken({ type: AST_TOKEN_TYPES.Keyword, value: 'function' }), false);
  assert.strictEqual(isCommentToken(null), false);
  assert.strictEqual(isCommentToken({}), false);

  // 3. isLiteralToken utility classifies literal values using AST_TOKEN_TYPES Boolean, Null, Numeric, String, and RegularExpression
  assert.strictEqual(isLiteralToken({ type: AST_TOKEN_TYPES.Boolean, value: 'true' }), true);
  assert.strictEqual(isLiteralToken({ type: AST_TOKEN_TYPES.Null, value: 'null' }), true);
  assert.strictEqual(isLiteralToken({ type: AST_TOKEN_TYPES.Numeric, value: '123' }), true);
  assert.strictEqual(isLiteralToken({ type: AST_TOKEN_TYPES.String, value: '"hello"' }), true);
  assert.strictEqual(isLiteralToken({ type: AST_TOKEN_TYPES.RegularExpression, value: '/abc/' }), true);
  assert.strictEqual(isLiteralToken({ type: AST_TOKEN_TYPES.Identifier, value: 'foo' }), false);
  assert.strictEqual(isLiteralToken(null), false);

  // 4. isIdentifierToken utility categorizes identifier tokens using AST_TOKEN_TYPES Identifier, JSXIdentifier, and PrivateIdentifier
  assert.strictEqual(isIdentifierToken({ type: AST_TOKEN_TYPES.Identifier, value: 'myVar' }), true);
  assert.strictEqual(isIdentifierToken({ type: AST_TOKEN_TYPES.JSXIdentifier, value: 'Component' }), true);
  assert.strictEqual(isIdentifierToken({ type: AST_TOKEN_TYPES.PrivateIdentifier, value: '#field' }), true);
  assert.strictEqual(isIdentifierToken({ type: AST_TOKEN_TYPES.Punctuator, value: '.' }), false);

  // 5. classifyToken categorizes tokens into structural groups based on AST_TOKEN_TYPES
  assert.strictEqual(classifyToken({ type: AST_TOKEN_TYPES.Line, value: '//' }), 'comment');
  assert.strictEqual(classifyToken({ type: AST_TOKEN_TYPES.Numeric, value: '42' }), 'literal');
  assert.strictEqual(classifyToken({ type: AST_TOKEN_TYPES.Identifier, value: 'name' }), 'identifier');
  assert.strictEqual(classifyToken({ type: AST_TOKEN_TYPES.Punctuator, value: ';' }), 'punctuator');
  assert.strictEqual(classifyToken({ type: AST_TOKEN_TYPES.Keyword, value: 'const' }), 'keyword');
  assert.strictEqual(classifyToken({ type: AST_TOKEN_TYPES.Template, value: '`text`' }), 'template');
  assert.strictEqual(classifyToken({ type: AST_TOKEN_TYPES.JSXText, value: 'hello' }), 'jsx-text');
  assert.strictEqual(classifyToken({ type: 'UnknownType' }), 'unknown');
  assert.strictEqual(classifyToken(null), 'unknown');

  // 6. isValidTokenType and getTokenTypeName validate known token type strings against AST_TOKEN_TYPES
  assert.strictEqual(isValidTokenType(AST_TOKEN_TYPES.Keyword), true);
  assert.strictEqual(isValidTokenType(AST_TOKEN_TYPES.PrivateIdentifier), true);
  assert.strictEqual(isValidTokenType('InvalidTokenType'), false);
  assert.strictEqual(isValidTokenType(123), false);
  assert.strictEqual(getTokenTypeName('Keyword'), 'Keyword');
  assert.strictEqual(getTokenTypeName('PrivateIdentifier'), 'PrivateIdentifier');
  assert.strictEqual(getTokenTypeName('NonExistent'), null);

  // 7. TSESTree namespace exports AST_TOKEN_TYPES with identical references to the top-level AST_TOKEN_TYPES export
  assert.strictEqual(typeof TSESTree, 'object');
  assert.strictEqual(TSESTree.AST_TOKEN_TYPES, AST_TOKEN_TYPES);
  assert.strictEqual(TSESTree.AST_TOKEN_TYPES.Punctuator, 'Punctuator');

  console.log('AST_TOKEN_TYPES contract assertions passed successfully.');
}

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

오리진 시더

익명