CodeSampleX

Beispiel

@eslint/eslintrc 3.3.6: Legacy

Verifiziertes Beispiel für npm @eslint/eslintrc 3.3.6: Legacy. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:759b5cd54f27482e374f0be55b639c7f4ee5ebb1e41f9d2166d919385d227c5b

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-04

Fall

HOW
Ziel
verify @eslint/eslintrc.Legacy in pkg:npm/%40eslint/eslintrc@3.3.6
Pakete
Symbole
  • @eslint/eslintrc.Legacy
Erstellt
2026-09-04T11:47:40Z

Contract

  1. Legacy.environments exposes predefined environment configs with builtin globals and parser options
  2. Legacy.naming normalizes plugin package names with prefixes and resolves shorthand identifiers
  3. Legacy.ConfigOps resolves and checks rule severity values across numeric, string, and array formats
  4. Legacy.ConfigOps normalizes rule severities to strings in configuration objects and standardizes global variable settings
  5. Legacy.ConfigValidator validates legacy configuration structures against schema and rejects invalid property types

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/eslintrc.Legacy in pkg:npm/%40eslint/eslintrc@3.3.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40eslint/eslintrc@3.3.6
Demonstrate these symbols/APIs:
  - @eslint/eslintrc.Legacy

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:de55c82b6d7b9c80c951c47ff38a836fadf2418613df6d47422d1cbb634d4180","contract":["Legacy.environments exposes predefined environment configs with builtin globals and parser options","Legacy.naming normalizes plugin package names with prefixes and resolves shorthand identifiers","Legacy.ConfigOps resolves and checks rule severity values across numeric, string, and array formats","Legacy.ConfigOps normalizes rule severities to strings in configuration objects and standardizes global variable settings","Legacy.ConfigValidator validates legacy configuration structures against schema and rejects invalid property types"],"goal":"verify @eslint/eslintrc.Legacy in pkg:npm/%40eslint/eslintrc@3.3.6","kind":"HOW","packages":["pkg:npm/%40eslint/eslintrc@3.3.6"],"schemaVersion":1,"symbols":["@eslint/eslintrc.Legacy"]},"contractCommand":["node","test/contract.cjs"],"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/eslintrc@3.3.6"],"schemaVersion":1,"subject":"pkg:npm/%40eslint/eslintrc@3.3.6","symbols":["@eslint/eslintrc.Legacy"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-eslint-eslintrc-legacy",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-eslint-eslintrc-legacy",
      "version": "1.0.0",
      "dependencies": {
        "@eslint/eslintrc": "3.3.6"
      }
    },
    "node_modules/@eslint/eslintrc": {
      "version": "3.3.6",
      "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.6.tgz",
      "integrity": "sha512-l2Ul9PrHsPCKcEY/ac7VgFj9D80C7S68sOKc618SyHDPK36s1XcFebXY0iTzUVn4Yq+YbwvSnDmCz9yxjX+QrA==",
      "license": "MIT",
      "dependencies": {
        "ajv": "^6.14.0",
        "debug": "^4.3.2",
        "espree": "^10.0.1",
        "globals": "^14.0.0",
        "ignore": "^5.2.0",
        "import-fresh": "^3.2.1",
        "js-yaml": "^4.3.0",
        "minimatch": "^3.1.5",
        "strip-json-comments": "^3.1.1"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "url": "https://opencollective.com/eslint"
      }
    },
    "node_modules/acorn": {
      "version": "8.18.0",
      "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
      "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
      "license": "MIT",
      "bin": {
        "acorn": "bin/acorn"
      },
      "engines": {
        "node": ">=0.4.0"
      }
    },
    "node_modules/acorn-jsx": {
      "version": "5.3.2",
      "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
      "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
      "license": "MIT",
      "peerDependencies": {
        "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
      }
    },
    "node_modules/ajv": {
      "version": "6.15.0",
      "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz",
      "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
      "license": "MIT",
      "dependencies": {
        "fast-deep-equal": "^3.1.1",
        "fast-json-stable-stringify": "^2.0.0",
        "json-schema-traverse": "^0.4.1",
        "uri-js": "^4.2.2"
      },
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/epoberezkin"
      }
    },
    "node_modules/argparse": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
      "license": "Python-2.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/callsites": {
      "version": "3.1.0",
      "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
      "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "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/eslint-visitor-keys": {
      "version": "4.2.1",
      "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
      "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
      "license": "Apache-2.0",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "url": "https://opencollective.com/eslint"
      }
    },
    "node_modules/espree": {
      "version": "10.4.0",
      "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz",
      "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==",
      "license": "BSD-2-Clause",
      "dependencies": {
        "acorn": "^8.15.0",
        "acorn-jsx": "^5.3.2",
        "eslint-visitor-keys": "^4.2.1"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "url": "https://opencollective.com/eslint"
      }
    },
    "node_modules/fast-deep-equal": {
      "version": "3.1.3",
      "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
      "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
      "license": "MIT"
    },
    "node_modules/fast-json-stable-stringify": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
      "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
      "license": "MIT"
    },
    "node_modules/globals": {
      "version": "14.0.0",
      "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
      "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/ignore": {
      "version": "5.3.2",
      "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
      "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",
      "license": "MIT",
      "engines": {
        "node": ">= 4"
      }
    },
    "node_modules/import-fresh": {
      "version": "3.3.1",
      "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
      "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
      "license": "MIT",
      "dependencies": {
        "parent-module": "^1.0.0",
        "resolve-from": "^4.0.0"
      },
      "engines": {
        "node": ">=6"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/js-yaml": {
      "version": "4.3.2",
      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz",
      "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/puzrin"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/nodeca"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "argparse": "^2.0.1"
      },
      "bin": {
        "js-yaml": "bin/js-yaml.js"
      }
    },
    "node_modules/json-schema-traverse": {
      "version": "0.4.1",
      "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
      "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
      "license": "MIT"
    },
    "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"
    },
    "node_modules/parent-module": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
      "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
      "license": "MIT",
      "dependencies": {
        "callsites": "^3.0.0"
      },
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/punycode": {
      "version": "2.3.1",
      "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
      "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/resolve-from": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
      "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
      "license": "MIT",
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/strip-json-comments": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
      "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/uri-js": {
      "version": "4.4.1",
      "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
      "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
      "license": "BSD-2-Clause",
      "dependencies": {
        "punycode": "^2.1.0"
      }
    }
  }
}
package.json
{
  "name": "verify-eslint-eslintrc-legacy",
  "version": "1.0.0",
  "private": true,
  "description": "verify @eslint/eslintrc.Legacy in pkg:npm/@eslint/eslintrc@3.3.6",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@eslint/eslintrc": "3.3.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @eslint/eslintrc.Legacy in pkg:npm/%40eslint/eslintrc@3.3.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40eslint/eslintrc@3.3.6"
  ],
  "symbols": [
    "@eslint/eslintrc.Legacy"
  ]
}
src/index.js
const { Legacy } = require('@eslint/eslintrc');

