mirror of
https://github.com/jsmorabito/obsidian-commander.git
synced 2026-07-22 06:40:31 +00:00
Resolves the rest of the no-unsafe-* family by giving TypeScript enough information instead of suppressing it: - Extend the Obsidian module augmentation (types.ts) with App.commands.removeCommand and Vault.getConfig so util.tsx and main.ts no longer need @ts-ignore around them. - Cast event.target to the concrete HTMLElement subtype at each DOM event handler that reads .value/.checked/.offsetWidth (ChangeableText, MacroBuilder, commandComponent) instead of @ts-ignore/@ts-expect-error. - Cast JSON.parse() results to their known shape (MacroBuilder's macro clone, locales.test.ts's loadJson, main.ts's loadSettings) instead of letting `any` flow through. - Drop menuManager's unusual `this: (_item: MenuItem) => void` parameter and the .call(this, ...) it required - the returned closure never reads `this`, so this was both unnecessary and, under this project's non-strict bind/call/apply typing, exactly why the arguments passed through untyped. Calling the method directly is equivalent and fully typed. - Same root cause for MacroBuilderModal's this.close.bind(this) and executeMacro.test.ts's .bind() - replaced with equivalent non-bind forms. - confirmDeleteModal/mobileModifyModal: inline the h(...) call into render() instead of round-tripping through an intermediately VNode-typed field, which is where preact's h() lost prop typing. - vitest.config.ts-style import.meta.dirname swapped for fileURLToPath(import.meta.url) in eslint.config.mts, since the project's TS lib doesn't type import.meta.dirname. Type-level only; no behavior change beyond what's already covered by the two preceding commits.
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import tseslint from 'typescript-eslint';
|
|
import obsidianmd from 'eslint-plugin-obsidianmd';
|
|
import globals from 'globals';
|
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
import { fileURLToPath } from 'url';
|
|
import path from 'path';
|
|
|
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
export default defineConfig(
|
|
globalIgnores([
|
|
'node_modules',
|
|
'build',
|
|
'scripts',
|
|
'main.js',
|
|
'main.css',
|
|
'styles.css',
|
|
'tailwind.config.js',
|
|
]),
|
|
{
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
},
|
|
parserOptions: {
|
|
projectService: {
|
|
allowDefaultProject: ['eslint.config.mts', 'manifest.json'],
|
|
},
|
|
tsconfigRootDir: dirname,
|
|
extraFileExtensions: ['.json'],
|
|
},
|
|
},
|
|
},
|
|
...tseslint.configs.recommended,
|
|
{
|
|
rules: {
|
|
'@typescript-eslint/ban-ts-comment': 'off',
|
|
'no-prototype-builtins': 'off',
|
|
'@typescript-eslint/no-empty-function': 'error',
|
|
'@typescript-eslint/class-literal-property-style': ['error', 'fields'],
|
|
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
'@typescript-eslint/explicit-member-accessibility': 'error',
|
|
},
|
|
},
|
|
...obsidianmd.configs.recommended,
|
|
{
|
|
files: ['src/main.ts'],
|
|
rules: {
|
|
// Renaming this command's id would break existing users' saved hotkeys
|
|
'obsidianmd/commands/no-command-in-command-id': 'off',
|
|
},
|
|
},
|
|
);
|