CodeSampleX

サンプル

@typescript-eslint/typescript-estree 8.66.0: clearCaches

検証済みサンプル — npm @typescript-eslint/typescript-estree 8.66.0: clearCaches. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました.

sha256:79b305dee16a012f7767095c9554cb2c45b93f0d4e6b4b1116cb4d83c2a0cf3f

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
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-23

ケース

HOW
ゴール
verify @typescript-eslint/typescript-estree.clearCaches in pkg:npm/%40typescript-eslint/typescript-estree@8.66.0
パッケージ
シンボル
  • @typescript-eslint/typescript-estree.clearCaches
環境
node 22.23.2
作成日
2026-08-23T05:28:21Z

コントラクト

  1. clearCaches is exported as a function from @typescript-eslint/typescript-estree
  2. clearCaches executes cleanly and resets parser caches without throwing
  3. parse converts TypeScript source code into an ESTree AST with Program node
  4. clearCaches resets state after parsing multiple TypeScript source snippets
  5. parseAndGenerateServices returns AST and semantic services object
  6. clearCaches resets TSConfig and parser caches after parseAndGenerateServices invocation
  7. simpleTraverse visits AST nodes in hierarchical traversal

ファイル

  • 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/typescript-estree.clearCaches in pkg:npm/%40typescript-eslint/typescript-estree@8.66.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40typescript-eslint/typescript-estree@8.66.0
