CodeSampleX

Exemplo

@eslint-community/regexpp 4.12.2

Amostra verificada para npm @eslint-community/regexpp 4.12.2. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.

sha256:1304c2c3101fbf9e9bb6eb1792d78aa7b33575c8f65c46cc29680691ca5a4087

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 pkg:npm/%40eslint-community/regexpp@4.12.2
Pacotes
Criado
2026-08-27T16:14:25Z

Contrato

  1. assert parseRegExpLiteral parses regular expression literal into AST with pattern and flags
  2. assert RegExpParser parses ECMAScript regular expression patterns with configurable options
  3. assert RegExpValidator validates regular expression literals and triggers callbacks
  4. assert validateRegExpLiteral validates regular expressions and throws RegExpSyntaxError on syntax errors
  5. assert visitRegExpAST traverses AST nodes and invokes visitor callbacks

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-community/regexpp@4.12.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40eslint-community/regexpp@4.12.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:2cf8200628cde3a87e742e7a7b270665b310b5ab2028f4232153a8b983a5ed77","contract":["assert parseRegExpLiteral parses regular expression literal into AST with pattern and flags","assert RegExpParser parses ECMAScript regular expression patterns with configurable options","assert RegExpValidator validates regular expression literals and triggers callbacks","assert validateRegExpLiteral validates regular expressions and throws RegExpSyntaxError on syntax errors","assert visitRegExpAST traverses AST nodes and invokes visitor callbacks"],"goal":"verify pkg:npm/%40eslint-community/regexpp@4.12.2","kind":"HOW","packages":["pkg:npm/%40eslint-community/regexpp@4.12.2"],"schemaVersion":1},"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/%40eslint-community/regexpp@4.12.2"],"schemaVersion":1,"subject":"pkg:npm/%40eslint-community/regexpp@4.12.2","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-eslint-community-regexpp",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-eslint-community-regexpp",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@eslint-community/regexpp": "4.12.2"
      }
    },
    "node_modules/@eslint-community/regexpp": {
      "version": "4.12.2",
      "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz",
      "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==",
      "license": "MIT",
      "engines": {
        "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-eslint-community-regexpp",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@eslint-community/regexpp": "4.12.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40eslint-community/regexpp@4.12.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40eslint-community/regexpp@4.12.2"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  parseRegExpLiteral,
  validateRegExpLiteral,
  visitRegExpAST,
  RegExpParser,
  RegExpValidator,
  RegExpSyntaxError
} from '@eslint-community/regexpp';

// 1. parseRegExpLiteral parses regular expression literal into AST with pattern and flags
const ast = parseRegExpLiteral('/(?<year>\\d{4})-(?<month>\\d{2})/gu');
assert.equal(ast.type, 'RegExpLiteral');
assert.equal(ast.flags.unicode, true);
assert.equal(ast.flags.global, true);
assert.equal(ast.pattern.alternatives.length, 1);
assert.equal(ast.pattern.alternatives[0].elements.length, 3);
assert.equal(ast.pattern.alternatives[0].elements[0].type, 'CapturingGroup');
assert.equal(ast.pattern.alternatives[0].elements[0].name, 'year');
assert.equal(ast.pattern.alternatives[0].elements[2].type, 'CapturingGroup');
assert.equal(ast.pattern.alternatives[0].elements[2].name, 'month');

// 2. RegExpParser parses ECMAScript regular expression patterns with configurable options
const parser = new RegExpParser({ ecmaVersion: 2024 });
const patternStr = '^[a-z]+$';
const patternAst = parser.parsePattern(patternStr, 0, patternStr.length, { unicode: true });
assert.equal(patternAst.type, 'Pattern');
assert.equal(patternAst.alternatives[0].elements.length, 3);
assert.equal(patternAst.alternatives[0].elements[0].type, 'Assertion');
assert.equal(patternAst.alternatives[0].elements[0].kind, 'start');
assert.equal(patternAst.alternatives[0].elements[1].type, 'Quantifier');
assert.equal(patternAst.alternatives[0].elements[2].type, 'Assertion');
assert.equal(patternAst.alternatives[0].elements[2].kind, 'end');

// 3. RegExpValidator validates regular expression literals and triggers callbacks
let groupCount = 0;
const names = [];
const validator = new RegExpValidator({
  onCapturingGroupEnter(start, name) {
    groupCount++;
    if (name) names.push(name);
  }
});
validator.validateLiteral('/(?<first>[a-z]+)-(?<second>[0-9]+)/u');
assert.equal(groupCount, 2);
assert.deepEqual(names, ['first', 'second']);

// 4. validateRegExpLiteral validates regular expressions and throws RegExpSyntaxError on syntax errors
assert.doesNotThrow(() => validateRegExpLiteral('/[0-9]+/i'));
assert.throws(
  () => validateRegExpLiteral('/[0-9+/i'),
  (err) => err instanceof RegExpSyntaxError || err.name === 'RegExpSyntaxError'
);

// 5. visitRegExpAST traverses AST nodes and invokes visitor callbacks
const visitedGroups = [];
visitRegExpAST(ast, {
  onCapturingGroupEnter(node) {
    visitedGroups.push(node.name);
  }
});
assert.deepEqual(visitedGroups, ['year', 'month']);

Seeder de origem

anônimo