CodeSampleX

Exemple

@typescript-eslint/scope-manager 8.65.0: ScopeType

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

sha256:740b99404cc5f8f9582f65f1dba1033590962e43c205ed7b8f08b45c17cce355

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é linux 24 · ubuntu · glibc 2.39 x64 npm

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.ScopeType in pkg:npm/%40typescript-eslint/scope-manager@8.65.0
Paquets
Symboles
  • @typescript-eslint/scope-manager.ScopeType
Créé
2026-09-05T18:00:48Z

Contrat

  1. assert ScopeType exports canonical string discriminators for lexical and TypeScript scopes
  2. assert analyze creates root global scope and nests module ScopeType when sourceType is module
  3. assert analyze identifies function and block ScopeType in function declarations with block bodies
  4. assert analyze assigns for, catch, and switch ScopeType to control flow and exception scopes
  5. assert analyze assigns class ScopeType and registers class member definitions

Fichiers

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

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.ScopeType 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.ScopeType

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:0fe83dd2c86e4e6e8fc7c414205e483b7f68c5cd8231e507ad67f4b1340aa021","contract":["assert ScopeType exports canonical string discriminators for lexical and TypeScript scopes","assert analyze creates root global scope and nests module ScopeType when sourceType is module","assert analyze identifies function and block ScopeType in function declarations with block bodies","assert analyze assigns for, catch, and switch ScopeType to control flow and exception scopes","assert analyze assigns class ScopeType and registers class member definitions"],"goal":"verify @typescript-eslint/scope-manager.ScopeType 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.ScopeType"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","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.ScopeType"],"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.ScopeType 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.ScopeType"
  ]
}
test/contract.mjs
import assert from "node:assert/strict";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const { ScopeType, analyze } = require("@typescript-eslint/scope-manager");

// 1. assert ScopeType exports canonical string discriminators for lexical and TypeScript scopes
assert.strictEqual(ScopeType.block, "block");
assert.strictEqual(ScopeType.catch, "catch");
assert.strictEqual(ScopeType.class, "class");
assert.strictEqual(ScopeType.classFieldInitializer, "class-field-initializer");
assert.strictEqual(ScopeType.classStaticBlock, "class-static-block");
assert.strictEqual(ScopeType.conditionalType, "conditionalType");
assert.strictEqual(ScopeType.for, "for");
assert.strictEqual(ScopeType.function, "function");
assert.strictEqual(ScopeType.functionExpressionName, "function-expression-name");
assert.strictEqual(ScopeType.functionType, "functionType");
assert.strictEqual(ScopeType.global, "global");
assert.strictEqual(ScopeType.mappedType, "mappedType");
assert.strictEqual(ScopeType.module, "module");
assert.strictEqual(ScopeType.switch, "switch");
assert.strictEqual(ScopeType.tsEnum, "tsEnum");
assert.strictEqual(ScopeType.tsModule, "tsModule");
assert.strictEqual(ScopeType.type, "type");
assert.strictEqual(ScopeType.with, "with");

// 2. assert analyze creates root global scope and nests module ScopeType when sourceType is module
const moduleAst = {
  type: "Program",
  sourceType: "module",
  body: [],
  range: [0, 0]
};
const moduleManager = analyze(moduleAst, { sourceType: "module" });
assert.strictEqual(moduleManager.scopes.length, 2);
assert.strictEqual(moduleManager.scopes[0].type, ScopeType.global);
assert.strictEqual(moduleManager.scopes[1].type, ScopeType.module);

const scriptAst = {
  type: "Program",
  sourceType: "script",
  body: [],
  range: [0, 0]
};
const scriptManager = analyze(scriptAst, { sourceType: "script" });
assert.strictEqual(scriptManager.scopes.length, 1);
assert.strictEqual(scriptManager.scopes[0].type, ScopeType.global);

