script-utils/linters/eslint-rules/manifest-helpers
Shared helpers for the manifest.json ESLint rules.
The manifest is linted through @eslint/json’s json/json language, whose AST is Momoa (Document -> Object -> Member) rather than ESTree, so these rules visit Document instead of Program. That difference is exactly why obsidianmd/validate-manifest can never fire: it registers a Program visitor and expects an ESTree ObjectExpression, which no shipped JSON parser produces.
The Momoa node shapes are declared structurally here rather than imported from @humanwhocodes/momoa, which is only a transitive dependency of @eslint/json. A type-only import would leak into the published declarations and force every consumer to resolve a package it never installed.
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| JsonDocumentNode | The root node of a parsed JSON document. |
| JsonLiteralNode | A JSON literal - a string, number, boolean or null. |
| JsonMemberNode | A single "key": value pair of a JSON object. |
| JsonNode | Any node of the Momoa JSON AST. |
| JsonObjectNode | A JSON object value. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| findManifestMember | Finds a top-level member of the manifest by key. |
| getManifestObject | Reads the manifest’s root object out of the visited Document node. |
| getManifestStringValue | Reads the value of a top-level string member of the manifest. |
| getMemberKey | Reads a member’s key. Under the json/json language a member’s name is always a string node - identifier keys exist only in JSON5 - so this never has to account for a missing key. |
| getStringValue | Reads the value of a Momoa string node. |
| toReportNode | Bridges a Momoa node to the node type context.report() is typed against. The two are structurally incompatible - ESLint’s rule types describe ESTree - but the json/json language’s source code adapter resolves a Momoa node’s position at report time, so they are compatible at runtime. This mirrors the bridge rule-tester-helper.ts makes over the same kind of type-level gap. |
Variables
Section titled “Variables”| Variable | Description |
|---|---|
| JSON_NODE_TYPE_BOOLEAN | The Momoa node type of a JSON boolean value. |
| JSON_NODE_TYPE_OBJECT | The Momoa node type of a JSON object value. |
| JSON_NODE_TYPE_STRING | The Momoa node type of a JSON string value. |
| jsonPlugin | @eslint/json, typed as the plugin type a flat config and RuleTester are written against. The package’s rule definitions are generic over its own JSON language, which @types/eslint’s ESLint.Plugin - written against ESTree rules - cannot express, so the two are nominally incompatible while being exactly compatible at runtime. Registering it is what makes language: 'json/json' resolvable, so there is no way to avoid the bridge. |
| UNRELEASED_VERSION | The version a plugin repo carries before its first release, when minAppVersion is legitimately absent. |