-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheslint.config.mjs
More file actions
196 lines (193 loc) · 6.9 KB
/
Copy patheslint.config.mjs
File metadata and controls
196 lines (193 loc) · 6.9 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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-create-el': 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: ['Qoderian', 'Qoder', 'WSL', 'I'],
brands: [...DEFAULT_BRANDS, 'Qoderian', 'Qoder'],
acronyms: [...DEFAULT_ACRONYMS, 'TOML', 'WSL'],
ignoreRegex: ['\\.qoder/'],
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: {
clearTimeout: 'readonly',
console: 'readonly',
module: 'readonly',
process: 'readonly',
setTimeout: 'readonly',
},
},
},
...tseslint.configs['flat/recommended'],
{
// The dev reloader is a CommonJS Obsidian plugin that runs in the Electron
// renderer, so it needs both Node and browser globals.
files: ['scripts/dev-reloader/**/*.js'],
languageOptions: {
globals: {
module: 'readonly',
require: 'readonly',
window: 'readonly',
},
},
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
{
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',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: ['function', 'method'],
format: ['camelCase'],
leadingUnderscore: 'allow',
},
],
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
{
files: ['src/**/*.ts'],
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir,
},
},
plugins: {
obsidianmd,
},
rules: {
...stagedObsidianRules,
// Mirrored from the type-aware review that runs on GitHub, so the
// matching disable directives stay meaningful in local lint too.
'no-console': ['warn', { allow: ['warn', 'error'] }],
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
},
},
// Layer boundaries. Arrows point inward to core: core depends on nobody,
// qoder implements the core contracts. features may call into qoder
// directly (Qoder CLI is the only integration), but not the other way
// around, so cycles stay impossible.
{
files: ['src/core/**/*.ts'],
rules: {
'no-restricted-imports': ['error', { patterns: [{
regex: '^(@/|(\\.\\./)+)((qoder|features|shared|app)(/.*)?|main)$',
message: 'core must not import outer layers. Define a contract here and let qoder/features depend on it.',
}] }],
},
},
{
files: ['src/shared/**/*.ts'],
rules: {
'no-restricted-imports': ['error', { patterns: [{
regex: '^(@/|(\\.\\./)+)((qoder|features|app)(/.*)?|main)$',
message: 'shared may depend on core only.',
}] }],
},
},
{
files: ['src/app/**/*.ts'],
rules: {
'no-restricted-imports': ['error', { patterns: [
{
regex: '^(@/|(\\.\\./)+)(features(/.*)?|main)$',
message: 'app must not import features or main. app is composed from main.ts, not the other way around.',
},
{
regex: '^(@/|(\\.\\./)+)qoder/(?!config/|QoderServices$)',
message: 'app may only use qoder/config and qoder/QoderServices. Deeper qoder internals belong behind the QoderServices composition root.',
},
] }],
},
},
{
files: ['src/qoder/**/*.ts'],
rules: {
'no-restricted-imports': ['error', { patterns: [{
regex: '^(@/|(\\.\\./)+)((features|shared|app)(/.*)?|main)$',
message: 'qoder may depend on core and its own adapters only. Inject host contracts instead of importing outer layers.',
}] }],
},
},
{
files: ['tests/**/*.ts'],
...jestRecommended,
rules: {
...jestRecommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
},
},
]);