eslint-plugin-obsidianmd

August 24, 2026 · View on GitHub

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-obsidianmd:

npm install eslint-plugin-obsidianmd --save-dev

Usage

Add the recommended configuration to your eslint.config.mjs. This enables all recommended rules, including ESLint core, typescript-eslint type-checked rules, and Obsidian-specific rules.

// eslint.config.mjs
import { defineConfig } from "eslint/config";
import obsidianmd from "eslint-plugin-obsidianmd";

export default defineConfig([
  ...obsidianmd.configs.recommended,
  {
    languageOptions: {
      parserOptions: {
        projectService: {
          allowDefaultProject: ["eslint.config.*"],
        },
      },
    },
    rules: {
      // example: turn off a rule from the recommended set
      "obsidianmd/sample-names": "off",
    },
  },
]);

The parserOptions block is required because the recommended config includes type-checked rules that need access to your TypeScript project. allowDefaultProject ensures files not listed in your tsconfig.json (like the ESLint config file itself) are still linted without errors. See the configuration guide for details on why this is needed and how to customize it.

Note: You do not need to separately add eslint.configs.recommended or tseslint.configs.recommended — both are already included in the recommended config.

For advanced usage — layering stricter typescript-eslint configs, ignoring files, disabling rules for non-plugin code, and troubleshooting common errors — see the configuration guide.

Configurations

Name
recommended
🇬🇧recommendedWithLocalesEn

Rules

💼 Configurations enabled in.
⚠️ Configurations set to warn in.
🚫 Configurations disabled in.
✅ Set in the recommended configuration.
🇬🇧 Set in the recommendedWithLocalesEn configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.

Name                                         Description💼⚠️🚫🔧💡
commands/no-command-in-command-idDisallow using the word 'command' in a command ID.✅ 🇬🇧
commands/no-command-in-command-nameDisallow using the word 'command' in a command name.✅ 🇬🇧
commands/no-default-hotkeysDiscourage providing default hotkeys for commands.✅ 🇬🇧
commands/no-plugin-id-in-command-idDisallow including the plugin ID in a command ID.✅ 🇬🇧
commands/no-plugin-name-in-command-nameDisallow including the plugin name in a command name.✅ 🇬🇧
detach-leavesDon't detach leaves in onunload.✅ 🇬🇧🔧
editor-drop-pasteRequire checking evt.defaultPrevented and calling evt.preventDefault() in editor-drop/editor-paste handlers.✅ 🇬🇧
hardcoded-config-pathDisallow hardcoded .obsidian config paths. Use Vault#configDir instead.✅ 🇬🇧
no-forbidden-elementsDisallow attachment of forbidden elements to the DOM in Obsidian plugins.✅ 🇬🇧
no-global-thisDisallow global and globalThis. Use window or activeWindow for popout window compatibility.✅ 🇬🇧🔧
no-nodejs-modulesDisallow importing Node.js built-in modules unless guarded by Platform.isDesktop✅ 🇬🇧
no-plugin-as-componentDisallow anti-patterns when passing a component to MarkdownRenderer.render to prevent memory leaks.✅ 🇬🇧
no-sample-codeDisallow sample code snippets from the Obsidian plugin template.✅ 🇬🇧🔧
no-static-styles-assignmentDisallow setting styles directly on DOM elements, favoring CSS classes instead.✅ 🇬🇧
no-tfile-tfolder-castDisallow type casting to TFile or TFolder, suggesting instanceof checks instead.✅ 🇬🇧
no-unsupported-apiDisallow usage of Obsidian APIs not available in the plugin's minimum app version✅ 🇬🇧
no-view-references-in-pluginDisallow storing references to custom views directly in the plugin, which can cause memory leaks.✅ 🇬🇧
object-assignDiscourage using Object.assign with two arguments✅ 🇬🇧
platformDisallow use of navigator API for OS detection✅ 🇬🇧
prefer-abstract-input-suggestDisallow Liam's frequently copied TextInputSuggest implementation in favor of the built-in AbstractInputSuggest.✅ 🇬🇧
prefer-active-docPrefer activeDocument over document for popout window compatibility.✅ 🇬🇧
prefer-create-elPrefer Obsidian DOM helpers (createEl, createDiv, createSpan, createSvg, createFragment) over native DOM methods.✅ 🇬🇧🔧💡
prefer-file-manager-trash-filePrefer FileManager.trashFile() over Vault.trash() or Vault.delete() to respect user settings.✅ 🇬🇧
prefer-get-languagePrefer Obsidian's getLanguage() over localStorage.getItem('language') and i18next-browser-languagedetector for detecting the user's language.✅ 🇬🇧
prefer-instanceofPrefer .instanceOf(T) over instanceof T for cross-window safe type checks on DOM Nodes and UIEvents.✅ 🇬🇧🔧💡
prefer-window-timersPrefer window.setTimeout() and related timer functions over bare global calls for popout window compatibility.✅ 🇬🇧🔧
regex-lookbehindUsing lookbehinds in Regex is not supported in some iOS versions✅ 🇬🇧
rule-custom-messageAllows redefining error messages from other ESLint rules that don't provide this functionality natively.✅ 🇬🇧
sample-namesRename sample plugin class names✅ 🇬🇧
settings-tab/no-deprecated-displayDisallow a leftover display() method on PluginSettingTab subclasses once getSettingDefinitions() is implemented and minAppVersion is 1.13.0 or later.✅ 🇬🇧🔧
settings-tab/no-manual-html-headingsDisallow using HTML heading elements for settings headings.✅ 🇬🇧🔧
settings-tab/no-problematic-settings-headingsDiscourage anti-patterns in settings headings.✅ 🇬🇧🔧
settings-tab/prefer-setting-definitionsEncourage PluginSettingTab subclasses to implement getSettingDefinitions() so settings appear in Obsidian 1.13+ settings search.✅ 🇬🇧
settings-tab/prefer-update-over-displayPrefer this.update() over this.display() to refresh a PluginSettingTab on Obsidian 1.13+.✅ 🇬🇧🔧
settings-tab/require-displayRequire a display() method on PluginSettingTab subclasses when minAppVersion is below 1.13.0.✅ 🇬🇧
ui/sentence-caseEnforce sentence case for UI strings✅ 🇬🇧🔧
ui/sentence-case-jsonEnforce sentence case for English JSON locale strings🇬🇧🔧
ui/sentence-case-locale-moduleEnforce sentence case for English TS/JS locale module strings🇬🇧🔧
validate-licenseValidate the structure of copyright notices in LICENSE files for Obsidian plugins.✅ 🇬🇧
validate-manifestValidate the structure of manifest.json for Obsidian plugins.✅ 🇬🇧
vault/iterateAvoid iterating all files to find a file by its path✅ 🇬🇧🔧

UI sentence case

Checks UI strings for sentence case. The rule reports warnings but doesn't change text unless you run ESLint with --fix and enable allowAutoFix.

  • Included at warn level in recommended config
  • Extended locale checks available via recommendedWithLocalesEn
  • By default allows CamelCase words like AutoReveal
  • Set enforceCamelCaseLower: true to flag CamelCase as incorrect

Usage (flat config)

// eslint.config.mjs
import { defineConfig } from "eslint/config";
import obsidianmd from "eslint-plugin-obsidianmd";

export default defineConfig([
  ...obsidianmd.configs.recommended,
  // Or include English locale files (JSON and TS/JS modules)
  // ...obsidianmd.configs.recommendedWithLocalesEn,

  {
    languageOptions: {
      parserOptions: {
        projectService: {
          allowDefaultProject: ["eslint.config.*"],
        },
      },
    },

    // Optional project overrides
    rules: {
      "obsidianmd/ui/sentence-case": [
        "warn",
        {
          brands: ["YourBrand"],
          acronyms: ["OK"],
          enforceCamelCaseLower: true,
        },
      ],
    },
  },
]);

Notes

  • Hyphenated words: Auto-Reveal becomes auto-reveal
  • Locale file patterns in recommendedWithLocalesEn: en*.json, en*.ts, en*.js, en/**/*

Known limitations

Sentence detection may incorrectly split on abbreviations (Dr., Inc., etc.). Use single sentences or adjust rule options when needed.