fix: walk up directory tree to find manifest.json#107
Open
mdbraber wants to merge 1 commit intoobsidianmd:masterfrom
Open
fix: walk up directory tree to find manifest.json#107mdbraber wants to merge 1 commit intoobsidianmd:masterfrom
mdbraber wants to merge 1 commit intoobsidianmd:masterfrom
Conversation
Instead of only looking for manifest.json in the current working directory, walk up the directory tree until a valid Obsidian plugin manifest is found (identified by having an `id` field). This fixes noisy console.error output in monorepo setups where ESLint runs from a workspace root or sub-package that doesn't contain manifest.json directly. The plugin now silently returns null when no manifest is found, which preserves the existing fallback behavior (Node.js imports are disallowed, no Node globals added). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Collaborator
|
I don't like how this walks up the directory tree indefinitely, there should be a limit. |
Author
|
@joethei what would be reasonable limit? if we consider monorepo package structure I would say 2 or 3 would suffice? Or should it be configurable? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
manifest.jsoninprocess.cwd(), walk up the directory tree until a valid Obsidian plugin manifest is found (identified by having anidfield)nullwhen no manifest is found, removing theconsole.errorthat fires in monorepo setupsisDesktopOnlyrules default to the safer option (Node.js imports disallowed, no Node globals)Motivation
In monorepo setups (e.g., pnpm workspaces with Turborepo), ESLint often runs from the workspace root or a sub-package directory — neither of which contains
manifest.json. The current code logs a noisyconsole.error("Failed to load JSON file:", err)every time, even though this is expected and harmless.The walk-up approach mirrors how tools like ESLint itself find config files — start at cwd and check each parent directory. The
idfield check ensures we only match actual Obsidian plugin manifests, not unrelatedmanifest.jsonfiles (e.g., Chrome extensions).Test plan
manifest.jsonis in a parent directory🤖 Generated with Claude Code