fix: lint (#7433)
* chore: fix lint * fix: constants check:lint command * chore(lint): permit unused vars which begin w/ _ * chore: rm dead code * fix(lint): more lint fixes to constants pkg * fix(lint): lint the live server - fix lint issues * chore: improve clean script * fix(lint): more lint * chore: set live server process title * chore(deps): update to turbo@2.5.5 * chore(live): target node22 * fix(dev): add missing ui pkg dependency * fix(dev): lint decorators * fix(dev): lint space app * fix(dev): address lint issues in types pkg * fix(dev): lint editor pkg * chore(dev): moar lint * fix(dev): live server exit code * chore: address PR feedback * fix(lint): better TPageExtended type * chore: refactor * chore: revert most live server changes * fix: few more lint issues * chore: enable ci checks Ensure we can build + confirm that lint is not getting worse. * chore: address PR feedback * fix: web lint warning added to package.json * fix: ci:lint command --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
parent
514686d9d5
commit
57479f4554
95 changed files with 348 additions and 460 deletions
|
|
@ -16,7 +16,7 @@ interface ControllerInstance {
|
|||
}
|
||||
|
||||
interface ControllerConstructor {
|
||||
new (...args: any[]): ControllerInstance;
|
||||
new (...args: unknown[]): ControllerInstance;
|
||||
prototype: ControllerInstance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ type RestMethod = "get" | "post" | "put" | "patch" | "delete";
|
|||
* @returns
|
||||
*/
|
||||
export function Controller(baseRoute: string = ""): ClassDecorator {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
return function (target: Function) {
|
||||
Reflect.defineMetadata("baseRoute", baseRoute, target);
|
||||
};
|
||||
|
|
@ -24,11 +25,7 @@ function createHttpMethodDecorator(
|
|||
method: RestMethod,
|
||||
): (route: string) => MethodDecorator {
|
||||
return function (route: string): MethodDecorator {
|
||||
return function (
|
||||
target: object,
|
||||
propertyKey: string | symbol,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
return function (target: object, propertyKey: string | symbol) {
|
||||
Reflect.defineMetadata("method", method, target, propertyKey);
|
||||
Reflect.defineMetadata("route", route, target, propertyKey);
|
||||
};
|
||||
|
|
@ -48,11 +45,7 @@ export const Delete = createHttpMethodDecorator("delete");
|
|||
* @returns
|
||||
*/
|
||||
export function Middleware(middleware: RequestHandler): MethodDecorator {
|
||||
return function (
|
||||
target: object,
|
||||
propertyKey: string | symbol,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
return function (target: object, propertyKey: string | symbol) {
|
||||
const middlewares =
|
||||
Reflect.getMetadata("middlewares", target, propertyKey) || [];
|
||||
middlewares.push(middleware);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ interface ControllerInstance {
|
|||
}
|
||||
|
||||
interface ControllerConstructor {
|
||||
new (...args: any[]): ControllerInstance;
|
||||
new (...args: unknown[]): ControllerInstance;
|
||||
prototype: ControllerInstance;
|
||||
}
|
||||
|
||||
|
|
@ -34,27 +34,23 @@ export function registerWebSocketControllers(
|
|||
|
||||
if (
|
||||
typeof handler === "function" &&
|
||||
typeof (router as any).ws === "function"
|
||||
"ws" in router &&
|
||||
typeof router.ws === "function"
|
||||
) {
|
||||
(router as any).ws(
|
||||
`${baseRoute}${route}`,
|
||||
(ws: WebSocket, req: Request) => {
|
||||
try {
|
||||
handler.call(instance, ws, req);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`WebSocket error in ${Controller.name}.${methodName}`,
|
||||
error,
|
||||
);
|
||||
ws.close(
|
||||
1011,
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Internal server error",
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
router.ws(`${baseRoute}${route}`, (ws: WebSocket, req: Request) => {
|
||||
try {
|
||||
handler.call(instance, ws, req);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`WebSocket error in ${Controller.name}.${methodName}`,
|
||||
error,
|
||||
);
|
||||
ws.close(
|
||||
1011,
|
||||
error instanceof Error ? error.message : "Internal server error",
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ import "reflect-metadata";
|
|||
* @returns
|
||||
*/
|
||||
export function WebSocket(route: string): MethodDecorator {
|
||||
return function (
|
||||
target: object,
|
||||
propertyKey: string | symbol,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
return function (target: object, propertyKey: string | symbol) {
|
||||
Reflect.defineMetadata("method", "ws", target, propertyKey);
|
||||
Reflect.defineMetadata("route", route, target, propertyKey);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["./src"],
|
||||
"include": ["./src", "./*.ts"],
|
||||
"exclude": ["dist", "build", "node_modules"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue