-
Notifications
You must be signed in to change notification settings - Fork 686
Expand file tree
/
Copy patheslint.config.mjs
More file actions
143 lines (140 loc) · 4.89 KB
/
eslint.config.mjs
File metadata and controls
143 lines (140 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import jestPlugin from 'eslint-plugin-jest';
import obsidianmd from 'eslint-plugin-obsidianmd';
import { DEFAULT_ACRONYMS } from 'eslint-plugin-obsidianmd/dist/lib/rules/ui/acronyms.js';
import { DEFAULT_BRANDS } from 'eslint-plugin-obsidianmd/dist/lib/rules/ui/brands.js';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import { defineConfig } from 'eslint/config';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const jestRecommended = jestPlugin.configs['flat/recommended'];
const tsconfigRootDir = dirname(fileURLToPath(import.meta.url));
const obsidianRuleSeverity = 'warn';
const stagedObsidianRules = {
'obsidianmd/commands/no-command-in-command-id': obsidianRuleSeverity,
'obsidianmd/commands/no-command-in-command-name': obsidianRuleSeverity,
'obsidianmd/commands/no-default-hotkeys': obsidianRuleSeverity,
'obsidianmd/commands/no-plugin-id-in-command-id': obsidianRuleSeverity,
'obsidianmd/commands/no-plugin-name-in-command-name': obsidianRuleSeverity,
'obsidianmd/detach-leaves': obsidianRuleSeverity,
'obsidianmd/editor-drop-paste': obsidianRuleSeverity,
'obsidianmd/hardcoded-config-path': obsidianRuleSeverity,
'obsidianmd/no-forbidden-elements': obsidianRuleSeverity,
'obsidianmd/no-global-this': obsidianRuleSeverity,
'obsidianmd/no-plugin-as-component': obsidianRuleSeverity,
'obsidianmd/no-sample-code': obsidianRuleSeverity,
'obsidianmd/no-static-styles-assignment': obsidianRuleSeverity,
'obsidianmd/no-tfile-tfolder-cast': obsidianRuleSeverity,
'obsidianmd/no-unsupported-api': obsidianRuleSeverity,
'obsidianmd/no-view-references-in-plugin': obsidianRuleSeverity,
'obsidianmd/object-assign': obsidianRuleSeverity,
'obsidianmd/platform': obsidianRuleSeverity,
'obsidianmd/prefer-abstract-input-suggest': obsidianRuleSeverity,
'obsidianmd/prefer-active-doc': obsidianRuleSeverity,
'obsidianmd/prefer-file-manager-trash-file': obsidianRuleSeverity,
'obsidianmd/prefer-get-language': obsidianRuleSeverity,
'obsidianmd/prefer-instanceof': obsidianRuleSeverity,
'obsidianmd/prefer-window-timers': obsidianRuleSeverity,
'obsidianmd/regex-lookbehind': obsidianRuleSeverity,
'obsidianmd/sample-names': obsidianRuleSeverity,
'obsidianmd/settings-tab/no-manual-html-headings': obsidianRuleSeverity,
'obsidianmd/settings-tab/no-problematic-settings-headings': obsidianRuleSeverity,
'obsidianmd/ui/sentence-case': [
obsidianRuleSeverity,
{
ignoreWords: ['Claudian', 'Codex', 'OpenCode', 'WSL'],
brands: [...DEFAULT_BRANDS, 'Claudian', 'Codex', 'OpenCode'],
acronyms: [...DEFAULT_ACRONYMS, 'TOML', 'WSL'],
ignoreRegex: ['\\.(?:claude|codex|opencode)/'],
enforceCamelCaseLower: true,
},
],
'obsidianmd/vault/iterate': obsidianRuleSeverity,
};
export default defineConfig([
{
ignores: ['dist/**', 'node_modules/**', 'coverage/**', 'main.js'],
},
js.configs.recommended,
{
files: ['esbuild.config.mjs', 'scripts/**/*.js', 'scripts/**/*.mjs'],
languageOptions: {
globals: {
console: 'readonly',
module: 'readonly',
process: 'readonly',
},
},
},
...tseslint.configs['flat/recommended'],
{
files: ['src/**/*.ts', 'tests/**/*.ts'],
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' },
],
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'none', ignoreRestSiblings: true },
],
'@typescript-eslint/no-explicit-any': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
{
files: ['src/**/*.ts'],
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir,
},
},
plugins: {
obsidianmd,
},
rules: stagedObsidianRules,
},
{
files: [
'src/ClaudianService.ts',
'src/InlineEditService.ts',
'src/InstructionRefineService.ts',
'src/images/**/*.ts',
'src/prompt/**/*.ts',
'src/sdk/**/*.ts',
'src/security/**/*.ts',
'src/tools/**/*.ts',
],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['./ui', './ui/*', '../ui', '../ui/*'],
message: 'Service and shared modules must not import UI modules.',
},
{
group: ['./ClaudianView', '../ClaudianView'],
message: 'Service and shared modules must not import the view.',
},
],
},
],
},
},
{
files: ['tests/**/*.ts'],
...jestRecommended,
rules: {
...jestRecommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
},
},
]);