CodeSampleX

サンプル

@eslint/js 9.20.0: configs

検証済みサンプル — npm @eslint/js 9.20.0: configs. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: configs provides recommended and all configuration…

sha256:dc5e7865bd22b4c6eb75e5e8010db25e6ac0166b55f23d4e0d1e58f2fe552030

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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.');

オリジンシーダー

匿名