CodeSampleX

Пример

@eslint/js 9.20.0: configs

Проверенный пример — npm @eslint/js 9.20.0: configs. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: configs provides recommended and all…

sha256:dc5e7865bd22b4c6eb75e5e8010db25e6ac0166b55f23d4e0d1e58f2fe552030

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда linux 24 · ubuntu · glibc 2.39 x64 npm

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-06

Кейс

HOW
Цель
verify @eslint/js.configs in pkg:npm/%40eslint/js@9.20.0
Пакеты
Символы
  • @eslint/js.configs
Создан
2026-09-06T15:33:07Z

Контракт

  1. configs provides recommended and all configuration objects with rule definitions
  2. configs.recommended is a frozen configuration object containing essential recommended rules
  3. configs.all contains comprehensive rules encompassing every recommended rule

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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 @eslint/js.configs in pkg:npm/%40eslint/js@9.20.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40eslint/js@9.20.0
Demonstrate these symbols/APIs:
  - @eslint/js.configs

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:6fdb3e1d58b31c2dced6b6dad250cf604ac1332c68c243326da93c936e3b2ecb","contract":["configs provides recommended and all configuration objects with rule definitions","configs.recommended is a frozen configuration object containing essential recommended rules","configs.all contains comprehensive rules encompassing every recommended rule"],"goal":"verify @eslint/js.configs in pkg:npm/%40eslint/js@9.20.0","kind":"HOW","packages":["pkg:npm/%40eslint/js@9.20.0"],"schemaVersion":1,"symbols":["@eslint/js.configs"]},"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/js@9.20.0"],"schemaVersion":1,"subject":"pkg:npm/%40eslint/js@9.20.0","symbols":["@eslint/js.configs"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-eslint-js-configs",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-eslint-js-configs",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@eslint/js": "9.20.0"
      }
    },
    "node_modules/@eslint/js": {
      "version": "9.20.0",
      "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.20.0.tgz",
      "integrity": "sha512-iZA07H9io9Wn836aVTytRaNqh00Sad+EamwOVJT12GTLw1VGMFV/4JaME+JjLtr9fiGaoWgYnS54wrfWsSs4oQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-eslint-js-configs",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of @eslint/js configs",
  "type": "module",
  "main": "src/index.mjs",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "@eslint/js": "9.20.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @eslint/js.configs in pkg:npm/%40eslint/js@9.20.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40eslint/js@9.20.0"
  ],
  "symbols": [
    "@eslint/js.configs"
  ]
}
src/index.mjs
import js from '@eslint/js';

/**
 * Return the full configs object from @eslint/js.
 *
 * @returns {object} The configs object containing recommended and all configs.
 */
export function getConfigs() {
  return js.configs;
}

/**
 * Return the recommended configuration object.
 *
 * @returns {object} The recommended configuration.
 */
export function getRecommendedConfig() {
  return js.configs.recommended;
}

/**
 * Return the all configuration object.
 *
 * @returns {object} The all configuration.
 */
export function getAllConfig() {
  return js.configs.all;
}

/**
 * Check whether a specific rule is active in the recommended configuration.
 *
 * @param {string} ruleName - The ESLint rule name to check.
 * @returns {boolean} True if the rule is present in recommended rules.
 */
export function isRecommendedRule(ruleName) {
  return Boolean(js.configs?.recommended?.rules && ruleName in js.configs.recommended.rules);
}

export { js };
export const configs = js.configs;
test/contract.mjs
import assert from 'node:assert/strict';
import {
  getConfigs,
  getRecommendedConfig,
  getAllConfig,
  isRecommendedRule,
  configs,
  js,
} from '../src/index.mjs';

// 1. configs provides recommended and all configuration objects with rule definitions
{
  assert.ok(configs, 'configs must be defined');
  assert.equal(typeof configs, 'object', 'configs must be an object');
  assert.equal(configs, js.configs, 'configs must match js.configs');
  assert.equal(getConfigs(), js.configs, 'getConfigs helper must return js.configs');

  assert.ok(configs.recommended, 'configs.recommended must be defined');
  assert.ok(configs.all, 'configs.all must be defined');
  assert.equal(typeof configs.recommended, 'object', 'recommended must be an object');
  assert.equal(typeof configs.all, 'object', 'all must be an object');

  assert.equal(getRecommendedConfig(), configs.recommended, 'getRecommendedConfig must return recommended');
  assert.equal(getAllConfig(), configs.all, 'getAllConfig must return all');

  assert.equal(typeof configs.recommended.rules, 'object', 'recommended.rules must be an object');
  assert.equal(typeof configs.all.rules, 'object', 'all.rules must be an object');
  assert.ok(Object.keys(configs.recommended.rules).length > 0, 'recommended.rules must not be empty');
  assert.ok(Object.keys(configs.all.rules).length > 0, 'all.rules must not be empty');
}

