Skip to content

Commit 526b844

Browse files
authored
chore(lint): migrate from eslint to oxlint (#242)
* chore(lint): migrate from eslint to oxlint oxlint runs the same policy surface in ~1s with no typescript peer constraint of its own: - typescript/unicorn/oxc/import plugins + correctness category cover the old js/ts recommended sets; consistent-type-imports, no-unused-vars(args:none) and import/no-duplicates carried over - eslint-plugin-obsidianmd runs unchanged via oxlint jsPlugins (all 7 guideline rules verified firing, incl. nested-name rules) along with the no-restricted-globals app/fetch/localStorage policy - eslint itself remains only as an internal dependency of eslint-plugin-obsidianmd; our direct eslint/typescript-eslint/ import-x devDeps and eslint.config.mjs are gone Fixes for real issues oxlint surfaced that eslint missed: - main.ts imported ./store twice via different specifiers (src/store and ./store) - merged - useless {} fallbacks in loadedData spreads (main.ts) - ambiguous new Array(n) in assertFetchableUrl + TranscriptionService - unsafe optional-chain calls in main.activateView.test.ts Svelte files are excluded (parity with the old ts-only eslint globs; svelte-check owns those). * chore(lint): carry over explicit rule relaxations from the old eslint config The repo lints clean either way today; pinning ban-ts-comment, no-empty-function and no-prototype-builtins off guards against these activating via category changes in future oxlint upgrades.
1 parent c177485 commit 526b844

8 files changed

Lines changed: 79 additions & 695 deletions

File tree

.oxlintrc.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "unicorn", "oxc", "import"],
4+
"jsPlugins": ["eslint-plugin-obsidianmd"],
5+
"categories": {
6+
"correctness": "error"
7+
},
8+
"env": {
9+
"browser": true,
10+
"node": true,
11+
"es2021": true
12+
},
13+
"globals": {
14+
"app": "readonly",
15+
"activeWindow": "readonly",
16+
"activeDocument": "readonly"
17+
},
18+
"ignorePatterns": ["node_modules", "build", "npm", "main.js", "**/*.svelte"],
19+
"rules": {
20+
"no-prototype-builtins": "off",
21+
"typescript/ban-ts-comment": "off",
22+
"typescript/no-empty-function": "off",
23+
"no-unused-vars": ["error", { "args": "none" }],
24+
"import/no-duplicates": "error",
25+
"typescript/consistent-type-imports": [
26+
"error",
27+
{
28+
"prefer": "type-imports",
29+
"disallowTypeAnnotations": false,
30+
"fixStyle": "inline-type-imports"
31+
}
32+
]
33+
},
34+
"overrides": [
35+
{
36+
"files": ["src/**/*.ts"],
37+
"excludeFiles": ["src/**/*.test.ts", "src/**/*.spec.ts"],
38+
"rules": {
39+
"obsidianmd/no-static-styles-assignment": "error",
40+
"obsidianmd/prefer-window-timers": "error",
41+
"obsidianmd/prefer-active-doc": "error",
42+
"obsidianmd/detach-leaves": "error",
43+
"obsidianmd/no-global-this": "error",
44+
"obsidianmd/settings-tab/no-manual-html-headings": "error",
45+
"obsidianmd/commands/no-plugin-name-in-command-name": "error",
46+
"no-restricted-globals": [
47+
"error",
48+
{
49+
"name": "app",
50+
"message": "Avoid the global app object. Use the reference provided by your plugin instance (this.app, or get(plugin).app for module-level code)."
51+
},
52+
{
53+
"name": "fetch",
54+
"message": "Use Obsidian's requestUrl instead of fetch for network requests."
55+
},
56+
{
57+
"name": "localStorage",
58+
"message": "Use App#saveLocalStorage / App#loadLocalStorage for vault-scoped storage instead of the global localStorage."
59+
}
60+
]
61+
}
62+
}
63+
]
64+
}

eslint.config.mjs

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)