|
| 1 | +import eslint from '@eslint/js'; |
| 2 | +import tseslint from 'typescript-eslint'; |
| 3 | +import obsidianmd from 'eslint-plugin-obsidianmd'; |
| 4 | + |
| 5 | +export default tseslint.config( |
| 6 | + // Ignore patterns |
| 7 | + { |
| 8 | + ignores: ['main.js', 'node_modules/**', '.git/**', '*.config.js', 'package.json'] |
| 9 | + }, |
| 10 | + |
| 11 | + // Node.js config files (version-bump.mjs, esbuild.config.mjs) |
| 12 | + { |
| 13 | + files: ['*.mjs', '*.config.mjs'], |
| 14 | + languageOptions: { |
| 15 | + globals: { |
| 16 | + process: 'readonly', |
| 17 | + console: 'readonly', |
| 18 | + __dirname: 'readonly', |
| 19 | + __filename: 'readonly' |
| 20 | + } |
| 21 | + } |
| 22 | + }, |
| 23 | + |
| 24 | + // Base ESLint recommended rules |
| 25 | + eslint.configs.recommended, |
| 26 | + |
| 27 | + // TypeScript ESLint recommended rules |
| 28 | + ...tseslint.configs.recommended, |
| 29 | + |
| 30 | + // Obsidian plugin recommended rules |
| 31 | + ...obsidianmd.configs.recommended, |
| 32 | + |
| 33 | + // Custom rules and overrides |
| 34 | + { |
| 35 | + files: ['**/*.ts'], |
| 36 | + languageOptions: { |
| 37 | + parser: tseslint.parser, |
| 38 | + parserOptions: { |
| 39 | + projectService: true, |
| 40 | + tsconfigRootDir: import.meta.dirname, |
| 41 | + }, |
| 42 | + globals: { |
| 43 | + // Node.js globals |
| 44 | + console: 'readonly', |
| 45 | + process: 'readonly', |
| 46 | + Buffer: 'readonly', |
| 47 | + __dirname: 'readonly', |
| 48 | + __filename: 'readonly', |
| 49 | + setTimeout: 'readonly', |
| 50 | + clearTimeout: 'readonly', |
| 51 | + // Browser globals |
| 52 | + window: 'readonly', |
| 53 | + document: 'readonly', |
| 54 | + // Obsidian globals |
| 55 | + moment: 'readonly', |
| 56 | + createDiv: 'readonly' |
| 57 | + } |
| 58 | + }, |
| 59 | + rules: { |
| 60 | + // Disable unused vars for function arguments |
| 61 | + '@typescript-eslint/no-unused-vars': ['error', { args: 'none' }], |
| 62 | + // Allow ts-comment for necessary cases (with descriptions) |
| 63 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 64 | + // Allow prototype builtins |
| 65 | + 'no-prototype-builtins': 'off', |
| 66 | + // Allow empty functions |
| 67 | + '@typescript-eslint/no-empty-function': 'off', |
| 68 | + // Disable overly strict type-safety rules for plugin development |
| 69 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 70 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 71 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 72 | + '@typescript-eslint/no-unsafe-argument': 'off', |
| 73 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 74 | + '@typescript-eslint/no-base-to-string': 'off', |
| 75 | + // Allow builtin-modules for now |
| 76 | + 'depend/ban-dependencies': 'off', |
| 77 | + // Configure sentence case rule with regex ignores for technical terms |
| 78 | + 'obsidianmd/ui/sentence-case': ['error', { |
| 79 | + ignoreRegex: ['IGDB', 'API', 'ID', 'Twitch'] |
| 80 | + }] |
| 81 | + } |
| 82 | + } |
| 83 | +); |
0 commit comments