Skip to content

Commit

Permalink
chore(lint): update eslint rules (#2790)
Browse files Browse the repository at this point in the history
* chore(lint): update eslint rules

* fix formats
  • Loading branch information
yusukebe authored May 25, 2024
1 parent 82cfd46 commit cc4b2b3
Show file tree
Hide file tree
Showing 63 changed files with 180 additions and 177 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@
"nodejs"
],
"devDependencies": {
"@hono/eslint-config": "^0.0.4",
"@hono/eslint-config": "^0.0.6",
"@hono/node-server": "^1.8.2",
"@types/crypto-js": "^4.1.1",
"@types/glob": "^8.0.0",
Expand Down
5 changes: 3 additions & 2 deletions runtime_tests/bun/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach, afterAll } from 'vitest'
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { serveStatic, toSSG } from '../../src/adapter/bun'
import { createBunWebSocket, type BunWebSocketData } from '../../src/adapter/bun/websocket'
import { createBunWebSocket } from '../../src/adapter/bun/websocket'
import type { BunWebSocketData } from '../../src/adapter/bun/websocket'
import { Context } from '../../src/context'
import { env, getRuntimeKey } from '../../src/helper/adapter'
import type { WSMessageReceive } from '../../src/helper/websocket'
Expand Down
2 changes: 1 addition & 1 deletion runtime_tests/deno-jsx/jsx.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Style, css } from '../../src/helper/css/index.ts'
import { Suspense, renderToReadableStream } from '../../src/jsx/streaming.ts'
import type { HtmlEscapedString } from '../../src/utils/html.ts'
import { resolveCallback, HtmlEscapedCallbackPhase } from '../../src/utils/html.ts'
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../src/utils/html.ts'
import { assertEquals } from '../deno/deps.ts'

Deno.test('JSX', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/aws-lambda/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { Hono } from '../../hono'
import type { Env, Schema } from '../../types'
import { decodeBase64, encodeBase64 } from '../../utils/encode'
import type {
ALBRequestContext,
ApiGatewayRequestContext,
ApiGatewayRequestContextV2,
ALBRequestContext,
} from './custom-context'
import type { Handler, LambdaContext } from './types'

Expand Down
12 changes: 6 additions & 6 deletions src/adapter/bun/websocket.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
createWSMessageEvent,
type UpgradeWebSocket,
type WSContext,
type WSEvents,
type WSMessageReceive,
import { createWSMessageEvent } from '../../helper/websocket'
import type {
UpgradeWebSocket,
WSContext,
WSEvents,
WSMessageReceive,
} from '../../helper/websocket'

interface BunServerWebSocket<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/compose.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Context } from './context'
import type { ParamIndexMap, Params } from './router'
import type { Env, NotFoundHandler, ErrorHandler } from './types'
import type { Env, ErrorHandler, NotFoundHandler } from './types'

interface ComposeContext {
finalized: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/helper/accepts/accepts.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Hono } from '../..'
import type { Accept, acceptsConfig, acceptsOptions } from './accepts'
import { parseAccept, defaultMatch, accepts } from './accepts'
import { accepts, defaultMatch, parseAccept } from './accepts'

