Repository navigation
Expand file tree
/
Copy pathoxlint.base.ts
More file actions
199 lines (185 loc) · 6.34 KB
/
Copy pathoxlint.base.ts
File metadata and controls
199 lines (185 loc) · 6.34 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
import {join} from 'node:path';
import type {OxlintConfig} from 'oxlint';
// `import.meta.dirname`, not a file: URL's `.pathname`: a pathname is a URL path,
// so on Windows it is '/C:/…' and oxlint cannot load a plugin from it — which
// aborts the whole lint run rather than degrading. Taking the directory directly
// means no URL is constructed, so there is nothing to convert and nothing to get
// wrong.
const zeroPlugin = join(
import.meta.dirname,
'tools/oxlint-plugin-zero/index.js',
);
/**
* Shared oxlint configuration for all packages in the monorepo.
* This is a plain data module (not an oxlint config file) so it can be
* imported by both root configs without triggering nested-config validation.
*/
export const baseConfig = {
plugins: ['eslint', 'typescript', 'unicorn', 'jest'],
jsPlugins: ['@e18e/eslint-plugin', zeroPlugin],
ignorePatterns: [
'node_modules',
'dist',
'coverage',
'out',
'tool',
'bin',
'*_generated.ts',
'src/*/generated/',
'perf/index.js',
'um.js',
'prod/sst/sst-env.d.ts',
'**/um.js',
'**/__snapshots__/**',
// Expo app, deliberately not a workspace member: its tsconfig extends
// expo/tsconfig.base from its own node_modules, which type-aware linting
// cannot resolve from the repo root.
'packages/replicache-perf/rn',
'packages/zql-benchmarks/rn',
],
rules: {
// Disable unsafe optional chaining - many legitimate patterns in codebase
'no-unsafe-optional-chaining': 'off',
'no-console': 'error',
'curly': ['error', 'multi-line'],
'eqeqeq': 'error',
'arrow-body-style': 'error',
// Handle unused variables consistently with ESLint config
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// TypeScript-specific rules
'typescript/no-explicit-any': 'error',
'typescript/no-floating-promises': 'error',
'typescript/no-non-null-assertion': 'warn',
'typescript/consistent-type-imports': 'error',
'typescript/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// Require await in async functions
'require-await': 'error',
// Vitest rules uses "jest" plugin
'jest/no-focused-tests': 'error',
'jest/no-standalone-expect': 'off',
// Private class members (with inline disables for false positives)
'no-unused-private-class-members': 'error',
// Import restrictions - preserve the exact patterns from @rocicorp/eslint-config
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'datadog/*',
'otel/*',
'replicache/*',
'replicache-perf/*',
'shared/*',
'zero/*',
'zero-cache/*',
'zero-client/*',
'zero-protocol/*',
'zero-react/*',
'zero-react-native/*',
'zero-schema/*',
'zero-solid/*',
'zero-vue/*',
'zql/*',
'zqlite/*',
'zqlite-zql-test/*',
],
message: 'Use relative imports instead',
},
{
group: ['**/mod.ts'],
message:
"Don't import from barrel files. Import from the specific module instead.",
},
{
group: ['**/*.test.ts', '**/*.test.tsx'],
message: 'Do not import from test files.',
},
{
group: ['sinon'],
message: 'Use vi instead of sinon',
},
],
paths: [
{name: 'datadog', message: 'Use relative imports instead'},
{name: 'otel', message: 'Use relative imports instead'},
{name: 'replicache', message: 'Use relative imports instead'},
{
name: 'replicache-perf',
message: 'Use relative imports instead',
},
{name: 'shared', message: 'Use relative imports instead'},
{name: 'zero', message: 'Use relative imports instead'},
{name: 'zero-cache', message: 'Use relative imports instead'},
{name: 'zero-client', message: 'Use relative imports instead'},
{name: 'zero-protocol', message: 'Use relative imports instead'},
{name: 'zero-react', message: 'Use relative imports instead'},
{
name: 'zero-react-native',
message: 'Use relative imports instead',
},
{name: 'zero-schema', message: 'Use relative imports instead'},
{name: 'zero-solid', message: 'Use relative imports instead'},
{name: 'zero-vue', message: 'Use relative imports instead'},
{name: 'zql', message: 'Use relative imports instead'},
{name: 'zqlite', message: 'Use relative imports instead'},
{name: 'zqlite-zql-test', message: 'Use relative imports instead'},
],
},
],
// Additional beneficial rules
'unicorn/prefer-set-size': 'error',
'unicorn/prefer-string-starts-ends-with': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-set-has': 'error',
// e18e modernization rules
'e18e/prefer-array-at': 'error',
'e18e/prefer-array-fill': 'error',
'e18e/prefer-includes': 'error',
'e18e/prefer-array-to-reversed': 'error',
'e18e/prefer-array-to-sorted': 'error',
'e18e/prefer-array-to-spliced': 'error',
'e18e/prefer-nullish-coalescing': 'error',
'e18e/prefer-object-has-own': 'error',
'e18e/prefer-spread-syntax': 'error',
'e18e/prefer-url-canparse': 'error',
// e18e module replacement rules
'e18e/ban-dependencies': 'error',
// e18e performance improvement rules
'e18e/prefer-array-from-map': 'error',
'e18e/prefer-timer-args': 'error',
'e18e/prefer-date-now': 'error',
'e18e/prefer-regex-test': 'error',
'e18e/prefer-array-some': 'error',
'e18e/prefer-static-regex': 'error',
'zero/no-select-star': [
'error',
{
include: ['packages/zero-cache/src/'],
},
],
},
overrides: [
{
files: ['**/*.test.*', '**/*.config.ts'],
rules: {
'e18e/prefer-static-regex': 'off',
},
},
],
} satisfies OxlintConfig;