/**
 * Accesses legacy predefined environment configurations.
 * @param {string} envName - Environment name (e.g., 'browser', 'node', 'es6')
 * @returns {object|undefined} Environment configuration object
 */
function getBuiltinEnvironment(envName) {
  return Legacy.environments.get(envName);
}

/**
 * Normalizes an ESLint plugin package name with prefix.
 * @param {string} name - Plugin name or shorthand
 * @returns {string} Normalized plugin package name
 */
function normalizePluginName(name) {
  return Legacy.naming.normalizePackageName(name, 'eslint-plugin');
}

/**
 * Strips prefix from an ESLint plugin package name.
 * @param {string} fullName - Full plugin package name
 * @returns {string} Shorthand plugin name
 */
function getPluginShorthand(fullName) {
  return Legacy.naming.getShorthandName(fullName, 'eslint-plugin');
}

/**
 * Resolves rule severity to a numeric level (0: off, 1: warn, 2: error).
 * @param {string|number|Array} ruleConfig - Rule configuration
 * @returns {number} Numeric severity
 */
function resolveRuleSeverity(ruleConfig) {
  return Legacy.ConfigOps.getRuleSeverity(ruleConfig);
}

/**
 * Checks whether a rule configuration resolves to error severity.
 * @param {string|number|Array} ruleConfig - Rule configuration
 * @returns {boolean} True if error severity
 */
function isErrorSeverity(ruleConfig) {
  return Legacy.ConfigOps.isErrorSeverity(ruleConfig);
}

/**
 * Normalizes numeric rule severities in a configuration to string names.
 * @param {object} config - ESLint configuration object
 */
function normalizeConfigRules(config) {
  Legacy.ConfigOps.normalizeToStrings(config);
}

/**
 * Normalizes global variable configuration values to standard identifiers.
 * @param {boolean|string} value - Configured global value
 * @returns {string} Normalized value ('readonly', 'writable', 'off')
 */
function normalizeGlobalSetting(value) {
  return Legacy.ConfigOps.normalizeConfigGlobal(value);
}

/**
 * Validates a legacy ESLint configuration against schema.
 * @param {object} config - Configuration object to validate
 * @param {string} [source='config'] - Source name for error messages
 */
function validateLegacyConfig(config, source = 'config') {
  const validator = new Legacy.ConfigValidator();
  validator.validateConfigSchema(config, source);
}

module.exports = {
  Legacy,
  getBuiltinEnvironment,
  normalizePluginName,
  getPluginShorthand,
  resolveRuleSeverity,
  isErrorSeverity,
  normalizeConfigRules,
  normalizeGlobalSetting,
  validateLegacyConfig,
};
test/contract.cjs
const assert = require('node:assert/strict');
const { Legacy } = require('@eslint/eslintrc');
const {
  getBuiltinEnvironment,
  normalizePluginName,
  getPluginShorthand,
  resolveRuleSeverity,
  isErrorSeverity,
  normalizeConfigRules,
  normalizeGlobalSetting,
  validateLegacyConfig,
} = require('../src/index.js');

// 1. Legacy.environments exposes predefined environment configs with builtin globals and parser options
assert.ok(Legacy.environments.has('browser'), 'environments map should contain browser environment');
assert.ok(Legacy.environments.has('es6'), 'environments map should contain es6 environment');
assert.ok(Legacy.environments.has('node'), 'environments map should contain node environment');

const browserEnv = getBuiltinEnvironment('browser');
assert.ok(browserEnv && browserEnv.globals, 'browser environment should define globals');
assert.strictEqual(browserEnv.globals.window, false, 'browser window global should be defined as false (readonly)');
assert.strictEqual(browserEnv.globals.document, false, 'browser document global should be defined as false (readonly)');

const es6Env = getBuiltinEnvironment('es6');
assert.ok(es6Env && es6Env.globals && es6Env.parserOptions, 'es6 environment should define globals and parserOptions');
assert.strictEqual(es6Env.globals.Promise, false, 'es6 Promise global should be defined');
assert.strictEqual(es6Env.globals.Map, false, 'es6 Map global should be defined');
assert.strictEqual(es6Env.parserOptions.ecmaVersion, 6, 'es6 environment should configure ecmaVersion to 6');

// 2. Legacy.naming normalizes plugin package names with prefixes and resolves shorthand identifiers
assert.strictEqual(
  normalizePluginName('react'),
  'eslint-plugin-react',
  'unprefixed plugin name should receive eslint-plugin- prefix'
);
assert.strictEqual(
  normalizePluginName('eslint-plugin-react'),
  'eslint-plugin-react',
  'already prefixed plugin name should remain unchanged'
);
assert.strictEqual(
  normalizePluginName('@example/custom'),
  '@example/eslint-plugin-custom',
  'scoped plugin name should have prefix inserted after scope'
);
assert.strictEqual(
  normalizePluginName('@example'),
  '@example/eslint-plugin',
  'scope-only shorthand should resolve to scope/eslint-plugin'
);

assert.strictEqual(
  getPluginShorthand('eslint-plugin-react'),
  'react',
  'shorthand resolution should strip eslint-plugin- prefix'
);
assert.strictEqual(
  getPluginShorthand('@example/eslint-plugin-custom'),
  '@example/custom',
  'shorthand resolution should strip prefix from scoped plugin'
);

