CodeSampleX

Exemple

@typescript-eslint/scope-manager 8.65.0: Variable

Échantillon vérifié pour npm @typescript-eslint/scope-manager 8.65.0: Variable. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:b33e56ff98172d8068b95bc1466f63b574b4ad9cc770a50edd7847940a242cec

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify @typescript-eslint/scope-manager.Variable in pkg:npm/%40typescript-eslint/scope-manager@8.65.0
Paquets
Symboles
  • @typescript-eslint/scope-manager.Variable
Environnement
node 22.23.2
Créé
2026-09-05T19:04:44Z

Contrat

  1. assert Variable distinguishes value variables and type variables with isValueVariable and isTypeVariable
  2. assert Variable tracks definition AST identifiers and definitions array across redeclarations
  3. assert Variable records read and write references in scope with reference direction
  4. assert Variable maintains reference to its enclosing Scope

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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/scope-manager.Variable in pkg:npm/%40typescript-eslint/scope-manager@8.65.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40typescript-eslint/scope-manager@8.65.0
Demonstrate these symbols/APIs:
  - @typescript-eslint/scope-manager.Variable

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:1bd089e36240a800a6661a9873db3238070f0f4897c2445b41c9b1c74a854ad9","constraints":{"executionContext":"node"},"contract":["assert Variable distinguishes value variables and type variables with isValueVariable and isTypeVariable","assert Variable tracks definition AST identifiers and definitions array across redeclarations","assert Variable records read and write references in scope with reference direction","assert Variable maintains reference to its enclosing Scope"],"goal":"verify @typescript-eslint/scope-manager.Variable in pkg:npm/%40typescript-eslint/scope-manager@8.65.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/scope-manager@8.65.0"],"schemaVersion":1,"symbols":["@typescript-eslint/scope-manager.Variable"]},"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.65.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/scope-manager@8.65.0","symbols":["@typescript-eslint/scope-manager.Variable"],"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.65.0"
      }
    },
    "node_modules/@typescript-eslint/scope-manager": {
      "version": "8.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.65.0.tgz",
      "integrity": "sha512-Esbl8OSYiVxBokYgWPf7VVWg/BE798wXhimnn9ML9Pt5qoDf8bfQlgjlKXR/k98+AcNzlLKYrpCcrcuZ9DZLgg==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/types": "8.65.0",
        "@typescript-eslint/visitor-keys": "8.65.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.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.65.0.tgz",
      "integrity": "sha512-JSSwWNy+H0E/01jJEM+hrX6N0OFDzFzeIhHFSAS01tlVaevpG8cFyYRPhS5yjGOvBUx3sqQHVMjCL1CAZZMxBg==",
      "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.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.65.0.tgz",
      "integrity": "sha512-8C71BQkGjiMmXtop7pHVJu1l2NNShFdkCyD6a2ezzs5vU/L3LRtb69EtcteFwz0mYMPzIgOw0n6OV4VBUWZd7A==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/types": "8.65.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.65.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @typescript-eslint/scope-manager.Variable in pkg:npm/%40typescript-eslint/scope-manager@8.65.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40typescript-eslint/scope-manager@8.65.0"
  ],
  "symbols": [
    "@typescript-eslint/scope-manager.Variable"
  ]
}
test/contract.cjs
const assert = require("node:assert");
const {
  analyze,
  Variable
} = require("@typescript-eslint/scope-manager");

