Current audit of Vault Share - Obsidian Plugin flags many type errors which I do not see in my local dev environment, using the same obsidianmd/eslint-plugin.
All these warnings significantly reduce my review score and make me look careless! ![]()
Summary
Most of the warnings come from lack of obsidian module in the audit environment, where it is obviously present in my local plugin dev environment.
The rest of the warnings come from a second source tree in my repo which produces a Cloudflare worker rather than an obsidian plugin. Arguably, I should move that source tree to another repo to avoid confusion.
But the warnings have the same origin: the second tree depends on @cloudflare/workers-types and the audit environment doesn’t import that. My project eslint config contains globalIgnores google-auth-relay/** and the audit environment also ignores that.
So the tl;dr is that the audit environment ought to pay more attention to the project dependencies and lint config, or should provide some reliable means to suppress false-positive warnings.
I’m focusing here on the lack of obsidian module, which I really think the audit environment for an obsidian plugin ought to support.
Minimal A/B reproduction
I temporarily removed package obsidian from my local project node_modules/, then ran npx eslint src/gdrive/api.ts:
WITHOUT obsidian types (to simulate the audit env):
61 problems (61 errors, 0 warnings)
29 @typescript-eslint/no-unsafe-member-access
15 @typescript-eslint/no-unsafe-argument
12 @typescript-eslint/no-unsafe-assignment
2 @typescript-eslint/no-unsafe-return
2 @typescript-eslint/no-redundant-type-constituents
1 @typescript-eslint/no-unsafe-call
WITH types installed:
npx eslint src/gdrive/api.ts → clean (exit 0).
Those are the same warnings as the audit flagged for that source file. Repeating the test on the whole src/ tree produces the same number of issues as the audit env, leading me to believe all the warnings can be resolved by the one simple trick.
Suggested fix
Make obsidian’s types available to the audit’s type-checker:
- install the declared obsidian devDependency
- put obsidian.d.ts on the TS path before running type-checked rules
The other way to go is to suppress unsafe-type-* checking in cases where it spews false positives, but I’d rather have the audit environment be more picky than less.