サンプル
@eslint/plugin-kit 0.2.8: ConfigCommentParser
検証済みサンプル — npm @eslint/plugin-kit 0.2.8: ConfigCommentParser. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: assert…
sha256:a04e3f4955b932f39fb82399632bd6033ad8e62310b4dc432069d87e358be9de
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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/plugin-kit.ConfigCommentParser in pkg:npm/%40eslint/plugin-kit@0.2.8
- パッケージ
- シンボル
-
- @eslint/plugin-kit.ConfigCommentParser
- 環境
- node 22.23.2
- 作成日
- 2026-09-06T13:06:07Z
コントラクト
- assert ConfigCommentParser.parseDirective parses comments into label, value, and justification
- assert ConfigCommentParser.parseDirective returns undefined for empty or invalid directive text
- assert ConfigCommentParser.parseStringConfig parses key-value pairs into string values and null defaults
- assert ConfigCommentParser.parseListConfig parses comma-separated rule lists into boolean true maps
- assert ConfigCommentParser.parseJSONLikeConfig parses relaxed JSON configs and returns ok true with config
- assert ConfigCommentParser.parseJSONLikeConfig returns ok false with error message for invalid syntax
ファイル
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
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/plugin-kit.ConfigCommentParser in pkg:npm/%40eslint/plugin-kit@0.2.8
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40eslint/plugin-kit@0.2.8
Demonstrate these symbols/APIs:
- @eslint/plugin-kit.ConfigCommentParser
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- runtime: node@22.23.2
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.
{"case":{"caseId":"case:sha256:ab1db0f541c4910ce4dcb3f2110d943bd89f1b2186a8ad502f7ea3103296ac2b","constraints":{"executionContext":"node"},"contract":["assert ConfigCommentParser.parseDirective parses comments into label, value, and justification","assert ConfigCommentParser.parseDirective returns undefined for empty or invalid directive text","assert ConfigCommentParser.parseStringConfig parses key-value pairs into string values and null defaults","assert ConfigCommentParser.parseListConfig parses comma-separated rule lists into boolean true maps","assert ConfigCommentParser.parseJSONLikeConfig parses relaxed JSON configs and returns ok true with config","assert ConfigCommentParser.parseJSONLikeConfig returns ok false with error message for invalid syntax"],"goal":"verify @eslint/plugin-kit.ConfigCommentParser in pkg:npm/%40eslint/plugin-kit@0.2.8","kind":"HOW","packages":["pkg:npm/%40eslint/plugin-kit@0.2.8"],"schemaVersion":1,"symbols":["@eslint/plugin-kit.ConfigCommentParser"]},"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/%40eslint/plugin-kit@0.2.8"],"schemaVersion":1,"subject":"pkg:npm/%40eslint/plugin-kit@0.2.8","symbols":["@eslint/plugin-kit.ConfigCommentParser"],"verifierAdapter":"node-typescript@1"}
const { ConfigCommentParser } = require('@eslint/plugin-kit');
/**
* Parses an ESLint directive comment string into its components.
*
* @param {string} comment - Comment text without comment delimiters.
* @returns {object|undefined} Parsed directive or undefined if invalid.
*/
function parseCommentDirective(comment) {
const parser = new ConfigCommentParser();
return parser.parseDirective(comment);
}
/**
* Parses a comma- or whitespace-separated list of configuration options.
*
* @param {string} text - Configuration string in format "name:value, name".
* @returns {Record<string, string|null>} Map of names to string values or null.
*/
function parseStringConfig(text) {
const parser = new ConfigCommentParser();
return parser.parseStringConfig(text);
}
/**
* Parses a comma-separated list of rule names.
*
* @param {string} text - List of rule names separated by commas.
* @returns {Record<string, true>} Map of rule names to boolean true.
*/
function parseListConfig(text) {
const parser = new ConfigCommentParser();
return parser.parseListConfig(text);
}
/**
* Parses a relaxed JSON-like configuration string.
*
* @param {string} text - JSON-like configuration string.
* @returns {{ ok: true, config: object } | { ok: false, error: { message: string } }} Parsing result.
*/
function parseJSONLikeConfig(text) {
const parser = new ConfigCommentParser();
return parser.parseJSONLikeConfig(text);
}
module.exports = {
ConfigCommentParser,
parseCommentDirective,
parseStringConfig,
parseListConfig,
parseJSONLikeConfig,
};
{
"name": "sample-eslint-plugin-kit-config-comment-parser",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-eslint-plugin-kit-config-comment-parser",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@eslint/plugin-kit": "0.2.8"
}
},
"node_modules/@eslint/core": {
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.13.0.tgz",
"integrity": "sha512-yfkgDw1KR66rkT5A8ci4irzDysN7FRpq3ttJolR88OqQikAWqwA8j5VZyas+vjyBNFIJ7MfybJ9plMILI2UrCw==",
"license": "Apache-2.0",
"dependencies": {
"@types/json-schema": "^7.0.15"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
},
"node_modules/@eslint/plugin-kit": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.8.tgz",
"integrity": "sha512-ZAoA40rNMPwSm+AeHpCq8STiNAwzWLJuP8Xv4CHIc9wv/PSuExjMrmjfYNj682vW0OOiZ1HKxzvjQr9XZIisQA==",
"license": "Apache-2.0",
"dependencies": {
"@eslint/core": "^0.13.0",
"levn": "^0.4.1"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
},
"node_modules/@types/json-schema": {
"version": "7.0.15",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"license": "MIT"
},
"node_modules/levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
"integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
"license": "MIT",
"dependencies": {
"prelude-ls": "^1.2.1",
"type-check": "~0.4.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"license": "MIT",
"dependencies": {
"prelude-ls": "^1.2.1"
},
"engines": {
"node": ">= 0.8.0"
}
}
}
}
{
"name": "sample-eslint-plugin-kit-config-comment-parser",
"version": "1.0.0",
"description": "Clean-room sample verifying @eslint/plugin-kit ConfigCommentParser",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"@eslint/plugin-kit": "0.2.8"
}
}
{
"schemaVersion": 1,
"goal": "verify @eslint/plugin-kit.ConfigCommentParser in pkg:npm/%40eslint/plugin-kit@0.2.8",
"kind": "HOW",
"packages": [
"pkg:npm/%40eslint/plugin-kit@0.2.8"
],
"symbols": [
"@eslint/plugin-kit.ConfigCommentParser"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert';
import {
ConfigCommentParser,
parseCommentDirective,
parseStringConfig,
parseListConfig,
parseJSONLikeConfig,
} from '../index.js';
// 1. Verify ConfigCommentParser.parseDirective
const parser = new ConfigCommentParser();
const directiveWithJustification = parser.parseDirective(
'eslint-disable prefer-const, semi -- disable rules with comment'
);
assert.strictEqual(directiveWithJustification.label, 'eslint-disable');
assert.strictEqual(directiveWithJustification.value, 'prefer-const, semi');
assert.strictEqual(
directiveWithJustification.justification,
'disable rules with comment'
);
const directiveWithoutJustification = parser.parseDirective('eslint-enable no-console');
assert.strictEqual(directiveWithoutJustification.label, 'eslint-enable');
assert.strictEqual(directiveWithoutJustification.value, 'no-console');
assert.strictEqual(directiveWithoutJustification.justification, '');
const emptyDirective = parser.parseDirective('');
assert.strictEqual(emptyDirective, undefined);
const nonDirective = parser.parseDirective('!eslint-disable');
assert.strictEqual(nonDirective, undefined);
const helperDirective = parseCommentDirective(
'eslint-disable-line no-undef -- inline suppression'
);
assert.strictEqual(helperDirective.label, 'eslint-disable-line');
assert.strictEqual(helperDirective.value, 'no-undef');
assert.strictEqual(helperDirective.justification, 'inline suppression');
// 2. Verify ConfigCommentParser.parseStringConfig
const stringConfigResult = parser.parseStringConfig('quotes: single, semi: always, indent');
assert.deepStrictEqual(stringConfigResult, {
quotes: 'single',
semi: 'always',
indent: null,
});
const helperStringConfig = parseStringConfig('env: browser, es6');
assert.deepStrictEqual(helperStringConfig, {
env: 'browser',
es6: null,
});
// 3. Verify ConfigCommentParser.parseListConfig
const listConfigResult = parser.parseListConfig('no-unused-vars, eqeqeq, curly');
assert.deepStrictEqual(listConfigResult, {
'no-unused-vars': true,
eqeqeq: true,
curly: true,
});
const quotedListConfig = parser.parseListConfig('"no-alert", \'no-debugger\'');
assert.deepStrictEqual(quotedListConfig, {
'no-alert': true,
'no-debugger': true,
});
const helperListConfig = parseListConfig('no-alert, no-debugger');
assert.deepStrictEqual(helperListConfig, {
'no-alert': true,
'no-debugger': true,
});
// 4. Verify ConfigCommentParser.parseJSONLikeConfig
const validJSONResult = parser.parseJSONLikeConfig(
'semi: ["error", "never"], prefer-const: "warn"'
);
assert.strictEqual(validJSONResult.ok, true);
assert.deepStrictEqual(validJSONResult.config, {
semi: ['error', 'never'],
'prefer-const': 'warn',
});
const invalidJSONResult = parser.parseJSONLikeConfig('invalid { json syntax');
assert.strictEqual(invalidJSONResult.ok, false);
assert.ok(invalidJSONResult.error);
assert.strictEqual(typeof invalidJSONResult.error.message, 'string');
const helperJSONResult = parseJSONLikeConfig('rules: { indent: 2 }');
assert.strictEqual(helperJSONResult.ok, true);
assert.deepStrictEqual(helperJSONResult.config, {
rules: { indent: 2 },
});
console.log('All ConfigCommentParser contract assertions passed successfully.');
オリジンシーダー
匿名