Skip to content

Commit

Permalink
Fix eslint errors + enable linting during CI
Browse files Browse the repository at this point in the history
  • Loading branch information
benvinegar committed Dec 31, 2023
1 parent 09954b0 commit c183ffe
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 93 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ module.exports = {
es6: true,
},

globals: {
// tracker global on window
'tallyho': true
},

// Base config
extends: ["eslint:recommended"],

Expand Down Expand Up @@ -62,6 +67,14 @@ module.exports = {
},
},
},
rules: {
// we're cool with explicit any (for now)
"@typescript-eslint/no-explicit-any": 0,

// https://stackoverflow.com/questions/68802881/get-rid-of-is-defined-but-never-used-in-function-parameter
"no-unused-vars": 0,
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm run lint
- run: npm run test
6 changes: 3 additions & 3 deletions app/analytics/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const defaultRequestParams = {
ns: '1',
}).toString(),
headers: {
get: (header: string) => {
get: (_header: string) => {
return "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36";
}
},
Expand All @@ -32,10 +32,10 @@ describe("collectRequestHandler", () => {
} as CFAnalyticsEngine,
} as Environment;

// @ts-expect-error
// @ts-expect-error - we're mocking the request object
const request = httpMocks.createRequest(defaultRequestParams);

const response = collectRequestHandler(request, env);
collectRequestHandler(request, env);

const writeDataPoint = env.TALLYHO.writeDataPoint;
expect(env.TALLYHO.writeDataPoint).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions app/analytics/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface AnalyticsQueryResult {
interface AnalyticsCountResult {
views: number,
visits: number
};
}

export class AnalyticsEngineAPI {
cfApiToken: string;
Expand Down Expand Up @@ -186,7 +186,7 @@ export class AnalyticsEngineAPI {
}

const responseData = await response.json() as AnalyticsQueryResult;
var result = responseData.data.reduce((acc, cur) => {
const result = responseData.data.reduce((acc, cur) => {
acc.push([cur['siteId'], cur['count']]);
return acc;
}, []);
Expand Down
39 changes: 0 additions & 39 deletions app/components/BrowserCard.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions app/components/CountryCard.tsx

This file was deleted.

1 change: 1 addition & 0 deletions app/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
Expand Down
2 changes: 2 additions & 0 deletions app/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import * as React from "react"

import { cn } from "~/lib/utils"
Expand Down Expand Up @@ -33,6 +34,7 @@ const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
/* eslint jsx-a11y/heading-has-content: 0 */
<h3
ref={ref}
className={cn(
Expand Down
5 changes: 3 additions & 2 deletions app/components/ui/select.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import * as React from "react"
import * as SelectPrimitive from "@radix-ui/react-select"
import { Check, ChevronDown, ChevronUp } from "lucide-react"
Expand Down Expand Up @@ -75,7 +76,7 @@ const SelectContent = React.forwardRef<
className={cn(
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
className
)}
position={position}
Expand All @@ -86,7 +87,7 @@ const SelectContent = React.forwardRef<
className={cn(
"p-1",
position === "popper" &&
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
)}
>
{children}
Expand Down
1 change: 1 addition & 0 deletions app/components/ui/table.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import * as React from "react"

import { cn } from "~/lib/utils"
Expand Down
2 changes: 2 additions & 0 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export default async function handleRequest(
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,

// This is ignored so we can keep it in the template for visibility. Feel
// free to delete this parameter in your app if you're not using it!

// eslint-disable-next-line @typescript-eslint/no-unused-vars
loadContext: AppLoadContext
) {
Expand Down
11 changes: 4 additions & 7 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, CardTitle, CardDescription, CardContent, CardHeader } from "~/components/ui/card"
import { Card, CardContent } from "~/components/ui/card"
import {
Select,
SelectContent,
Expand All @@ -9,12 +9,10 @@ import {

import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/cloudflare";
import { json } from "@remix-run/cloudflare";
import { useLoaderData, useNavigate, useSearchParams } from "@remix-run/react";
import { useLoaderData, useSearchParams } from "@remix-run/react";

import { AnalyticsEngineAPI } from "../analytics/query";

import BrowserCard from "~/components/BrowserCard";
import CountryCard from "~/components/CountryCard";
import TableCard from "~/components/TableCard";

export const meta: MetaFunction = () => {
Expand Down Expand Up @@ -54,7 +52,7 @@ export const loader = async ({ context, request }: LoaderFunctionArgs) => {
siteId = sitesByHits[0][0];
}

let actualSiteId = siteId == '@unknown' ? '' : siteId;
const actualSiteId = siteId == '@unknown' ? '' : siteId;

const counts = analyticsEngine.getCounts(actualSiteId, interval);
const countByPath = analyticsEngine.getCountByPath(actualSiteId, interval);
Expand All @@ -77,10 +75,9 @@ export const loader = async ({ context, request }: LoaderFunctionArgs) => {
};

export default function Index() {
const [searchParams, setSearchParams] = useSearchParams();
const [, setSearchParams] = useSearchParams();

const data = useLoaderData<typeof loader>();
let navigate = useNavigate()

function changeSite(site: string) {
setSearchParams((prev) => {
Expand Down
6 changes: 5 additions & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
interface CFAnalyticsEngine {
writeDataPoint: Function
writeDataPoint: (data: {
indexes: string[],
blobs: string[],
doubles: number[],
}) => void;
}

interface Environment {
Expand Down

0 comments on commit c183ffe

Please sign in to comment.