CodeSampleX

Sample

browserslist 4.28.7: findConfigFile

Verified sample for npm browserslist 4.28.7: findConfigFile. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:7ddf8b1f70efe716b4297473c4ef34f02b2f0a3695e1b517ed834ade1dd465ac

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
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-09-17

Case

HOW
Goal
verify browserslist.findConfigFile in pkg:npm/browserslist@4.28.7
Packages
Symbols
  • browserslist.findConfigFile
Environment
node 22.23.2
Created
2026-09-17T02:06:56Z

Contract

  1. browserslist.findConfigFile(dir) discovers .browserslistrc files and returns their absolute path
  2. browserslist.findConfigFile(dir) discovers browserslist files without extension and returns their absolute path
  3. browserslist.findConfigFile(dir) discovers package.json with browserslist field and returns its absolute path
  4. browserslist.findConfigFile(childDir) traverses parent directories to discover configuration files
  5. browserslist.findConfigFile(dir) ignores package.json lacking a browserslist configuration section
  6. browserslist.findConfigFile(dir) returns undefined when no configuration file exists in the directory tree
  7. browserslist.findConfigFile(dir) throws BrowserslistError when both .browserslistrc and package.json with browsers exist
  8. browserslist.findConfigFile(dir) throws BrowserslistError when both browserslist and package.json with browsers exist
  9. browserslist.findConfigFile(dir) throws BrowserslistError when both .browserslistrc and browserslist exist

Files

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

Download the source artifact (tar.gz)

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 browserslist.findConfigFile in pkg:npm/browserslist@4.28.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/browserslist@4.28.7
Demonstrate these symbols/APIs:
  - browserslist.findConfigFile

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:197559b4597f1175f67a87377ade230245c1780d91d619bc6052fe74b528f883","contract":["browserslist.findConfigFile(dir) discovers .browserslistrc files and returns their absolute path","browserslist.findConfigFile(dir) discovers browserslist files without extension and returns their absolute path","browserslist.findConfigFile(dir) discovers package.json with browserslist field and returns its absolute path","browserslist.findConfigFile(childDir) traverses parent directories to discover configuration files","browserslist.findConfigFile(dir) ignores package.json lacking a browserslist configuration section","browserslist.findConfigFile(dir) returns undefined when no configuration file exists in the directory tree","browserslist.findConfigFile(dir) throws BrowserslistError when both .browserslistrc and package.json with browsers exist","browserslist.findConfigFile(dir) throws BrowserslistError when both browserslist and package.json with browsers exist","browserslist.findConfigFile(dir) throws BrowserslistError when both .browserslistrc and browserslist exist"],"goal":"verify browserslist.findConfigFile in pkg:npm/browserslist@4.28.7","kind":"HOW","packages":["pkg:npm/browserslist@4.28.7"],"schemaVersion":1,"symbols":["browserslist.findConfigFile"]},"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/browserslist@4.28.7"],"schemaVersion":1,"subject":"pkg:npm/browserslist@4.28.7","symbols":["browserslist.findConfigFile"],"verifierAdapter":"node-typescript@1"}
index.js
const browserslist = require('browserslist');

/**
 * Discovers configuration files for browserslist from the given directory.
 *
 * @param {string} from - Starting directory or file path.
 * @returns {string | undefined} Absolute path to the config file, or undefined.
 */
function findConfigFile(from) {
  return browserslist.findConfigFile(from);
}

