Skip to content

Commit

Permalink
eslintrc: add typescript-eslint recommended config
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnord committed Aug 21, 2023
1 parent 0a464ab commit cc2f814
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 91 deletions.
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "plugin:react-hooks/recommended", "prettier"],
extends: [
"eslint:recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
env: {
node: true,
"cypress/globals": true,
},
plugins: ["cypress"],
rules: {
"@typescript-eslint/no-namespace": ["error", { allowDeclarations: true }],
},
// We're using vitest which has a very similar API to jest
// (so the linting plugins work nicely), but we have to
// set the jest version explicitly.
Expand Down
4 changes: 2 additions & 2 deletions app/components/prompt/countdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function Countdown({
const center = (numBars - 1) / 2;

const [count, setCount] = React.useState(numBars / 2);
const animationRef = React.useRef<number>();
const animationRef = React.useRef(0);

React.useEffect(() => {
const animate = (timeMs: number) => {
Expand All @@ -44,7 +44,7 @@ export function Countdown({
animationRef.current = requestAnimationFrame(() => animate(startTime));
}

return () => cancelAnimationFrame(animationRef.current!);
return () => cancelAnimationFrame(animationRef.current);
}, [count, startTime, durationSec, numBars]);

const bars = Array.from({ length: numBars }, (_, i) => (
Expand Down
1 change: 1 addition & 0 deletions app/db.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NODE_ENV, SUPABASE_ANON_KEY, SUPABASE_URL } from "~/utils";
let db: SupabaseClient<Database>;

declare global {
// eslint-disable-next-line no-var
var __db__: SupabaseClient<Database>;
}

Expand Down
2 changes: 1 addition & 1 deletion app/engine/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export function gameEngine(state: State, action: Action): State {
const players = new Map(state.players);
const clueValue = state.getClueValue([i, j], userId);

let isAnswered = setIsAnswered(state.isAnswered, i, j, (prev) => {
const isAnswered = setIsAnswered(state.isAnswered, i, j, (prev) => {
prev.answeredBy.set(userId, correct);
});
const numExpectedChecks = isLongForm ? state.answers.size : 1;
Expand Down
3 changes: 3 additions & 0 deletions app/models/convert.server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable no-prototype-builtins */
/* eslint-disable no-empty */
// To parse this data:
//
// import { Convert, Game } from "./file";
Expand Down
4 changes: 2 additions & 2 deletions app/routes/howto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function HowTo() {
const [lockout, setLockout] = React.useState(false);
const [hadLockout, setHadLockout] = React.useState(false);
const [msLeft, setMsLeft] = React.useState<number | undefined>();
const animationRef = React.useRef<number>();
const animationRef = React.useRef(0);

const buzzDurationMs =
buzzedAt !== undefined && buzzerOpenAt !== undefined
Expand Down Expand Up @@ -99,7 +99,7 @@ export default function HowTo() {
animationRef.current = requestAnimationFrame(() => animate(buzzerOpenAt));
}

return () => cancelAnimationFrame(animationRef.current!);
return () => cancelAnimationFrame(animationRef.current);
}, [buzzerOpenAt, buzzedAt]);

return (
Expand Down
2 changes: 0 additions & 2 deletions app/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ declare global {
SUPABASE_ANON_KEY: string;
};
}
}

declare global {
namespace NodeJS {
interface ProcessEnv {
BASE_URL: string;
Expand Down
2 changes: 1 addition & 1 deletion app/utils/use-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from "react";
*/
export default function useScrollToBottom(
callback: () => void,
thresholdPx: number = 50,
thresholdPx = 50,
) {
const [isNearBottom, setIsNearBottom] = React.useState(false);

Expand Down
Loading

0 comments on commit cc2f814

Please sign in to comment.