Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

chore: extend ESLint configs from plugin:typescript-eslint/recommended (#1691)

Josh Goldberg ✨e9e005e3aafa
diff --git a/apps/admin/src/utils/with-unstable-cache.ts b/apps/admin/src/utils/with-unstable-cache.ts
index 2a4e13cf..f9686dad 100644
--- a/apps/admin/src/utils/with-unstable-cache.ts
+++ b/apps/admin/src/utils/with-unstable-cache.ts
@@ -1,6 +1,7 @@
import { unstable_cache } from 'next/cache';
-// eslint-disable-next-line
+// TODO: there is definitely a way to get this to work
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function withUnstableCache<T extends (...args: any[]) => Promise<any>>(opts: {
fn: T;
args: Parameters<T>;
diff --git a/apps/aot/src/app/events/[year]/[day]/_components/challenge-layout.tsx b/apps/aot/src/app/events/[year]/[day]/_components/challenge-layout.tsx
index 5222e52e..e748ceb0 100644
--- a/apps/aot/src/app/events/[year]/[day]/_components/challenge-layout.tsx
+++ b/apps/aot/src/app/events/[year]/[day]/_components/challenge-layout.tsx
@@ -179,11 +179,14 @@ export function ChallengeLayout({
}
}
+ // TODO: Either leftSide.current is always defined, or leftWidth can be nullish
+ /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
if (isDesktop) {
leftWidth = leftSide.current?.getBoundingClientRect().width!;
} else {
topHeight = leftSide.current?.getBoundingClientRect().height!;
}
+ /* eslint-enable @typescript-eslint/no-non-null-asserted-optional-chain */
// Attach the listeners to `document`
if (e instanceof MouseEvent) {
diff --git a/apps/aot/src/app/events/[year]/[day]/_components/comments/comment-input.tsx b/apps/aot/src/app/events/[year]/[day]/_components/comments/comment-input.tsx
index 18e20eff..82d4f3af 100644
--- a/apps/aot/src/app/events/[year]/[day]/_components/comments/comment-input.tsx
+++ b/apps/aot/src/app/events/[year]/[day]/_components/comments/comment-input.tsx
@@ -43,6 +43,8 @@ export const CommentInput = forwardRef<CommentInputRefProps, CommentInputProps>(
// We need to control the textarea element from parent component.
useImperativeHandle(ref, () => ({
+ // TODO: Either textAreaRef is always defined, or textarea can be nullish
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
textarea: textAreaRef?.current!,
setInputValue: (value: string) => {
form.setValue('text', value);
@@ -156,6 +158,7 @@ function useAutosizeTextArea(
// Trying to set this with state or a ref will product an incorrect value.
textAreaRef.current.style.height = `${scrollHeight}px`;
}
- // eslint-disable-next-line
+ // TODO: Fix this incorrect set of deps
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [textAreaRef.current, value, commentMode]);
}
diff --git a/apps/aot/src/app/events/[year]/[day]/_components/description/index.tsx b/apps/aot/src/app/events/[year]/[day]/_components/description/index.tsx
index f859e98d..e1e4f2e2 100644
--- a/apps/aot/src/app/events/[year]/[day]/_components/description/index.tsx
+++ b/apps/aot/src/app/events/[year]/[day]/_components/description/index.tsx
@@ -52,7 +52,8 @@ export function Description({ challenge }: DescriptionProps) {
return (
<div
- // eslint-disable-next-line
+ // TODO: Fix this accessibility issue!
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
className="custom-scrollable-element h-full overflow-y-auto px-4 pb-[11.4rem] pt-3 outline-none"
>
@@ -128,6 +129,8 @@ export function Description({ challenge }: DescriptionProps) {
shouldBookmark = true;
setHasBookmarked(true);
}
+ // TODO: Is this guaranteed to exist, or is userId actually optional?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
debouncedBookmark(challenge.id, session.data?.user?.id!, shouldBookmark)?.catch(
(e) => {
console.error(e);
diff --git a/apps/aot/src/app/events/[year]/[day]/solutions/_components/edit-solution.tsx b/apps/aot/src/app/events/[year]/[day]/solutions/_components/edit-solution.tsx
index f1d04d38..67811656 100644
--- a/apps/aot/src/app/events/[year]/[day]/solutions/_components/edit-solution.tsx
+++ b/apps/aot/src/app/events/[year]/[day]/solutions/_components/edit-solution.tsx
@@ -49,6 +49,8 @@ export function EditSolution({ solution, setIsEditing }: EditSolutionProps) {
description: data.content ?? '',
slug: slug as string,
title: data.title ?? '',
+ // TODO: Is this guaranteed to exist, or is userId actually optional?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
userId: session.data?.user?.id!,
});
diff --git a/apps/aot/src/app/events/[year]/[day]/solutions/_components/solution-editor.tsx b/apps/aot/src/app/events/[year]/[day]/solutions/_components/solution-editor.tsx
index b11d4c23..e45ed297 100644
--- a/apps/aot/src/app/events/[year]/[day]/solutions/_components/solution-editor.tsx
+++ b/apps/aot/src/app/events/[year]/[day]/solutions/_components/solution-editor.tsx
@@ -67,6 +67,8 @@ export function SolutionEditor({ dismiss, challengeId, code }: SolutionEditorPro
description: data.content ?? '',
slug,
title: data.title ?? `${session.data?.user?.name}'s Solution`,
+ // TODO: Is this guaranteed to exist, or is userId actually optional?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
userId: session.data?.user?.id!,
});
diff --git a/apps/aot/src/components/landing/Snowfall.tsx b/apps/aot/src/components/landing/Snowfall.tsx
index 9b3e4d06..a6d9d5ee 100644
--- a/apps/aot/src/components/landing/Snowfall.tsx
+++ b/apps/aot/src/components/landing/Snowfall.tsx
@@ -156,8 +156,11 @@ export default function Snowfall() {
}
return () => {
+ // TODO: Is this a bug? () => {} is not the original listener.
+ /* eslint-disable @typescript-eslint/no-empty-function */
removeEventListener('mousemove', () => {});
removeEventListener('resize', () => {});
+ /* eslint-enable @typescript-eslint/no-empty-function */
};
}, []);
diff --git a/apps/aot/src/utils/withUnstableCache.ts b/apps/aot/src/utils/withUnstableCache.ts
index 2a4e13cf..f9686dad 100644
--- a/apps/aot/src/utils/withUnstableCache.ts
+++ b/apps/aot/src/utils/withUnstableCache.ts
@@ -1,6 +1,7 @@
import { unstable_cache } from 'next/cache';
-// eslint-disable-next-line
+// TODO: there is definitely a way to get this to work
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function withUnstableCache<T extends (...args: any[]) => Promise<any>>(opts: {
fn: T;
args: Parameters<T>;
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index aea8186d..e84a278e 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -62,8 +62,6 @@ const withVercelToolbar = vercelToolbar();
export default million.next(
withSentryConfig(
- // NOTE: this whole package is bugged and once they fix this we can remove this workaround
- // @ts-ignore
withBundleAnalyzer(withVercelToolbar(nextConfig)),
{
// For all available options, see:
diff --git a/apps/web/src/app/(playgrounds)/challenge-playground/wrapper.tsx b/apps/web/src/app/(playgrounds)/challenge-playground/wrapper.tsx
index 35cdda6d..cc8f6d4d 100644
--- a/apps/web/src/app/(playgrounds)/challenge-playground/wrapper.tsx
+++ b/apps/web/src/app/(playgrounds)/challenge-playground/wrapper.tsx
@@ -18,6 +18,8 @@ export function Wrapper() {
return (
<CodePanel
challenge={values.challenge}
+ // TODO: Why is saveSubmission required if it's not always provided?
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
saveSubmission={(() => {}) as unknown as CodePanelProps['saveSubmission']}
submissionDisabled={false}
settingsElement={<SettingsElements />}
diff --git a/apps/web/src/app/_components/feature-card.tsx b/apps/web/src/app/_components/feature-card.tsx
index 7b152039..d472b505 100644
--- a/apps/web/src/app/_components/feature-card.tsx
+++ b/apps/web/src/app/_components/feature-card.tsx
@@ -280,6 +280,8 @@ export function ChallengeCreationCard({
}}
/>
<div className="absolute -right-4 bottom-4 w-full">
+ {/* TODO: Why is onChange required if it's not always provided? */}
+ {/* eslint-disable-next-line @typescript-eslint/no-empty-function */}
<Steps current={step} onChange={() => {}} steps={steps} />
</div>
</>
@@ -355,6 +357,8 @@ export function ChallengeCreationCard({
}}
/>
<div className="absolute -right-4 bottom-4 w-full">
+ {/* TODO: Why is onChange required if it's not always provided? */}
+ {/* eslint-disable-next-line @typescript-eslint/no-empty-function */}
<Steps current={step} onChange={() => {}} steps={steps} />
</div>
</>
diff --git a/apps/web/src/app/challenge/[slug]/solutions/_components/edit-solution.tsx b/apps/web/src/app/challenge/[slug]/solutions/_components/edit-solution.tsx
index ba03fcdf..8ea1aedf 100644
--- a/apps/web/src/app/challenge/[slug]/solutions/_components/edit-solution.tsx
+++ b/apps/web/src/app/challenge/[slug]/solutions/_components/edit-solution.tsx
@@ -49,6 +49,8 @@ export function EditSolution({ solution, setIsEditing }: EditSolutionProps) {
description: data.content ?? '',
slug: slug as string,
title: data.title ?? '',
+ // TODO: Is this guaranteed to exist, or is userId actually optional?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
userId: session.data?.user?.id!,
});
diff --git a/apps/web/src/app/challenge/[slug]/solutions/_components/solution-detail.tsx b/apps/web/src/app/challenge/[slug]/solutions/_components/solution-detail.tsx
index 6c3a8608..0365a848 100644
--- a/apps/web/src/app/challenge/[slug]/solutions/_components/solution-detail.tsx
+++ b/apps/web/src/app/challenge/[slug]/solutions/_components/solution-detail.tsx
@@ -103,6 +103,8 @@ export function SolutionDetails({ solution }: SolutionDetailsProps) {
<div className="flex items-center gap-3">
<Vote
challengeSlug={solution.challenge?.slug ?? ''}
+ // TODO: Is this guaranteed to exist, or is userId actually optional?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
toUserId={solution.user?.id!}
voteCount={solution._count.vote}
initialHasVoted={solution.vote.length > 0}
diff --git a/apps/web/src/app/challenge/[slug]/solutions/_components/solution-editor.tsx b/apps/web/src/app/challenge/[slug]/solutions/_components/solution-editor.tsx
index ca5c498a..284fe457 100644
--- a/apps/web/src/app/challenge/[slug]/solutions/_components/solution-editor.tsx
+++ b/apps/web/src/app/challenge/[slug]/solutions/_components/solution-editor.tsx
@@ -65,6 +65,8 @@ export function SolutionEditor({ dismiss, challengeId, code }: SolutionEditorPro
description: data.content ?? '',
slug: slug as string,
title: data.title ?? `${session.data?.user?.name}'s Solution`,
+ // TODO: Is this guaranteed to exist, or is userId actually optional?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
userId: session.data?.user?.id!,
});
diff --git a/apps/web/src/app/challenge/_components/challenge-layout.tsx b/apps/web/src/app/challenge/_components/challenge-layout.tsx
index 5c4c7576..48d2eac4 100644
--- a/apps/web/src/app/challenge/_components/challenge-layout.tsx
+++ b/apps/web/src/app/challenge/_components/challenge-layout.tsx
@@ -188,11 +188,14 @@ export function ChallengeLayout({
}
}
+ // TODO: Either leftSide.current is always defined, or leftWidth can be nullish
+ /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
if (isDesktop) {
leftWidth = leftSide.current?.getBoundingClientRect().width!;
} else {
topHeight = leftSide.current?.getBoundingClientRect().height!;
}
+ /* eslint-enable @typescript-eslint/no-non-null-asserted-optional-chain */
// Attach the listeners to `document`
if (e instanceof MouseEvent) {
diff --git a/apps/web/src/app/challenge/_components/comments/comment-input.tsx b/apps/web/src/app/challenge/_components/comments/comment-input.tsx
index 18e20eff..82d4f3af 100644
--- a/apps/web/src/app/challenge/_components/comments/comment-input.tsx
+++ b/apps/web/src/app/challenge/_components/comments/comment-input.tsx
@@ -43,6 +43,8 @@ export const CommentInput = forwardRef<CommentInputRefProps, CommentInputProps>(
// We need to control the textarea element from parent component.
useImperativeHandle(ref, () => ({
+ // TODO: Either textAreaRef is always defined, or textarea can be nullish
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
textarea: textAreaRef?.current!,
setInputValue: (value: string) => {
form.setValue('text', value);
@@ -156,6 +158,7 @@ function useAutosizeTextArea(
// Trying to set this with state or a ref will product an incorrect value.
textAreaRef.current.style.height = `${scrollHeight}px`;
}
- // eslint-disable-next-line
+ // TODO: Fix this incorrect set of deps
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [textAreaRef.current, value, commentMode]);
}
diff --git a/apps/web/src/app/challenge/_components/description/index.tsx b/apps/web/src/app/challenge/_components/description/index.tsx
index ad9f9d23..08b84e82 100644
--- a/apps/web/src/app/challenge/_components/description/index.tsx
+++ b/apps/web/src/app/challenge/_components/description/index.tsx
@@ -58,7 +58,8 @@ export function Description({ challenge }: DescriptionProps) {
return (
<div
- // eslint-disable-next-line
+ // TODO: Fix this accessibility issue!
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
className="custom-scrollable-element h-full overflow-y-auto px-4 pb-36 pt-3 outline-none"
>
@@ -167,6 +168,8 @@ export function Description({ challenge }: DescriptionProps) {
shouldBookmark = true;
setHasBookmarked(true);
}
+ // TODO: Is this guaranteed to exist, or is userId actually optional?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
debouncedBookmark(challenge.id, session.data?.user?.id!, shouldBookmark)?.catch(
(e) => {
console.error(e);
diff --git a/apps/web/src/app/notifications/notification-page.tsx b/apps/web/src/app/notifications/notification-page.tsx
index 63743ff2..8f64594e 100644
--- a/apps/web/src/app/notifications/notification-page.tsx
+++ b/apps/web/src/app/notifications/notification-page.tsx
@@ -19,7 +19,6 @@ export default function NotificationPage() {
const client = useQueryClient();
const mutation = useMutation({
mutationFn: markNotificationsAsRead,
- onSuccess() {},
});
const onSeen = (id: number) => {
diff --git a/apps/web/src/utils/withUnstableCache.ts b/apps/web/src/utils/withUnstableCache.ts
index 2a4e13cf..f9686dad 100644
--- a/apps/web/src/utils/withUnstableCache.ts
+++ b/apps/web/src/utils/withUnstableCache.ts
@@ -1,6 +1,7 @@
import { unstable_cache } from 'next/cache';
-// eslint-disable-next-line
+// TODO: there is definitely a way to get this to work
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function withUnstableCache<T extends (...args: any[]) => Promise<any>>(opts: {
fn: T;
args: Parameters<T>;
diff --git a/packages/monaco/src/split-editor.tsx b/packages/monaco/src/split-editor.tsx
index 608178b0..484cdf87 100644
--- a/packages/monaco/src/split-editor.tsx
+++ b/packages/monaco/src/split-editor.tsx
@@ -297,6 +297,8 @@ export default function SplitEditor({
debounce(async (monaco: typeof monacoType) => {
inlayHintsRef.current?.dispose();
+ // TODO: Surely monaco is guaranteed to exist, right? Why the optional chaining?
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
const model = monaco?.editor.getModel(monaco.Uri.parse(USER_CODE_PATH))!;
const getTsWorker = await monaco?.languages.typescript.getTypeScriptWorker();
const tsWorker = await getTsWorker?.(model.uri);
diff --git a/packages/monaco/src/twoslash/queries.ts b/packages/monaco/src/twoslash/queries.ts
index 4be2f565..e6d60d40 100644
--- a/packages/monaco/src/twoslash/queries.ts
+++ b/packages/monaco/src/twoslash/queries.ts
@@ -132,6 +132,8 @@ export async function getHintsFromQueries(queryInfo: Query): Promise<{
return {
hints: results,
+ // TODO: is InlayHintList's dispose() required? Or is it just an optional Disposable?
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
dispose: () => {},
};
}
diff --git a/packages/ui/src/components/markdown.tsx b/packages/ui/src/components/markdown.tsx
index 36d37b3f..fc21fc51 100644
--- a/packages/ui/src/components/markdown.tsx
+++ b/packages/ui/src/components/markdown.tsx
@@ -25,7 +25,7 @@ const HTML_COMMENT_REGEX = new RegExp('<!--([\\s\\S]*?)-->', 'g');
function removeHtmlComments(): Transformer {
return (tree) => {
// TODO: PRs are welcomed to fix the any type
- // eslint-disable-next-line
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const handler: BuildVisitor<any> = (node, index, parent) => {
const isComment = node.value.match(HTML_COMMENT_REGEX);
diff --git a/packages/ui/src/components/rich-markdown-editor.tsx b/packages/ui/src/components/rich-markdown-editor.tsx
index 53e39f8f..2496abe1 100644
--- a/packages/ui/src/components/rich-markdown-editor.tsx
+++ b/packages/ui/src/components/rich-markdown-editor.tsx
@@ -37,7 +37,6 @@ export function RichMarkdownEditor({
const editorRef = useRef<typeof MDEditor & { textarea: HTMLTextAreaElement }>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const [isImageUploading, setIsImageUploading] = useState(false);
- const handleFileChange = () => {};
const { theme } = useTheme();
useEffect(() => {
@@ -217,7 +216,7 @@ export function RichMarkdownEditor({
<div>Uploading image...</div>
</div>
) : null}
- <input className="hidden" onChange={handleFileChange} ref={fileInputRef} type="file" />
+ <input className="hidden" ref={fileInputRef} type="file" />
</div>
);
}
diff --git a/tooling/config-eslint/node.js b/tooling/config-eslint/node.js
index c044f74b..c76b02ac 100644
--- a/tooling/config-eslint/node.js
+++ b/tooling/config-eslint/node.js
@@ -5,6 +5,7 @@ const { rules } = require('./utils/rules');
module.exports = {
extends: [
'turbo',
+ 'plugin:@typescript-eslint/recommended',
...['@vercel/style-guide/eslint/node', '@vercel/style-guide/eslint/typescript'].map((config) =>
require.resolve(config),
),
diff --git a/tooling/config-eslint/utils/rules.js b/tooling/config-eslint/utils/rules.js
index ca62df95..36327228 100644
--- a/tooling/config-eslint/utils/rules.js
+++ b/tooling/config-eslint/utils/rules.js
@@ -23,9 +23,7 @@ module.exports = {
// ---
// Potential Bugs
'@typescript-eslint/no-confusing-void-expression': 'off',
- '@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-misused-promises': 'off',
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-shadow': 'off',