module.exports = {
  browserslist,
  findConfigFile,
};
package-lock.json
{
  "name": "sample-browserslist-find-config-file",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-browserslist-find-config-file",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "browserslist": "4.28.7"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.24",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.24.tgz",
      "integrity": "sha512-hYrgxie335U08WqICoGqKRzV1HFXv6zdxwJE4ekCb80CM9a0SVVsN4QPwT67RraRo+9h8IATk6uxHJw7QSkdOg==",
      "license": "Apache-2.0",
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.28.7",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.7.tgz",
      "integrity": "sha512-JxV13hNrFxqjOc8alRbq9dK1MM79NEXYpma2B2J4wAtpWS5zIEIKqWPGCl7N4o7Uc7B7itylh7SuDujATRyyTw==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "baseline-browser-mapping": "^2.10.44",
        "caniuse-lite": "^1.0.30001806",
        "electron-to-chromium": "^1.5.393",
        "node-releases": "^2.0.51",
        "update-browserslist-db": "^1.2.3"
      },
      "bin": {
        "browserslist": "cli.js"
      },
      "engines": {
        "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001810",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz",
      "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "CC-BY-4.0"
    },
    "node_modules/electron-to-chromium": {
      "version": "1.5.430",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.430.tgz",
      "integrity": "sha512-e1QEj72Y4zd8RlNZVmoTg+iCOSVwpk05IOiiQwdrkwCSVlZfPthevErhE+nckGd2YbsXfp1SkisznhGVIXP2NQ==",
      "license": "ISC"
    },
    "node_modules/escalade": {
      "version": "3.2.0",
      "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
      "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/node-releases": {
      "version": "2.0.55",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.55.tgz",
      "integrity": "sha512-mIrE/Cw9y+9Au6dS5vDKDhQza9YvG6w+ZrS6X+ZzA7yFW/soAeaups4Qzn1bL6g5FVy8WtP79+0j82oPIbqRjQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/picocolors": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
      "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
      "license": "ISC"
    },
    "node_modules/update-browserslist-db": {
      "version": "1.3.3",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz",
      "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "escalade": "^3.2.0",
        "picocolors": "^1.1.1"
      },
      "bin": {
        "update-browserslist-db": "cli.js"
      },
      "peerDependencies": {
        "browserslist": ">= 4.21.0"
      }
    }
  }
}
package.json
{
  "name": "sample-browserslist-find-config-file",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room sample verifying browserslist.findConfigFile discovery and mutual exclusivity",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "browserslist": "4.28.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify browserslist.findConfigFile in pkg:npm/browserslist@4.28.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/browserslist@4.28.7"
  ],
  "symbols": [
    "browserslist.findConfigFile"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import browserslist from 'browserslist';
import { findConfigFile } from '../index.js';

const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-bll-contract-'));

try {
  // 1. browserslist.findConfigFile(dir) discovers .browserslistrc files and returns their absolute path
  const dir1 = path.join(tmpDir, 'case1');
  fs.mkdirSync(dir1, { recursive: true });
  const rc1 = path.join(dir1, '.browserslistrc');
  fs.writeFileSync(rc1, '> 1%\n');
  assert.strictEqual(browserslist.findConfigFile(dir1), rc1);
  assert.strictEqual(findConfigFile(dir1), rc1);

  // 2. browserslist.findConfigFile(dir) discovers browserslist files without extension and returns their absolute path
  const dir2 = path.join(tmpDir, 'case2');
  fs.mkdirSync(dir2, { recursive: true });
  const bfile2 = path.join(dir2, 'browserslist');
  fs.writeFileSync(bfile2, 'last 2 versions\n');
  assert.strictEqual(browserslist.findConfigFile(dir2), bfile2);
  assert.strictEqual(findConfigFile(dir2), bfile2);

  // 3. browserslist.findConfigFile(dir) discovers package.json with browserslist field and returns its absolute path
  const dir3 = path.join(tmpDir, 'case3');
  fs.mkdirSync(dir3, { recursive: true });
  const pkg3 = path.join(dir3, 'package.json');
  fs.writeFileSync(pkg3, JSON.stringify({ browserslist: ['defaults'] }));
  assert.strictEqual(browserslist.findConfigFile(dir3), pkg3);
  assert.strictEqual(findConfigFile(dir3), pkg3);

  // 4. browserslist.findConfigFile(childDir) traverses parent directories to discover configuration files
  const dir4Parent = path.join(tmpDir, 'case4');
  const dir4Child = path.join(dir4Parent, 'nested', 'child');
  fs.mkdirSync(dir4Child, { recursive: true });
  const rc4 = path.join(dir4Parent, '.browserslistrc');
  fs.writeFileSync(rc4, 'defaults\n');
  assert.strictEqual(browserslist.findConfigFile(dir4Child), rc4);
  assert.strictEqual(findConfigFile(dir4Child), rc4);

  // 5. browserslist.findConfigFile(dir) ignores package.json lacking a browserslist configuration section
  const dir5Parent = path.join(tmpDir, 'case5');
  const dir5Child = path.join(dir5Parent, 'child');
  fs.mkdirSync(dir5Child, { recursive: true });
  const rc5 = path.join(dir5Parent, '.browserslistrc');
  fs.writeFileSync(rc5, 'defaults\n');
  const pkg5 = path.join(dir5Child, 'package.json');
  fs.writeFileSync(pkg5, JSON.stringify({ name: 'unrelated-subpackage' }));
  assert.strictEqual(browserslist.findConfigFile(dir5Child), rc5);
  assert.strictEqual(findConfigFile(dir5Child), rc5);

  // 6. browserslist.findConfigFile(dir) returns undefined when no configuration file exists in the directory tree
  const dir6 = path.join(tmpDir, 'case6');
  fs.mkdirSync(dir6, { recursive: true });
  assert.strictEqual(browserslist.findConfigFile(dir6), undefined);
  assert.strictEqual(findConfigFile(dir6), undefined);

  // 7. browserslist.findConfigFile(dir) throws BrowserslistError when both .browserslistrc and package.json with browsers exist
  const dir7 = path.join(tmpDir, 'case7');
  fs.mkdirSync(dir7, { recursive: true });
  fs.writeFileSync(path.join(dir7, '.browserslistrc'), 'defaults\n');
  fs.writeFileSync(path.join(dir7, 'package.json'), JSON.stringify({ browserslist: ['defaults'] }));
  assert.throws(
    () => browserslist.findConfigFile(dir7),
    (err) => err.name === 'BrowserslistError' && err.message.includes('contains both .browserslistrc and package.json with browsers')
  );

  // 8. browserslist.findConfigFile(dir) throws BrowserslistError when both browserslist and package.json with browsers exist
  const dir8 = path.join(tmpDir, 'case8');
  fs.mkdirSync(dir8, { recursive: true });
  fs.writeFileSync(path.join(dir8, 'browserslist'), 'defaults\n');
  fs.writeFileSync(path.join(dir8, 'package.json'), JSON.stringify({ browserslist: ['defaults'] }));
  assert.throws(
    () => browserslist.findConfigFile(dir8),
    (err) => err.name === 'BrowserslistError' && err.message.includes('contains both browserslist and package.json with browsers')
  );

  // 9. browserslist.findConfigFile(dir) throws BrowserslistError when both .browserslistrc and browserslist exist
  const dir9 = path.join(tmpDir, 'case9');
  fs.mkdirSync(dir9, { recursive: true });
  fs.writeFileSync(path.join(dir9, '.browserslistrc'), 'defaults\n');
  fs.writeFileSync(path.join(dir9, 'browserslist'), 'defaults\n');
  assert.throws(
    () => browserslist.findConfigFile(dir9),
    (err) => err.name === 'BrowserslistError' && err.message.includes('contains both .browserslistrc and browserslist')
  );

  console.log('Contract passed successfully.');
} finally {
  fs.rmSync(tmpDir, { recursive: true, force: true });
}

Origin Seeder

anonymous