From 76d18e28668c6399205762e2b8515404f6ea7374 Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Wed, 21 Feb 2024 00:12:21 +0100 Subject: [PATCH] Fix linter --- index.d.ts | 4 ++-- package.json | 2 +- test/router.test.ts | 32 ++++++++++++++++---------------- test/ssr.test.ts | 2 +- test/types.ts | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/index.d.ts b/index.d.ts index c48c033..427cdb0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -43,7 +43,7 @@ type ParamsFromConfig = { // Converting string params to string | number type Input = { - [P in keyof T]: string | number + [P in keyof T]: number | string } type MappedC = { @@ -53,7 +53,7 @@ type OptionalKeys = MappedC>[keyof T] type EmptyObject = Record -type SearchParams = Record +type SearchParams = Record export type ParamsArg< Config extends RouterConfig, diff --git a/package.json b/package.json index 61b683d..a6c9565 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/test/router.test.ts b/test/router.test.ts index 8b18918..bb8e471 100644 --- a/test/router.test.ts +++ b/test/router.test.ts @@ -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, @@ -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' ) @@ -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' } ) @@ -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' diff --git a/test/ssr.test.ts b/test/ssr.test.ts index 4efd546..d8afd3a 100644 --- a/test/ssr.test.ts +++ b/test/ssr.test.ts @@ -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' diff --git a/test/types.ts b/test/types.ts index 3b48589..0e002db 100644 --- a/test/types.ts +++ b/test/types.ts @@ -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')