示例
@typescript-eslint/tsconfig-utils 8.67.0
已验证示例 — npm @typescript-eslint/tsconfig-utils 8.67.0. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: CORE_COMPILER_OPTIONS defines required compiler…
sha256:d31229b23523c4d9b1ca02678aa8826a1c03568a294d81585f6bf694de245585
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
案例
HOW- 目标
- verify pkg:npm/%40typescript-eslint/tsconfig-utils@8.67.0
- 环境
- node 22.23.2
- 创建时间
- 2026-08-27T12:25:32Z
契约
- CORE_COMPILER_OPTIONS defines required compiler options including noEmit noUnusedLocals and noUnusedParameters
- getParsedConfigFile parses tsconfig.json and enforces CORE_COMPILER_OPTIONS in parsed compiler options
- getParsedConfigFile resolves source file paths according to tsconfig files and include configurations
- getParsedConfigFile throws diagnostic error when tsconfig file contains invalid syntax or cannot be read
- getParsedConfigFile throws error when invoked in a non-Node environment without tsserver sys
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
源代码
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/tsconfig-utils@8.67.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40typescript-eslint/tsconfig-utils@8.67.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.
{"case":{"caseId":"case:sha256:b278051380f57900ac3f4e9d81f7e2702790f2fa7db83074496f3e5a6d763e06","constraints":{"executionContext":"node"},"contract":["CORE_COMPILER_OPTIONS defines required compiler options including noEmit noUnusedLocals and noUnusedParameters","getParsedConfigFile parses tsconfig.json and enforces CORE_COMPILER_OPTIONS in parsed compiler options","getParsedConfigFile resolves source file paths according to tsconfig files and include configurations","getParsedConfigFile throws diagnostic error when tsconfig file contains invalid syntax or cannot be read","getParsedConfigFile throws error when invoked in a non-Node environment without tsserver sys"],"goal":"verify pkg:npm/%40typescript-eslint/tsconfig-utils@8.67.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/tsconfig-utils@8.67.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/tsconfig-utils@8.67.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/tsconfig-utils@8.67.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-tsconfig-utils",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-tsconfig-utils",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@typescript-eslint/tsconfig-utils": "8.67.0",
"typescript": "5.7.3"
}
},
"node_modules/@typescript-eslint/tsconfig-utils": {
"version": "8.67.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.67.0.tgz",
"integrity": "sha512-vV+LUSv5njUWsknE71fqKTlXUva+R76SaeORd6Zojcunk/6DvKFXONU3BrAs2H49mbygUXt6gbYunzwqNwlhdg==",
"license": "MIT",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <6.1.0"
}
},
"node_modules/typescript": {
"version": "5.7.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
}
}
}
{
"name": "sample-tsconfig-utils",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for @typescript-eslint/tsconfig-utils",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"@typescript-eslint/tsconfig-utils": "8.67.0",
"typescript": "5.7.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40typescript-eslint/tsconfig-utils@8.67.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40typescript-eslint/tsconfig-utils@8.67.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const ts = require('typescript');
const {
CORE_COMPILER_OPTIONS,
getParsedConfigFile
} = require('@typescript-eslint/tsconfig-utils');
/**
* Returns the default core compiler options enforced by tsconfig-utils.
*
* @returns {object} The core compiler options.
*/
function getCoreCompilerOptions() {
return CORE_COMPILER_OPTIONS;
}
/**
* Parses a tsconfig file using TypeScript and tsconfig-utils logic.
*
* @param {string} configPath - Path to tsconfig.json relative to projectRoot.
* @param {string} [projectRoot] - Path to project root (defaults to process.cwd()).
* @returns {object} The parsed command line configuration.
*/
function loadParsedConfig(configPath, projectRoot) {
return getParsedConfigFile(ts, configPath, projectRoot);
}
module.exports = {
CORE_COMPILER_OPTIONS,
getParsedConfigFile,
getCoreCompilerOptions,
loadParsedConfig
};
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
CORE_COMPILER_OPTIONS,
getParsedConfigFile,
getCoreCompilerOptions,
loadParsedConfig
} = require('../src/index.js');
const ts = require('typescript');
async function runTests() {
// 1. CORE_COMPILER_OPTIONS defines required compiler options including noEmit noUnusedLocals and noUnusedParameters
assert.equal(typeof CORE_COMPILER_OPTIONS, 'object', 'CORE_COMPILER_OPTIONS must be an object');
assert.equal(CORE_COMPILER_OPTIONS.noEmit, true, 'noEmit must be true');
assert.equal(CORE_COMPILER_OPTIONS.noUnusedLocals, true, 'noUnusedLocals must be true');
assert.equal(CORE_COMPILER_OPTIONS.noUnusedParameters, true, 'noUnusedParameters must be true');
assert.deepEqual(getCoreCompilerOptions(), CORE_COMPILER_OPTIONS, 'getCoreCompilerOptions helper matches constant');
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-tsconfig-test-'));
try {
const srcDir = path.join(tmpDir, 'src');
fs.mkdirSync(srcDir, { recursive: true });
const dummySource = path.join(srcDir, 'index.ts');
fs.writeFileSync(dummySource, 'export const greeting = "hello";');
// 2. getParsedConfigFile parses tsconfig.json and enforces CORE_COMPILER_OPTIONS in parsed compiler options
const tsconfigPath = path.join(tmpDir, 'tsconfig.json');
fs.writeFileSync(
tsconfigPath,
JSON.stringify({
compilerOptions: {
target: 'ES2022',
module: 'commonjs',
strict: true,
noEmit: false,
noUnusedLocals: false
},
files: ['src/index.ts']
}, null, 2)
);
const parsed = loadParsedConfig('tsconfig.json', tmpDir);
assert.ok(parsed, 'Parsed config must not be null');
assert.equal(parsed.options.noEmit, true, 'noEmit must be overridden to true');
assert.equal(parsed.options.noUnusedLocals, true, 'noUnusedLocals must be overridden to true');
assert.equal(parsed.options.noUnusedParameters, true, 'noUnusedParameters must be set to true');
assert.equal(parsed.options.strict, true, 'strict option must be preserved');
// 3. getParsedConfigFile resolves source file paths according to tsconfig files and include configurations
assert.ok(Array.isArray(parsed.fileNames), 'fileNames must be an array');
assert.equal(parsed.fileNames.length, 1, 'fileNames should contain one matched file');
assert.equal(
path.resolve(parsed.fileNames[0]),
path.resolve(dummySource),
'fileNames must resolve to the source file path'
);
// 4. getParsedConfigFile throws diagnostic error when tsconfig file contains invalid syntax or cannot be read
const badConfigPath = path.join(tmpDir, 'bad-tsconfig.json');
fs.writeFileSync(badConfigPath, '{ compilerOptions: { target: ');
assert.throws(
() => {
getParsedConfigFile(ts, 'bad-tsconfig.json', tmpDir);
},
/Unable to parse the specified 'tsconfig' file/,
'Must throw diagnostic error on invalid tsconfig JSON syntax'
);
assert.throws(
() => {
getParsedConfigFile(ts, 'nonexistent-tsconfig.json', tmpDir);
},
/Cannot read file/,
'Must throw error on missing tsconfig file'
);
// 5. getParsedConfigFile throws error when invoked in a non-Node environment without tsserver sys
assert.throws(
() => {
getParsedConfigFile({}, 'tsconfig.json', tmpDir);
},
/only supported in a Node-like environment/,
'Must throw when tsserver.sys is undefined'
);
console.log('All contract assertions for @typescript-eslint/tsconfig-utils passed successfully.');
} finally {
fs.rmSync(tmpDir, { recursive: true, force: true });
}
}
runTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
原始种子者
匿名