-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathserver.mts
More file actions
239 lines (178 loc) · 7.8 KB
/
server.mts
File metadata and controls
239 lines (178 loc) · 7.8 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
/**
* ESLint configuration for Fluid Framework server packages.
*
* Server packages (routerlicious, gitrest, historian) are Node.js services with
* different requirements than client-side code. This config provides appropriate
* rule overrides for server code.
*
* @example
* ```typescript
* // In your eslint.config.mts
* import { server } from "@fluidframework/eslint-config-fluid/server.mts";
* export default [...server];
* ```
*/
import { minimalDeprecated, recommended } from "./flat.mts";
/**
* Server-specific rule overrides.
* These packages are server-side Node.js services.
*
* Many rules are disabled with TODOs to re-enable them after fixing violations.
* The server codebase predates many of these stricter TypeScript rules.
*/
const serverOverrides = {
rules: {
// Server packages are server-side Node.js code that legitimately uses Node built-in modules.
"import-x/no-nodejs-modules": "off",
// Allow finally blocks in promise chains.
// Server code has patterns where catch throws, which this rule doesn't understand.
// TODO: Review and re-enable with appropriate configuration.
"promise/catch-or-return": "off",
// Import ordering is handled by the formatter.
"import-x/order": "off",
// #region TypeScript strict rules - disabled for server code migration
// TODO: Fix violations and re-enable these rules incrementally.
// This rule is too strict for server code - many implicit boolean coercions.
"@typescript-eslint/strict-boolean-expressions": "off",
// Server code has many functions without explicit return types.
// TODO: Add return types and re-enable as error.
"@typescript-eslint/explicit-function-return-type": "off",
// Related to explicit-function-return-type - covers module boundaries.
// TODO: Add return types and re-enable as error.
"@typescript-eslint/explicit-module-boundary-types": "off",
// Server code has extensive use of `any` types.
// TODO: Replace `any` with proper types and re-enable as error.
"@typescript-eslint/no-explicit-any": "off",
// These rules flag unsafe usage of `any` typed values.
// TODO: Fix type safety issues and re-enable as errors.
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
// #endregion
// TODO: enable strict null checks in tsconfig and remove this override
"@typescript-eslint/prefer-nullish-coalescing": "off",
// TODO: remove usages of deprecated APIs and remove this override
"import-x/no-deprecated": "warn",
// Keep as warning to track usage, but don't fail the build.
"@fluid-internal/fluid/no-unchecked-record-access": "warn",
// JSDoc hyphen rules are stylistic.
"jsdoc/require-hyphen-before-param-description": "off",
"jsdoc/require-param-description": "off",
// TSDoc hyphen rule.
// TODO: Change this to error.
"tsdoc/syntax": "warn",
// Unicorn prefer-type-error is stylistic.
"unicorn/prefer-type-error": "off",
// Spaced-comment is stylistic, handled by formatter.
"spaced-comment": "off",
// Prefer template literals is stylistic.
"prefer-template": "off",
// Import namespace errors may be false positives with some libraries.
"import-x/namespace": "off",
// Workspace packages can't be resolved without building first.
// TODO: Configure import-x resolver for pnpm workspaces if needed.
"import-x/no-unresolved": "off",
// #region Additional rules disabled for server code migration
// TODO: Fix violations and re-enable these rules.
// Server code has many unhandled promises - needs cleanup.
"@typescript-eslint/no-floating-promises": "off",
// Lodash/body-parser are used throughout server code.
// TODO: Migrate to alternatives as recommended.
"depend/ban-dependencies": "off",
// Server code uses type assertions extensively.
// TODO: Refactor to use type guards or proper typing.
"@typescript-eslint/consistent-type-assertions": "off",
// Server code has functions returning promises that aren't marked async.
// TODO: Add async keyword where appropriate.
"@typescript-eslint/promise-function-async": "off",
// Server code uses promises in contexts expecting void.
// TODO: Fix promise handling.
"@typescript-eslint/no-misused-promises": "off",
// Server code has some instances that prefer bracket notation.
"@typescript-eslint/dot-notation": "off",
// Server code has relative imports reaching into sibling packages.
// TODO: Refactor to use package imports.
"import-x/no-internal-modules": "off",
// Prefer const over let.
// TODO: Fix let declarations that should be const.
"prefer-const": "warn",
// Server code uses non-null assertions.
// TODO: Add proper null checks.
"@typescript-eslint/no-non-null-assertion": "off",
// Server code has await on non-promises.
"@typescript-eslint/await-thenable": "off",
// Server code has unused expressions.
"@typescript-eslint/no-unused-expressions": "off",
// Server code uses bitwise operators legitimately.
"no-bitwise": "off",
// Server code uses comma operators.
"no-sequences": "off",
// Server code has unnecessary type assertions.
"@typescript-eslint/no-unnecessary-type-assertion": "off",
// Server code uses prefer-arrow-callback style.
"prefer-arrow-callback": "off",
// Server code uses regex exec vs test inconsistently.
"@typescript-eslint/prefer-regexp-exec": "off",
// Server code has one-var style.
"one-var": "off",
// Server code has prefer-promise-reject-errors issues.
"@typescript-eslint/prefer-promise-reject-errors": "off",
// Named exports from default.
"import-x/no-named-as-default-member": "off",
// Rule was renamed in newer versions.
"@typescript-eslint/no-throw-literal": "off",
// Variable shadowing in server code.
// TODO: Rename shadowed variables.
"@typescript-eslint/no-shadow": "off",
// JSDoc hyphen formatting.
"@fluid-internal/fluid/no-hyphen-after-jsdoc-tag": "off",
// Assert import style.
// TODO: Update to use strict assert.
"@typescript-eslint/no-restricted-imports": "off",
// Ternary expression preference.
"unicorn/prefer-ternary": "off",
// Spread vs concat preference.
"unicorn/prefer-spread": "off",
// Promise catch-or-return is handled by our custom config.
// Some patterns legitimately don't need explicit returns.
// TODO: Review and enable where appropriate.
// Type definition style.
"@typescript-eslint/consistent-type-definitions": "off",
// Object shorthand style.
"object-shorthand": "off",
// Empty blocks may be intentional.
"no-empty": "off",
// Optional chain preference.
"@typescript-eslint/prefer-optional-chain": "off",
// Type side effects - import type handling.
"@typescript-eslint/no-import-type-side-effects": "off",
// Base to string conversion warnings.
"@typescript-eslint/no-base-to-string": "off",
// Parameter reassignment in server code.
"no-param-reassign": "off",
// Strict equality - some legacy code uses ==.
// TODO: Fix to use ===.
"eqeqeq": "off",
// Return-await style - server code uses various patterns.
// TODO: Standardize on in-try-catch style.
"@typescript-eslint/return-await": "off",
// #endregion
},
};
/**
* ESLint flat config for server packages.
* Uses minimalDeprecated config with server-specific rule overrides.
*/
export const server = [...minimalDeprecated, serverOverrides];
/**
* ESLint flat config for server packages using the recommended config level.
* For packages that were previously using the full recommended config
* (e.g. routerlicious/gitresources, routerlicious/lambdas).
*/
export const serverRecommended = [...recommended, serverOverrides];