describe('parseAccept', () => {
test('should parse accept header', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/helper/cookie/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hono } from '../../hono'
import { getCookie, getSignedCookie, setCookie, setSignedCookie, deleteCookie } from '.'
import { deleteCookie, getCookie, getSignedCookie, setCookie, setSignedCookie } from '.'

describe('Cookie Middleware', () => {
describe('Parse cookie', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/helper/cookie/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Context } from '../../context'
import { parse, parseSigned, serialize, serializeSigned } from '../../utils/cookie'
import type { CookieOptions, Cookie, SignedCookie, CookiePrefixOptions } from '../../utils/cookie'
import type { Cookie, CookieOptions, CookiePrefixOptions, SignedCookie } from '../../utils/cookie'

interface GetCookie {
(c: Context, key: string): string | undefined
Expand Down
4 changes: 2 additions & 2 deletions src/helper/css/common.case.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable quotes */
/** @jsxImportSource ../../jsx */
import type {
Style as StyleComponent,
css as cssHelper,
keyframes as keyframesHelper,
viewTransition as viewTransitionHelper,
rawCssString as rawCssStringHelper,
Style as StyleComponent,
viewTransition as viewTransitionHelper,
} from './index'

interface Support {
Expand Down
2 changes: 1 addition & 1 deletion src/helper/css/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Suspense, renderToReadableStream } from '../../jsx/streaming'
import type { HtmlEscapedString } from '../../utils/html'
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../utils/html'
import { renderTest } from './common.case.test'
import { css, cx, keyframes, viewTransition, rawCssString, Style, createCssContext } from './index'
import { Style, createCssContext, css, cx, keyframes, rawCssString, viewTransition } from './index'

async function toString(
template: JSXNode | Promise<HtmlEscapedString> | Promise<string> | HtmlEscapedString
Expand Down
8 changes: 4 additions & 4 deletions src/helper/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { createCssJsxDomObjects } from '../../jsx/dom/css'
import type { HtmlEscapedCallback, HtmlEscapedString } from '../../utils/html'
import type { CssClassName as CssClassNameCommon, CssVariableType } from './common'
import {
SELECTOR,
CLASS_NAME,
STYLE_STRING,
SELECTORS,
PSEUDO_GLOBAL_SELECTOR,
DEFAULT_STYLE_ID,
PSEUDO_GLOBAL_SELECTOR,
SELECTOR,
SELECTORS,
STYLE_STRING,
cssCommon,
cxCommon,
keyframesCommon,
Expand Down
2 changes: 1 addition & 1 deletion src/helper/dev/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Hono } from '../../hono'
import { RegExpRouter } from '../../router/reg-exp-router'
import type { Handler, MiddlewareHandler } from '../../types'
import { inspectRoutes, showRoutes, getRouterName } from '.'
import { getRouterName, inspectRoutes, showRoutes } from '.'

const namedMiddleware: MiddlewareHandler = (_, next) => next()
const namedHandler: Handler = (c) => c.text('hi')
Expand Down
2 changes: 1 addition & 1 deletion src/helper/factory/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Hono } from '../../index'
import type { ToSchema, TypedResponse } from '../../types'
import type { StatusCode } from '../../utils/http-status'
import { validator } from '../../validator'
import { createMiddleware, createFactory } from './index'
import { createFactory, createMiddleware } from './index'

describe('createMiddleware', () => {
type Env = { Variables: { foo: string } }
Expand Down
2 changes: 1 addition & 1 deletion src/helper/html/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolveCallback, HtmlEscapedCallbackPhase } from '../../utils/html'
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../utils/html'
import { html, raw } from '.'

describe('Tagged Template Literals', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/helper/html/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { escapeToBuffer, stringBufferToString, raw } from '../../utils/html'
import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../../utils/html'
import { escapeToBuffer, raw, stringBufferToString } from '../../utils/html'
import type { HtmlEscaped, HtmlEscapedString, StringBuffer } from '../../utils/html'

export { raw }

Expand Down
10 changes: 5 additions & 5 deletions src/helper/ssg/ssg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { Hono } from '../../hono'
import { poweredBy } from '../../middleware/powered-by'
import {
X_HONO_DISABLE_SSG_HEADER_KEY,
ssgParams,
isSSGContext,
disableSSG,
isSSGContext,
onlySSG,
ssgParams,
} from './middleware'
import { fetchRoutesContent, saveContentToFile, toSSG, defaultExtensionMap } from './ssg'
import { defaultExtensionMap, fetchRoutesContent, saveContentToFile, toSSG } from './ssg'
import type {
BeforeRequestHook,
AfterResponseHook,
AfterGenerateHook,
AfterResponseHook,
BeforeRequestHook,
FileSystemModule,
ToSSGResult,
} from './ssg'
Expand Down
4 changes: 2 additions & 2 deletions src/helper/ssg/ssg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Env, Schema } from '../../types'
import { createPool } from '../../utils/concurrent'
import { getExtension } from '../../utils/mime'
import type { AddedSSGDataRequest, SSGParams } from './middleware'
import { X_HONO_DISABLE_SSG_HEADER_KEY, SSG_CONTEXT } from './middleware'
import { joinPaths, dirname, filterStaticGenerateRoutes } from './utils'
import { SSG_CONTEXT, X_HONO_DISABLE_SSG_HEADER_KEY } from './middleware'
import { dirname, filterStaticGenerateRoutes, joinPaths } from './utils'

const DEFAULT_CONCURRENCY = 2 // default concurrency for ssg

Expand Down
4 changes: 2 additions & 2 deletions src/helper/ssg/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { joinPaths, dirname } from './utils'
import { describe, expect, it } from 'vitest'
import { dirname, joinPaths } from './utils'

describe('joinPath', () => {
it('Should joined path is valid.', () => {
Expand Down
10 changes: 5 additions & 5 deletions src/hono-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import type { ExecutionContext } from './context'
import { HTTPException } from './http-exception'
import { HonoRequest } from './request'
import type { Router } from './router'
import { METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE, METHODS } from './router'
import { METHODS, METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE } from './router'
import type {
Env,
ErrorHandler,
FetchEventLike,
H,
HandlerInterface,
MergePath,
MergeSchemaPath,
MiddlewareHandler,
MiddlewareHandlerInterface,
Next,
NotFoundHandler,
OnHandlerInterface,
MergePath,
MergeSchemaPath,
FetchEventLike,
Schema,
RouterRoute,
Schema,
} from './types'
import { getPath, getPathNoStrict, getQueryStrings, mergePath } from './utils/url'

Expand Down
2 changes: 1 addition & 1 deletion src/hono.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { RegExpRouter } from './router/reg-exp-router'
import { SmartRouter } from './router/smart-router'
import { TrieRouter } from './router/trie-router'
import type { Handler, MiddlewareHandler, Next } from './types'
import type { Expect, Equal } from './utils/types'
import type { Equal, Expect } from './utils/types'
import { getPath } from './utils/url'

// https://stackoverflow.com/a/65666402
Expand Down
5 changes: 2 additions & 3 deletions src/jsx/base.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { raw } from '../helper/html'
import { escapeToBuffer, stringBufferToString } from '../utils/html'
import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../utils/html'
import type { HtmlEscaped, HtmlEscapedString, StringBuffer } from '../utils/html'
import type { Context } from './context'
import { globalContexts } from './context'
import type { IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements'
import type { Hono } from './intrinsic-elements'
import type { Hono, IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements'
import { normalizeIntrinsicElementProps, styleObjectForEach } from './utils'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
4 changes: 2 additions & 2 deletions src/jsx/components.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { raw } from '../helper/html'
import type { HtmlEscapedString, HtmlEscapedCallback } from '../utils/html'
import type { HtmlEscapedCallback, HtmlEscapedString } from '../utils/html'
import { HtmlEscapedCallbackPhase, resolveCallback } from '../utils/html'
import { DOM_RENDERER } from './constants'
import { ErrorBoundary as ErrorBoundaryDomRenderer } from './dom/components'
import type { HasRenderToDom } from './dom/render'
import type { FC, PropsWithChildren, Child } from './'
import type { Child, FC, PropsWithChildren } from './'

let errorBoundaryCounter = 0

Expand Down
5 changes: 2 additions & 3 deletions src/jsx/dom/components.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/** @jsxImportSource ../ */
import { JSDOM } from 'jsdom'
import { Suspense as SuspenseCommon, ErrorBoundary as ErrorBoundaryCommon } from '..' // for common
import { ErrorBoundary as ErrorBoundaryCommon, Suspense as SuspenseCommon } from '..' // for common
// run tests by old style jsx default
// hono/jsx/jsx-runtime and hono/jsx/dom/jsx-runtime are tested in their respective settings
import { use, useState } from '../hooks'
import { Suspense as SuspenseDom, ErrorBoundary as ErrorBoundaryDom } from '.' // for dom
import { render } from '.'
import { ErrorBoundary as ErrorBoundaryDom, Suspense as SuspenseDom, render } from '.' // for dom

runner('Common', SuspenseCommon, ErrorBoundaryCommon)
runner('DOM', SuspenseDom, ErrorBoundaryDom)
Expand Down
4 changes: 2 additions & 2 deletions src/jsx/dom/components.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC, PropsWithChildren, Child } from '../'
import type { FallbackRender, ErrorHandler } from '../components'
import type { Child, FC, PropsWithChildren } from '../'
import type { ErrorHandler, FallbackRender } from '../components'
import { DOM_ERROR_HANDLER } from '../constants'
import { Fragment } from './jsx-runtime'

Expand Down
11 changes: 7 additions & 4 deletions src/jsx/dom/context.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/** @jsxImportSource ../ */
import { JSDOM } from 'jsdom'
import { createContext as createContextCommon, useContext as useContextCommon } from '..' // for common
import { use, Suspense } from '..'
import {
Suspense,
createContext as createContextCommon,
use,
useContext as useContextCommon,
} from '..' // for common
// run tests by old style jsx default
// hono/jsx/jsx-runtime and hono/jsx/dom/jsx-runtime are tested in their respective settings
import { createContext as createContextDom, useContext as useContextDom } from '.' // for dom
import { render, useState } from '.'
import { createContext as createContextDom, render, useContext as useContextDom, useState } from '.' // for dom

runner('Common', createContextCommon, useContextCommon)
runner('DOM', createContextDom, useContextDom)
Expand Down
2 changes: 1 addition & 1 deletion src/jsx/dom/css.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { JSDOM } from 'jsdom'
// hono/jsx/jsx-runtime and hono/jsx/dom/jsx-runtime are tested in their respective settings
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { JSXNode } from '..'
import { Style, css, rawCssString, createCssContext } from '../../helper/css'
import { Style, createCssContext, css, rawCssString } from '../../helper/css'
import { minify } from '../../helper/css/common'
import { renderTest } from '../../helper/css/common.case.test'
import { render } from '.'
Expand Down
8 changes: 4 additions & 4 deletions src/jsx/dom/css.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { FC, PropsWithChildren } from '../'
import type { CssClassName, CssVariableType } from '../../helper/css/common'
import {
SELECTOR,
CLASS_NAME,
STYLE_STRING,
SELECTORS,
PSEUDO_GLOBAL_SELECTOR,
DEFAULT_STYLE_ID,
PSEUDO_GLOBAL_SELECTOR,
SELECTOR,
SELECTORS,
STYLE_STRING,
cssCommon,
cxCommon,
keyframesCommon,
Expand Down
27 changes: 14 additions & 13 deletions src/jsx/dom/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
/** @jsxImportSource ../ */
import { JSDOM } from 'jsdom'
import type { FC, Child } from '..'
import type { Child, FC } from '..'
// run tests by old style jsx default
// hono/jsx/jsx-runtime and hono/jsx/dom/jsx-runtime are tested in their respective settings
import { createElement, jsx } from '..'
import type { RefObject } from '../hooks'
import {
useState,
createRef,
useCallback,
useEffect,
useLayoutEffect,
useInsertionEffect,
useCallback,
useRef,
useLayoutEffect,
useMemo,
createRef,
useRef,
useState,
} from '../hooks'
import DefaultExport from '.'
import { memo, isValidElement, cloneElement } from '.'
import {
render,
flushSync,
createPortal,
createElement as createElementForDom,
import DefaultExport, {
cloneElement,
cloneElement as cloneElementForDom,
createElement as createElementForDom,
createPortal,
flushSync,
isValidElement,
memo,
render,
} from '.'

describe('Common', () => {
Expand Down
Loading

0 comments on commit cc4b2b3

Please sign in to comment.