CodeSampleX

Exemple

postcss-selector-parser 7.1.1: tag

Échantillon vérifié pour npm postcss-selector-parser 7.1.1: tag. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:cd80d1db4620275c65d5432ed94292955d82266bc25c822c1566858981b9c893

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

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-10-12

Cas

HOW
Objectif
verify postcss-selector-parser.tag in pkg:npm/postcss-selector-parser@7.1.1
Paquets
Symboles
  • postcss-selector-parser.tag
Environnement
node 22.23.2
Créé
2026-10-12T05:24:43Z

Contrat

  1. parser.tag creates a Tag AST node with tag type, given value, and passes parser.isTag validation
  2. parser.tag formats simple tag selector matching its value via toString
  3. parser.tag supports namespace string prefix and formats as namespace|tag
  4. parser.tag supports wildcard namespace string and boolean empty namespace prefix
  5. parser.tag creates an empty Tag node when called without arguments
  6. parser.tag nodes integrate with selector AST parsing, walking, and replacement
  7. parser.isTag discriminates tag nodes from other AST node types but throws TypeError for null

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 postcss-selector-parser.tag in pkg:npm/postcss-selector-parser@7.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/postcss-selector-parser@7.1.1
Demonstrate these symbols/APIs:
  - postcss-selector-parser.tag

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:211dfedecab544ba32ea924b6895801c9adc3475a07d06ded7f5129a854729b1","contract":["parser.tag creates a Tag AST node with tag type, given value, and passes parser.isTag validation","parser.tag formats simple tag selector matching its value via toString","parser.tag supports namespace string prefix and formats as namespace|tag","parser.tag supports wildcard namespace string and boolean empty namespace prefix","parser.tag creates an empty Tag node when called without arguments","parser.tag nodes integrate with selector AST parsing, walking, and replacement","parser.isTag discriminates tag nodes from other AST node types but throws TypeError for null"],"goal":"verify postcss-selector-parser.tag in pkg:npm/postcss-selector-parser@7.1.1","kind":"HOW","packages":["pkg:npm/postcss-selector-parser@7.1.1"],"schemaVersion":1,"symbols":["postcss-selector-parser.tag"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/postcss-selector-parser@7.1.1"],"schemaVersion":1,"subject":"pkg:npm/postcss-selector-parser@7.1.1","symbols":["postcss-selector-parser.tag"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-postcss-selector-parser-tag",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-postcss-selector-parser-tag",
      "version": "1.0.0",
      "dependencies": {
        "postcss-selector-parser": "7.1.1"
      }
    },
    "node_modules/cssesc": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
      "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
      "license": "MIT",
      "bin": {
        "cssesc": "bin/cssesc"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/postcss-selector-parser": {
      "version": "7.1.1",
      "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.1.tgz",
      "integrity": "sha512-orRsuYpJVw8LdAwqqLykBj9ecS5/cRHlI5+nvTo8LcCKmzDmqVORXtOIYEEQuL9D4BxtA1lm5isAqzQZCoQ6Eg==",
      "license": "MIT",
      "dependencies": {
        "cssesc": "^3.0.0",
        "util-deprecate": "^1.0.2"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/util-deprecate": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
      "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-postcss-selector-parser-tag",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "description": "Clean-room verification of postcss-selector-parser.tag in pkg:npm/postcss-selector-parser@7.1.1",
  "dependencies": {
    "postcss-selector-parser": "7.1.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify postcss-selector-parser.tag in pkg:npm/postcss-selector-parser@7.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/postcss-selector-parser@7.1.1"
  ],
  "symbols": [
    "postcss-selector-parser.tag"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import parser from 'postcss-selector-parser';

const { tag, isTag, className } = parser;

// 1. parser.tag creates a Tag AST node with tag type, given value, and passes parser.isTag validation
{
  const node = tag({ value: 'button' });
  assert.equal(typeof tag, 'function');
  assert.equal(node.type, 'tag');
  assert.equal(node.value, 'button');
  assert.equal(isTag(node), true);
}

// 2. parser.tag formats simple tag selector matching its value via toString
{
  const node = tag({ value: 'div' });
  assert.equal(node.toString(), 'div');
  assert.equal(String(node), 'div');
}

// 3. parser.tag supports namespace string prefix and formats as namespace|tag
{
  const node = tag({ value: 'circle', namespace: 'svg' });
  assert.equal(node.type, 'tag');
  assert.equal(node.value, 'circle');
  assert.equal(node.namespace, 'svg');
  assert.equal(node.ns, 'svg');
  assert.equal(node.toString(), 'svg|circle');
}

// 4. parser.tag supports wildcard namespace string and boolean empty namespace prefix
{
  const wildcard = tag({ value: 'div', namespace: '*' });
  assert.equal(wildcard.namespace, '*');
  assert.equal(wildcard.toString(), '*|div');

  const emptyNs = tag({ value: 'span', namespace: true });
  assert.equal(emptyNs.namespace, true);
  assert.equal(emptyNs.toString(), '|span');
}

// 5. parser.tag creates an empty Tag node when called without arguments
{
  const empty = tag();
  assert.equal(empty.type, 'tag');
  assert.equal(empty.value, undefined);
  assert.equal(empty.toString(), 'undefined');
  assert.equal(isTag(empty), true);
}

// 6. parser.tag nodes integrate with selector AST parsing, walking, and replacement
{
  const ast = parser().astSync('main.hero > span');
  const found = [];
  ast.walkTags((node) => {
    found.push(node.value);
  });
  assert.deepEqual(found, ['main', 'span']);

  ast.walkTags((node) => {
    if (node.value === 'main') {
      node.replaceWith(tag({ value: 'section' }));
    }
  });
  assert.equal(ast.toString(), 'section.hero > span');
}

// 7. parser.isTag discriminates tag nodes from other AST node types but throws TypeError for null
{
  const tagNode = tag({ value: 'p' });
  const classNode = className({ value: 'intro' });
  assert.equal(isTag(tagNode), true);
  assert.equal(isTag(classNode), false);
  assert.equal(isTag(undefined), false);
  assert.equal(isTag('tag'), false);
  assert.throws(() => isTag(null), { name: 'TypeError' });
}

Seeder d'origine

anonyme