Exemplo
eslint-scope 5.1.1: verify ScopeManager and analyze in eslint-scope
Amostra verificada para npm eslint-scope 5.1.1: verify ScopeManager and analyze in eslint-scope. O contrato rodou em node 22 · linux alpine/x64 · docker e…
sha256:df1e530fb8fe83a1ab67d39dfcdf32c40f235d338dd110d638af56383753f7ab
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-27 |
Caso
HOW- Objetivo
- verify ScopeManager and analyze in eslint-scope
- Pacotes
- Símbolos
-
- ScopeManager
- analyze
- Criado
- 2026-08-27T23:11:11Z
Contrato
- analyze generates a ScopeManager with global and module scopes from ESTree AST
- ScopeManager.acquire retrieves the Scope associated with an AST node
- ScopeManager.getDeclaredVariables returns variables declared by an AST node
- Scope tracks variable references and distinguishes read and write operations
- GlobalScope.through records unresolved references to undeclared variables across nested scopes
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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 ScopeManager and analyze in eslint-scope
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/eslint-scope@5.1.1
Demonstrate these symbols/APIs:
- ScopeManager
- analyze
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.
{"case":{"caseId":"case:sha256:29d527635e59000acae398eb2a015c71938c12c420677a8e46c9b495d41283d9","contract":["analyze generates a ScopeManager with global and module scopes from ESTree AST","ScopeManager.acquire retrieves the Scope associated with an AST node","ScopeManager.getDeclaredVariables returns variables declared by an AST node","Scope tracks variable references and distinguishes read and write operations","GlobalScope.through records unresolved references to undeclared variables across nested scopes"],"goal":"verify ScopeManager and analyze in eslint-scope","kind":"HOW","packages":["pkg:npm/eslint-scope@5.1.1"],"schemaVersion":1,"symbols":["ScopeManager","analyze"]},"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/eslint-scope@5.1.1"],"schemaVersion":1,"subject":"pkg:npm/eslint-scope@5.1.1","symbols":["ScopeManager","analyze"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-eslint-scope",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-eslint-scope",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"eslint-scope": "5.1.1"
}
},
"node_modules/eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
"integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
"license": "BSD-2-Clause",
"dependencies": {
"esrecurse": "^4.3.0",
"estraverse": "^4.1.1"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/esrecurse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
"integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
"license": "BSD-2-Clause",
"dependencies": {
"estraverse": "^5.2.0"
},
"engines": {
"node": ">=4.0"
}
},
"node_modules/esrecurse/node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=4.0"
}
},
"node_modules/estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=4.0"
}
}
}
}
{
"name": "sample-eslint-scope",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"dependencies": {
"eslint-scope": "5.1.1"
}
}
{
"schemaVersion": 1,
"goal": "verify ScopeManager and analyze in eslint-scope",
"kind": "HOW",
"packages": [
"pkg:npm/eslint-scope@5.1.1"
],
"symbols": [
"ScopeManager",
"analyze"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { analyze, ScopeManager } = require('eslint-scope');
// Build an ESTree AST representing module declarations, functions, and cross-scope references
const varDeclNode = {
type: 'VariableDeclaration',
kind: 'const',
range: [0, 25],
declarations: [
{
type: 'VariableDeclarator',
range: [6, 25],
id: { type: 'Identifier', name: 'baseValue', range: [6, 15] },
init: { type: 'Literal', value: 42, range: [18, 20] }
}
]
};
const funcNode = {
type: 'FunctionDeclaration',
range: [27, 130],
id: { type: 'Identifier', name: 'compute', range: [36, 43] },
params: [
{ type: 'Identifier', name: 'factor', range: [44, 50] }
],
body: {
type: 'BlockStatement',
range: [52, 130],
body: [
{
type: 'VariableDeclaration',
kind: 'let',
range: [58, 80],
declarations: [
{
type: 'VariableDeclarator',
range: [62, 80],
id: { type: 'Identifier', name: 'total', range: [62, 67] },
init: {
type: 'BinaryExpression',
operator: '*',
range: [70, 79],
left: { type: 'Identifier', name: 'baseValue', range: [70, 79] },
right: { type: 'Identifier', name: 'factor', range: [80, 86] }
}
}
]
},
{
type: 'ExpressionStatement',
range: [86, 110],
expression: {
type: 'AssignmentExpression',
operator: '=',
range: [86, 110],
left: { type: 'Identifier', name: 'factor', range: [86, 92] },
right: { type: 'Identifier', name: 'externalGlobal', range: [95, 109] }
}
},
{
type: 'ReturnStatement',
range: [114, 128],
argument: { type: 'Identifier', name: 'total', range: [121, 126] }
}
]
}
};
const ast = {
type: 'Program',
range: [0, 130],
sourceType: 'module',
body: [varDeclNode, funcNode]
};
const scopeManager = analyze(ast, { ecmaVersion: 2020, sourceType: 'module' });
// 1. analyze generates a ScopeManager with global and module scopes from ESTree AST
assert.ok(scopeManager instanceof ScopeManager, 'ScopeManager should be created');
assert.equal(scopeManager.scopes.length, 3);
assert.equal(scopeManager.scopes[0].type, 'global');
assert.equal(scopeManager.scopes[1].type, 'module');
assert.equal(scopeManager.scopes[2].type, 'function');
// 2. ScopeManager.acquire retrieves the Scope associated with an AST node
const moduleScope = scopeManager.scopes[1];
const functionScope = scopeManager.acquire(funcNode);
assert.ok(functionScope, 'FunctionScope should be acquired');
assert.equal(functionScope.type, 'function');
assert.equal(functionScope.block, funcNode);
assert.equal(functionScope.upper, moduleScope);
// 3. ScopeManager.getDeclaredVariables returns variables declared by an AST node
const moduleVars = scopeManager.getDeclaredVariables(varDeclNode);
assert.equal(moduleVars.length, 1);
assert.equal(moduleVars[0].name, 'baseValue');
const funcDeclaredVars = scopeManager.getDeclaredVariables(funcNode);
assert.deepEqual(funcDeclaredVars.map(v => v.name), ['compute', 'factor']);
// 4. Scope tracks variable references and distinguishes read and write operations
const baseVar = moduleScope.set.get('baseValue');
assert.ok(baseVar, 'baseValue variable should exist in module scope');
assert.equal(baseVar.references.length, 2);
const baseWrite = baseVar.references.find(r => r.isWrite());
const baseRead = baseVar.references.find(r => r.isRead());
assert.ok(baseWrite.isWriteOnly(), 'Definition reference should be write-only');
assert.ok(baseRead.isReadOnly(), 'Usage reference should be read-only');
assert.equal(baseRead.resolved, baseVar);
assert.equal(baseRead.from, functionScope);
const factorVar = functionScope.set.get('factor');
assert.ok(factorVar, 'factor variable should exist in function scope');
const factorWrite = factorVar.references.find(r => r.isWrite());
assert.ok(factorWrite, 'Assignment expression should create a write reference');
assert.equal(factorWrite.from, functionScope);
// 5. GlobalScope.through records unresolved references to undeclared variables across nested scopes
const globalScope = scopeManager.scopes[0];
assert.equal(globalScope.through.length, 1);
assert.equal(globalScope.through[0].identifier.name, 'externalGlobal');
assert.equal(globalScope.through[0].resolved, null);
assert.equal(globalScope.through[0].from, functionScope);
Seeder de origem
anônimo