Repository navigation
Expand file tree
/
Copy pathoxlint.config.ts
More file actions
210 lines (206 loc) · 7.18 KB
/
Copy pathoxlint.config.ts
File metadata and controls
210 lines (206 loc) · 7.18 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import { defineConfig } from 'oxlint';
const restrictedSyntax = [
{
selector:
"CallExpression[callee.name='useEffect'] UnaryExpression[operator='typeof'] > Identifier[name='window']",
message:
"Do not use `typeof window !== 'undefined'` inside useEffect; useEffect already runs client-side.",
},
{
selector:
"CallExpression[callee.name='useLayoutEffect'] UnaryExpression[operator='typeof'] > Identifier[name='window']",
message:
"Do not use `typeof window !== 'undefined'` inside useLayoutEffect; useLayoutEffect already runs client-side.",
},
{
selector:
"CallExpression[callee.object.name='vi'][callee.property.name='doMock'] Literal[value='@/components/ui/tooltip'], CallExpression[callee.object.name='vi'][callee.property.name='mock'] Literal[value='@/components/ui/tooltip']",
message:
'Do not mock tooltip primitives. Import TooltipProvider and wrap the rendered component instead.',
},
];
const noRequireInTests = {
selector: "CallExpression[callee.name='require'], CallExpression[callee.object.name='require']",
message:
'require() is not available in an ESM test module. Use a static import or await import(); for a native/CJS addon use createRequire(import.meta.url) bound to a name other than "require" (e.g. require_).',
};
const NO_COMMENTS_PLUGIN = './lint-plugins/no-comments/plugin.mjs';
const OK_RULES_PLUGIN = './lint-plugins/ok-rules/index.mjs';
const NO_COMMENTS_RULE = 'no-comments/no-comments';
const NO_COMMENTS_SEVERITY = 'error';
export default defineConfig({
ignorePatterns: [
'.agents/skills/**',
'.codex/skills/**',
'/reports/**',
'/specs/**',
'lint-plugins/no-comments/__fixtures__/**',
'lint-plugins/ok-rules/__fixtures__/**',
],
options: {
reportUnusedDisableDirectives: 'error',
typeAware: true,
},
plugins: ['unicorn', 'typescript', 'oxc', 'react', 'jsx-a11y'],
jsPlugins: [
{ name: 'eslint-js', specifier: 'oxlint-plugin-eslint' },
{ name: 'unicorn-js', specifier: 'eslint-plugin-unicorn' },
NO_COMMENTS_PLUGIN,
OK_RULES_PLUGIN,
],
rules: {
'ok/class-proof-registration-discipline': 'error',
'ok/cst-pm-handler-todo-stub': 'error',
'ok/microcopy-ellipsis': 'error',
'ok/no-app-core-barrel-import': 'error',
'ok/no-blind-agent-host-fanout': 'error',
'ok/no-blocking-error-box': 'error',
'ok/no-custom-toast': 'error',
'ok/no-demoted-dialog-confirm': 'error',
'ok/no-empty-jsx-expression': 'error',
'ok/no-fixed-palette-color': 'error',
'ok/no-hand-rolled-branch-validation': 'error',
'ok/no-hand-rolled-test-file-suffix': 'error',
'ok/no-hand-rolled-spinner': 'error',
'ok/no-inline-tolerance-class': 'error',
'ok/no-loosely-typed-webcontents-ipc': 'error',
'ok/no-native-renderer-dialog': 'error',
'ok/no-physical-direction-utility': 'error',
'ok/no-raw-error-toast': 'error',
'ok/no-raw-html-interactive-element': 'error',
'ok/no-raw-route-hash-construction': 'error',
'ok/no-redundant-jsx-element-braces': 'error',
'ok/no-resolved-value-theme-source': 'error',
'ok/no-roundtrip-identity-oracle': 'error',
'ok/no-sentinel-signal-target': 'error',
'ok/no-split-suggestion-dispatch': 'error',
'ok/no-themeless-pierre-diff': 'error',
'ok/no-unconverted-git-pathspec': 'error',
'ok/no-uninstall-forbidden-import': 'error',
'ok/no-unportaled-editor-content': 'error',
'ok/no-unwrapped-user-facing-string': 'error',
'ok/path-conditional-map-driven-origin': 'error',
'ok/playwright-prefer-to-have-count': 'error',
'ok/require-utf8-multipart-parser': 'error',
'ok/require-windowshide-on-spawn': 'error',
[NO_COMMENTS_RULE]: NO_COMMENTS_SEVERITY,
'eslint/logical-assignment-operators': [
'error',
'always',
{
enforceForIfStatements: true,
},
],
'eslint-js/no-restricted-syntax': ['error', ...restrictedSyntax],
'unicorn-js/prefer-promise-with-resolvers': 'error',
'react/jsx-curly-brace-presence': [
'error',
{ children: 'never', props: 'never', propElementValues: 'ignore' },
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'bun:test',
message: 'Import test APIs directly from vitest.',
},
],
},
],
'eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'typescript/no-floating-promises': 'off',
'eslint/no-unsafe-optional-chaining': 'off',
'typescript/await-thenable': 'off',
'typescript/no-implied-eval': 'off',
'unicorn/no-invalid-fetch-options': 'off',
'typescript/restrict-template-expressions': 'off',
'typescript/no-base-to-string': 'off',
'typescript/unbound-method': 'off',
'typescript/no-misused-spread': 'off',
'typescript/no-this-alias': 'off',
'typescript/no-duplicate-type-constituents': 'off',
'typescript/no-meaningless-void-operator': 'off',
'typescript/require-array-sort-compare': 'off',
'typescript/no-redundant-type-constituents': 'off',
'unicorn/no-new-array': 'off',
'eslint/no-shadow-restricted-names': 'off',
'eslint/no-empty-pattern': 'off',
'unicorn/no-empty-file': 'off',
'eslint/no-control-regex': 'off',
'oxc/erasing-op': 'off',
'typescript/no-useless-default-assignment': 'off',
'typescript/prefer-as-const': 'off',
'react/set-state-in-effect': 'off',
'react-hooks/exhaustive-deps': 'off',
'react/refs': 'off',
'react/globals': 'off',
'react/static-components': 'off',
'react/immutability': 'off',
'jsx-a11y/anchor-ambiguous-text': 'error',
'jsx-a11y/anchor-is-valid': 'error',
'jsx-a11y/click-events-have-key-events': 'error',
'jsx-a11y/no-noninteractive-tabindex': 'error',
'jsx-a11y/no-static-element-interactions': [
'error',
{
handlers: [
'onBlur',
'onClick',
'onContextMenu',
'onDblClick',
'onDoubleClick',
'onDrag',
'onDragEnd',
'onDragEnter',
'onDragExit',
'onDragLeave',
'onDragOver',
'onDragStart',
'onDrop',
'onFocus',
'onKeyDown',
'onKeyPress',
'onKeyUp',
'onMouseDown',
'onMouseEnter',
'onMouseLeave',
'onMouseMove',
'onMouseOut',
'onMouseOver',
'onMouseUp',
],
},
],
'react/no-danger': 'error',
'jsx-a11y/prefer-tag-over-role': 'off',
'jsx-a11y/no-autofocus': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'jsx-a11y/interactive-supports-focus': 'off',
'jsx-a11y/media-has-caption': 'off',
'jsx-a11y/control-has-associated-label': 'off',
'jsx-a11y/role-has-required-aria-props': 'off',
'jsx-a11y/heading-has-content': 'off',
},
overrides: [
{
files: ['**/*.{ts,tsx}'],
rules: {
'typescript/no-deprecated': 'error',
},
},
{
files: ['**/*.test.{ts,tsx,cts,mts,mjs}'],
rules: {
'eslint-js/no-restricted-syntax': ['error', ...restrictedSyntax, noRequireInTests],
},
},
],
});