Demonstrate these symbols/APIs:
  - @typescript-eslint/typescript-estree.clearCaches
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:934347eb08d2bb050fbea727c73561737a9ed77751be16a52ebc809d73d2ae16","constraints":{"executionContext":"node"},"contract":["clearCaches is exported as a function from @typescript-eslint/typescript-estree","clearCaches executes cleanly and resets parser caches without throwing","parse converts TypeScript source code into an ESTree AST with Program node","clearCaches resets state after parsing multiple TypeScript source snippets","parseAndGenerateServices returns AST and semantic services object","clearCaches resets TSConfig and parser caches after parseAndGenerateServices invocation","simpleTraverse visits AST nodes in hierarchical traversal"],"goal":"verify @typescript-eslint/typescript-estree.clearCaches in pkg:npm/%40typescript-eslint/typescript-estree@8.66.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/typescript-estree@8.66.0"],"schemaVersion":1,"symbols":["@typescript-eslint/typescript-estree.clearCaches"]},"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/typescript-estree@8.66.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/typescript-estree@8.66.0","symbols":["@typescript-eslint/typescript-estree.clearCaches"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-typescript-estree-clearcaches",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-typescript-estree-clearcaches",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@typescript-eslint/typescript-estree": "8.66.0"
      }
    },
    "node_modules/@typescript-eslint/project-service": {
      "version": "8.66.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.66.0.tgz",
      "integrity": "sha512-7MthGPTt4BP69lSryqpqq8HQqxuzynssckL/jyDyk3+TNMQ3y2jFWkptCrktWvBrP+EH787Nl5N5Qpw7WZg+5g==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/tsconfig-utils": "^8.66.0",
        "@typescript-eslint/types": "^8.66.0",
        "debug": "^4.4.3"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4 <6.1.0"
      }
    },
    "node_modules/@typescript-eslint/tsconfig-utils": {
      "version": "8.66.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.66.0.tgz",
      "integrity": "sha512-9D5gLYZG4rOjcoag8MQ/fWI8WqA9wcPDyOGyWtWFhvM1lHRbliqUSPIY5J3zqCU1tvSwzXxnnjhQhz5Ne7mJ4g==",
      "license": "MIT",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4 <6.1.0"
      }
    },
    "node_modules/@typescript-eslint/types": {
      "version": "8.66.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.66.0.tgz",
      "integrity": "sha512-H6gcYaSDOyvL3AD/jHUtUFo2jqGgn/F6nuyuZSu0QTesxL+cP4dQoIMrODRofuJC09g64+WgZ6tE19Y1N2YIFQ==",
      "license": "MIT",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      }
    },
    "node_modules/@typescript-eslint/typescript-estree": {
      "version": "8.66.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.66.0.tgz",
      "integrity": "sha512-8/x4INiiQb10jGgXYD7116/zQ+OL84ZIFn0za68wwFHCanT/VLbBEroWht8RV8fn0/ZCAoazHLQgwUC0UQcDfg==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/project-service": "8.66.0",
        "@typescript-eslint/tsconfig-utils": "8.66.0",
        "@typescript-eslint/types": "8.66.0",
        "@typescript-eslint/visitor-keys": "8.66.0",
        "debug": "^4.4.3",
        "minimatch": "^10.2.2",
        "semver": "^7.7.3",
        "tinyglobby": "^0.2.15",
        "ts-api-utils": "^2.5.0"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4 <6.1.0"
      }
    },
    "node_modules/@typescript-eslint/visitor-keys": {
      "version": "8.66.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.66.0.tgz",
      "integrity": "sha512-dkKR8q+lKciskj1Y3vthHktl+3cMLWGyVUP23bRiPZ5O9BRT++4EqDDV+TVeIKBL1VXVEqrJlz8MYbcnvJcAlg==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/types": "8.66.0",
        "eslint-visitor-keys": "^5.0.0"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      }
    },
    "node_modules/balanced-match": {
      "version": "4.0.4",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
      "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
      "license": "MIT",
      "engines": {
        "node": "18 || 20 || >=22"
      }
    },
    "node_modules/brace-expansion": {
      "version": "5.0.9",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
      "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^4.0.2"
      },
      "engines": {
        "node": "20 || >=22"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/eslint-visitor-keys": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz",
      "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==",
      "license": "Apache-2.0",
      "engines": {
        "node": "^20.19.0 || ^22.13.0 || >=24"
      },
      "funding": {
        "url": "https://opencollective.com/eslint"
      }
    },
    "node_modules/fdir": {
      "version": "6.5.0",
      "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
      "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
      "license": "MIT",
      "engines": {
        "node": ">=12.0.0"
      },
      "peerDependencies": {
        "picomatch": "^3 || ^4"
      },
      "peerDependenciesMeta": {
        "picomatch": {
          "optional": true
        }
      }
    },
    "node_modules/minimatch": {
      "version": "10.2.6",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
      "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
      "license": "BlueOak-1.0.0",
      "dependencies": {
        "brace-expansion": "^5.0.8"
      },
      "engines": {
        "node": "18 || 20 || >=22"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/picomatch": {
      "version": "4.0.5",
      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
      "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      },
      "funding": {
        "url": "https://github.com/sponsors/jonschlinkert"
      }
    },
    "node_modules/semver": {
      "version": "7.8.5",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
      "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/tinyglobby": {
      "version": "0.2.17",
      "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
      "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
      "license": "MIT",
      "dependencies": {
        "fdir": "^6.5.0",
        "picomatch": "^4.0.4"
      },
      "engines": {
        "node": ">=12.0.0"
      },
      "funding": {
        "url": "https://github.com/sponsors/SuperchupuDev"
      }
    },
    "node_modules/ts-api-utils": {
      "version": "2.5.0",
      "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz",
      "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==",
      "license": "MIT",
      "engines": {
        "node": ">=18.12"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4"
      }
    },
    "node_modules/typescript": {
      "version": "6.0.3",
      "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
      "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
      "license": "Apache-2.0",
      "peer": true,
      "bin": {
        "tsc": "bin/tsc",
        "tsserver": "bin/tsserver"
      },
      "engines": {
        "node": ">=14.17"
      }
    }
  }
}
package.json
{
  "name": "sample-typescript-estree-clearcaches",
  "version": "1.0.0",
  "private": true,
  "description": "verify @typescript-eslint/typescript-estree.clearCaches in pkg:npm/%40typescript-eslint/typescript-estree@8.66.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "@typescript-eslint/typescript-estree": "8.66.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @typescript-eslint/typescript-estree.clearCaches in pkg:npm/%40typescript-eslint/typescript-estree@8.66.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40typescript-eslint/typescript-estree@8.66.0"
  ],
  "symbols": [
    "@typescript-eslint/typescript-estree.clearCaches"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const estree = require('@typescript-eslint/typescript-estree');

const {
  clearCaches,
  clearProgramCache,
  parse,
  parseAndGenerateServices,
  simpleTraverse,
  addCandidateTSConfigRootDir,
  clearCandidateTSConfigRootDirs,
  AST_NODE_TYPES
} = estree;

/**
 * Parses TypeScript source code into an ESTree AST.
 *
 * @param {string} code - The TypeScript source code to parse.
 * @param {object} [options={}] - Additional parser options.
 * @returns {object} The parsed AST root node.
 */
function parseTypeScript(code, options = {}) {
  return parse(code, {
    loc: true,
    range: true,
    tokens: true,
    comment: true,
    ...options
  });
}

/**
 * Parses TypeScript source code and returns both AST and semantic service mappings.
 *
 * @param {string} code - The TypeScript source code to parse.
 * @param {object} [options={}] - Additional parser and project options.
 * @returns {{ ast: object, services: object }} Object containing AST and services.
 */
function parseWithServices(code, options = {}) {
  return parseAndGenerateServices(code, {
    project: false,
    loc: true,
    range: true,
    ...options
  });
}

/**
 * Clears all internal parser, program, watch, and configuration caches.
 */
function resetParserCaches() {
  clearCaches();
}

/**
 * Traverses an ESTree AST using visitor callbacks.
 *
 * @param {object} ast - The root AST node to traverse.
 * @param {object} visitor - Visitor object with enter/exit callbacks.
 */
function traverseAst(ast, visitor) {
  simpleTraverse(ast, visitor);
}

/**
 * Registers a candidate directory for TSConfig resolution.
 *
 * @param {string} dir - Candidate directory path.
 */
function registerCandidateTSConfigDir(dir) {
  addCandidateTSConfigRootDir(dir);
}

module.exports = {
  estree,
  clearCaches,
  clearProgramCache,
  parse,
  parseAndGenerateServices,
  simpleTraverse,
  addCandidateTSConfigRootDir,
  clearCandidateTSConfigRootDirs,
  AST_NODE_TYPES,
  parseTypeScript,
  parseWithServices,
  resetParserCaches,
  traverseAst,
  registerCandidateTSConfigDir
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  estree,
  clearCaches,
  clearProgramCache,
  parseTypeScript,
  parseWithServices,
  resetParserCaches,
  traverseAst,
  registerCandidateTSConfigDir,
  AST_NODE_TYPES
} = require('../src/index.js');

async function runTests() {
  // 1. clearCaches is exported as a function from @typescript-eslint/typescript-estree
  assert.equal(typeof clearCaches, 'function', 'clearCaches must be a function');
  assert.equal(typeof estree.clearCaches, 'function', 'estree.clearCaches must be a function');
  assert.equal(typeof resetParserCaches, 'function', 'resetParserCaches helper must be a function');
  assert.equal(typeof clearProgramCache, 'function', 'clearProgramCache alias must be a function');

  // 2. clearCaches executes cleanly and resets parser caches without throwing
  assert.doesNotThrow(() => {
    resetParserCaches();
  }, 'resetParserCaches must execute without throwing');

  // 3. parse converts TypeScript source code into an ESTree AST with Program node
  const tsCode = 'const count: number = 100; function getCount(): number { return count; }';
  const ast = parseTypeScript(tsCode);
  assert.ok(ast, 'AST must be non-null');
  assert.equal(ast.type, AST_NODE_TYPES.Program, 'AST type must be Program');
  assert.equal(ast.body.length, 2, 'Program body must contain 2 statements');
  assert.equal(ast.body[0].type, AST_NODE_TYPES.VariableDeclaration, 'First statement is VariableDeclaration');
  assert.equal(ast.body[1].type, AST_NODE_TYPES.FunctionDeclaration, 'Second statement is FunctionDeclaration');

  // 4. clearCaches resets state after parsing multiple TypeScript source snippets
  for (let i = 0; i < 5; i++) {
    const codeSnippet = `const var${i}: number = ${i * 10};`;
    const snippetAst = parseTypeScript(codeSnippet);
    assert.equal(snippetAst.type, AST_NODE_TYPES.Program, 'Snippet AST type must be Program');
    assert.equal(snippetAst.body.length, 1, 'Snippet body must contain 1 statement');
    resetParserCaches();
  }

  // 5. parseAndGenerateServices returns AST and semantic services object
  const interfaceCode = 'interface User { id: string; name: string; } const u: User = { id: "1", name: "Alice" };';
  const result = parseWithServices(interfaceCode);
  assert.ok(result, 'Result must be non-null');
  assert.ok(result.ast, 'Result must contain ast property');
  assert.ok(result.services, 'Result must contain services property');
  assert.equal(result.ast.type, AST_NODE_TYPES.Program, 'Services AST type must be Program');

  // 6. clearCaches resets TSConfig and parser caches after parseAndGenerateServices invocation
  assert.doesNotThrow(() => {
    registerCandidateTSConfigDir('/mock/project/root');
    resetParserCaches();
  }, 'clearCaches must reset candidate TSConfig directories and parser caches cleanly');

  // 7. simpleTraverse visits AST nodes in hierarchical traversal
  const visitedTypes = [];
  traverseAst(ast, {
    enter(node) {
      visitedTypes.push(node.type);
    }
  });
  assert.ok(visitedTypes.length > 0, 'Traversal must visit AST nodes');
  assert.ok(visitedTypes.includes(AST_NODE_TYPES.Program), 'Visited nodes must include Program');
  assert.ok(visitedTypes.includes(AST_NODE_TYPES.Identifier), 'Visited nodes must include Identifier');

  console.log('All contract assertions for @typescript-eslint/typescript-estree.clearCaches passed successfully.');
}

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

オリジンシーダー

匿名