Skip to content

Commit

Permalink
Whitespace ESLint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
N2D4 committed Jun 7, 2024
1 parent ca7da8d commit 7938ff6
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 12 deletions.
7 changes: 5 additions & 2 deletions apps/custom-pages-example/src/app/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export default function CustomCredentialSignIn() {
};

return (
<form onSubmit={(e) => { e.preventDefault(); onSubmit(); } }>
<form onSubmit={(e) => {
e.preventDefault();
onSubmit();
}}>
{error}
{message ?
<div>{message}</div> :
Expand All @@ -94,4 +97,4 @@ export default function CustomCredentialSignIn() {
</>}
</form>
);
}
}
7 changes: 5 additions & 2 deletions apps/custom-pages-example/src/app/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ export default function CustomCredentialSignUp() {
};

return (
<form onSubmit={(e) => { e.preventDefault(); onSubmit(); } }>
<form onSubmit={(e) => {
e.preventDefault();
onSubmit();
}}>
{error}
<input type='email' placeholder="[email protected]" value={email} onChange={(e) => setEmail(e.target.value)} />
<input type='password' placeholder="password" value={password} onChange={(e) => setPassword(e.target.value)} />
<button type='submit'>Sign Up</button>
</form>
);
}
}
3 changes: 3 additions & 0 deletions eslint-configs/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = {
"CallExpression",
],
}],
"keyword-spacing": "warn",
"block-spacing": "warn",
"max-statements-per-line": "warn",
semi: ["error", "always"],
"no-fallthrough": "error",
"@typescript-eslint/switch-exhaustiveness-check": "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ export default function PageClient() {
</div>
<div className="flex-grow flex justify-start items-end gap-2">
<Button variant='secondary' onClick={() => router.push('emails/templates/' + template.type)}>Edit Template</Button>
{!template.default && <ActionCell dangerItems={[{ item: 'Reset to Default', onClick: () => { setResetTemplateType(template.type); setResetTemplateDialogOpen(true); } }]} />}
{!template.default && <ActionCell
dangerItems={[{
item: 'Reset to Default',
onClick: () => {
setResetTemplateType(template.type);
setResetTemplateDialogOpen(true);
}
}]}
/>}
</div>
</div>
<EmailPreview content={template.content} type={template.type} />
Expand Down
18 changes: 14 additions & 4 deletions packages/stack-server/src/components/form-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export function SmartFormDialog<S extends yup.ObjectSchema<any, any, any, any>>(
<ActionDialog
{...props}
open={props.open ?? openState}
onOpenChange={(open) => { setOpenState(open); props.onOpenChange?.(open); }}
onOpenChange={(open) => {
setOpenState(open);
props.onOpenChange?.(open);
}}
okButton={{
onClick: async () => "prevent-close",
...(typeof props.okButton === "boolean" ? {} : props.okButton),
Expand Down Expand Up @@ -89,12 +92,19 @@ export function FormDialog<F extends FieldValues>(
<ActionDialog
{...props}
open={props.open ?? openState}
onOpenChange={(open) => { if(open) setOpenState(true); props.onOpenChange?.(open); }}
onClose={() => { form.reset(); setOpenState(false); runAsynchronouslyWithAlert(props.onClose?.()); }}
onOpenChange={(open) => {
if (open) setOpenState(true);
props.onOpenChange?.(open);
}}
onClose={() => {
form.reset();
setOpenState(false);
runAsynchronouslyWithAlert(props.onClose?.());
}}
okButton={{
onClick: async () => "prevent-close",
...(typeof props.okButton == "boolean" ? {} : props.okButton),
props: {
props: {
form: formId,
type: "submit",
loading: submitting,
Expand Down
2 changes: 1 addition & 1 deletion packages/stack-server/src/lib/permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export async function listUserDirectPermissions({
p => serverPermissionDefinitionJsonFromDbType(p.permission)
).filter(
p => {
switch(p.scope.type) {
switch (p.scope.type) {
case "global": {
return type === "global";
}
Expand Down
11 changes: 10 additions & 1 deletion packages/stack-server/src/route-handlers/smart-route-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { runAsynchronously, wait } from "@stackframe/stack-shared/dist/utils/pro
import { MergeSmartRequest, SmartRequest, createLazyRequestParser } from "./smart-request";
import { SmartResponse, createResponse } from "./smart-response";

/**
* Known errors that are common and should not be logged with their stacktrace.
*/
const commonErrors = [
KnownErrors.AccessTokenExpired,
];

/**
* Catches the given error, logs it if needed and returns it as a StatusError. Errors that are not actually errors
* (such as Next.js redirects) will be rethrown.
Expand Down Expand Up @@ -73,7 +80,9 @@ export function deprecatedSmartRouteHandler(handler: (req: NextRequest, options:
}

console.log(`[ ERR] [${requestId}] ${req.method} ${req.url}: ${statusError.message}`);
console.debug(`For the error above with request ID ${requestId}, the full error is:`, statusError);
if (!commonErrors.some(e => statusError instanceof e)) {
console.debug(`For the error above with request ID ${requestId}, the full error is:`, statusError);
}

const res = await createResponse(req, requestId, {
statusCode: statusError.statusCode,
Expand Down
2 changes: 1 addition & 1 deletion packages/stack-shared/src/hooks/use-async-callback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function useAsyncCallback<A extends any[], R>(
setLoadingCount((c) => c + 1);
try {
return await callback(...args);
} catch(e) {
} catch (e) {
setError(e);
throw e;
} finally {
Expand Down

0 comments on commit 7938ff6

Please sign in to comment.