Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import obsidianmd from "eslint-plugin-obsidianmd";

export default defineConfig([
...obsidianmd.configs.recommended,
...obsidianmd.configs.packageJson,
{
files: ["**/*.ts"],
languageOptions: {
Expand Down Expand Up @@ -82,8 +83,11 @@ You can also override or add rules:

| | Name |
| :--- | :------------------------- |
| | `packageJson` |
| ⚛️ | `react` |
| ✅ | `recommended` |
| 🇬🇧 | `recommendedWithLocalesEn` |
| 🔥 | `svelte` |

<!-- end auto-generated configs list -->

Expand Down Expand Up @@ -160,6 +164,7 @@ import obsidianmd from "eslint-plugin-obsidianmd";

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

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/commands/no-command-in-command-id.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow using the word 'command' in a command ID.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/commands/no-command-in-command-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow using the word 'command' in a command name.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/commands/no-default-hotkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Discourage providing default hotkeys for commands.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/commands/no-plugin-id-in-command-id.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Disallow including the plugin ID in a command ID.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/commands/no-plugin-name-in-command-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Disallow including the plugin name in a command name.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/detach-leaves.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Don't detach leaves in onunload.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/editor-drop-paste.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Require checking `evt.defaultPrevented` and calling `evt.preventDefault()` in editor-drop/editor-paste handlers.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/hardcoded-config-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Test.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/no-forbidden-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow attachment of forbidden elements to the DOM in Obsidian plugins.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 0 additions & 2 deletions docs/rules/no-global-this.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

📝 Disallow `global` and `globalThis`. Use `window` or `activeWindow` for popout window compatibility.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/no-nodejs-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow importing Node.js built-in modules unless guarded by Platform.isDesktop.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/no-plugin-as-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow anti-patterns when passing a component to MarkdownRenderer.render to prevent memory leaks.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/no-sample-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Disallow sample code snippets from the Obsidian plugin template.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-static-styles-assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow setting styles directly on DOM elements, favoring CSS classes instead.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/no-tfile-tfolder-cast.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow type casting to TFile or TFolder, suggesting instanceof checks instead.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/no-unsupported-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Disallow usage of Obsidian APIs not available in the plugin's minimum app version.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-view-references-in-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow storing references to custom views directly in the plugin, which can cause memory leaks.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/object-assign.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Discourage using `Object.assign` with two arguments.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow use of navigator API for OS detection.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/prefer-abstract-input-suggest.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Disallow Liam's frequently copied `TextInputSuggest` implementation in favor of the built-in `AbstractInputSuggest`.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/prefer-active-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Prefer `activeDocument` over `document` for popout window compatibility.

⚠️ This rule _warns_ in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
🚫 This rule is _disabled_ in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/prefer-create-el.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Prefer Obsidian DOM helpers (`createEl`, `createDiv`, `createSpan`, `createSvg`, `createFragment`) over native DOM methods.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/prefer-file-manager-trash-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Prefer FileManager.trashFile() over Vault.trash() or Vault.delete() to respect user settings.

⚠️ This rule _warns_ in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
⚠️ This rule _warns_ in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/prefer-get-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Prefer Obsidian's `getLanguage()` over `localStorage.getItem('language')` and `i18next-browser-languagedetector` for detecting the user's language.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/prefer-instanceof.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Prefer `.instanceOf(T)` over `instanceof T` for cross-window safe type checks on DOM Nodes and UIEvents.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
2 changes: 0 additions & 2 deletions docs/rules/prefer-window-timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

📝 Prefer `window.setTimeout()` and related timer functions over bare global calls for popout window compatibility.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/regex-lookbehind.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Using lookbehinds in Regex is not supported in some iOS versions.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/rule-custom-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Allows redefining error messages from other ESLint rules that don't provide this functionality natively.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/sample-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Rename sample plugin class names.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/settings-tab/no-manual-html-headings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Disallow using HTML heading elements for settings headings.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Discourage anti-patterns in settings headings.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/ui/sentence-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Enforce sentence case for UI strings.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/validate-license.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Validate the structure of copyright notices in LICENSE files for Obsidian plugins.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/validate-manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

📝 Validate the structure of manifest.json for Obsidian plugins.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

<!-- end auto-generated rule header -->
2 changes: 1 addition & 1 deletion docs/rules/vault/iterate.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📝 Avoid iterating all files to find a file by its path.

💼 This rule is enabled in the following configs: ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`.
💼 This rule is enabled in the following configs: `react`, ✅ `recommended`, 🇬🇧 `recommendedWithLocalesEn`, `svelte`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

Expand Down
24 changes: 12 additions & 12 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import obsidianmd from "./dist/lib/index.js";

export default [
obsidianmd.configs.all,
{
files: ["**/*.ts"],
languageOptions: {
parser: (await import("@typescript-eslint/parser")).default,
ecmaVersion: 2020,
sourceType: "module",
parserOptions: {
project: "./tsconfig.json",
},
},
},
...obsidianmd.configs.recommended,
{
files: ["**/*.ts"],
languageOptions: {
parser: (await import("@typescript-eslint/parser")).default,
ecmaVersion: 2020,
sourceType: "module",
parserOptions: {
project: "./tsconfig.json",
},
},
},
];
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ declare module 'eslint-plugin-obsidianmd' {
export const configs: {
recommended: Linter.Config;
recommendedWithLocalesEn: Linter.Config;
packageJson: Linter.Config;
react: Linter.Config;
svelte: Linter.Config;
};
export const rules: {
[key: string]: Rule.RuleModule;
Expand Down
Loading
Loading