// Construct AST covering value declarations, type aliases, classes, redeclarations, and references
const ast = {
  type: "Program",
  body: [
    // const count = 42;
    {
      type: "VariableDeclaration",
      kind: "const",
      declarations: [
        {
          type: "VariableDeclarator",
          id: { type: "Identifier", name: "count", range: [6, 11], decorators: [] },
          init: { type: "Literal", value: 42, raw: "42", range: [14, 16] },
          range: [6, 16]
        }
      ],
      range: [0, 17],
      decorators: []
    },
    // type UserId = string;
    {
      type: "TSTypeAliasDeclaration",
      id: { type: "Identifier", name: "UserId", range: [23, 29], decorators: [] },
      typeAnnotation: { type: "TSStringKeyword", range: [32, 38] },
      range: [18, 39]
    },
    // class Session {}
    {
      type: "ClassDeclaration",
      id: { type: "Identifier", name: "Session", range: [46, 53], decorators: [] },
      superClass: null,
      implements: [],
      body: { type: "ClassBody", body: [], range: [54, 56] },
      range: [40, 56],
      decorators: []
    },
    // var status = "init"; var status = "ready";
    {
      type: "VariableDeclaration",
      kind: "var",
      declarations: [
        {
          type: "VariableDeclarator",
          id: { type: "Identifier", name: "status", range: [61, 67], decorators: [] },
          init: { type: "Literal", value: "init", raw: '"init"', range: [70, 76] },
          range: [61, 76]
        }
      ],
      range: [57, 77],
      decorators: []
    },
    {
      type: "VariableDeclaration",
      kind: "var",
      declarations: [
        {
          type: "VariableDeclarator",
          id: { type: "Identifier", name: "status", range: [82, 88], decorators: [] },
          init: { type: "Literal", value: "ready", raw: '"ready"', range: [91, 98] },
          range: [82, 98]
        }
      ],
      range: [78, 99],
      decorators: []
    },
    // count;
    {
      type: "ExpressionStatement",
      expression: { type: "Identifier", name: "count", range: [100, 105] },
      range: [100, 106]
    }
  ],
  sourceType: "module",
  range: [0, 110],
  comments: [],
  tokens: []
};

const scopeManager = analyze(ast, { sourceType: "module" });
const moduleScope = scopeManager.scopes.find(s => s.type === "module");
assert(moduleScope, "module scope must exist");

// 1. Assert Variable distinguishes value variables and type variables with isValueVariable and isTypeVariable
const countVar = moduleScope.set.get("count");
assert(countVar instanceof Variable, "count is an instance of Variable");
assert.strictEqual(countVar.name, "count", "count variable has name count");
assert.strictEqual(countVar.isValueVariable, true, "count is a value variable");
assert.strictEqual(countVar.isTypeVariable, false, "count is not a type variable");

const typeVar = moduleScope.set.get("UserId");
assert(typeVar instanceof Variable, "UserId is an instance of Variable");
assert.strictEqual(typeVar.name, "UserId", "UserId variable has name UserId");
assert.strictEqual(typeVar.isValueVariable, false, "UserId is not a value variable");
assert.strictEqual(typeVar.isTypeVariable, true, "UserId is a type variable");

const classVar = moduleScope.set.get("Session");
assert(classVar instanceof Variable, "Session is an instance of Variable");
assert.strictEqual(classVar.name, "Session", "Session variable has name Session");
assert.strictEqual(classVar.isValueVariable, true, "Session class is a value variable");
assert.strictEqual(classVar.isTypeVariable, true, "Session class is a type variable");

// 2. Assert Variable tracks definition AST identifiers and definitions array across redeclarations
const statusVar = moduleScope.set.get("status");
assert(statusVar instanceof Variable, "status is an instance of Variable");
assert.strictEqual(statusVar.name, "status", "status variable has name status");
assert.strictEqual(statusVar.identifiers.length, 2, "redeclared variable has 2 identifier AST nodes");
assert.strictEqual(statusVar.identifiers[0].name, "status", "first identifier matches name");
assert.strictEqual(statusVar.identifiers[1].name, "status", "second identifier matches name");
assert.strictEqual(statusVar.defs.length, 2, "redeclared variable has 2 definitions");
assert.strictEqual(statusVar.defs[0].name.name, "status", "first def name matches");
assert.strictEqual(statusVar.defs[1].name.name, "status", "second def name matches");

// 3. Assert Variable records read and write references in scope with reference direction
assert(countVar.references.length >= 2, "count variable records write and read references");
const writeRef = countVar.references.find(ref => ref.isWrite());
const readRef = countVar.references.find(ref => ref.isRead());
assert(writeRef, "count has a write reference from initialization");
assert.strictEqual(writeRef.identifier.name, "count", "write reference identifier is count");
assert(readRef, "count has a read reference from expression statement");
assert.strictEqual(readRef.identifier.name, "count", "read reference identifier is count");

// 4. Assert Variable maintains reference to its enclosing Scope
assert.strictEqual(countVar.scope, moduleScope, "count references its enclosing module scope");
assert.strictEqual(typeVar.scope, moduleScope, "UserId references its enclosing module scope");
assert.strictEqual(statusVar.scope, moduleScope, "status references its enclosing module scope");

Seeder d'origine

anonyme