CodeSampleX

샘플

@eslint/config-array 0.21.2: ConfigArray

검증된 샘플 — npm @eslint/config-array 0.21.2: ConfigArray. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: ConfigArray can be instantiated with…

sha256:ff591ff703185460973af63fbaa470bcadf474e9ec3f3cea9afbb0780a70686f

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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/config-array.ConfigArray in pkg:npm/%40eslint/config-array@0.21.2
패키지
심벌
  • @eslint/config-array.ConfigArray
환경
node 22.23.2
생성일
2026-09-06T16:06:55Z

컨트랙트

  1. ConfigArray can be instantiated with config objects, basePath, and schema
  2. normalizeSync normalizes configuration objects and sets isNormalized to true
  3. getConfig returns the merged configuration matching the file path
  4. getConfigWithStatus returns the configuration along with matched or unconfigured status
  5. getConfigStatus returns matched for matching files and unconfigured for non-matching files
  6. isFileIgnored returns true for paths matching ignore patterns and false otherwise
  7. isDirectoryIgnored correctly identifies ignored directories

파일

  • 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/config-array.ConfigArray in pkg:npm/%40eslint/config-array@0.21.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40eslint/config-array@0.21.2
Demonstrate these symbols/APIs:
  - @eslint/config-array.ConfigArray

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:3fcd04619445b158e779d1d387ea8fc42c9e004be38530d46fbd15cd0c6afb18","contract":["ConfigArray can be instantiated with config objects, basePath, and schema","normalizeSync normalizes configuration objects and sets isNormalized to true","getConfig returns the merged configuration matching the file path","getConfigWithStatus returns the configuration along with matched or unconfigured status","getConfigStatus returns matched for matching files and unconfigured for non-matching files","isFileIgnored returns true for paths matching ignore patterns and false otherwise","isDirectoryIgnored correctly identifies ignored directories"],"goal":"verify @eslint/config-array.ConfigArray in pkg:npm/%40eslint/config-array@0.21.2","kind":"HOW","packages":["pkg:npm/%40eslint/config-array@0.21.2"],"schemaVersion":1,"symbols":["@eslint/config-array.ConfigArray"]},"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/%40eslint/config-array@0.21.2"],"schemaVersion":1,"subject":"pkg:npm/%40eslint/config-array@0.21.2","symbols":["@eslint/config-array.ConfigArray"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-eslint-config-array",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-eslint-config-array",
      "version": "1.0.0",
      "dependencies": {
        "@eslint/config-array": "0.21.2"
      }
    },
    "node_modules/@eslint/config-array": {
      "version": "0.21.2",
      "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.2.tgz",
      "integrity": "sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==",
      "license": "Apache-2.0",
      "dependencies": {
        "@eslint/object-schema": "^2.1.7",
        "debug": "^4.3.1",
        "minimatch": "^3.1.5"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      }
    },
    "node_modules/@eslint/object-schema": {
      "version": "2.1.7",
      "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz",
      "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==",
      "license": "Apache-2.0",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "1.1.18",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
      "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0",
        "concat-map": "0.0.1"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
      "license": "MIT"
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/minimatch": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
      "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^1.1.7"
      },
      "engines": {
        "node": "*"
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "verify-eslint-config-array",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "@eslint/config-array": "0.21.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @eslint/config-array.ConfigArray in pkg:npm/%40eslint/config-array@0.21.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40eslint/config-array@0.21.2"
  ],
  "symbols": [
    "@eslint/config-array.ConfigArray"
  ]
}
src/index.mjs
import { ConfigArray } from '@eslint/config-array';

/**
 * Creates and normalizes a ConfigArray instance with optional basePath and schema.
 *
 * @param {Array<Object>} configs - Configuration objects array.
 * @param {Object} [options] - Options passed to ConfigArray.
 * @returns {ConfigArray} The normalized ConfigArray instance.
 */
export function createConfigArray(configs, options = {}) {
  const configArray = new ConfigArray(configs, options);
  configArray.normalizeSync();
  return configArray;
}

export { ConfigArray };
test/contract.mjs
import assert from 'node:assert/strict';
import { ConfigArray, createConfigArray } from '../src/index.mjs';

const customSchema = {
  settings: {
    validate(value) {
      if (typeof value !== 'object' || value === null) {
        throw new TypeError('Settings must be an object');
      }
    },
    merge(first = {}, second = {}) {
      return { ...first, ...second };
    }
  },
  rules: {
    validate(value) {
      if (typeof value !== 'object' || value === null) {
        throw new TypeError('Rules must be an object');
      }
    },
    merge(first = {}, second = {}) {
      return { ...first, ...second };
    }
  }
};