// 3. Legacy.ConfigOps resolves and checks rule severity values across numeric, string, and array formats
assert.strictEqual(resolveRuleSeverity('off'), 0, 'string off should resolve to severity 0');
assert.strictEqual(resolveRuleSeverity(0), 0, 'numeric 0 should resolve to severity 0');
assert.strictEqual(resolveRuleSeverity('warn'), 1, 'string warn should resolve to severity 1');
assert.strictEqual(resolveRuleSeverity(['warn', 'always']), 1, 'rule config array with warn should resolve to 1');
assert.strictEqual(resolveRuleSeverity('error'), 2, 'string error should resolve to severity 2');
assert.strictEqual(resolveRuleSeverity([2, { opt: true }]), 2, 'rule config array with numeric 2 should resolve to 2');
assert.strictEqual(resolveRuleSeverity('unrecognized'), 0, 'unknown severity string should fallback to 0');

assert.strictEqual(isErrorSeverity(2), true, 'numeric 2 is error severity');
assert.strictEqual(isErrorSeverity('error'), true, 'string error is error severity');
assert.strictEqual(isErrorSeverity(['error']), true, 'array containing error is error severity');
assert.strictEqual(isErrorSeverity('warn'), false, 'warn is not error severity');
assert.strictEqual(isErrorSeverity(0), false, 'off is not error severity');

assert.strictEqual(Legacy.ConfigOps.isValidSeverity(0), true, 'numeric 0 is valid severity');
assert.strictEqual(Legacy.ConfigOps.isValidSeverity('warn'), true, 'warn is valid severity');
assert.strictEqual(Legacy.ConfigOps.isValidSeverity('error'), true, 'error is valid severity');
assert.strictEqual(Legacy.ConfigOps.isValidSeverity('invalid'), false, 'invalid string is not valid severity');

// 4. Legacy.ConfigOps normalizes rule severities to strings in configuration objects and standardizes global variable settings
const configToNormalize = {
  rules: {
    'no-unused-vars': 2,
    'semi': 1,
    'no-debugger': 0,
    'quotes': [1, 'single'],
  },
};
normalizeConfigRules(configToNormalize);
assert.strictEqual(configToNormalize.rules['no-unused-vars'], 'error', 'numeric 2 should be normalized to error');
assert.strictEqual(configToNormalize.rules['semi'], 'warn', 'numeric 1 should be normalized to warn');
assert.strictEqual(configToNormalize.rules['no-debugger'], 'off', 'numeric 0 should be normalized to off');
assert.deepStrictEqual(
  configToNormalize.rules['quotes'],
  ['warn', 'single'],
  'first element of rule option array should be normalized'
);

assert.strictEqual(normalizeGlobalSetting(true), 'writable', 'boolean true should normalize to writable');
assert.strictEqual(normalizeGlobalSetting('writable'), 'writable', 'writable string should remain writable');
assert.strictEqual(normalizeGlobalSetting(false), 'readonly', 'boolean false should normalize to readonly');
assert.strictEqual(normalizeGlobalSetting('readonly'), 'readonly', 'readonly string should remain readonly');
assert.strictEqual(normalizeGlobalSetting('off'), 'off', 'off string should remain off');

assert.throws(
  () => normalizeGlobalSetting('unsupported-mode'),
  /'unsupported-mode' is not a valid configuration for a global/,
  'invalid global setting value should throw descriptive error'
);

// 5. Legacy.ConfigValidator validates legacy configuration structures against schema and rejects invalid property types
assert.doesNotThrow(() => {
  validateLegacyConfig(
    {
      rules: {
        semi: 'error',
        eqeqeq: ['warn', 'always'],
      },
      env: {
        browser: true,
        es6: true,
      },
    },
    'valid-sample-config'
  );
}, 'valid legacy configuration object should pass schema validation');

assert.throws(
  () => {
    validateLegacyConfig(
      {
        rules: 'invalid-rules-type-string',
      },
      'invalid-sample-config'
    );
  },
  /Property "rules" is the wrong type/,
  'configuration with non-object rules property should fail schema validation'
);

console.log('All contract assertions passed successfully.');

Ursprungs-Seeder

anonym