// 2. configs.recommended is a frozen configuration object containing essential recommended rules
{
  const recommended = getRecommendedConfig();

  assert.equal(Object.isFrozen(recommended), true, 'configs.recommended must be frozen');
  assert.equal(Object.isFrozen(recommended.rules), true, 'configs.recommended.rules must be frozen');
  assert.equal(recommended.name, undefined, 'configs.recommended must not define a name property');

  const essentialRules = [
    'constructor-super',
    'for-direction',
    'getter-return',
    'no-async-promise-executor',
    'no-case-declarations',
    'no-class-assign',
    'no-compare-neg-zero',
    'no-cond-assign',
    'no-const-assign',
    'no-constant-binary-expression',
    'no-constant-condition',
    'no-control-regex',
    'no-debugger',
    'no-delete-var',
    'no-dupe-args',
    'no-dupe-class-members',
    'no-dupe-else-if',
    'no-dupe-keys',
    'no-duplicate-case',
    'no-empty',
    'no-empty-character-class',
    'no-empty-pattern',
    'no-empty-static-block',
    'no-ex-assign',
    'no-extra-boolean-cast',
    'no-fallthrough',
    'no-func-assign',
    'no-global-assign',
    'no-import-assign',
    'no-invalid-regexp',
    'no-irregular-whitespace',
    'no-loss-of-precision',
    'no-misleading-character-class',
    'no-new-native-nonconstructor',
    'no-nonoctal-decimal-escape',
    'no-obj-calls',
    'no-octal',
    'no-prototype-builtins',
    'no-redeclare',
    'no-regex-spaces',
    'no-self-assign',
    'no-setter-return',
    'no-shadow-restricted-names',
    'no-sparse-arrays',
    'no-this-before-super',
    'no-undef',
    'no-unexpected-multiline',
    'no-unreachable',
    'no-unsafe-finally',
    'no-unsafe-negation',
    'no-unsafe-optional-chaining',
    'no-unused-labels',
    'no-unused-private-class-members',
    'no-unused-vars',
    'no-useless-backreference',
    'no-useless-catch',
    'no-useless-escape',
    'no-with',
    'require-yield',
    'use-isnan',
    'valid-typeof',
  ];

  for (const rule of essentialRules) {
    assert.equal(
      recommended.rules[rule],
      'error',
      `recommended rule "${rule}" must be set to "error"`
    );
    assert.equal(
      isRecommendedRule(rule),
      true,
      `isRecommendedRule("${rule}") helper must return true`
    );
  }

  assert.equal(isRecommendedRule('non-existent-rule-xyz'), false);
}

// 3. configs.all contains comprehensive rules encompassing every recommended rule
{
  const all = getAllConfig();
  const recommended = getRecommendedConfig();

  assert.equal(Object.isFrozen(all), true, 'configs.all must be frozen');

  const allRuleKeys = Object.keys(all.rules);
  const recommendedRuleKeys = Object.keys(recommended.rules);

  assert.ok(
    allRuleKeys.length > recommendedRuleKeys.length,
    `configs.all rules count (${allRuleKeys.length}) must be strictly greater than recommended rules count (${recommendedRuleKeys.length})`
  );

  // Every recommended rule is included in configs.all
  for (const rule of recommendedRuleKeys) {
    assert.ok(
      rule in all.rules,
      `every recommended rule ("${rule}") must be included in configs.all`
    );
  }

  // Every rule in configs.all is set to 'error'
  for (const [rule, setting] of Object.entries(all.rules)) {
    assert.equal(
      setting,
      'error',
      `rule "${rule}" in configs.all must be configured as "error"`
    );
  }
}

console.log('Contract tests for @eslint/js.configs (pkg:npm/%40eslint/js@9.20.0) passed successfully.');

Исходный сидер

аноним