const rawConfigs = [
  {
    name: 'base-js',
    files: ['**/*.js'],
    settings: { env: 'node', version: 20 },
    rules: { semi: 'always', quotes: 'double' }
  },
  {
    name: 'test-overrides',
    files: ['**/test/**/*.js', '**/*.test.js'],
    settings: { env: 'jest' },
    rules: { quotes: 'single' }
  },
  {
    name: 'global-ignores',
    ignores: ['**/dist/**', '**/coverage/**', 'build/']
  }
];

// 1. ConfigArray can be instantiated with config objects, basePath, and schema
const configArray = new ConfigArray(rawConfigs, {
  basePath: '/workspace/project',
  schema: customSchema
});
assert.ok(configArray instanceof ConfigArray, 'configArray must be an instance of ConfigArray');
assert.equal(configArray.basePath, '/workspace/project', 'basePath should match constructor option');
assert.equal(configArray.isNormalized(), false, 'isNormalized should initially be false');

// 2. normalizeSync normalizes configuration objects and sets isNormalized to true
configArray.normalizeSync();
assert.equal(configArray.isNormalized(), true, 'isNormalized should be true after normalizeSync()');

// 3. getConfig returns the merged configuration matching the file path
const srcConfig = configArray.getConfig('/workspace/project/src/index.js');
assert.ok(srcConfig, 'src/index.js should have a matching config');
assert.deepEqual(srcConfig.settings, { env: 'node', version: 20 }, 'src/index.js settings should match base-js');
assert.equal(srcConfig.rules.semi, 'always', 'rules.semi should be always');
assert.equal(srcConfig.rules.quotes, 'double', 'rules.quotes should be double');

const testConfig = configArray.getConfig('/workspace/project/test/unit.test.js');
assert.ok(testConfig, 'test/unit.test.js should have a matching config');
assert.deepEqual(testConfig.settings, { env: 'jest', version: 20 }, 'test config should merge base settings with test-overrides settings');
assert.equal(testConfig.rules.quotes, 'single', 'test config should override quotes rule to single');
assert.equal(testConfig.rules.semi, 'always', 'test config should inherit unmodified semi rule');

// 4. getConfigWithStatus returns the configuration along with matched or unconfigured status
const matchedResult = configArray.getConfigWithStatus('/workspace/project/src/index.js');
assert.equal(matchedResult.status, 'matched', 'status should be matched');
assert.deepEqual(matchedResult.config.settings, { env: 'node', version: 20 }, 'matched config settings should match');

const unconfiguredResult = configArray.getConfigWithStatus('/workspace/project/README.txt');
assert.equal(unconfiguredResult.status, 'unconfigured', 'status should be unconfigured');
assert.equal(unconfiguredResult.config, undefined, 'config should be undefined when unconfigured');

// 5. getConfigStatus returns matched for matching files and unconfigured for non-matching files
const srcStatus = configArray.getConfigStatus('/workspace/project/src/index.js');
assert.equal(srcStatus, 'matched', 'status for matched file should be matched');

const txtStatus = configArray.getConfigStatus('/workspace/project/README.txt');
assert.equal(txtStatus, 'unconfigured', 'status for unconfigured file should be unconfigured');

// 6. isFileIgnored returns true for paths matching ignore patterns and false otherwise
assert.equal(configArray.isFileIgnored('/workspace/project/dist/bundle.js'), true, 'dist/bundle.js should be ignored');
assert.equal(configArray.isFileIgnored('/workspace/project/coverage/lcov.info'), true, 'coverage file should be ignored');
assert.equal(configArray.isFileIgnored('/workspace/project/src/index.js'), false, 'src/index.js should not be ignored');

// 7. isDirectoryIgnored correctly identifies ignored directories
assert.equal(configArray.isDirectoryIgnored('/workspace/project/build'), true, 'build/ directory should be ignored');
assert.equal(configArray.isDirectoryIgnored('/workspace/project/src'), false, 'src directory should not be ignored');

// Helper createConfigArray test
const helperInstance = createConfigArray(rawConfigs, {
  basePath: '/workspace/project',
  schema: customSchema
});
assert.ok(helperInstance.isNormalized(), 'createConfigArray returns a pre-normalized instance');
assert.deepEqual(
  helperInstance.getConfig('/workspace/project/src/index.js'),
  srcConfig,
  'helper instance matches standalone instance behavior'
);

console.log('Contract assertions passed.');

오리진 시더

익명