Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
a01sa01to committed Sep 26, 2024
1 parent f5300d9 commit 6c5a513
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 18 deletions.
10 changes: 10 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default tseslint.config(
...tseslint.configs.strict,
{
plugins: {
'@typescript-eslint': tseslint.plugin,
'unused-imports': unusedImports,
import: importPlugin,
'sort-exports': sortExports,
Expand Down Expand Up @@ -74,6 +75,15 @@ export default tseslint.config(
sortExportKindFirst: 'value',
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
},
},
)
1 change: 1 addition & 0 deletions package/src/internal/goparam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const verifyMac = async (
try {
return await verify(baseParam.toString(), mac, trustedPubkey)
} catch (e) {
console.error(e)
return false
}
}
6 changes: 4 additions & 2 deletions package/src/internal/handleCallback.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions package/src/internal/tokengen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions package/src/userinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions package/src/validate.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 2 additions & 0 deletions package/test/internal/cookieUtil.ts
Original file line number Diff line number Diff line change
@@ -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<string, [string, Map<string, string>]>()
Expand Down
2 changes: 2 additions & 0 deletions package/test/internal/goparam.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions package/test/internal/handleCallback.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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<typeof import('../../src/internal/const')>()
return {
...mod,
Expand Down
3 changes: 2 additions & 1 deletion package/test/internal/handleLogin.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
3 changes: 2 additions & 1 deletion package/test/internal/handleLogout.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion package/test/internal/handleMe.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 2 additions & 1 deletion package/test/middleware.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion package/test/userinfo.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 0 additions & 2 deletions package/test/validate.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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<typeof import('../src/internal')>()
return {
...mod,
Expand Down
2 changes: 1 addition & 1 deletion webapp/app/routes/cb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions webapp/app/routes/continue/route.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */

import type {
ActionFunction,
LoaderFunction,
Expand Down
4 changes: 3 additions & 1 deletion webapp/app/routes/go.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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'))
Expand Down
2 changes: 2 additions & 0 deletions webapp/app/routes/user.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */

import type { ActionFunction, LoaderFunction } from '@remix-run/cloudflare'

import {
Expand Down
4 changes: 2 additions & 2 deletions webapp/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export default tseslint.config(
},
eslint.configs.recommended,
...rootConfig,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
{
languageOptions: {
globals: {
Expand Down Expand Up @@ -48,6 +46,8 @@ export default tseslint.config(
],
'import/resolver': { typescript: {} },
},
...react.configs.flat.recommended,
...react.configs.flat['jsx-runtime'],
},
{
// typescript
Expand Down
3 changes: 1 addition & 2 deletions worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> {
for (const key of ['PRIVKEY', 'AUTH_DOMAIN', 'AUTH_PUBKEY'] as const) {
if (!env[key]) {
Expand Down
3 changes: 2 additions & 1 deletion worker/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit 6c5a513

Please sign in to comment.