-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.ts
More file actions
101 lines (94 loc) · 3.22 KB
/
Copy patheslint.config.ts
File metadata and controls
101 lines (94 loc) · 3.22 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
// @ts-check
import { fileURLToPath } from 'node:url';
import eslint from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
export default defineConfig([
// ignores
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/build/**',
'**/*.js',
'**/*.html',
'**/playwright.config.ts',
'eslint.config.ts',
'cli/src/tui/banner.ts',
'cli/src/version.ts',
'server/src/version.ts',
'web/src/version.ts',
],
},
// base rule sets
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
// all typescript files
{
files: ['**/*.ts'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
// projectService auto-discovers each file's nearest tsconfig.json.
// The web build-glue files live in tsconfig.tools.json (not an
// auto-discovered name), so allow them onto the inferred default
// project rather than excluding them from lint.
projectService: {
allowDefaultProject: ['web/vite.config.ts', 'web/build.ts'],
},
tsconfigRootDir: fileURLToPath(new URL('.', import.meta.url)),
},
},
rules: {
// formatting
indent: ['error', 'tab'],
'no-tabs': 'off',
quotes: ['error', 'single'],
semi: ['error', 'always'],
'linebreak-style': ['error', 'unix'],
'no-trailing-spaces': 'error',
'spaced-comment': ['error', 'always'],
'keyword-spacing': ['error', { before: true, after: true }],
'space-before-blocks': 'error',
'space-infix-ops': 'error',
'comma-spacing': ['error', { before: false, after: true }],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'brace-style': ['error', '1tbs', { allowSingleLine: false }],
// safety
'no-eval': 'error',
'no-var': 'error',
eqeqeq: ['error', 'always', { null: 'ignore' }],
// Allow _ prefix for intentionally unused params/vars
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
},
},
// web client: no raw HTML-string DOM sinks
// The web client builds DOM via el()/createElement + textContent so a
// user-controlled value can never become markup. The one legitimate exception
// (static SVG icons) goes through setHtml(el, SafeHtml) in web/src/safehtml.ts,
// which is the sole sanctioned sink and carries its own disable comment.
{
files: ['web/src/**/*.ts'],
rules: {
'no-restricted-properties': ['error',
{ property: 'innerHTML', message: 'No raw HTML. Use setHtml(el, SafeHtml) from safehtml.ts.' },
{ property: 'outerHTML', message: 'No raw HTML. Use setHtml(el, SafeHtml) from safehtml.ts.' },
{ property: 'insertAdjacentHTML', message: 'No raw HTML. Build DOM with el()/createElement.' },
{ object: 'document', property: 'write', message: 'document.write is forbidden.' },
{ object: 'document', property: 'writeln', message: 'document.write is forbidden.' },
],
},
},
// test files
{
files: ['**/test/**/*.ts'],
rules: {
// Non-null assertions are acceptable in tests, shapes are known
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
]);