mirror of
https://github.com/jsmorabito/obsidian-commander.git
synced 2026-07-22 06:40:31 +00:00
- 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.
77 lines
2.2 KiB
TypeScript
77 lines
2.2 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: ['**/*.ts', '**/*.tsx'],
|
|
rules: {
|
|
// Preact discards the return value of JSX event handlers at
|
|
// runtime (unlike React's synthetic events), so async onClick
|
|
// handlers are safe here - only check non-attribute misuse
|
|
// (forEach callbacks, addEventListener, Promise executors, etc).
|
|
'@typescript-eslint/no-misused-promises': [
|
|
'error',
|
|
{ checksVoidReturn: { attributes: false } },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: ['src/main.ts'],
|
|
rules: {
|
|
// Renaming this command's id would break existing users' saved hotkeys
|
|
'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',
|
|
},
|
|
},
|
|
);
|