From 36cf7171a8c526b22ad751f84ed1b47e9176d6ff Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Mon, 25 Jul 2022 18:37:35 +0100 Subject: [PATCH] chore: fix eslint warnings --- .eslintrc.json | 24 ++++- components/TextInput.tsx | 2 + package.json | 1 + pages/comic/[comic]/transcribe/random.tsx | 8 +- pnpm-lock.yaml | 126 +++++++++++++++++++++- prisma/seed.ts | 15 --- src/utils.ts | 9 +- 7 files changed, 157 insertions(+), 28 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1c2aa65..79d9fa7 100755 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,25 @@ { - "extends": "next/core-web-vitals" + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "next/core-web-vitals", + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react/jsx-runtime" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": ["react", "@typescript-eslint"], + "rules": { + "@typescript-eslint/no-non-null-assertion": "off" + } } diff --git a/components/TextInput.tsx b/components/TextInput.tsx index 273d919..2f44cec 100644 --- a/components/TextInput.tsx +++ b/components/TextInput.tsx @@ -21,6 +21,7 @@ export default function TextInput({ multiline, className, ...props }: Props) { className={ 'bg-slate-600 p-1 overflow-auto rounded ' + className } + // eslint-disable-next-line @typescript-eslint/no-explicit-any {...(props as any)} /> ); @@ -30,6 +31,7 @@ export default function TextInput({ multiline, className, ...props }: Props) { className={ 'bg-slate-600 p-1 overflow-auto rounded ' + className } + // eslint-disable-next-line @typescript-eslint/no-explicit-any {...(props as any)} /> ); diff --git a/package.json b/package.json index f95c559..58b0d16 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@types/node": "18.0.6", "@types/react": "18.0.15", "@types/react-dom": "18.0.6", + "@typescript-eslint/eslint-plugin": "^5.31.0", "autoprefixer": "^10.4.7", "eslint": "8.20.0", "eslint-config-next": "12.2.2", diff --git a/pages/comic/[comic]/transcribe/random.tsx b/pages/comic/[comic]/transcribe/random.tsx index 5c1d04e..87a4c57 100644 --- a/pages/comic/[comic]/transcribe/random.tsx +++ b/pages/comic/[comic]/transcribe/random.tsx @@ -10,10 +10,10 @@ export default function RandomPage() { return <>Please wait...; } -export const getServerSideProps: GetServerSideProps<{}, Params> = async ({ - params, - query, -}) => { +export const getServerSideProps: GetServerSideProps< + Record, + Params +> = async ({ params, query }) => { const { comic: comicSlug } = params!; const pages = await prisma.comicPage diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 007b8e9..4559808 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,7 @@ specifiers: '@types/node': 18.0.6 '@types/react': 18.0.15 '@types/react-dom': 18.0.6 + '@typescript-eslint/eslint-plugin': ^5.31.0 autoprefixer: ^10.4.7 eslint: 8.20.0 eslint-config-next: 12.2.2 @@ -38,6 +39,7 @@ devDependencies: '@types/node': 18.0.6 '@types/react': 18.0.15 '@types/react-dom': 18.0.6 + '@typescript-eslint/eslint-plugin': 5.31.0_eslint@8.20.0+typescript@4.7.4 autoprefixer: 10.4.7_postcss@8.4.14 eslint: 8.20.0 eslint-config-next: 12.2.2_eslint@8.20.0+typescript@4.7.4 @@ -466,6 +468,10 @@ packages: resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} dev: true + /@types/json-schema/7.0.11: + resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} + dev: true + /@types/json5/0.0.29: resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} dev: true @@ -503,6 +509,32 @@ packages: /@types/scheduler/0.16.2: resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} + /@typescript-eslint/eslint-plugin/5.31.0_eslint@8.20.0+typescript@4.7.4: + resolution: {integrity: sha512-VKW4JPHzG5yhYQrQ1AzXgVgX8ZAJEvCz0QI6mLRX4tf7rnFfh5D8SKm0Pq6w5PyNfAWJk6sv313+nEt3ohWMBQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + '@typescript-eslint/parser': ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/scope-manager': 5.31.0 + '@typescript-eslint/type-utils': 5.31.0_eslint@8.20.0+typescript@4.7.4 + '@typescript-eslint/utils': 5.31.0_eslint@8.20.0+typescript@4.7.4 + debug: 4.3.4 + eslint: 8.20.0 + functional-red-black-tree: 1.0.1 + ignore: 5.2.0 + regexpp: 3.2.0 + semver: 7.3.7 + tsutils: 3.21.0_typescript@4.7.4 + typescript: 4.7.4 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/parser/5.30.7_eslint@8.20.0+typescript@4.7.4: resolution: {integrity: sha512-Rg5xwznHWWSy7v2o0cdho6n+xLhK2gntImp0rJroVVFkcYFYQ8C8UJTSuTw/3CnExBmPjycjmUJkxVmjXsld6A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -531,11 +563,43 @@ packages: '@typescript-eslint/visitor-keys': 5.30.7 dev: true + /@typescript-eslint/scope-manager/5.31.0: + resolution: {integrity: sha512-8jfEzBYDBG88rcXFxajdVavGxb5/XKXyvWgvD8Qix3EEJLCFIdVloJw+r9ww0wbyNLOTYyBsR+4ALNGdlalLLg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + '@typescript-eslint/types': 5.31.0 + '@typescript-eslint/visitor-keys': 5.31.0 + dev: true + + /@typescript-eslint/type-utils/5.31.0_eslint@8.20.0+typescript@4.7.4: + resolution: {integrity: sha512-7ZYqFbvEvYXFn9ax02GsPcEOmuWNg+14HIf4q+oUuLnMbpJ6eHAivCg7tZMVwzrIuzX3QCeAOqKoyMZCv5xe+w==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: '*' + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/utils': 5.31.0_eslint@8.20.0+typescript@4.7.4 + debug: 4.3.4 + eslint: 8.20.0 + tsutils: 3.21.0_typescript@4.7.4 + typescript: 4.7.4 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/types/5.30.7: resolution: {integrity: sha512-ocVkETUs82+U+HowkovV6uxf1AnVRKCmDRNUBUUo46/5SQv1owC/EBFkiu4MOHeZqhKz2ktZ3kvJJ1uFqQ8QPg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@typescript-eslint/types/5.31.0: + resolution: {integrity: sha512-/f/rMaEseux+I4wmR6mfpM2wvtNZb1p9hAV77hWfuKc3pmaANp5dLAZSiE3/8oXTYTt3uV9KW5yZKJsMievp6g==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + /@typescript-eslint/typescript-estree/5.30.7_typescript@4.7.4: resolution: {integrity: sha512-tNslqXI1ZdmXXrHER83TJ8OTYl4epUzJC0aj2i4DMDT4iU+UqLT3EJeGQvJ17BMbm31x5scSwo3hPM0nqQ1AEA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -557,6 +621,45 @@ packages: - supports-color dev: true + /@typescript-eslint/typescript-estree/5.31.0_typescript@4.7.4: + resolution: {integrity: sha512-3S625TMcARX71wBc2qubHaoUwMEn+l9TCsaIzYI/ET31Xm2c9YQ+zhGgpydjorwQO9pLfR/6peTzS/0G3J/hDw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/types': 5.31.0 + '@typescript-eslint/visitor-keys': 5.31.0 + debug: 4.3.4 + globby: 11.1.0 + is-glob: 4.0.3 + semver: 7.3.7 + tsutils: 3.21.0_typescript@4.7.4 + typescript: 4.7.4 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/utils/5.31.0_eslint@8.20.0+typescript@4.7.4: + resolution: {integrity: sha512-kcVPdQS6VIpVTQ7QnGNKMFtdJdvnStkqS5LeALr4rcwx11G6OWb2HB17NMPnlRHvaZP38hL9iK8DdE9Fne7NYg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + '@types/json-schema': 7.0.11 + '@typescript-eslint/scope-manager': 5.31.0 + '@typescript-eslint/types': 5.31.0 + '@typescript-eslint/typescript-estree': 5.31.0_typescript@4.7.4 + eslint: 8.20.0 + eslint-scope: 5.1.1 + eslint-utils: 3.0.0_eslint@8.20.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@typescript-eslint/visitor-keys/5.30.7: resolution: {integrity: sha512-KrRXf8nnjvcpxDFOKej4xkD7657+PClJs5cJVSG7NNoCNnjEdc46juNAQt7AyuWctuCgs6mVRc1xGctEqrjxWw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -565,6 +668,14 @@ packages: eslint-visitor-keys: 3.3.0 dev: true + /@typescript-eslint/visitor-keys/5.31.0: + resolution: {integrity: sha512-ZK0jVxSjS4gnPirpVjXHz7mgdOsZUHzNYSfTw2yPa3agfbt9YfqaBiBZFSSxeBWnpWkzCxTfUpnzA3Vily/CSg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + '@typescript-eslint/types': 5.31.0 + eslint-visitor-keys: 3.3.0 + dev: true + /acorn-jsx/5.3.2_acorn@8.7.1: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -1201,6 +1312,14 @@ packages: string.prototype.matchall: 4.0.7 dev: true + /eslint-scope/5.1.1: + resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} + engines: {node: '>=8.0.0'} + dependencies: + esrecurse: 4.3.0 + estraverse: 4.3.0 + dev: true + /eslint-scope/7.1.1: resolution: {integrity: sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1296,6 +1415,11 @@ packages: estraverse: 5.3.0 dev: true + /estraverse/4.3.0: + resolution: {integrity: sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==} + engines: {node: '>=4.0'} + dev: true + /estraverse/5.3.0: resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} engines: {node: '>=4.0'} @@ -1822,7 +1946,7 @@ packages: dev: true /ms/2.0.0: - resolution: {integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=} + resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} dev: true /ms/2.1.2: diff --git a/prisma/seed.ts b/prisma/seed.ts index c438972..c2d5ef7 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -2,21 +2,6 @@ import { prisma } from '../src/db'; import { ComicCharacter, ComicPage, Prisma } from '@prisma/client'; import rain from './seed-data/comics/rain.json'; -interface Page { - id: number; - chapterId: number; - name: string; - pageUrl: string; - imageUrl: string; - imageSizeBytes: number; - alt: string; - prevPageId?: number; - nextPageId?: number; - url: string; - width: number; - height: number; -} - async function seedComicRain() { const comicData = { slug: 'rain', diff --git a/src/utils.ts b/src/utils.ts index 6c572ae..798e336 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -37,15 +37,10 @@ function hsvToRgb(h: number, s: number, v: number): string { )}`; } -export function randomColour( - index: number, - s: number = 0.3, - v: number = 0.99, - opacity: number = 1 -) { +export function randomColour(index: number, s = 0.3, v = 0.99, opacity = 1) { // Generated with Math.random() let h = 0.6220694728604135; - for (var i = 0; i < index; i++) { + for (let i = 0; i < index; i++) { h += ONE_OVER_PHI; h %= 1; }