mirror of
https://github.com/jsmorabito/obsidian-commander.git
synced 2026-07-22 06:40:31 +00:00
lint: scope Node/mobile-compat rules off test and config files, tidy up a few regressions
- no-nodejs-modules, no-global-this, and prefer-create-el only exist to protect the shipped mobile bundle; scope them off for eslint.config.mts, vitest.config.ts, and src/__tests__/** since none of that runs inside Obsidian. - Fix vitest.config.ts's __dirname the same way eslint.config.mts already was (fileURLToPath(import.meta.url)), since __dirname isn't defined under ESM. - Disable no-empty-function (with a description) on the two intentionally-empty open()/close() mock methods introduced earlier. - Drop the now-unused `error` catch binding left over from removing its console.log in an earlier commit.
This commit is contained in:
parent
2851834290
commit
4c18a66984
4 changed files with 19 additions and 1 deletions
|
|
@ -63,4 +63,15 @@ export default defineConfig(
|
|||
'obsidianmd/commands/no-command-in-command-id': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['eslint.config.mts', 'vitest.config.ts', 'src/__tests__/**'],
|
||||
rules: {
|
||||
// These only run under Node (eslint/vitest CLI), never bundled
|
||||
// into main.js or loaded inside Obsidian, so the mobile/runtime
|
||||
// compatibility rationale behind these rules doesn't apply here.
|
||||
'obsidianmd/no-nodejs-modules': 'off',
|
||||
'obsidianmd/no-global-this': 'off',
|
||||
'obsidianmd/prefer-create-el': 'off',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -27,14 +27,18 @@ export class FuzzySuggestModal<T> {
|
|||
public app: unknown;
|
||||
protected declare items: T[];
|
||||
public constructor(app: unknown) { this.app = app; }
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function -- minimal test double, no-op is intentional
|
||||
public open(): void {}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function -- minimal test double, no-op is intentional
|
||||
public close(): void {}
|
||||
}
|
||||
export class SuggestModal<T> {
|
||||
public app: unknown;
|
||||
protected declare items: T[];
|
||||
public constructor(app: unknown) { this.app = app; }
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function -- minimal test double, no-op is intentional
|
||||
public open(): void {}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function -- minimal test double, no-op is intentional
|
||||
public close(): void {}
|
||||
}
|
||||
export class PluginSettingTab {
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ abstract class Base extends CommandManagerBase {
|
|||
const pair = await chooseNewCommand(plugin);
|
||||
commandList.push(pair);
|
||||
await plugin.saveSettings();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
// User cancelled command/icon selection, nothing to do
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { defineConfig } from "vitest/config";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue