diff --git a/eslint.config.mjs b/eslint.config.mjs index a8a37a2..97c711c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -24,6 +24,7 @@ export default tseslint.config( ...tseslint.configs.strict, { plugins: { + '@typescript-eslint': tseslint.plugin, 'unused-imports': unusedImports, import: importPlugin, 'sort-exports': sortExports, @@ -74,6 +75,15 @@ export default tseslint.config( sortExportKindFirst: 'value', }, ], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + }, + ], }, }, ) diff --git a/package/src/internal/goparam.ts b/package/src/internal/goparam.ts index cd86a03..89db66f 100644 --- a/package/src/internal/goparam.ts +++ b/package/src/internal/goparam.ts @@ -43,6 +43,7 @@ export const verifyMac = async ( try { return await verify(baseParam.toString(), mac, trustedPubkey) } catch (e) { + console.error(e) return false } } diff --git a/package/src/internal/handleCallback.ts b/package/src/internal/handleCallback.ts index 4e5c226..6e21d51 100644 --- a/package/src/internal/handleCallback.ts +++ b/package/src/internal/handleCallback.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import { parse as parseCookie, serialize as serializeCookie } from 'cookie' import { AUTH_PUBKEY } from './const' @@ -207,8 +209,8 @@ export const handleCallback = async ( if ( !(await verify( - param.get('authdata')!, - param.get('signature')!, + param.get('authdata') as string, + param.get('signature') as string, authPubkey, )) || !(await verify(param.get('iv')!, param.get('signatureIv')!, authPubkey)) diff --git a/package/src/internal/tokengen.ts b/package/src/internal/tokengen.ts index b177fd1..570f75c 100644 --- a/package/src/internal/tokengen.ts +++ b/package/src/internal/tokengen.ts @@ -36,6 +36,7 @@ export const verifyToken = async ( try { decrypted = await decrypt(token, key, iv) } catch (e) { + console.error(e) return [false, 'invalid token'] } const tokenData = atob(decrypted) diff --git a/package/src/userinfo.ts b/package/src/userinfo.ts index fb8cfa4..2ac954b 100644 --- a/package/src/userinfo.ts +++ b/package/src/userinfo.ts @@ -116,6 +116,7 @@ const getUserInfo = async ( if (await checkLoggedIn(request, publicKey)) { // checkLoggedIn で Cookie があることを前提としている + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const cookie = parseCookie(request.headers.get('Cookie')!) const postData = { diff --git a/package/src/validate.ts b/package/src/validate.ts index 1fc1acf..abc1a49 100644 --- a/package/src/validate.ts +++ b/package/src/validate.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import dayjs from 'dayjs' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' diff --git a/package/test/internal/cookieUtil.ts b/package/test/internal/cookieUtil.ts index e6d4f14..f4a0e03 100644 --- a/package/test/internal/cookieUtil.ts +++ b/package/test/internal/cookieUtil.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + // Memo: Cloudflare Types で型推論されてしまうが、テスト時は jsdom なので Web Standard に従う const cookieParser = (cookieString: string) => { const mp = new Map]>() diff --git a/package/test/internal/goparam.test.ts b/package/test/internal/goparam.test.ts index e7b796a..220eaa7 100644 --- a/package/test/internal/goparam.test.ts +++ b/package/test/internal/goparam.test.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import { describe, expect, it } from 'vitest' import { generateGoParam, verifyMac } from '../../src/internal/goparam' diff --git a/package/test/internal/handleCallback.test.ts b/package/test/internal/handleCallback.test.ts index af93c9a..9ce9642 100644 --- a/package/test/internal/handleCallback.test.ts +++ b/package/test/internal/handleCallback.test.ts @@ -1,4 +1,5 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import { describe, expect, it, vi } from 'vitest' import { handleCallback } from '../../src/internal/handleCallback' @@ -12,7 +13,6 @@ import { import { cookieParser, removesCookie } from './cookieUtil' vi.mock('../../src/internal/const', async importOriginal => { - // eslint-disable-next-line @typescript-eslint/consistent-type-imports const mod = await importOriginal() return { ...mod, diff --git a/package/test/internal/handleLogin.test.ts b/package/test/internal/handleLogin.test.ts index fcd1ab1..5d9d6b2 100644 --- a/package/test/internal/handleLogin.test.ts +++ b/package/test/internal/handleLogin.test.ts @@ -1,4 +1,5 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import type { MockInstance } from 'vitest' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' diff --git a/package/test/internal/handleLogout.test.ts b/package/test/internal/handleLogout.test.ts index e40f0e2..7aedca9 100644 --- a/package/test/internal/handleLogout.test.ts +++ b/package/test/internal/handleLogout.test.ts @@ -1,4 +1,5 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import { describe, expect, it } from 'vitest' import { handleLogout } from '../../src/internal/handleLogout' diff --git a/package/test/internal/handleMe.test.ts b/package/test/internal/handleMe.test.ts index 79cf232..2374b1a 100644 --- a/package/test/internal/handleMe.test.ts +++ b/package/test/internal/handleMe.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ import dayjs from 'dayjs' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' diff --git a/package/test/middleware.test.ts b/package/test/middleware.test.ts index e2d7f46..2a256d6 100644 --- a/package/test/middleware.test.ts +++ b/package/test/middleware.test.ts @@ -1,4 +1,5 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import dayjs from 'dayjs' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' diff --git a/package/test/userinfo.test.ts b/package/test/userinfo.test.ts index c897fd2..b563d1f 100644 --- a/package/test/userinfo.test.ts +++ b/package/test/userinfo.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ import dayjs from 'dayjs' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' diff --git a/package/test/validate.test.ts b/package/test/validate.test.ts index 46cb0b0..7dd0887 100644 --- a/package/test/validate.test.ts +++ b/package/test/validate.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import dayjs from 'dayjs' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' @@ -12,7 +11,6 @@ dayjs.extend(timezone) dayjs.tz.setDefault('Asia/Tokyo') vi.mock('../src/internal', async importOriginal => { - // eslint-disable-next-line @typescript-eslint/consistent-type-imports const mod = await importOriginal() return { ...mod, diff --git a/webapp/app/routes/cb.tsx b/webapp/app/routes/cb.tsx index ab90827..dfd21be 100644 --- a/webapp/app/routes/cb.tsx +++ b/webapp/app/routes/cb.tsx @@ -75,7 +75,7 @@ export const loader: LoaderFunction = async ({ context, request }) => { }, ) isMember = (checkIsOrgMemberRes.status as number) === 204 - } catch (e) { + } catch (_) { isMember = false } session.set('id', String(user.id)) diff --git a/webapp/app/routes/continue/route.tsx b/webapp/app/routes/continue/route.tsx index 7fd14a4..a436cfc 100644 --- a/webapp/app/routes/continue/route.tsx +++ b/webapp/app/routes/continue/route.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import type { ActionFunction, LoaderFunction, diff --git a/webapp/app/routes/go.tsx b/webapp/app/routes/go.tsx index 478f888..9062152 100644 --- a/webapp/app/routes/go.tsx +++ b/webapp/app/routes/go.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import type { LoaderFunction, ActionFunction } from '@remix-run/cloudflare' import { redirect } from '@remix-run/cloudflare' @@ -54,7 +56,7 @@ export const loader: LoaderFunction = async ({ context, request }) => { let theirPubkey: CryptoKey try { theirPubkey = await importKey(registeredData.pubkey, 'publicKey') - } catch (e) { + } catch (_) { throw new Response('invalid pubkey', { status: 400 }) } if (!theirPubkey.usages.includes('verify')) diff --git a/webapp/app/routes/user.tsx b/webapp/app/routes/user.tsx index 0b492c0..a0b6564 100644 --- a/webapp/app/routes/user.tsx +++ b/webapp/app/routes/user.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import type { ActionFunction, LoaderFunction } from '@remix-run/cloudflare' import { diff --git a/webapp/eslint.config.mjs b/webapp/eslint.config.mjs index 91c68c8..0ce1fbf 100644 --- a/webapp/eslint.config.mjs +++ b/webapp/eslint.config.mjs @@ -15,8 +15,6 @@ export default tseslint.config( }, eslint.configs.recommended, ...rootConfig, - react.configs.flat.recommended, - react.configs.flat['jsx-runtime'], { languageOptions: { globals: { @@ -48,6 +46,8 @@ export default tseslint.config( ], 'import/resolver': { typescript: {} }, }, + ...react.configs.flat.recommended, + ...react.configs.flat['jsx-runtime'], }, { // typescript diff --git a/worker/src/index.ts b/worker/src/index.ts index f5eca2b..8a5d1b6 100644 --- a/worker/src/index.ts +++ b/worker/src/index.ts @@ -24,8 +24,7 @@ export default { async fetch( request: Request, env: Env, - // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars - ctx: ExecutionContext, + _ctx: ExecutionContext, ): Promise { for (const key of ['PRIVKEY', 'AUTH_DOMAIN', 'AUTH_PUBKEY'] as const) { if (!env[key]) { diff --git a/worker/test/index.test.ts b/worker/test/index.test.ts index 1fd5827..d2b50dd 100644 --- a/worker/test/index.test.ts +++ b/worker/test/index.test.ts @@ -1,4 +1,5 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import dayjs from 'dayjs' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc'