CodeSampleX

示例

@typescript-eslint/project-service 8.65.0: ProjectService

已验证示例 — npm @typescript-eslint/project-service 8.65.0: ProjectService. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: createProjectService returns…

sha256:4c3273e319eb2218c8149f218552248956d9ac1be4ae4b401c6ca3e0892860f5

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 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-29

案例

HOW
目标
verify ProjectService in pkg:npm/%40typescript-eslint/project-service@8.65.0
包
符号
  • ProjectService
环境
node 22.23.2
创建时间
2026-08-29T05:45:19Z

契约

  1. createProjectService returns ProjectService instance and metadata
  2. service opens client TypeScript file with resolved tsconfig.json
  3. service retrieves ScriptInfo for open client file

文件

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.ts
  • test/contract.cjs
  • tsconfig.json

下载源代码构件 (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 ProjectService in pkg:npm/%40typescript-eslint/project-service@8.65.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40typescript-eslint/project-service@8.65.0
Demonstrate these symbols/APIs:
  - ProjectService

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:f73585840c34165f2d18a88e1a57a7a97b7dee79cd162bfacf2a92f51c0b1753","constraints":{"executionContext":"node"},"contract":["createProjectService returns ProjectService instance and metadata","service opens client TypeScript file with resolved tsconfig.json","service retrieves ScriptInfo for open client file"],"goal":"verify ProjectService in pkg:npm/%40typescript-eslint/project-service@8.65.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/project-service@8.65.0"],"schemaVersion":1,"symbols":["ProjectService"]},"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/project-service@8.65.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/project-service@8.65.0","symbols":["ProjectService"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-project-service",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-project-service",
      "version": "1.0.0",
      "dependencies": {
        "@typescript-eslint/project-service": "8.65.0",
        "typescript": "5.7.3"
      }
    },
    "node_modules/@typescript-eslint/project-service": {
      "version": "8.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.65.0.tgz",
      "integrity": "sha512-SxnPhbTsGahizDgbu7oqFH/xVtzIqMd/s+WtnSxNxJZJpLbdT5IPdzg8EZxO3+PoKahXmwJLeNQOpKJb3/bi7Q==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/tsconfig-utils": "^8.65.0",
        "@typescript-eslint/types": "^8.65.0",
        "debug": "^4.4.3"
      },
      "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-eslint/tsconfig-utils": {
      "version": "8.68.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.68.0.tgz",
      "integrity": "sha512-F7zrGQfiJHojPwi8vhxZQC1tWtJzvL74cK/nqri2lk8YUXvYaYwl263xOJ69jDWPUk1hmcdoayFwk9lX09npVw==",
      "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-eslint/types": {
      "version": "8.68.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.68.0.tgz",
      "integrity": "sha512-9RnpsGJjrAllCMefGVVsImJM24YurhC0Q1h4UbvivtvOqXmR/vEJge2OoE++z9m6hyg8T1Q8t5SNT6tHSbrxcg==",
      "license": "MIT",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "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"
      }
    }
  }
}
package.json
{
  "name": "sample-project-service",
  "version": "1.0.0",
  "description": "Clean-room code sample verifying ProjectService in @typescript-eslint/project-service@8.65.0",
  "main": "src/index.ts",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@typescript-eslint/project-service": "8.65.0",
    "typescript": "5.7.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify ProjectService in pkg:npm/%40typescript-eslint/project-service@8.65.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40typescript-eslint/project-service@8.65.0"
  ],
  "symbols": [
    "ProjectService"
  ]
}
src/index.ts
export function add(a: number, b: number): number {
  return a + b;
}
test/contract.cjs
const assert = require('assert');
const path = require('path');
const { createProjectService } = require('@typescript-eslint/project-service');

function runContract() {
  const rootDir = path.resolve(__dirname, '..');
  const result = createProjectService({
    tsconfigRootDir: rootDir,
    options: {
      defaultProject: 'tsconfig.json',
      maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 10
    }
  });

  // Assertion 1: createProjectService returns ProjectService instance and metadata
  assert(result !== null && typeof result === 'object', 'Result must be an object');
  assert(result.service !== null && typeof result.service === 'object', 'service must be an object');
  assert(typeof result.lastReloadTimestamp === 'number' && result.lastReloadTimestamp > 0, 'lastReloadTimestamp must be a positive number');
  assert.strictEqual(result.maximumDefaultProjectFileMatchCount, 10, 'maximumDefaultProjectFileMatchCount must match configured value');

  // Assertion 2: service opens client TypeScript file with resolved tsconfig.json
  const targetFile = path.join(rootDir, 'src', 'index.ts');
  const openResult = result.service.openClientFile(targetFile);
  assert(openResult !== null && typeof openResult === 'object', 'openClientFile must return an object');
  assert(openResult.configFileName && openResult.configFileName.endsWith('tsconfig.json'), 'configFileName must resolve to tsconfig.json');
  assert(Array.isArray(openResult.configFileErrors) && openResult.configFileErrors.length === 0, 'configFileErrors must be empty');

  // Assertion 3: service retrieves ScriptInfo for open client file
  const scriptInfo = result.service.getScriptInfo(targetFile);
  assert(scriptInfo !== null && typeof scriptInfo === 'object', 'ScriptInfo must not be null');
  assert.strictEqual(scriptInfo.fileName, targetFile, 'ScriptInfo fileName must match target file');

  console.log('Contract assertions passed successfully.');
}

runContract();
tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "commonjs",
    "moduleResolution": "node",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": [
    "src/**/*"
  ]
}

原始种子者

匿名