CodeSampleX

Exemple

@eslint-community/regexpp 4.12.2

Échantillon vérifié pour npm @eslint-community/regexpp 4.12.2. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:1304c2c3101fbf9e9bb6eb1792d78aa7b33575c8f65c46cc29680691ca5a4087

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify pkg:npm/%40eslint-community/regexpp@4.12.2
Paquets
Créé
2026-08-27T16:14:25Z

Contrat

  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

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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 d'origine

anonyme