Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Feb 20, 2024
1 parent f666137 commit 76d18e2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ParamsFromConfig<K extends RouterConfig> = {

// Converting string params to string | number
type Input<T> = {
[P in keyof T]: string | number
[P in keyof T]: number | string
}

type MappedC<A, B> = {
Expand All @@ -53,7 +53,7 @@ type OptionalKeys<T> = MappedC<T, Required<T>>[keyof T]

type EmptyObject = Record<string, never>

type SearchParams = Record<string, string | number>
type SearchParams = Record<string, number | string>

export type ParamsArg<
Config extends RouterConfig,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"clean": true
},
"eslintConfig": {
"extends": "@logux/eslint-config",
"extends": "@logux/eslint-config/ts",
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"consistent-return": "off"
Expand Down
32 changes: 16 additions & 16 deletions test/router.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JSDOM } from 'jsdom'
import { cleanStores } from 'nanostores'
import { test, afterEach } from 'node:test'
import { deepStrictEqual, throws, equal } from 'node:assert'
import { deepStrictEqual, equal, throws } from 'node:assert'
import { afterEach, test } from 'node:test'

import {
createRouter,
Expand Down Expand Up @@ -431,22 +431,22 @@ test('generates URLs', () => {
)
equal(getPagePath(router, 'optional'), '/profile')

equal(getPagePath(router, { route: 'posts', params: {} }), '/posts')
equal(getPagePath(router, { params: {}, route: 'posts' }), '/posts')
equal(
getPagePath(router, { route: 'posts', params: {} }, { a: 1 }),
getPagePath(router, { params: {}, route: 'posts' }, { a: 1 }),
'/posts?a=1'
)
equal(
getPagePath(router, {
route: 'post',
params: { categoryId: 'guides', id: '1' }
params: { categoryId: 'guides', id: '1' },
route: 'post'
}),
'/posts/guides/1'
)
equal(
getPagePath(router, {
route: 'post',
params: { categoryId: 'guides', id: 1 }
params: { categoryId: 'guides', id: 1 },
route: 'post'
}),
'/posts/guides/1'
)
Expand Down Expand Up @@ -483,16 +483,16 @@ test('opens URLs manually by route name, pushing new stare', () => {
})

openPage(router, {
route: 'post',
params: { categoryId: 'guides', id: '12' }
params: { categoryId: 'guides', id: '12' },
route: 'post'
})
equal(location.href, 'http://localhost/posts/guides/12')

openPage(
router,
{
route: 'post',
params: { categoryId: 'guides', id: '12' }
params: { categoryId: 'guides', id: '12' },
route: 'post'
},
{ sort: 'name' }
)
Expand Down Expand Up @@ -530,16 +530,16 @@ test('opens URLs manually by route name, replacing state', () => {
})

redirectPage(router, {
route: 'post',
params: { categoryId: 'guides', id: '12' }
params: { categoryId: 'guides', id: '12' },
route: 'post'
})
equal(location.href, 'http://localhost/posts/guides/12')

redirectPage(
router,
{
route: 'post',
params: { categoryId: 'guides', id: '12' }
params: { categoryId: 'guides', id: '12' },
route: 'post'
},
{
sort: 'name'
Expand Down
2 changes: 1 addition & 1 deletion test/ssr.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cleanStores } from 'nanostores'
import { test, afterEach } from 'node:test'
import { deepStrictEqual } from 'node:assert'
import { afterEach, test } from 'node:test'

import { createRouter } from '../index.js'

Expand Down
8 changes: 4 additions & 4 deletions test/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ router.subscribe(page => {
openPage(router, 'profile', {})
openPage(router, 'profile', { userId: '123' })
openPage(router, 'profile', { userId: 123 })
openPage(router, { route: 'profile', params: {} })
openPage(router, { route: 'post', params: { id: '1' } })
openPage(router, { route: 'post', params: { id: 1 } })
openPage(router, { route: 'home', params: {} })
openPage(router, { params: {}, route: 'profile' })
openPage(router, { params: { id: '1' }, route: 'post' })
openPage(router, { params: { id: 1 }, route: 'post' })
openPage(router, { params: {}, route: 'home' })
openPage(router, { route: 'home' })
redirectPage(router, 'post', { id: '1' })
redirectPage(router, 'home')
Expand Down

0 comments on commit 76d18e2

Please sign in to comment.