Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): replace standard with neostandard #56

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
ts: true
})
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"unit": "tap test/**/*.test.js",
"test": "npm run unit && npm run test:typescript",
"test:typescript": "tsd"
Expand All @@ -26,8 +26,8 @@
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"fastify": "^5.0.0",
"neostandard": "^0.11.9",
"sanitize-filename": "^1.6.3",
"standard": "^17.1.0",
"tap": "^18.7.2",
"tsd": "^0.31.0"
},
Expand Down
10 changes: 5 additions & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ declare namespace SerializerSelector {
export type SerializerFactory = (
externalSchemas?: unknown,
options?: Options
) => SerializerCompiler;
) => SerializerCompiler

export type SerializerCompiler = (
externalSchemas?: unknown,
options?: Options
) => Serializer;
) => Serializer

export type Serializer = (doc: any) => string

Expand All @@ -35,11 +35,11 @@ declare namespace SerializerSelector {
}

export type { Options }
export const SerializerSelector: FastJsonStringifyFactory;
export function StandaloneSerializer(options: StandaloneOptions): SerializerFactory;
export const SerializerSelector: FastJsonStringifyFactory
export function StandaloneSerializer (options: StandaloneOptions): SerializerFactory

export { SerializerSelector as default }
}

declare function SerializerSelector(...params: Parameters<FastJsonStringifyFactory>): ReturnType<FastJsonStringifyFactory>
declare function SerializerSelector (...params: Parameters<FastJsonStringifyFactory>): ReturnType<FastJsonStringifyFactory>
export = SerializerSelector
50 changes: 24 additions & 26 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
import { expectAssignable, expectError, expectType } from "tsd";
import { expectAssignable, expectError, expectType } from 'tsd'
import SerializerSelector, {
RouteDefinition,
Serializer,
SerializerCompiler,
SerializerFactory,
SerializerSelector as SerializerSelectorNamed,
StandaloneSerializer,
} from "..";
} from '..'

/**
* SerializerSelector
*/

{
const compiler = SerializerSelector();
expectType<SerializerFactory>(compiler);
const compiler = SerializerSelector()
expectType<SerializerFactory>(compiler)
}

{
const compiler = SerializerSelectorNamed();
expectType<SerializerFactory>(compiler);
const compiler = SerializerSelectorNamed()
expectType<SerializerFactory>(compiler)
}

{
{
const sampleSchema = {
$id: 'example1',
type: 'object',
properties: {
name: { type: 'string' }
}
const sampleSchema = {
$id: 'example1',
type: 'object',
properties: {
name: { type: 'string' }
}
}

const externalSchemas1 = {}
const externalSchemas1 = {}

const factory = SerializerSelector()
expectType<SerializerFactory>(factory);
const compiler = factory(externalSchemas1, {})
expectType<SerializerCompiler>(compiler);
const serializeFunc = compiler({ schema: sampleSchema })
expectType<Serializer>(serializeFunc);
const factory = SerializerSelector()
expectType<SerializerFactory>(factory)
const compiler = factory(externalSchemas1, {})
expectType<SerializerCompiler>(compiler)
const serializeFunc = compiler({ schema: sampleSchema })
expectType<Serializer>(serializeFunc)

expectType<string>(serializeFunc({ name: 'hello' }))
}
expectType<string>(serializeFunc({ name: 'hello' }))
}

/**
Expand All @@ -55,17 +53,17 @@ const reader = StandaloneSerializer({
expectAssignable<RouteDefinition>(route)
return {} as Serializer
},
});
expectType<SerializerFactory>(reader);
})
expectType<SerializerFactory>(reader)

const writer = StandaloneSerializer({
readMode: false,
storeFunction: (route: RouteDefinition, code: string) => {
expectAssignable<RouteDefinition>(route)
expectAssignable<string>(code)
},
});
expectType<SerializerFactory>(writer);
})
expectType<SerializerFactory>(writer)

{
const base = {
Expand Down
Loading