-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
145 lines (144 loc) · 4.55 KB
/
Copy patheslint.config.js
File metadata and controls
145 lines (144 loc) · 4.55 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
// Flat ESLint config for the jsonforms-lit workspace.
import js from '@eslint/js';
import tsparser from '@typescript-eslint/parser';
import tsplugin from '@typescript-eslint/eslint-plugin';
import prettier from 'eslint-config-prettier';
export default [
// Global ignores — must be in its own config entry with no other keys.
{
ignores: [
'**/dist/**',
'**/node_modules/**',
'**/*.tsbuildinfo',
'**/coverage/**',
'apps/demo/dist/**',
'pnpm-lock.yaml',
],
},
js.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
// Type-aware linting. A dedicated `tsconfig.eslint.json` covers
// every source + test file across the workspace without fighting
// the per-package `rootDir` settings used by `tsc --build`.
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: import.meta.dirname,
},
globals: {
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
customElements: 'readonly',
HTMLElement: 'readonly',
HTMLInputElement: 'readonly',
HTMLSelectElement: 'readonly',
HTMLTextAreaElement: 'readonly',
HTMLButtonElement: 'readonly',
HTMLDivElement: 'readonly',
HTMLLegendElement: 'readonly',
HTMLLabelElement: 'readonly',
HTMLOptionElement: 'readonly',
ShadowRoot: 'readonly',
DocumentFragment: 'readonly',
ParentNode: 'readonly',
Node: 'readonly',
Element: 'readonly',
Event: 'readonly',
CustomEvent: 'readonly',
KeyboardEvent: 'readonly',
MouseEvent: 'readonly',
InputEvent: 'readonly',
PropertyKey: 'readonly',
NodeFilter: 'readonly',
MutationObserver: 'readonly',
CSSStyleSheet: 'readonly',
CustomElementConstructor: 'readonly',
getComputedStyle: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
console: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
queueMicrotask: 'readonly',
Symbol: 'readonly',
Promise: 'readonly',
process: 'readonly',
},
},
plugins: {
'@typescript-eslint': tsplugin,
},
rules: {
// TS handles undefined symbols and unused imports; eslint's
// no-undef / no-unused-vars don't understand type imports.
'no-undef': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'no-empty': ['error', { allowEmptyCatch: true }],
// Type-aware safety rules — catch forgotten awaits and promise
// misuse in the Lit async update machinery.
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: {
// Event handlers legitimately return promises (async
// `@click` handlers etc.) and that's fine in lit-html.
attributes: false,
arguments: false,
},
},
],
// Prefer the `import type` form for type-only imports so output
// code stays clean and `verbatimModuleSyntax` can be enabled later
// without churn.
'@typescript-eslint/consistent-type-imports': [
'warn',
{
prefer: 'type-imports',
disallowTypeAnnotations: false,
fixStyle: 'separate-type-imports',
},
],
},
},
{
// `describe` / `it` / `before` from `node:test` return promises that
// the runner tracks internally; user code doesn't (and shouldn't) await
// them. Same story for the `fixture.updateComplete` no-op awaits scattered
// through integration tests. Turn off no-floating-promises inside tests
// so the type-aware rule doesn't drown the genuine signal from src.
files: ['**/test/**/*.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
},
},
{
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
console: 'readonly',
process: 'readonly',
},
},
rules: {
'no-empty': ['error', { allowEmptyCatch: true }],
},
},
prettier,
];