CodeSampleX

サンプル

@typescript-eslint/scope-manager 8.66.0

検証済みサンプル — npm @typescript-eslint/scope-manager 8.66.0. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: assert analyze parses AST and creates…

sha256:8892e7609cd5a8531b661fcd4a24f6eb26d6b034dad44e344e0ff3cd28c838a9

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。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@1
2026-08-21

ケース

HOW
ゴール
verify pkg:npm/%40typescript-eslint/scope-manager@8.66.0
パッケージ
環境
node 22.23.2
作成日
2026-08-21T09:35:45Z

コントラクト

  1. assert analyze parses AST and creates ScopeManager with global and module scopes
  2. assert analyze resolves TypeScript type declarations and variables into scope definitions
  3. assert acquire returns the function scope associated with a FunctionDeclaration AST node
  4. assert references differentiate between variable write definitions and variable read references

ファイル

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

ソースアーティファクトをダウンロード (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 pkg:npm/%40typescript-eslint/scope-manager@8.66.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40typescript-eslint/scope-manager@8.66.0
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:dbe00e5d883d5f02f6ae7049e9a8782ee3ec18ce2da209071a6747129ce5d941","constraints":{"executionContext":"node"},"contract":["assert analyze parses AST and creates ScopeManager with global and module scopes","assert analyze resolves TypeScript type declarations and variables into scope definitions","assert acquire returns the function scope associated with a FunctionDeclaration AST node","assert references differentiate between variable write definitions and variable read references"],"goal":"verify pkg:npm/%40typescript-eslint/scope-manager@8.66.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/scope-manager@8.66.0"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/scope-manager@8.66.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/scope-manager@8.66.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-typescript-eslint-scope-manager",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-typescript-eslint-scope-manager",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@typescript-eslint/scope-manager": "8.66.0"
      }
    },
    "node_modules/@typescript-eslint/scope-manager": {
      "version": "8.66.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.66.0.tgz",
      "integrity": "sha512-8TGcH25j9zqJ/IULB/ppyhRvxA8QYfFEZ7nfbg6/BN9spDgb8fPWQXlE5l8TWBL50EtUx007uZ1o9VOwrq2/9g==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/types": "8.66.0",
        "@typescript-eslint/visitor-keys": "8.66.0"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      }
    },
    "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/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/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"
      }
    }
  }
}
package.json
{
  "name": "sample-typescript-eslint-scope-manager",
  "version": "1.0.0",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "@typescript-eslint/scope-manager": "8.66.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40typescript-eslint/scope-manager@8.66.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40typescript-eslint/scope-manager@8.66.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
const assert = require("node:assert");
const {
  analyze,
  ScopeManager,
  ScopeType,
  DefinitionType,
  Reference,
  Variable
} = require("@typescript-eslint/scope-manager");

// 1. Assert analyze parses AST and creates ScopeManager with global and module scopes
const ast = {
  type: "Program",
  body: [
    // type Status = string;
    {
      type: "TSTypeAliasDeclaration",
      id: { type: "Identifier", name: "Status", range: [5, 11], decorators: [] },
      typeAnnotation: { type: "TSStringKeyword", range: [14, 20] },
      range: [0, 20],
      decorators: []
    },
    // let currentStatus: Status = "idle";
    {
      type: "VariableDeclaration",
      kind: "let",
      declarations: [
        {
          type: "VariableDeclarator",
          id: {
            type: "Identifier",
            name: "currentStatus",
            typeAnnotation: {
              type: "TSTypeAnnotation",
              typeAnnotation: {
                type: "TSTypeReference",
                typeName: { type: "Identifier", name: "Status", range: [19, 25], decorators: [] },
                range: [19, 25]
              },
              range: [17, 25]
            },
            range: [4, 25],
            decorators: []
          },
          init: {
            type: "Literal",
            value: "idle",
            raw: "\"idle\"",
            range: [28, 34]
          },
          range: [4, 34]
        }
      ],
      range: [0, 35],
      decorators: []
    },
    // function updateStatus(nextStatus: Status) { currentStatus = nextStatus; return currentStatus; }
    {
      type: "FunctionDeclaration",
      id: { type: "Identifier", name: "updateStatus", range: [45, 57], decorators: [] },
      params: [
        {
          type: "Identifier",
          name: "nextStatus",
          typeAnnotation: {
            type: "TSTypeAnnotation",
            typeAnnotation: {
              type: "TSTypeReference",
              typeName: { type: "Identifier", name: "Status", range: [69, 75], decorators: [] },
              range: [69, 75]
            },
            range: [67, 75]
          },
          range: [58, 75],
          decorators: []
        }
      ],
      body: {
        type: "BlockStatement",
        body: [
          {
            type: "ExpressionStatement",
            expression: {
              type: "AssignmentExpression",
              operator: "=",
              left: { type: "Identifier", name: "currentStatus", range: [79, 92], decorators: [] },
              right: { type: "Identifier", name: "nextStatus", range: [95, 105], decorators: [] },
              range: [79, 105]
            },
            range: [79, 106]
          },
          {
            type: "ReturnStatement",
            argument: { type: "Identifier", name: "currentStatus", range: [114, 127], decorators: [] },
            range: [107, 128]
          }
        ],
        range: [77, 130]
      },
      range: [36, 130],
      decorators: []
    }
  ],
  sourceType: "module",
  range: [0, 130],
  comments: [],
  tokens: []
};

const scopeManager = analyze(ast, { sourceType: "module" });

// 1. Assert analyze parses AST and creates ScopeManager with global and module scopes
assert(scopeManager instanceof ScopeManager, "analyze returns a ScopeManager instance");
assert.strictEqual(scopeManager.globalScope.type, ScopeType.global, "root scope is global");
const moduleScope = scopeManager.scopes.find((s) => s.type === ScopeType.module);
assert(moduleScope, "module scope exists");

// 2. Assert analyze resolves TypeScript type declarations and variables into scope definitions
const statusVar = moduleScope.set.get("Status");
assert(statusVar instanceof Variable, "Status is tracked as a Variable");
assert.strictEqual(statusVar.defs[0].type, DefinitionType.Type, "Status definition is Type");
assert.strictEqual(statusVar.isTypeVariable, true, "Status is marked as type variable");

const currentStatusVar = moduleScope.set.get("currentStatus");
assert(currentStatusVar instanceof Variable, "currentStatus is tracked as a Variable");
assert.strictEqual(currentStatusVar.defs[0].type, DefinitionType.Variable, "currentStatus definition is Variable");
assert.strictEqual(currentStatusVar.isValueVariable, true, "currentStatus is marked as value variable");

// 3. Assert acquire returns the function scope associated with a FunctionDeclaration AST node
const fnNode = ast.body[2];
const fnScope = scopeManager.acquire(fnNode);
assert(fnScope, "scopeManager.acquire returns function scope");
assert.strictEqual(fnScope.type, ScopeType.function, "acquired scope type is function");
assert.strictEqual(fnScope.block, fnNode, "function scope block matches function AST node");
assert(fnScope.set.has("nextStatus"), "parameter nextStatus exists in function scope");
assert.strictEqual(fnScope.set.get("nextStatus").defs[0].type, DefinitionType.Parameter, "nextStatus def is Parameter");

// 4. Assert references differentiate between variable write definitions and variable read references
assert.strictEqual(currentStatusVar.references.length, 3, "currentStatus has 3 references across module and function");

const writeRefs = currentStatusVar.references.filter((r) => r.isWrite());
const readRefs = currentStatusVar.references.filter((r) => r.isRead());

assert.strictEqual(writeRefs.length, 2, "2 write references (init declarator and assignment expression)");
assert.strictEqual(readRefs.length, 1, "1 read reference (return statement)");

assert.strictEqual(writeRefs[0].isWriteOnly(), true, "init declarator is write-only");
assert.strictEqual(writeRefs[1].isWriteOnly(), true, "assignment expression is write-only");
assert.strictEqual(readRefs[0].isReadOnly(), true, "return statement is read-only");

オリジンシーダー

匿名