// 3. assert analyze identifies function and block ScopeType in function declarations with block bodies
const fnAst = {
  type: "Program",
  sourceType: "module",
  body: [
    {
      type: "FunctionDeclaration",
      id: { type: "Identifier", name: "compute", range: [9, 16], decorators: [] },
      params: [{ type: "Identifier", name: "x", range: [17, 18], decorators: [] }],
      generator: false,
      async: false,
      decorators: [],
      body: {
        type: "BlockStatement",
        body: [
          {
            type: "BlockStatement",
            body: [
              {
                type: "VariableDeclaration",
                kind: "let",
                declarations: [
                  {
                    type: "VariableDeclarator",
                    id: { type: "Identifier", name: "y", range: [35, 36], decorators: [] },
                    init: { type: "Identifier", name: "x", range: [39, 40], decorators: [] }
                  }
                ]
              }
            ],
            range: [25, 45]
          }
        ],
        range: [20, 48]
      },
      range: [0, 48]
    }
  ],
  range: [0, 48]
};
const fnManager = analyze(fnAst, { sourceType: "module" });
const fnScope = fnManager.scopes.find(s => s.type === ScopeType.function);
assert.ok(fnScope, "function scope should be created with ScopeType.function");
assert.strictEqual(fnScope.block.type, "FunctionDeclaration");

const blockScope = fnManager.scopes.find(s => s.type === ScopeType.block);
assert.ok(blockScope, "block scope should be created with ScopeType.block");
assert.strictEqual(blockScope.upper, fnScope);

// 4. assert analyze assigns for, catch, and switch ScopeType to control flow and exception scopes
const controlAst = {
  type: "Program",
  sourceType: "module",
  body: [
    {
      type: "ForStatement",
      init: {
        type: "VariableDeclaration",
        kind: "let",
        declarations: [
          {
            type: "VariableDeclarator",
            id: { type: "Identifier", name: "i", range: [9, 10], decorators: [] },
            init: { type: "Literal", value: 0, range: [13, 14] }
          }
        ]
      },
      test: null,
      update: null,
      body: { type: "BlockStatement", body: [], range: [18, 20] },
      range: [0, 20]
    },
    {
      type: "TryStatement",
      block: { type: "BlockStatement", body: [], range: [25, 27] },
      handler: {
        type: "CatchClause",
        param: { type: "Identifier", name: "err", range: [35, 38], decorators: [] },
        body: { type: "BlockStatement", body: [], range: [40, 42] },
        range: [28, 42]
      },
      finalizer: null,
      range: [21, 42]
    },
    {
      type: "SwitchStatement",
      discriminant: { type: "Identifier", name: "i", range: [51, 52], decorators: [] },
      cases: [],
      range: [44, 56]
    }
  ],
  range: [0, 56]
};
const controlManager = analyze(controlAst, { sourceType: "module" });
const forScope = controlManager.scopes.find(s => s.type === ScopeType.for);
assert.ok(forScope, "for scope created with ScopeType.for");

const catchScope = controlManager.scopes.find(s => s.type === ScopeType.catch);
assert.ok(catchScope, "catch scope created with ScopeType.catch");

const switchScope = controlManager.scopes.find(s => s.type === ScopeType.switch);
assert.ok(switchScope, "switch scope created with ScopeType.switch");

// 5. assert analyze assigns class ScopeType and registers class member definitions
const classAst = {
  type: "Program",
  sourceType: "module",
  body: [
    {
      type: "ClassDeclaration",
      id: { type: "Identifier", name: "Container", range: [6, 15], decorators: [] },
      superClass: null,
      implements: [],
      decorators: [],
      body: {
        type: "ClassBody",
        body: [],
        range: [16, 18]
      },
      range: [0, 18]
    }
  ],
  range: [0, 18]
};
const classManager = analyze(classAst, { sourceType: "module" });
const classScope = classManager.scopes.find(s => s.type === ScopeType.class);
assert.ok(classScope, "class scope created with ScopeType.class");
assert.strictEqual(classScope.block.type, "ClassDeclaration");

Seeder d'origine

anonyme