linters/eslint-rules/no-local-obsidian-internals
ESLint rule: no-local-obsidian-internals
Reports every member a declare module 'obsidian' augmentation adds to Obsidian’s types.
Obsidian’s internal (undocumented) API is typed in obsidian-typings, where each member is checked against the shipped app.js on every release that has it. A local augmentation is a second, unchecked copy of the same claim: it drifts from what Obsidian actually ships, and when obsidian-typings gains the member the two declarations merge silently, or clash. The fix for a member obsidian-typings lacks or declares wrongly goes into obsidian-typings, and the consumer imports it from there.
One shape is exempt: an overload of on, off, trigger or tryTrigger whose first parameter is a string-literal type, or a union of them. That is how a plugin types its OWN custom events on Workspace or another Events subclass, so it describes the plugin’s code rather than Obsidian’s. A name typed through an alias (name: MyEventName) is recognized only when the file is linted with type information, which the shared configuration always has.
Only the module named exactly obsidian is read. A declare module 'obsidian-typings' augmentation of PluginsPluginsRecord is obsidian-typings’ designed extension point for third-party plugin types, and is not reported.
Not attempted: a local interface or an inline cast that spells an internal shape cannot be told apart from a repository’s own types mechanically, so those are left to review.
Variables
Section titled “Variables”| Variable | Description |
|---|---|
| MESSAGE_ID | Message ID reported for a member a declare module 'obsidian' augmentation adds. |
| noLocalObsidianInternals | ESLint rule disallowing locally declared Obsidian internals in a declare module 'obsidian' augmentation. |