CodeSampleX

Exemplo

@eslint/core 1.2.1

Amostra verificada para npm @eslint/core 1.2.1. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: package manifest specifies ESM and CJS type…

sha256:fbf943dd834215acca03dd221ce39d6a47ef37cf10bb489bc0ee73e434dcedbb

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

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 pkg:npm/%40eslint/core@1.2.1
Pacotes
Ambiente
node 22.23.2
Criado
2026-08-27T12:32:03Z

Contrato

  1. package manifest specifies ESM and CJS type declaration exports and dependency on @types/json-schema
  2. declares Language interface for custom file parsing, AST generation, and SourceCode creation
  3. declares RuleDefinition, RuleContext, and CustomRule interfaces with rule metadata, visitor methods, and violation reporting
  4. declares SourceCodeBase, TextSourceCode, BinarySourceCode, TraversalStep, and Directive interfaces supporting AST traversal and location mapping
  5. declares ConfigObject, Plugin, and Processor interfaces for ESLint flat configuration ecosystem
  6. declares diagnostics and fix interfaces including LintMessage, ViolationReport, and RuleTextEditor

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 pkg:npm/%40eslint/core@1.2.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40eslint/core@1.2.1
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.
csx.json
{"case":{"caseId":"case:sha256:29b24fd2f9b1f56e4f1806678eca5d1f26039fa9b09d124c7816e55c420bd410","constraints":{"executionContext":"node"},"contract":["package manifest specifies ESM and CJS type declaration exports and dependency on @types/json-schema","declares Language interface for custom file parsing, AST generation, and SourceCode creation","declares RuleDefinition, RuleContext, and CustomRule interfaces with rule metadata, visitor methods, and violation reporting","declares SourceCodeBase, TextSourceCode, BinarySourceCode, TraversalStep, and Directive interfaces supporting AST traversal and location mapping","declares ConfigObject, Plugin, and Processor interfaces for ESLint flat configuration ecosystem","declares diagnostics and fix interfaces including LintMessage, ViolationReport, and RuleTextEditor"],"goal":"verify pkg:npm/%40eslint/core@1.2.1","kind":"HOW","packages":["pkg:npm/%40eslint/core@1.2.1"],"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/%40eslint/core@1.2.1"],"schemaVersion":1,"subject":"pkg:npm/%40eslint/core@1.2.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-eslint-core",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-eslint-core",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@eslint/core": "1.2.1"
      }
    },
    "node_modules/@eslint/core": {
      "version": "1.2.1",
      "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.2.1.tgz",
      "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==",
      "license": "Apache-2.0",
      "dependencies": {
        "@types/json-schema": "^7.0.15"
      },
      "engines": {
        "node": "^20.19.0 || ^22.13.0 || >=24"
      }
    },
    "node_modules/@types/json-schema": {
      "version": "7.0.15",
      "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
      "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-eslint-core",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@eslint/core": "1.2.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40eslint/core@1.2.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40eslint/core@1.2.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';

// Locate package directory from node_modules relative to process.cwd() or import.meta.url
const cwdPkgDir = path.resolve(process.cwd(), 'node_modules/@eslint/core');
const scriptRelativePkgDir = path.resolve(path.dirname(new URL(import.meta.url).pathname), '../node_modules/@eslint/core');
const pkgDir = fs.existsSync(cwdPkgDir) ? cwdPkgDir : scriptRelativePkgDir;
const pkgPath = path.join(pkgDir, 'package.json');

assert.ok(fs.existsSync(pkgPath), 'package.json must exist in node_modules/@eslint/core');

const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

// 1. Resolve @eslint/core package manifest and verify type declaration export paths
assert.equal(pkg.name, '@eslint/core', 'Package name must be @eslint/core');
assert.equal(pkg.version, '1.2.1', 'Package version must be 1.2.1');
assert.equal(pkg.type, 'module', 'Package type must be module');
assert.equal(pkg.types, './dist/esm/types.d.ts', 'types entry must point to ./dist/esm/types.d.ts');
assert.equal(
  pkg.exports?.types?.import,
  './dist/esm/types.d.ts',
  'ESM types export must point to ./dist/esm/types.d.ts'
);
assert.equal(
  pkg.exports?.types?.require,
  './dist/cjs/types.d.cts',
  'CJS types export must point to ./dist/cjs/types.d.cts'
);
assert.ok(
  pkg.dependencies?.['@types/json-schema'],
  'Package must declare dependency on @types/json-schema'
);

const esmDtsContent = fs.readFileSync(path.join(pkgDir, 'dist/esm/types.d.ts'), 'utf8');
const cjsDtsContent = fs.readFileSync(path.join(pkgDir, 'dist/cjs/types.d.cts'), 'utf8');

// 2. Verify Language plugin interface declarations
assert.ok(
  esmDtsContent.includes('export interface Language<Options extends LanguageTypeOptions'),
  'Language interface with LanguageTypeOptions generic must be exported'
);
assert.ok(
  esmDtsContent.includes('fileType: "text";') &&
  esmDtsContent.includes('lineStart: 0 | 1;') &&
  esmDtsContent.includes('columnStart: 0 | 1;') &&
  esmDtsContent.includes('nodeTypeKey: string;') &&
  esmDtsContent.includes('validateLanguageOptions(languageOptions: Options["LangOptions"]): void;') &&
  esmDtsContent.includes('parse(file: File, context: LanguageContext<Options["LangOptions"]>): ParseResult<Options["RootNode"]>;') &&
  esmDtsContent.includes('createSourceCode(file: File, input: OkParseResult<Options["RootNode"]>, context: LanguageContext<Options["LangOptions"]>): Options["Code"];'),
  'Language interface must declare fileType, lineStart, columnStart, nodeTypeKey, validateLanguageOptions, parse, and createSourceCode'
);
assert.ok(
  esmDtsContent.includes('export interface File {') &&
  esmDtsContent.includes('path: string;') &&
  esmDtsContent.includes('physicalPath: string;') &&
  esmDtsContent.includes('bom: boolean;') &&
  esmDtsContent.includes('body: string | Uint8Array;'),
  'File interface must declare path, physicalPath, bom, and body'
);
assert.ok(
  esmDtsContent.includes('export interface OkParseResult<RootNode = unknown> {') &&
  esmDtsContent.includes('export interface NotOkParseResult {') &&
  esmDtsContent.includes('export type ParseResult<RootNode = unknown> = OkParseResult<RootNode> | NotOkParseResult;'),
  'ParseResult discriminated union with OkParseResult and NotOkParseResult must be exported'
);

// 3. Verify RuleDefinition, RuleContext, and CustomRule interfaces
assert.ok(
  esmDtsContent.includes('export interface RuleDefinition<Options extends RuleDefinitionTypeOptions'),
  'RuleDefinition interface must be exported'
);
assert.ok(
  esmDtsContent.includes('export interface RuleContext<Options extends RuleContextTypeOptions'),
  'RuleContext interface must be exported'
);
assert.ok(
  esmDtsContent.includes('export interface RulesMeta<MessageIds extends string = string, RuleOptions = unknown[], ExtRuleDocs = unknown> {'),
  'RulesMeta interface must be exported with generic MessageIds, RuleOptions, ExtRuleDocs'
);
assert.ok(
  esmDtsContent.includes('export interface CustomRuleTypeDefinitions {') &&
  esmDtsContent.includes('export type CustomRuleDefinitionType<LanguageSpecificOptions extends Omit<RuleDefinitionTypeOptions, keyof CustomRuleTypeDefinitions>, Options extends Partial<CustomRuleTypeDefinitions>>'),
  'CustomRuleTypeDefinitions and CustomRuleDefinitionType must be exported'
);
assert.ok(
  esmDtsContent.includes('cwd: string;') &&
  esmDtsContent.includes('filename: string;') &&
  esmDtsContent.includes('physicalFilename: string;') &&
  esmDtsContent.includes('sourceCode: Options["Code"];') &&
  esmDtsContent.includes('settings: SettingsConfig;') &&
  esmDtsContent.includes('languageOptions: Options["LangOptions"];') &&
  esmDtsContent.includes('id: string;') &&
  esmDtsContent.includes('options: Options["RuleOptions"];') &&
  esmDtsContent.includes('report(violation: ViolationReport<Options["Node"], Options["MessageIds"]>): void;'),
  'RuleContext must provide cwd, filename, physicalFilename, sourceCode, settings, languageOptions, id, options, report'
);
assert.ok(
  esmDtsContent.includes('export type RuleVisitor = Record<string, ((...args: any[]) => void) | undefined>;'),
  'RuleVisitor type alias must be exported'
);

// 4. Verify SourceCodeBase, TextSourceCode, BinarySourceCode, TraversalStep, and Directive interfaces
assert.ok(
  esmDtsContent.includes('interface SourceCodeBase<Options extends SourceCodeBaseTypeOptions'),
  'SourceCodeBase interface must be declared'
);
assert.ok(
  esmDtsContent.includes('getLoc(syntaxElement: Options["SyntaxElementWithLoc"]): SourceLocation;') &&
  esmDtsContent.includes('getRange(syntaxElement: Options["SyntaxElementWithLoc"]): SourceRange;') &&
  esmDtsContent.includes('traverse(): Iterable<TraversalStep>;'),
  'SourceCodeBase must declare getLoc, getRange, and traverse methods'
);
assert.ok(
  esmDtsContent.includes('export interface TextSourceCode<') &&
  esmDtsContent.includes('text: string;') &&
  esmDtsContent.includes('export interface BinarySourceCode<') &&
  esmDtsContent.includes('body: Uint8Array;') &&
  esmDtsContent.includes('export type SourceCode<Options extends SourceCodeBaseTypeOptions'),
  'TextSourceCode, BinarySourceCode, and SourceCode union must be exported'
);
assert.ok(
  esmDtsContent.includes('export interface VisitTraversalStep {') &&
  esmDtsContent.includes('export interface CallTraversalStep {') &&
  esmDtsContent.includes('export type TraversalStep = VisitTraversalStep | CallTraversalStep;'),
  'TraversalStep discriminated union with VisitTraversalStep and CallTraversalStep must be exported'
);
assert.ok(
  esmDtsContent.includes('export type DirectiveType = "disable" | "enable" | "disable-line" | "disable-next-line";') &&
  esmDtsContent.includes('export interface Directive {'),
  'DirectiveType and Directive interface must be exported'
);

// 5. Verify ConfigObject, Plugin, and Processor interfaces
assert.ok(
  esmDtsContent.includes('export interface ConfigObject<Rules extends RulesConfig = RulesConfig> {') &&
  esmDtsContent.includes('name?: string;') &&
  esmDtsContent.includes('basePath?: string;') &&
  esmDtsContent.includes('files?: (string | string[])[];') &&
  esmDtsContent.includes('ignores?: string[];') &&
  esmDtsContent.includes('language?: string;') &&
  esmDtsContent.includes('languageOptions?: LanguageOptions;') &&
  esmDtsContent.includes('linterOptions?: LinterOptionsConfig;') &&
  esmDtsContent.includes('processor?: string | Processor;') &&
  esmDtsContent.includes('plugins?: Record<string, Plugin>;') &&
  esmDtsContent.includes('rules?: Partial<Rules>;') &&
  esmDtsContent.includes('settings?: SettingsConfig;'),
  'ConfigObject flat config interface must declare name, basePath, files, ignores, language, languageOptions, linterOptions, processor, plugins, rules, settings'
);
assert.ok(
  esmDtsContent.includes('export interface Plugin extends ObjectMetaProperties {') &&
  esmDtsContent.includes('configs?: Record<string, LegacyConfigObject | ConfigObject | ConfigObject[]> | undefined;') &&
  esmDtsContent.includes('environments?: Record<string, EnvironmentConfig> | undefined;') &&
  esmDtsContent.includes('languages?: Record<string, Language> | undefined;') &&
  esmDtsContent.includes('processors?: Record<string, Processor> | undefined;') &&
  esmDtsContent.includes('rules?: Record<string, RuleDefinition> | undefined;'),
  'Plugin interface must declare configs, environments, languages, processors, and rules maps'
);
assert.ok(
  esmDtsContent.includes('export interface Processor<T extends string | ProcessorFile = string | ProcessorFile> extends ObjectMetaProperties {') &&
  esmDtsContent.includes('supportsAutofix?: boolean | undefined;') &&
  esmDtsContent.includes('preprocess?(text: string, filename: string): T[];') &&
  esmDtsContent.includes('postprocess?(messages: LintMessage[][], filename: string): LintMessage[];'),
  'Processor interface must declare preprocess and postprocess methods'
);

// 6. Verify diagnostics and fix interfaces
assert.ok(
  esmDtsContent.includes('export interface LintMessage {') &&
  esmDtsContent.includes('column: number;') &&
  esmDtsContent.includes('line: number;') &&
  esmDtsContent.includes('ruleId: string | null;') &&
  esmDtsContent.includes('message: string;') &&
  esmDtsContent.includes('severity: Exclude<SeverityLevel, 0>;'),
  'LintMessage interface must declare column, line, ruleId, message, severity'
);
assert.ok(
  esmDtsContent.includes('export type ViolationReport<Node = unknown, MessageIds extends string = string> = ViolationReportBase<MessageIds> & ViolationMessage<MessageIds> & ViolationLocation<Node>;'),
  'ViolationReport intersection type must be exported'
);
assert.ok(
  esmDtsContent.includes('export interface RuleTextEditor<EditableSyntaxElement = unknown> {') &&
  esmDtsContent.includes('insertTextAfter(') &&
  esmDtsContent.includes('insertTextBefore(') &&
  esmDtsContent.includes('remove(') &&
  esmDtsContent.includes('replaceText(') &&
  esmDtsContent.includes('replaceTextRange('),
  'RuleTextEditor interface must declare insertTextAfter, insertTextBefore, remove, replaceText, replaceTextRange'
);

// 7. Verify CJS declaration mirrors ESM declaration
assert.equal(
  cjsDtsContent,
  esmDtsContent,
  'dist/cjs/types.d.cts must match dist/esm/types.d.ts'
);

console.log('Contract tests passed successfully.');

Seeder de origem

anônimo