Skip to content

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.

InterfaceDescription
JsonDocumentNodeThe root node of a parsed JSON document.
JsonLiteralNodeA JSON literal - a string, number, boolean or null.
JsonMemberNodeA single "key": value pair of a JSON object.
JsonNodeAny node of the Momoa JSON AST.
JsonObjectNodeA JSON object value.
FunctionDescription
findManifestMemberFinds a top-level member of the manifest by key.
getManifestObjectReads the manifest’s root object out of the visited Document node.
getManifestStringValueReads the value of a top-level string member of the manifest.
getMemberKeyReads 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.
getStringValueReads the value of a Momoa string node.
toReportNodeBridges 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.
VariableDescription
JSON_NODE_TYPE_BOOLEANThe Momoa node type of a JSON boolean value.
JSON_NODE_TYPE_OBJECTThe Momoa node type of a JSON object value.
JSON_NODE_TYPE_STRINGThe 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_VERSIONThe version a plugin repo carries before its first release, when minAppVersion is legitimately absent.