From 8dc57a6dce45394e951fd9e81b0cc786eb47d9a7 Mon Sep 17 00:00:00 2001 From: Will Kelly Date: Wed, 24 Apr 2024 10:09:22 -0500 Subject: [PATCH] fix biome lint errors --- .eslintrc.cjs | 68 ++++----- biome.json | 9 +- capacitor.config.ts | 2 +- eslint.config.js | 58 +++---- package.json | 150 +++++++++---------- src/components/ChapterSelector.tsx | 2 +- src/components/Player.tsx | 11 +- src/components/PlaylistBookPicker.tsx | 4 +- src/components/PlaylistInfo.tsx | 2 +- src/components/Settings.tsx | 13 +- src/components/Settings/BulkListing.tsx | 10 +- src/components/Settings/DownloadBookItem.tsx | 9 +- src/components/Settings/SpeedControl.tsx | 5 +- src/components/VerseSegmentJump.tsx | 2 +- src/customTypes/bcApi.ts | 4 +- src/customTypes/types.ts | 4 +- src/lib/Ui.tsx | 5 +- src/lib/storage.ts | 8 +- src/lib/utils.ts | 4 +- src/main.tsx | 2 +- tests/dot.spec.ts | 132 ++++++++-------- tsconfig.json | 42 +++--- tsconfig.node.json | 14 +- vite.config.ts | 24 +-- 24 files changed, 296 insertions(+), 288 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 0a12c87..943b864 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,36 +1,36 @@ module.exports = { - env: { - browser: true, - es2021: true, - }, - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:react/recommended", - ], - overrides: [ - { - env: { - node: true, - }, - files: [".eslintrc.{js,cjs}"], - parserOptions: { - sourceType: "script", - }, - }, - ], - parser: "@typescript-eslint/parser", - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - }, - plugins: ["@typescript-eslint", "react"], - rules: { - indent: ["error", "tab"], - "linebreak-style": ["error", "unix"], - quotes: ["error", "double"], - semi: ["error", "always"], - "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", - "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", - }, + env: { + browser: true, + es2021: true, + }, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react/recommended", + ], + overrides: [ + { + env: { + node: true, + }, + files: [".eslintrc.{js,cjs}"], + parserOptions: { + sourceType: "script", + }, + }, + ], + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + }, + plugins: ["@typescript-eslint", "react"], + rules: { + indent: ["error", "tab"], + "linebreak-style": ["error", "unix"], + quotes: ["error", "double"], + semi: ["error", "always"], + "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", + "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", + }, }; diff --git a/biome.json b/biome.json index 705a7a1..b827cf8 100644 --- a/biome.json +++ b/biome.json @@ -12,14 +12,7 @@ "ignore": [] }, "files": { - "include": ["./src/**/*"], - "ignore": [ - "node_modules", - "bcApi.ts", - "tests", - "playwright.config.ts", - "dotPlayer.js" - ] + "ignore": [".DS_Store", "bcApi.ts"] }, "linter": { "enabled": true, diff --git a/capacitor.config.ts b/capacitor.config.ts index 0936e90..de86a2f 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -1,4 +1,4 @@ -import { CapacitorConfig } from "@capacitor/cli"; +import type { CapacitorConfig } from "@capacitor/cli"; const config: CapacitorConfig = { appId: "com.slbible.dotapp", diff --git a/eslint.config.js b/eslint.config.js index b082e1a..18facb7 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,37 +1,37 @@ -import eslintReact from "eslint-plugin-react"; import js from "@eslint/js"; import tseslint from "@typescript-eslint/eslint-plugin"; import tsParser from "@typescript-eslint/parser"; +import eslintReact from "eslint-plugin-react"; export default [ - js.configs.recommended, + js.configs.recommended, - eslintReact.configs.recommended, - // tseslint.configs.recommended, - { - files: ["src/**/*.{jsx,tsx,js,ts}"], - ignores: ["node_modules/*"], + eslintReact.configs.recommended, + // tseslint.configs.recommended, + { + files: ["src/**/*.{jsx,tsx,js,ts}"], + ignores: ["node_modules/*"], - linterOptions: { - reportUnusedDisableDirectives: true, - }, - plugins: { - react: eslintReact, - }, - languageOptions: { - ecmaVersion: 2020, - sourceType: "module", - // parser: { - // tsParser, - // }, - // parserOptions: { - // ecmaVersion: "latest", - // sourceType: "module", - // } - }, - rules: { - "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", - "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", - }, - }, + linterOptions: { + reportUnusedDisableDirectives: true, + }, + plugins: { + react: eslintReact, + }, + languageOptions: { + ecmaVersion: 2020, + sourceType: "module", + // parser: { + // tsParser, + // }, + // parserOptions: { + // ecmaVersion: "latest", + // sourceType: "module", + // } + }, + rules: { + "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", + "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", + }, + }, ]; diff --git a/package.json b/package.json index 23a2986..802c261 100644 --- a/package.json +++ b/package.json @@ -1,77 +1,77 @@ { - "name": "dotmobile", - "private": true, - "version": "0.0.1", - "type": "module", - "scripts": { - "dev": "vite", - "build": "NODE_ENV=production tsc && vite build", - "preview": "vite preview", - "test.e2e": "playwright test", - "test.unit": "vitest", - "lint": "biome check --apply --verbose src/**/* src/", - "build-ios": "ionic capacitor build ios --release --prod --no-open", - "build-android": "ionic capacitor build android --release --prod --no-open", - "ios": "npm run build && npm run sync && npx cap run ios", - "android": "npm run build && npx cap run android", - "sync": "cap sync", - "iconGenerate": "npx @capacitor/assets generate --iconBackgroundColor '#eeeeee' --iconBackgroundColorDark '#1E1F1D' --splashBackgroundColor '#eeeeee' --splashBackgroundColorDark '#1E1F1D'", - "updateAllPackages": "npx npm-check-updates -i", - "prepare": "husky install" - }, - "dependencies": { - "@capacitor/android": "^6.0.0", - "@capacitor/app": "6.0.0", - "@capacitor/core": "^6.0.0", - "@capacitor/device": "^6.0.0", - "@capacitor/filesystem": "^6.0.0", - "@capacitor/haptics": "6.0.0", - "@capacitor/ios": "^6.0.0", - "@capacitor/keyboard": "6.0.0", - "@capacitor/preferences": "^6.0.0", - "@capacitor/status-bar": "6.0.0", - "@ionic/react": "^8.0.0", - "@ionic/react-router": "^8.0.0", - "@types/react-router": "^5.1.20", - "@types/react-router-dom": "^5.3.3", - "@types/video.js": "^7.3.58", - "capacitor-blob-writer": "^1.1.16", - "i18next": "^23.11.2", - "i18next-browser-languagedetector": "^7.2.1", - "ionicons": "^7.3.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-i18next": "^14.1.1", - "react-router": "^5.3.4", - "react-router-dom": "^5.3.4" - }, - "devDependencies": { - "@ionic/cli": "^7.2.0", - "@capacitor/cli": "^6.0.0", - "@biomejs/biome": "1.7.1", - "@capacitor/assets": "^3.0.5", - "@playwright/test": "^1.43.1", - "@testing-library/dom": ">=7.21.4", - "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^14.1.2", - "@testing-library/user-event": "^14.4.3", - "@types/node": "^20.12.7", - "@types/react": "^18.2.79", - "@types/react-dom": "^18.2.25", - "@unocss/transformer-variant-group": "^0.59.4", - "@vitejs/plugin-legacy": "^5.3.2", - "@vitejs/plugin-react": "^4.2.1", - "husky": "^9.0.11", - "jsdom": "^24.0.0", - "lint-staged": "^15.2.2", - "terser": "^5.30.4", - "typescript": "^5.4.5", - "unocss": "^0.59.4", - "vite": "^5.2.10", - "vitest": "^1.5.0" - }, - "lint-staged": { - "*": "biome check --apply --verbose --config-path=./biome.json" - }, - "description": "WA Sign language bibles app" + "name": "dotmobile", + "private": true, + "version": "0.0.1", + "type": "module", + "scripts": { + "dev": "vite", + "build": "NODE_ENV=production tsc && vite build", + "preview": "vite preview", + "test.e2e": "playwright test", + "test.unit": "vitest", + "lint": "biome check --apply --verbose src/**/* src/", + "build-ios": "ionic capacitor build ios --release --prod --no-open", + "build-android": "ionic capacitor build android --release --prod --no-open", + "ios": "npm run build && npm run sync && npx cap run ios", + "android": "npm run build && npx cap run android", + "sync": "cap sync", + "iconGenerate": "npx @capacitor/assets generate --iconBackgroundColor '#eeeeee' --iconBackgroundColorDark '#1E1F1D' --splashBackgroundColor '#eeeeee' --splashBackgroundColorDark '#1E1F1D'", + "updateAllPackages": "npx npm-check-updates -i", + "prepare": "husky install" + }, + "dependencies": { + "@capacitor/android": "^6.0.0", + "@capacitor/app": "6.0.0", + "@capacitor/core": "^6.0.0", + "@capacitor/device": "^6.0.0", + "@capacitor/filesystem": "^6.0.0", + "@capacitor/haptics": "6.0.0", + "@capacitor/ios": "^6.0.0", + "@capacitor/keyboard": "6.0.0", + "@capacitor/preferences": "^6.0.0", + "@capacitor/status-bar": "6.0.0", + "@ionic/react": "^8.0.0", + "@ionic/react-router": "^8.0.0", + "@types/react-router": "^5.1.20", + "@types/react-router-dom": "^5.3.3", + "@types/video.js": "^7.3.58", + "capacitor-blob-writer": "^1.1.16", + "i18next": "^23.11.2", + "i18next-browser-languagedetector": "^7.2.1", + "ionicons": "^7.3.1", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-i18next": "^14.1.1", + "react-router": "^5.3.4", + "react-router-dom": "^5.3.4" + }, + "devDependencies": { + "@ionic/cli": "^7.2.0", + "@capacitor/cli": "^6.0.0", + "@biomejs/biome": "1.7.1", + "@capacitor/assets": "^3.0.5", + "@playwright/test": "^1.43.1", + "@testing-library/dom": ">=7.21.4", + "@testing-library/jest-dom": "^6.1.5", + "@testing-library/react": "^14.1.2", + "@testing-library/user-event": "^14.4.3", + "@types/node": "^20.12.7", + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "@unocss/transformer-variant-group": "^0.59.4", + "@vitejs/plugin-legacy": "^5.3.2", + "@vitejs/plugin-react": "^4.2.1", + "husky": "^9.0.11", + "jsdom": "^24.0.0", + "lint-staged": "^15.2.2", + "terser": "^5.30.4", + "typescript": "^5.4.5", + "unocss": "^0.59.4", + "vite": "^5.2.10", + "vitest": "^1.5.0" + }, + "lint-staged": { + "*": "biome check --apply --verbose src/**/* src/" + }, + "description": "WA Sign language bibles app" } diff --git a/src/components/ChapterSelector.tsx b/src/components/ChapterSelector.tsx index 19bfb93..a06de5d 100644 --- a/src/components/ChapterSelector.tsx +++ b/src/components/ChapterSelector.tsx @@ -1,5 +1,5 @@ import { useRef } from "react"; -import { IVidWithCustom } from "../customTypes/types"; +import type { IVidWithCustom } from "../customTypes/types"; import { ChapterList } from "./ChapterList"; import { IconMaterialSymbolsChevronLeft, diff --git a/src/components/Player.tsx b/src/components/Player.tsx index 3afa69f..ab0e4bd 100644 --- a/src/components/Player.tsx +++ b/src/components/Player.tsx @@ -1,6 +1,6 @@ -import { Dispatch, SetStateAction, useEffect, useRef } from "react"; -import { VideoJsPlayer } from "video.js"; -import { IVidWithCustom, chapterMarkers } from "../customTypes/types"; +import { type Dispatch, type SetStateAction, useEffect, useRef } from "react"; +import type { VideoJsPlayer } from "video.js"; +import type { IVidWithCustom, chapterMarkers } from "../customTypes/types"; import { handleVideoJsTaps, playerCustomHotKeys } from "../lib/Ui"; import { getSavedAppPreferences } from "../lib/storage"; type Iplayer = { @@ -40,7 +40,7 @@ export function VidJsPlayer({ ? { src: `${firstBook.savedSources?.video}`, type: "video/mp4", - } + } : firstBook.sources; const firstPoster = firstBook.savedSources?.poster @@ -158,9 +158,12 @@ export function VidJsPlayer({ } } + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { bootPlayer(); }, []); + + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { // a custom event dispatch listener handleSpeedChangesInApp(); diff --git a/src/components/PlaylistBookPicker.tsx b/src/components/PlaylistBookPicker.tsx index 95f9d43..376afbd 100644 --- a/src/components/PlaylistBookPicker.tsx +++ b/src/components/PlaylistBookPicker.tsx @@ -1,6 +1,6 @@ -import { Dispatch, SetStateAction } from "react"; +import type { Dispatch, SetStateAction } from "react"; import { useTranslation } from "react-i18next"; -import { IVidWithCustom } from "../customTypes/types"; +import type { IVidWithCustom } from "../customTypes/types"; import { manageShowingChapterArrows } from "../lib/Ui"; import { normalizeBookName } from "../lib/utils"; import { IconMaterialSymbolsCheckCircle } from "./Icons"; diff --git a/src/components/PlaylistInfo.tsx b/src/components/PlaylistInfo.tsx index db9794a..6df698a 100644 --- a/src/components/PlaylistInfo.tsx +++ b/src/components/PlaylistInfo.tsx @@ -1,4 +1,4 @@ -import { IVidWithCustom, validPlaylistSlugs } from "../customTypes/types"; +import type { IVidWithCustom, validPlaylistSlugs } from "../customTypes/types"; import { formatPlayListName, normalizeBookName } from "../lib/utils"; import { IconMaterialSymbolsCheckCircle } from "./Icons"; type IPlaylistInfo = { diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index 0abe95c..801d8f5 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -1,10 +1,16 @@ import { IonButton, IonIcon, IonModal } from "@ionic/react"; import { close } from "ionicons/icons"; import { settingsOutline } from "ionicons/icons"; -import { Dispatch, SetStateAction, useEffect, useRef, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { VideoJsPlayer } from "video.js"; import { + type Dispatch, + type SetStateAction, + useEffect, + useRef, + useState, +} from "react"; +import { useTranslation } from "react-i18next"; +import type { VideoJsPlayer } from "video.js"; +import type { IPlaylistData, IVidWithCustom, downloadProgressInfo, @@ -205,6 +211,7 @@ export function Settings(props: ISettings) { setCurrentVid: props.setCurrentVid, }); } + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { if (settingsRef?.current) { if (!settingsRef.current.dataset.listening) { diff --git a/src/components/Settings/BulkListing.tsx b/src/components/Settings/BulkListing.tsx index 133eddf..8a34b02 100644 --- a/src/components/Settings/BulkListing.tsx +++ b/src/components/Settings/BulkListing.tsx @@ -1,12 +1,12 @@ -import { CheckboxCustomEvent, IonButton } from "@ionic/react"; -import { Dispatch, SetStateAction, useState } from "react"; +import { type CheckboxCustomEvent, IonButton } from "@ionic/react"; +import { type Dispatch, type SetStateAction, useState } from "react"; import { useTranslation } from "react-i18next"; -import { +import type { IPlaylistData, IVidWithCustom, validPlaylistSlugs, } from "../../customTypes/types"; -import { downloadProgressInfo } from "../../customTypes/types"; +import type { downloadProgressInfo } from "../../customTypes/types"; import { getCurrentPlaylistDataFs, getDownloadSize, @@ -214,7 +214,7 @@ export function BulkListing({ size="small" fill="outline" color="primary" - disabled={booksSelected?.length ? false : true} + disabled={!!booksSelected?.length} className="text-surface" onClick={() => { if (downloadProgress?.started) { diff --git a/src/components/Settings/DownloadBookItem.tsx b/src/components/Settings/DownloadBookItem.tsx index 8a2d2fa..790861b 100644 --- a/src/components/Settings/DownloadBookItem.tsx +++ b/src/components/Settings/DownloadBookItem.tsx @@ -1,8 +1,11 @@ -import { CheckboxCustomEvent } from "@ionic/core"; +import type { CheckboxCustomEvent } from "@ionic/core"; import { IonButton, IonCheckbox, IonProgressBar } from "@ionic/react"; -import { Dispatch, SetStateAction } from "react"; +import type { Dispatch, SetStateAction } from "react"; import { useTranslation } from "react-i18next"; -import { IVidWithCustom, downloadProgressInfo } from "../../customTypes/types"; +import type { + IVidWithCustom, + downloadProgressInfo, +} from "../../customTypes/types"; import { IconCancelX, IconMaterialSymbolsCheckCircle } from "../Icons"; type BookToDownloadProps = { diff --git a/src/components/Settings/SpeedControl.tsx b/src/components/Settings/SpeedControl.tsx index 3053c9d..e075835 100644 --- a/src/components/Settings/SpeedControl.tsx +++ b/src/components/Settings/SpeedControl.tsx @@ -1,6 +1,6 @@ -import { ChangeEvent, useEffect, useState } from "react"; +import { type ChangeEvent, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { VideoJsPlayer } from "video.js"; +import type { VideoJsPlayer } from "video.js"; import { getSavedAppPreferences, updateSavedAppPreferences, @@ -21,6 +21,7 @@ export function SpeedControl(props: SpeedControlParams) { setPreferredSpeed(curAppState.preferredSpeed); } + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { setInitialPlayerSpeed(); }, []); diff --git a/src/components/VerseSegmentJump.tsx b/src/components/VerseSegmentJump.tsx index 090d812..7169390 100644 --- a/src/components/VerseSegmentJump.tsx +++ b/src/components/VerseSegmentJump.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; -import { +import type { IVidWithCustom, IadjacentChap, IvidJsPlayer, diff --git a/src/customTypes/bcApi.ts b/src/customTypes/bcApi.ts index 9114a52..f52d69c 100644 --- a/src/customTypes/bcApi.ts +++ b/src/customTypes/bcApi.ts @@ -341,8 +341,8 @@ export class HttpClient { property instanceof Blob ? property : typeof property === "object" && property !== null - ? JSON.stringify(property) - : `${property}`, + ? JSON.stringify(property) + : `${property}`, ); return formData; }, new FormData()), diff --git a/src/customTypes/types.ts b/src/customTypes/types.ts index 0e88bec..ab63be8 100644 --- a/src/customTypes/types.ts +++ b/src/customTypes/types.ts @@ -1,5 +1,5 @@ -import videojs from "video.js"; -import brightCovePlaylistConfig from "../brightcove/playlist-mappers"; +import type videojs from "video.js"; +import type brightCovePlaylistConfig from "../brightcove/playlist-mappers"; import type { PlaylistResponse, Video, VideoSources } from "./bcApi"; declare global { diff --git a/src/lib/Ui.tsx b/src/lib/Ui.tsx index b6aa72c..396caa4 100644 --- a/src/lib/Ui.tsx +++ b/src/lib/Ui.tsx @@ -1,7 +1,7 @@ import { Directory, Encoding, Filesystem } from "@capacitor/filesystem"; -import { Dispatch, SetStateAction } from "react"; -import { +import type { Dispatch, SetStateAction } from "react"; +import type { IPlaylistData, IPlaylistResponse, IVidWithCustom, @@ -391,7 +391,6 @@ export async function updatePrefsInBackground({ } } - // biome-ignore lint/correctness/noUnusedVariables: I'm destructuring to pick off the videos and formatted because we are using updating those properties with the spread on cacheBcPlaylistJson const { videos, formattedVideos, ...restPlaylistData } = data; mutateTimeStampBcResponse(restPlaylistData); diff --git a/src/lib/storage.ts b/src/lib/storage.ts index 42f73c5..82db8ef 100644 --- a/src/lib/storage.ts +++ b/src/lib/storage.ts @@ -2,13 +2,13 @@ import { Capacitor } from "@capacitor/core"; import { Directory, Filesystem } from "@capacitor/filesystem"; import { Preferences } from "@capacitor/preferences"; import write_blob from "capacitor-blob-writer"; -import { +import type { IPlaylistData, IVidWithCustom, fetchSession, writeAnInProgressBlobParams, } from "src/customTypes/types"; -import { +import type { IappState, validPlaylistSlugs, vidSavingWipData, @@ -65,7 +65,7 @@ export function makeVidSaver( return lowestMp4Size; }, async savePosterBlobAndGetSrc() { - let posterBlob; + let posterBlob: Blob | undefined; const posterPath = `${playlist}/${vid.id}/poster.jpeg`; if (vid.poster) { try { @@ -107,7 +107,7 @@ export function makeVidSaver( if (contentLength === null) { return -1; } - const fileSize = parseInt(contentLength, 10); + const fileSize = Number.parseInt(contentLength, 10); return fileSize; } catch (error) { console.warn(error); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d5fdc0d..2eaa7a8 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,4 +1,4 @@ -import { IVidWithCustom, validPlaylistSlugs } from "../customTypes/types"; +import type { IVidWithCustom, validPlaylistSlugs } from "../customTypes/types"; interface sortOrderI { [key: string]: number; @@ -179,7 +179,7 @@ export function massageVidsArray(vids: IVidWithCustom[]) { const bBookSort = getBibleBookSort(bCustomBook); const aChap = Number(a.custom_fields?.chapter); const bChap = Number(b.custom_fields?.chapter); - let retVal; + let retVal: number; if (aBookSort === bBookSort) { retVal = aChap < bChap ? -1 : aChap === bChap ? 0 : 1; } else { diff --git a/src/main.tsx b/src/main.tsx index 8d5c6e0..9c83933 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,8 +1,8 @@ +import "virtual:uno.css"; import React from "react"; import { createRoot } from "react-dom/client"; import App from "./App"; import "./i18n/i18nnext"; -import "virtual:uno.css"; const container = document.getElementById("root"); diff --git a/tests/dot.spec.ts b/tests/dot.spec.ts index 1eec4a9..3344216 100644 --- a/tests/dot.spec.ts +++ b/tests/dot.spec.ts @@ -1,4 +1,4 @@ -import {test, expect} from "@playwright/test"; +import { expect, test } from "@playwright/test"; import brightCovePlaylistConfig from "../src/brightcove/playlist-mappers"; // test('has title', async ({ page }) => { @@ -8,89 +8,91 @@ import brightCovePlaylistConfig from "../src/brightcove/playlist-mappers"; // await expect(page).toHaveTitle(/Playwright/); // }); -test("Home renders playlists", async ({page}) => { - await page.goto("/"); - const playlistListing = page.getByTestId("playlistsAvailable"); - const listItems = playlistListing.getByRole("listitem"); - const alphabetizedKeys = Object.keys( - brightCovePlaylistConfig - ).sort() as unknown as Array; +test("Home renders playlists", async ({ page }) => { + await page.goto("/"); + const playlistListing = page.getByTestId("playlistsAvailable"); + const listItems = playlistListing.getByRole("listitem"); + const alphabetizedKeys = Object.keys( + brightCovePlaylistConfig, + ).sort() as unknown as Array; - await expect(listItems).toHaveCount(alphabetizedKeys.length); + await expect(listItems).toHaveCount(alphabetizedKeys.length); }); -test("Listing on home page navigates to proper playlist", async ({page}) => { - await page.goto("/"); - const playlistListing = page.getByRole("link", {name: "benin"}); - await playlistListing.click(); - expect(page.url().includes("benin")); +test("Listing on home page navigates to proper playlist", async ({ page }) => { + await page.goto("/"); + const playlistListing = page.getByRole("link", { name: "benin" }); + await playlistListing.click(); + expect(page.url().includes("benin")); }); -test("No horizontal scroll", async ({page}) => { - // Navigate to the provided URL - await page.goto("/benin"); - // Use page.evaluate to run custom JavaScript code on the page - - const doesNotHaveHorizontalScroll = await page.evaluate( - () => document.body.scrollWidth <= window.innerWidth - ); - expect(doesNotHaveHorizontalScroll).toBe(true); +test("No horizontal scroll", async ({ page }) => { + // Navigate to the provided URL + await page.goto("/benin"); + // Use page.evaluate to run custom JavaScript code on the page + + const doesNotHaveHorizontalScroll = await page.evaluate( + () => document.body.scrollWidth <= window.innerWidth, + ); + expect(doesNotHaveHorizontalScroll).toBe(true); }); -test("New Testament renders 27 books", async ({page}) => { - await page.goto("/benin"); - const playlistListing = page.getByTestId("booksAvailable"); - await playlistListing.waitFor({ - state: "attached", - }); - const books = playlistListing.locator("li"); - await expect(books).toHaveCount(27); +test("New Testament renders 27 books", async ({ page }) => { + await page.goto("/benin"); + const playlistListing = page.getByTestId("booksAvailable"); + await playlistListing.waitFor({ + state: "attached", + }); + const books = playlistListing.locator("li"); + await expect(books).toHaveCount(27); }); -test("Matthew Renders 28 chapter buttons", async ({page}) => { - await page.goto("/benin"); +test("Matthew Renders 28 chapter buttons", async ({ page }) => { + await page.goto("/benin"); - const playlistListing = page.getByTestId("chapterSelector"); - await playlistListing.waitFor({ - state: "attached", - }); - const chapters = playlistListing.locator("li"); + const playlistListing = page.getByTestId("chapterSelector"); + await playlistListing.waitFor({ + state: "attached", + }); + const chapters = playlistListing.locator("li"); - await expect(chapters).toHaveCount(28); + await expect(chapters).toHaveCount(28); }); -test("state data attributes for chapter / vid are correct", async ({page}) => { - await page.goto("/benin"); +test("state data attributes for chapter / vid are correct", async ({ + page, +}) => { + await page.goto("/benin"); - const stateChecker = page.getByTestId("stateChecker"); - await stateChecker.waitFor(); + const stateChecker = page.getByTestId("stateChecker"); + await stateChecker.waitFor(); - await expect(stateChecker).toHaveAttribute("data-currentbook", /MAT/); - await expect(stateChecker).toHaveAttribute("data-currentchap", /^0*1$/); + await expect(stateChecker).toHaveAttribute("data-currentbook", /MAT/); + await expect(stateChecker).toHaveAttribute("data-currentchap", /^0*1$/); }); -test("chapter changes on click", async ({page}) => { - await page.goto("/benin"); +test("chapter changes on click", async ({ page }) => { + await page.goto("/benin"); - const chap2Btn = page - .getByTestId("chapterSelector") - .getByText("2", {exact: true}); + const chap2Btn = page + .getByTestId("chapterSelector") + .getByText("2", { exact: true }); - await chap2Btn.click(); - const stateChecker = page.getByTestId("stateChecker"); - await expect(stateChecker).toHaveAttribute("data-currentbook", /MAT/); - await expect(stateChecker).toHaveAttribute("data-currentchap", /^0*2$/); + await chap2Btn.click(); + const stateChecker = page.getByTestId("stateChecker"); + await expect(stateChecker).toHaveAttribute("data-currentbook", /MAT/); + await expect(stateChecker).toHaveAttribute("data-currentchap", /^0*2$/); }); -test("book changes on click", async ({page}) => { - await page.goto("/benin"); +test("book changes on click", async ({ page }) => { + await page.goto("/benin"); - const bookPicked = page.getByTestId("bookPicked"); + const bookPicked = page.getByTestId("bookPicked"); - const judeBtn = page - .getByTestId("booksAvailable") - .locator("li") - .getByText("Jude"); - await judeBtn.click(); - const stateChecker = page.getByTestId("stateChecker"); - expect(stateChecker).toHaveAttribute("data-currentbook", "JUD"); - await expect(bookPicked).toHaveText("Jude"); + const judeBtn = page + .getByTestId("booksAvailable") + .locator("li") + .getByText("Jude"); + await judeBtn.click(); + const stateChecker = page.getByTestId("stateChecker"); + expect(stateChecker).toHaveAttribute("data-currentbook", "JUD"); + await expect(bookPicked).toHaveText("Jude"); }); // testing vido diff --git a/tsconfig.json b/tsconfig.json index de09aa5..59e3e8d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,23 @@ { - "compilerOptions": { - "target": "es5", - "downlevelIteration": true, - "useDefineForClassFields": true, - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "allowJs": false, - "skipLibCheck": true, - "esModuleInterop": false, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "module": "ESNext", - "moduleResolution": "Node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - "baseUrl": "." - }, - "include": ["src", "public/bc", "public/brightcove/dotPlayer.js"], - "references": [{"path": "./tsconfig.node.json"}] + "compilerOptions": { + "target": "es5", + "downlevelIteration": true, + "useDefineForClassFields": true, + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "allowJs": false, + "skipLibCheck": true, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "ESNext", + "moduleResolution": "Node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "baseUrl": "." + }, + "include": ["src", "public/bc", "public/brightcove/dotPlayer.js"], + "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/tsconfig.node.json b/tsconfig.node.json index 9d31e2a..d3bf4b8 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -1,9 +1,9 @@ { - "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] } diff --git a/vite.config.ts b/vite.config.ts index 801cee5..cbf6284 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,19 +1,19 @@ import legacy from "@vitejs/plugin-legacy"; import react from "@vitejs/plugin-react"; -import {defineConfig} from "vite"; import UnoCSS from "unocss/vite"; +import { defineConfig } from "vite"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [UnoCSS(), react(), legacy()], - // build: { - // rollupOptions: { - // external: ["virtual:uno.css", "video.js", "@brightcove/loscore"], - // }, - // }, - // test: { - // globals: true, - // environment: "jsdom", - // setupFiles: "./src/setupTests.ts", - // }, + plugins: [UnoCSS(), react(), legacy()], + // build: { + // rollupOptions: { + // external: ["virtual:uno.css", "video.js", "@brightcove/loscore"], + // }, + // }, + // test: { + // globals: true, + // environment: "jsdom", + // setupFiles: "./src/setupTests.ts", + // }, });