diff --git a/.vscode/settings.json b/.vscode/settings.json index 55712c19..25fa6215 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "typescript.tsdk": "node_modules/typescript/lib" -} \ No newline at end of file + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/cdk/jest.config.js b/cdk/jest.config.js index 08263b89..a8f075a5 100644 --- a/cdk/jest.config.js +++ b/cdk/jest.config.js @@ -1,8 +1,8 @@ module.exports = { - testEnvironment: 'node', - roots: ['/test'], - testMatch: ['**/*.test.ts'], + testEnvironment: "node", + roots: ["/test"], + testMatch: ["**/*.test.ts"], transform: { - '^.+\\.tsx?$': 'ts-jest' - } + "^.+\\.tsx?$": "ts-jest", + }, }; diff --git a/cdk/lambdas/imageResize.js b/cdk/lambdas/imageResize.js index d294fa58..cee94879 100644 --- a/cdk/lambdas/imageResize.js +++ b/cdk/lambdas/imageResize.js @@ -37,7 +37,7 @@ exports.handler = async (event) => { Bucket: bucket, Key: targetKey, Body: resizedImage, - }) + }), ); return { diff --git a/cdk/lib/app-stack.ts b/cdk/lib/app-stack.ts index 89286898..c2b380c2 100644 --- a/cdk/lib/app-stack.ts +++ b/cdk/lib/app-stack.ts @@ -28,7 +28,7 @@ export class AppStack extends cdk.Stack { const domainName = ssm.StringParameter.valueForStringParameter( this, `/env/domainName`, - 1 + 1, ); const wwwDomainName = `www.${domainName}`; @@ -49,7 +49,7 @@ export class AppStack extends cdk.Stack { effect: iam.Effect.ALLOW, actions: ["s3:*Object", "SES:*"], resources: ["*"], - }) + }), ); taskDef @@ -65,36 +65,36 @@ export class AppStack extends cdk.Stack { ssm.StringParameter.fromSecureStringParameterAttributes( this, "dbUrl", - { parameterName: "/env/db/dbUrl", version: 1 } - ) + { parameterName: "/env/db/dbUrl", version: 1 }, + ), ), GITHUB_SECRET: ecs.Secret.fromSsmParameter( ssm.StringParameter.fromStringParameterName( this, "githubSecret", - "/env/githubSecret" - ) + "/env/githubSecret", + ), ), GITHUB_ID: ecs.Secret.fromSsmParameter( ssm.StringParameter.fromStringParameterName( this, "githubId", - "/env/githubId" - ) + "/env/githubId", + ), ), NEXTAUTH_SECRET: ecs.Secret.fromSsmParameter( ssm.StringParameter.fromStringParameterName( this, "nextauthSecret", - "/env/nextauthSecret" - ) + "/env/nextauthSecret", + ), ), DISCORD_INVITE_URL: ecs.Secret.fromSsmParameter( ssm.StringParameter.fromStringParameterName( this, "discordInviteUrl", - "/env/discordInviteUrl" - ) + "/env/discordInviteUrl", + ), ), }, logging: ecs.LogDrivers.awsLogs({ @@ -115,7 +115,7 @@ export class AppStack extends cdk.Stack { cpu: production ? 256 : 256, // Can alter if need more publicLoadBalancer: true, protocol: elbv2.ApplicationProtocol.HTTP, - } + }, ); fargateService.listener.addAction("DefaultListenerRule", { @@ -158,7 +158,7 @@ export class AppStack extends cdk.Stack { fargateService.service.connections.allowFromAnyIpv4( ec2.Port.tcp(this.appPort), - "app-inbound" + "app-inbound", ); this.loadbalancer = fargateService.loadBalancer; diff --git a/cdk/lib/cdn-stack.ts b/cdk/lib/cdn-stack.ts index f01ac7e8..395a2ace 100644 --- a/cdk/lib/cdn-stack.ts +++ b/cdk/lib/cdn-stack.ts @@ -20,13 +20,13 @@ export class CdnStack extends cdk.Stack { const domainName = ssm.StringParameter.valueForStringParameter( this, `/env/domainName`, - 1 + 1, ); const hostedZoneId = ssm.StringParameter.valueForStringParameter( this, `/env/hostedZoneId`, - 1 + 1, ); const wwwDomainName = `www.${domainName}`; @@ -70,12 +70,12 @@ export class CdnStack extends cdk.Stack { certificate, { aliases: [domainName], - } + }, ), comment: `Redirect to ${wwwDomainName} from ${domainName}`, priceClass: cloudfront.PriceClass.PRICE_CLASS_ALL, viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS, - } + }, ); const webDistribution = new cloudfront.CloudFrontWebDistribution( @@ -120,19 +120,19 @@ export class CdnStack extends cdk.Stack { certificate, { aliases: [wwwDomainName], - } + }, ), comment: `Web distribution for ${wwwDomainName}`, priceClass: cloudfront.PriceClass.PRICE_CLASS_ALL, viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS, - } + }, ); const redirectRecordProps = { zone, recordName: domainName, target: route53.RecordTarget.fromAlias( - new targets.CloudFrontTarget(redirectDist) + new targets.CloudFrontTarget(redirectDist), ), }; @@ -140,14 +140,14 @@ export class CdnStack extends cdk.Stack { new route53.AaaaRecord( this, "AaaaRedirectAliasRecord", - redirectRecordProps + redirectRecordProps, ); const recordProps = { zone, recordName: wwwDomainName, target: route53.RecordTarget.fromAlias( - new targets.CloudFrontTarget(webDistribution) + new targets.CloudFrontTarget(webDistribution), ), }; diff --git a/cdk/lib/pipeline-stack.ts b/cdk/lib/pipeline-stack.ts index e23f4713..ece825cc 100644 --- a/cdk/lib/pipeline-stack.ts +++ b/cdk/lib/pipeline-stack.ts @@ -28,12 +28,12 @@ export class PipelineStack extends cdk.Stack { const devAccountId = ssm.StringParameter.valueFromLookup( this, - `/env/dev/accountId` + `/env/dev/accountId`, ); const prodAccountId = ssm.StringParameter.valueFromLookup( this, - `/env/prod/accountId` + `/env/prod/accountId`, ); const defaultRegion = "eu-west-1"; diff --git a/cdk/lib/storage-stack.ts b/cdk/lib/storage-stack.ts index 104c141e..d3d66ad7 100644 --- a/cdk/lib/storage-stack.ts +++ b/cdk/lib/storage-stack.ts @@ -33,7 +33,7 @@ export class StorageStack extends cdk.Stack { const bucketName = ssm.StringParameter.valueForStringParameter( this, "/env/bucketname", - 1 + 1, ); this.originAccessIdentity = new OriginAccessIdentity(this, "OAI", { @@ -77,19 +77,19 @@ export class StorageStack extends cdk.Stack { new S3EventSource(this.bucket, { events: [s3.EventType.OBJECT_CREATED], filters: [{ prefix: "u/" }], - }) + }), ); const dbUsername = ssm.StringParameter.valueForStringParameter( this, "/env/db/username", - 1 + 1, ); const dbName = ssm.StringParameter.valueForStringParameter( this, "/env/db/name", - 1 + 1, ); // RDS @@ -101,7 +101,7 @@ export class StorageStack extends cdk.Stack { }), credentials: rds.Credentials.fromPassword( dbUsername, - cdk.SecretValue.ssmSecure("/env/db/password", "1") + cdk.SecretValue.ssmSecure("/env/db/password", "1"), ), vpc: vpc, vpcSubnets: vpc.selectSubnets({ @@ -109,7 +109,7 @@ export class StorageStack extends cdk.Stack { }), instanceType: ec2.InstanceType.of( ec2.InstanceClass.T4G, - ec2.InstanceSize.MICRO + ec2.InstanceSize.MICRO, ), allocatedStorage: 20, maxAllocatedStorage: 100, diff --git a/cdk/tsconfig.json b/cdk/tsconfig.json index 1c5a81e1..a3a7201d 100644 --- a/cdk/tsconfig.json +++ b/cdk/tsconfig.json @@ -3,9 +3,7 @@ "jsx": "react", "target": "ES2020", "module": "commonjs", - "lib": [ - "es2020", "dom" - ], + "lib": ["es2020", "dom"], "esModuleInterop": true, "declaration": true, "strict": true, @@ -21,13 +19,7 @@ "inlineSources": true, "experimentalDecorators": true, "strictPropertyInitialization": false, - "typeRoots": [ - "./node_modules/@types" - ] + "typeRoots": ["./node_modules/@types"] }, - "exclude": [ - "lambdas", - "node_modules", - "cdk.out" - ] + "exclude": ["lambdas", "node_modules", "cdk.out"] } diff --git a/components/ArticleSearch/SearchBar.tsx b/components/ArticleSearch/SearchBar.tsx index 1e4e5043..eeb96587 100644 --- a/components/ArticleSearch/SearchBar.tsx +++ b/components/ArticleSearch/SearchBar.tsx @@ -1,4 +1,3 @@ - interface Props { searchTerm: string; setSearchTerm: React.Dispatch>; @@ -10,7 +9,7 @@ const SearchBar = (props: Props) => { console.log(searchTerm); return ( -
+
setSearchTerm(e.target.value)} diff --git a/components/Comments/CommentsArea.tsx b/components/Comments/CommentsArea.tsx index 0ff79db9..939ad1de 100644 --- a/components/Comments/CommentsArea.tsx +++ b/components/Comments/CommentsArea.tsx @@ -116,12 +116,12 @@ const CommentsArea = ({ postId, postOwnerId }: Props) => { const onSubmit = async ( body: string, parentId: number | undefined, - fieldName: FieldName + fieldName: FieldName, ) => { // vaidate markdoc syntax const ast = Markdoc.parse(body); const errors = Markdoc.validate(ast, config).filter( - (e) => e.error.level === "critical" + (e) => e.error.level === "critical", ); if (errors.length > 0) { @@ -164,7 +164,7 @@ const CommentsArea = ({ postId, postOwnerId }: Props) => { const generateComments = ( commentsArr: Comments | Children | undefined, - depth = 0 + depth = 0, ) => { if (!commentsArr) return null; return commentsArr.map( @@ -196,7 +196,7 @@ const CommentsArea = ({ postId, postOwnerId }: Props) => { year: "numeric", month: "long", day: "numeric", - } + }, ); const commentUpdated = @@ -321,7 +321,7 @@ const CommentsArea = ({ postId, postOwnerId }: Props) => { // TODO: Add alert to confirm reset if there is already content being written resetField("reply"); setShowCommentBoxId((currentId) => - currentId === id ? null : id + currentId === id ? null : id, ); } }} @@ -362,7 +362,7 @@ const CommentsArea = ({ postId, postOwnerId }: Props) => { )} ); - } + }, ); }; @@ -415,7 +415,7 @@ const CommentsArea = ({ postId, postOwnerId }: Props) => { React, { components: markdocComponents, - } + }, )} ) : ( diff --git a/components/Course/CoursePreview.tsx b/components/Course/CoursePreview.tsx index 40ff566b..5b0ec461 100644 --- a/components/Course/CoursePreview.tsx +++ b/components/Course/CoursePreview.tsx @@ -17,11 +17,16 @@ const CoursePreview = ({ name, description, thumbnail }: Props) => { {name}
-

{name}

-
+

+ {name} +

+
- ) -} + ); +}; -export default CoursePreview +export default CoursePreview; diff --git a/components/CustomTextareAutosize/CustomTextareaAutosize.tsx b/components/CustomTextareAutosize/CustomTextareaAutosize.tsx index 968d1c7d..65c02a49 100644 --- a/components/CustomTextareAutosize/CustomTextareaAutosize.tsx +++ b/components/CustomTextareAutosize/CustomTextareaAutosize.tsx @@ -1,30 +1,35 @@ -import React, { forwardRef, Ref, ForwardRefRenderFunction } from 'react'; -import TextareaAutosize, { TextareaAutosizeProps } from 'react-textarea-autosize'; +import React, { forwardRef, Ref, ForwardRefRenderFunction } from "react"; +import TextareaAutosize, { + TextareaAutosizeProps, +} from "react-textarea-autosize"; interface TextareaAutosizeWrapperProps extends TextareaAutosizeProps { inputRef?: Ref; } -const TextareaAutosizeWrapper: ForwardRefRenderFunction = ( - props, - ref -) => { +const TextareaAutosizeWrapper: ForwardRefRenderFunction< + HTMLTextAreaElement, + TextareaAutosizeWrapperProps +> = (props, ref) => { const { inputRef, ...rest } = props; const combinedRef = (node: HTMLTextAreaElement | null) => { if (ref) { - if (typeof ref === 'function') { + if (typeof ref === "function") { ref(node); } else { - (ref as React.MutableRefObject).current = node; + (ref as React.MutableRefObject).current = + node; } } if (inputRef) { - if (typeof inputRef === 'function') { + if (typeof inputRef === "function") { inputRef(node); } else { - (inputRef as React.MutableRefObject).current = node; + ( + inputRef as React.MutableRefObject + ).current = node; } } }; diff --git a/components/Nav/MobileNav.tsx b/components/Nav/MobileNav.tsx index 6f98967a..3ae01e38 100644 --- a/components/Nav/MobileNav.tsx +++ b/components/Nav/MobileNav.tsx @@ -75,7 +75,7 @@ const MobileNav: FunctionComponent = ({ {item.name} - ) + ), )}
@@ -132,7 +132,7 @@ const SubNav: FunctionComponent = ({ session }) => { item.fancy ? "bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm px-4 block justify-center text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300" : "text-neutral-900 hover:text-black hover:bg-neutral-300 focus:bg-neutral-300 dark:focus:bg-neutral-900 focus:text-black dark:text-neutral-300 dark:hover:bg-neutral-900 dark:hover:text-white block px-3", - "rounded-md text-base font-medium py-2 text-center" + "rounded-md text-base font-medium py-2 text-center", )} key={item.name} href={item.href} diff --git a/components/Nav/Nav.tsx b/components/Nav/Nav.tsx index 16ae3332..5f1ce765 100644 --- a/components/Nav/Nav.tsx +++ b/components/Nav/Nav.tsx @@ -94,7 +94,7 @@ const Nav = () => { > {item.name} - ) + ), )} diff --git a/components/PromptService/PromptService.tsx b/components/PromptService/PromptService.tsx index cfab92b7..9ea198cd 100644 --- a/components/PromptService/PromptService.tsx +++ b/components/PromptService/PromptService.tsx @@ -37,7 +37,7 @@ export const PromptDialog = ({ router.events.emit("routeChangeError"); throw "Aborting route change. Please ignore this error."; }, - [shouldConfirmLeave] + [shouldConfirmLeave], ); const cancelRouteChange = () => { diff --git a/components/editor/editor/RenderPost.tsx b/components/editor/editor/RenderPost.tsx index fbe1ba4c..52b26033 100644 --- a/components/editor/editor/RenderPost.tsx +++ b/components/editor/editor/RenderPost.tsx @@ -1,7 +1,7 @@ -import React, { useMemo } from 'react'; -import DOMPurify from 'dompurify'; -import { generateHTML } from '@tiptap/core'; -import { TiptapExtensions } from './extensions'; +import React, { useMemo } from "react"; +import DOMPurify from "dompurify"; +import { generateHTML } from "@tiptap/core"; +import { TiptapExtensions } from "./extensions"; interface RenderPostProps { json: string; @@ -13,9 +13,7 @@ const RenderPost = ({ json }: RenderPostProps) => { return DOMPurify.sanitize(rawHTML); }, [json]); - return ( -
- ); + return
; }; export default RenderPost; diff --git a/components/editor/editor/components/bubble-menu.tsx b/components/editor/editor/components/bubble-menu.tsx index 17235aa8..c9f4b1f1 100644 --- a/components/editor/editor/components/bubble-menu.tsx +++ b/components/editor/editor/components/bubble-menu.tsx @@ -93,7 +93,7 @@ export const EditorBubbleMenu: FC = (props) => {
{items.map((item, index) => ( ))}
- ); -}; \ No newline at end of file +}; diff --git a/components/editor/editor/components/color-selector.tsx b/components/editor/editor/components/color-selector.tsx index a1f1d666..d5e608a5 100644 --- a/components/editor/editor/components/color-selector.tsx +++ b/components/editor/editor/components/color-selector.tsx @@ -107,7 +107,7 @@ export const ColorSelector: FC = ({ return (
); } diff --git a/components/editor/editor/plugins/upload-images.tsx b/components/editor/editor/plugins/upload-images.tsx index fda362ee..17d84f75 100644 --- a/components/editor/editor/plugins/upload-images.tsx +++ b/components/editor/editor/plugins/upload-images.tsx @@ -27,7 +27,7 @@ const UploadImagesPlugin = () => const image = document.createElement("img"); image.setAttribute( "class", - "opacity-40 rounded-lg border border-stone-200" + "opacity-40 rounded-lg border border-stone-200", ); image.src = src; placeholder.appendChild(image); @@ -37,7 +37,7 @@ const UploadImagesPlugin = () => set = set.add(tr.doc, [deco]); } else if (action && action.remove) { set = set.remove( - set.find(null, null, (spec) => spec.id == action.remove.id) + set.find(null, null, (spec) => spec.id == action.remove.id), ); } return set; @@ -140,7 +140,7 @@ export const handleImageUpload = (file: File) => { resolve(file); throw new Error( - "`BLOB_READ_WRITE_TOKEN` environment variable not found, reading image locally instead." + "`BLOB_READ_WRITE_TOKEN` environment variable not found, reading image locally instead.", ); // Unknown error } else { @@ -151,7 +151,7 @@ export const handleImageUpload = (file: File) => { loading: "Uploading image...", success: "Image uploaded successfully.", error: (e) => e.message, - } + }, ); }); }; diff --git a/components/editor/icons/index.tsx b/components/editor/icons/index.tsx index a5e00998..5b284462 100644 --- a/components/editor/icons/index.tsx +++ b/components/editor/icons/index.tsx @@ -1,3 +1,3 @@ -export { default as FontDefault } from './font-default' -export { default as FontSerif } from './font-serif' -export { default as FontMono } from './font-mono' +export { default as FontDefault } from "./font-default"; +export { default as FontSerif } from "./font-serif"; +export { default as FontMono } from "./font-mono"; diff --git a/components/editor/primitives/popover.tsx b/components/editor/primitives/popover.tsx index db2dda62..78c34787 100644 --- a/components/editor/primitives/popover.tsx +++ b/components/editor/primitives/popover.tsx @@ -19,7 +19,7 @@ const PopoverContent = React.forwardRef< sideOffset={sideOffset} className={cn( "z-50 items-center rounded-md border border-stone-200 bg-white shadow-md animate-in fade-in-20 slide-in-from-top-1", - className + className, )} {...props} /> diff --git a/components/markdocNodes/CodePen/CodePen.tsx b/components/markdocNodes/CodePen/CodePen.tsx index 84c8fc9f..1b8e4b97 100644 --- a/components/markdocNodes/CodePen/CodePen.tsx +++ b/components/markdocNodes/CodePen/CodePen.tsx @@ -6,18 +6,18 @@ interface Props { export function CodePen({ src, - defaultTab = 'html,result', - height = '300px', + defaultTab = "html,result", + height = "300px", }: Props) { const codePenSrc = new URL(src); - if (!codePenSrc.searchParams.get('default-tab')) { - codePenSrc.searchParams.set('default-tab', defaultTab); + if (!codePenSrc.searchParams.get("default-tab")) { + codePenSrc.searchParams.set("default-tab", defaultTab); } return (