CodeSampleX

샘플

@typescript-eslint/scope-manager 8.69.0: TSModuleScope

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

sha256:749ccd748b1730775a29c1545d81414ed4670c3d0566a7dc18afda80334beea5

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

케이스

HOW
목표
verify @typescript-eslint/scope-manager.TSModuleScope in pkg:npm/%40typescript-eslint/scope-manager@8.69.0
패키지
심벌
  • @typescript-eslint/scope-manager.TSModuleScope
환경
node 22.23.2
생성일
2026-10-12T05:16:03Z

컨트랙트

  1. TSModuleScope is exported and identifies scopes with ScopeType.tsModule
  2. TSModuleScope constructor establishes upper scope linkage, AST block node, and strict mode semantics
  3. ScopeManager.nestTSModuleScope creates and tracks a TSModuleScope instance in the scope hierarchy
  4. analyze produces TSModuleScope for TypeScript namespace and module declarations
  5. TSModuleScope captures and isolates inner variable declarations while defining module identifier in the enclosing scope

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • 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/scope-manager.TSModuleScope in pkg:npm/%40typescript-eslint/scope-manager@8.69.0
Kind: HOW

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

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:c0d24cd041d7bf9ce9cbb390250227a17b5abc6305826e3d9ad40a20264cc50b","contract":["TSModuleScope is exported and identifies scopes with ScopeType.tsModule","TSModuleScope constructor establishes upper scope linkage, AST block node, and strict mode semantics","ScopeManager.nestTSModuleScope creates and tracks a TSModuleScope instance in the scope hierarchy","analyze produces TSModuleScope for TypeScript namespace and module declarations","TSModuleScope captures and isolates inner variable declarations while defining module identifier in the enclosing scope"],"goal":"verify @typescript-eslint/scope-manager.TSModuleScope in pkg:npm/%40typescript-eslint/scope-manager@8.69.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/scope-manager@8.69.0"],"schemaVersion":1,"symbols":["@typescript-eslint/scope-manager.TSModuleScope"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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.69.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/scope-manager@8.69.0","symbols":["@typescript-eslint/scope-manager.TSModuleScope"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-scope-manager-ts-module-scope",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-scope-manager-ts-module-scope",
      "version": "1.0.0",
      "dependencies": {
        "@typescript-eslint/scope-manager": "8.69.0"
      }
    },
    "node_modules/@typescript-eslint/scope-manager": {
      "version": "8.69.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.69.0.tgz",
      "integrity": "sha512-ewfspqWvSxKSOaplqAUNbaSFO0eB6w1EtQ+esfYFRm3614Ty4uNtExkcbgd6nWsXphbqKyf9ZYdbZdv2xEoWEQ==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/types": "8.69.0",
        "@typescript-eslint/visitor-keys": "8.69.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.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"
      }
    },
    "node_modules/@typescript-eslint/visitor-keys": {
      "version": "8.69.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.69.0.tgz",
      "integrity": "sha512-+rmdgPA+EXkNgKYvHvFfhrs35utXbwaC5PGpDquSXcoXQDKUA5UjV0LmTucG/4JXkM31BTu4TilHtrN8IVBe8w==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/types": "8.69.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-scope-manager-ts-module-scope",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "@typescript-eslint/scope-manager": "8.69.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @typescript-eslint/scope-manager.TSModuleScope in pkg:npm/%40typescript-eslint/scope-manager@8.69.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40typescript-eslint/scope-manager@8.69.0"
  ],
  "symbols": [
    "@typescript-eslint/scope-manager.TSModuleScope"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  TSModuleScope,
  ScopeManager,
  ScopeType,
  GlobalScope,
  analyze,
} from '@typescript-eslint/scope-manager';

// 1. TSModuleScope is exported and identifies scopes with ScopeType.tsModule
assert.equal(typeof TSModuleScope, 'function');
assert.equal(ScopeType.tsModule, 'tsModule');

// 2. TSModuleScope constructor establishes upper scope linkage, AST block node, and strict mode semantics
{
  const manager = new ScopeManager({});
  const mockProgram = { type: 'Program', body: [] };
  const globalScope = new GlobalScope(manager, mockProgram);
  manager.scopes.push(globalScope);

  const mockModule = {
    type: 'TSModuleDeclaration',
    id: { type: 'Identifier', name: 'SampleModule' },
    kind: 'module',
    body: { type: 'TSModuleBlock', body: [] },
  };

  const tsModuleScope = new TSModuleScope(manager, globalScope, mockModule);
  assert.ok(tsModuleScope instanceof TSModuleScope);
  assert.equal(tsModuleScope.type, 'tsModule');
  assert.equal(tsModuleScope.type, ScopeType.tsModule);
  assert.equal(tsModuleScope.upper, globalScope);
  assert.equal(tsModuleScope.block, mockModule);
  assert.equal(tsModuleScope.isStrict, true);
  assert.deepEqual(tsModuleScope.variables, []);
  assert.deepEqual(tsModuleScope.childScopes, []);
}

// 3. ScopeManager.nestTSModuleScope creates and tracks a TSModuleScope instance in the scope hierarchy
{
  const manager = new ScopeManager({});
  const mockProgram = { type: 'Program', body: [] };
  const globalScope = new GlobalScope(manager, mockProgram);
  manager.scopes.push(globalScope);
  manager.currentScope = globalScope;

  const mockNamespace = {
    type: 'TSModuleDeclaration',
    id: { type: 'Identifier', name: 'NestedNamespace' },
    kind: 'namespace',
    body: { type: 'TSModuleBlock', body: [] },
  };

  const createdScope = manager.nestTSModuleScope(mockNamespace);
  assert.ok(createdScope instanceof TSModuleScope);
  assert.equal(createdScope.type, ScopeType.tsModule);
  assert.equal(createdScope.upper, globalScope);
  assert.equal(createdScope.block, mockNamespace);
  assert.ok(manager.scopes.includes(createdScope));
  assert.ok(globalScope.childScopes.includes(createdScope));
  assert.equal(manager.currentScope, createdScope);
}

// 4. analyze produces TSModuleScope for TypeScript namespace and module declarations
{
  const ast = {
    type: 'Program',
    sourceType: 'module',
    body: [
      {
        type: 'TSModuleDeclaration',
        id: {
          type: 'Identifier',
          name: 'Geometry',
          range: [10, 18],
          loc: { start: { line: 1, column: 10 }, end: { line: 1, column: 18 } },
        },
        kind: 'namespace',
        body: {
          type: 'TSModuleBlock',
          body: [
            {
              type: 'VariableDeclaration',
              kind: 'const',
              declarations: [
                {
                  type: 'VariableDeclarator',
                  id: {
                    type: 'Identifier',
                    name: 'PI',
                    range: [29, 31],
                    loc: { start: { line: 2, column: 8 }, end: { line: 2, column: 10 } },
                  },
                  init: {
                    type: 'Literal',
                    value: 3.14,
                    raw: '3.14',
                    range: [34, 38],
                    loc: { start: { line: 2, column: 13 }, end: { line: 2, column: 17 } },
                  },
                  range: [29, 38],
                  loc: { start: { line: 2, column: 8 }, end: { line: 2, column: 17 } },
                },
              ],
              range: [23, 39],
              loc: { start: { line: 2, column: 2 }, end: { line: 2, column: 18 } },
            },
          ],
          range: [19, 41],
          loc: { start: { line: 1, column: 19 }, end: { line: 3, column: 1 } },
        },
        range: [0, 41],
        loc: { start: { line: 1, column: 0 }, end: { line: 3, column: 1 } },
      },
    ],
    range: [0, 41],
    loc: { start: { line: 1, column: 0 }, end: { line: 3, column: 1 } },
    tokens: [],
    comments: [],
  };

  const scopeManager = analyze(ast);
  const moduleScopes = scopeManager.scopes.filter((s) => s instanceof TSModuleScope);
  assert.equal(moduleScopes.length, 1);

  const [geoScope] = moduleScopes;
  assert.equal(geoScope.type, ScopeType.tsModule);
  assert.equal(geoScope.block.type, 'TSModuleDeclaration');
  assert.equal(geoScope.block.id.name, 'Geometry');
  assert.equal(geoScope.upper.type, 'global');
}

// 5. TSModuleScope captures and isolates inner variable declarations while defining module identifier in the enclosing scope
{
  const ast = {
    type: 'Program',
    sourceType: 'module',
    body: [
      {
        type: 'TSModuleDeclaration',
        id: {
          type: 'Identifier',
          name: 'Utilities',
          range: [10, 19],
          loc: { start: { line: 1, column: 10 }, end: { line: 1, column: 19 } },
        },
        kind: 'module',
        body: {
          type: 'TSModuleBlock',
          body: [
            {
              type: 'VariableDeclaration',
              kind: 'let',
              declarations: [
                {
                  type: 'VariableDeclarator',
                  id: {
                    type: 'Identifier',
                    name: 'count',
                    range: [27, 32],
                    loc: { start: { line: 2, column: 6 }, end: { line: 2, column: 11 } },
                  },
                  init: {
                    type: 'Literal',
                    value: 0,
                    raw: '0',
                    range: [35, 36],
                    loc: { start: { line: 2, column: 14 }, end: { line: 2, column: 15 } },
                  },
                  range: [27, 36],
                  loc: { start: { line: 2, column: 6 }, end: { line: 2, column: 15 } },
                },
              ],
              range: [23, 37],
              loc: { start: { line: 2, column: 2 }, end: { line: 2, column: 16 } },
            },
          ],
          range: [20, 39],
          loc: { start: { line: 1, column: 20 }, end: { line: 3, column: 1 } },
        },
        range: [0, 39],
        loc: { start: { line: 1, column: 0 }, end: { line: 3, column: 1 } },
      },
    ],
    range: [0, 39],
    loc: { start: { line: 1, column: 0 }, end: { line: 3, column: 1 } },
    tokens: [],
    comments: [],
  };

  const scopeManager = analyze(ast);
  const globalScope = scopeManager.scopes.find((s) => s.type === 'global');
  const moduleScope = scopeManager.scopes.find((s) => s instanceof TSModuleScope);

  assert.ok(globalScope);
  assert.ok(moduleScope);

  // Module identifier is defined in the outer scope
  const moduleVar = globalScope.set.get('Utilities');
  assert.ok(moduleVar, 'Module identifier should be defined in enclosing scope');
  assert.equal(moduleVar.name, 'Utilities');

  // Inner variable is contained in TSModuleScope
  const countVar = moduleScope.set.get('count');
  assert.ok(countVar, 'Inner variable must be registered in TSModuleScope');
  assert.equal(countVar.name, 'count');
  assert.equal(globalScope.set.has('count'), false);
}

오리진 시더

익명