Skip to content

Commit 7a1fa19

Browse files
Copilothotlong
andcommitted
feat: enable ESLint waves 3-5 rules and fix no-unsafe-function-type violations
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent e37cd6b commit 7a1fa19

8 files changed

Lines changed: 35 additions & 19 deletions

File tree

eslint.config.mjs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@ export default tseslint.config(
1111
rules: {
1212
"@typescript-eslint/no-explicit-any": "off",
1313
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],
14-
"@typescript-eslint/no-require-imports": "off",
15-
"@typescript-eslint/no-empty-object-type": "off",
14+
"@typescript-eslint/no-require-imports": "error",
15+
"@typescript-eslint/no-empty-object-type": "warn",
1616
"no-case-declarations": "error",
17-
"no-useless-escape": "off",
17+
"no-useless-escape": "error",
1818
"prefer-const": "error",
1919
"no-empty": "warn",
2020
"no-undef": "off",
2121
"no-useless-catch": "error",
2222
"no-console": "warn",
23-
"@typescript-eslint/no-this-alias": "off",
24-
"@typescript-eslint/no-unsafe-function-type": "off"
23+
"@typescript-eslint/no-this-alias": "warn",
24+
"@typescript-eslint/no-unsafe-function-type": "error"
2525
}
2626
},
2727
{
2828
// CLI and tools: console output is intentional for user-facing terminal output
29+
// require() needed for dynamic module loading in CLI commands
2930
files: ["packages/tools/**/*.ts"],
3031
rules: {
31-
"no-console": "off"
32+
"no-console": "off",
33+
"@typescript-eslint/no-require-imports": "off"
3234
}
3335
},
3436
{
@@ -38,6 +40,20 @@ export default tseslint.config(
3840
"no-console": "off"
3941
}
4042
},
43+
{
44+
// Platform-node: require() needed for dynamic module loading at runtime
45+
files: ["packages/foundation/platform-node/**/*.ts"],
46+
rules: {
47+
"@typescript-eslint/no-require-imports": "off"
48+
}
49+
},
50+
{
51+
// Memory driver: require('fs') needed for persistence
52+
files: ["packages/drivers/memory/src/index.ts", "packages/drivers/memory/test/index.test.ts"],
53+
rules: {
54+
"@typescript-eslint/no-require-imports": "off"
55+
}
56+
},
4157
{
4258
// SDK driver: logging is user-controlled via enableLogging flag
4359
files: ["packages/drivers/sdk/src/index.ts"],

packages/foundation/plugin-formula/src/formula-engine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class FormulaEngine {
210210

211211
// Create and execute function
212212

213-
const func = new Function(...paramNames, wrappedExpression);
213+
const func = new Function(...paramNames, wrappedExpression) as (...args: any[]) => unknown;
214214

215215
// Execute with timeout protection
216216
const result = this.executeWithTimeout(func, paramValues, timeout);
@@ -289,7 +289,7 @@ export class FormulaEngine {
289289
* runtime; instead, formulas must be written to be fast and side-effect free.
290290
*/
291291
private executeWithTimeout(
292-
func: Function,
292+
func: (...args: any[]) => unknown,
293293
args: any[],
294294
timeout: number
295295
): unknown {

packages/foundation/plugin-multitenancy/__tests__/demo.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ describe('Multi-Tenancy E2E Demo', () => {
1717
});
1818

1919
// Simulate kernel installation
20-
const mockHooks = new Map<string, Function[]>();
20+
const mockHooks = new Map<string, ((...args: any[]) => any)[]>();
2121
const mockKernel = {
2222
hooks: {
23-
register: (name: string, handler: Function) => {
23+
register: (name: string, handler: (...args: any[]) => any) => {
2424
if (!mockHooks.has(name)) {
2525
mockHooks.set(name, []);
2626
}
@@ -31,7 +31,7 @@ describe('Multi-Tenancy E2E Demo', () => {
3131

3232
await plugin.install({
3333
engine: mockKernel,
34-
hook: (name: string, handler: Function) => {
34+
hook: (name: string, handler: (...args: any[]) => any) => {
3535
if (!mockHooks.has(name)) {
3636
mockHooks.set(name, []);
3737
}

packages/foundation/plugin-multitenancy/__tests__/integration.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { MultiTenancyPlugin, TenantIsolationError } from '../src';
88

99
describe('MultiTenancyPlugin - Integration', () => {
1010
let plugin: MultiTenancyPlugin;
11-
let mockHooks: Map<string, Function[]>;
11+
let mockHooks: Map<string, ((...args: any[]) => any)[]>;
1212

1313
beforeEach(() => {
1414
mockHooks = new Map();
@@ -23,15 +23,15 @@ describe('MultiTenancyPlugin - Integration', () => {
2323
const createMockContext = () => {
2424
const hooks = mockHooks;
2525
return {
26-
hook: (name: string, handler: Function) => {
26+
hook: (name: string, handler: (...args: any[]) => any) => {
2727
if (!hooks.has(name)) {
2828
hooks.set(name, []);
2929
}
3030
hooks.get(name)!.push(handler);
3131
},
3232
engine: {
3333
hooks: {
34-
register: (name: string, handler: Function) => {
34+
register: (name: string, handler: (...args: any[]) => any) => {
3535
if (!hooks.has(name)) {
3636
hooks.set(name, []);
3737
}

packages/foundation/plugin-security/__tests__/plugin.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ const ACCOUNTS_PERM: PermissionConfig = {
3636
};
3737

3838
function createMockKernel() {
39-
const hooks: Record<string, Function[]> = {};
39+
const hooks: Record<string, ((...args: any[]) => any)[]> = {};
4040
return {
4141
security: undefined as any,
42-
use: jest.fn((hookName: string, handler: Function) => {
42+
use: jest.fn((hookName: string, handler: (...args: any[]) => any) => {
4343
if (!hooks[hookName]) hooks[hookName] = [];
4444
hooks[hookName].push(handler);
4545
}),

packages/foundation/types/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class ObjectQLError extends Error {
9797
this.details = error.details;
9898

9999
// Preserve proper stack traces in Node.js environments
100-
const ErrorConstructor = Error as unknown as { captureStackTrace?: (target: object, constructor: Function) => void };
100+
const ErrorConstructor = Error as unknown as { captureStackTrace?: (target: object, constructor: new (...args: any[]) => any) => void };
101101
if (typeof ErrorConstructor.captureStackTrace === 'function') {
102102
ErrorConstructor.captureStackTrace(this, ObjectQLError);
103103
}

packages/protocols/json-rpc/src/features.e2e.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const createTestKernel = () => {
6565
};
6666

6767
// Mock action registry
68-
const actions = new Map<string, Function>();
68+
const actions = new Map<string, (...args: any[]) => any>();
6969
actions.set('sendEmail', async (params: any) => {
7070
return {
7171
success: true,

packages/protocols/json-rpc/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class JSONRPCPlugin implements RuntimePlugin {
146146

147147
private engine?: any;
148148
private config: Required<JSONRPCPluginConfig>;
149-
private methods: Map<string, Function>;
149+
private methods: Map<string, (...args: any[]) => any>;
150150
private methodSignatures: Map<string, MethodSignature>;
151151
private sessions: Map<string, Session> = new Map();
152152
private progressClients: Map<string, Set<(data: string) => void>> = new Map();

0 commit comments

Comments
 (0)