diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..89fd678 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,6 @@ +'use strict' + +module.exports = require('neostandard')({ + ignores: require('neostandard').resolveIgnoresFromGitignore(), + ts: true +}) diff --git a/package.json b/package.json index dcd593f..0cd4f0c 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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" }, diff --git a/types/index.d.ts b/types/index.d.ts index 26bbf1f..9f4645f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -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 @@ -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): ReturnType +declare function SerializerSelector (...params: Parameters): ReturnType export = SerializerSelector diff --git a/types/index.test-d.ts b/types/index.test-d.ts index d1dbd85..641c476 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -1,4 +1,4 @@ -import { expectAssignable, expectError, expectType } from "tsd"; +import { expectAssignable, expectError, expectType } from 'tsd' import SerializerSelector, { RouteDefinition, Serializer, @@ -6,43 +6,41 @@ import SerializerSelector, { SerializerFactory, SerializerSelector as SerializerSelectorNamed, StandaloneSerializer, -} from ".."; +} from '..' /** * SerializerSelector */ { - const compiler = SerializerSelector(); - expectType(compiler); + const compiler = SerializerSelector() + expectType(compiler) } { - const compiler = SerializerSelectorNamed(); - expectType(compiler); + const compiler = SerializerSelectorNamed() + expectType(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(factory); - const compiler = factory(externalSchemas1, {}) - expectType(compiler); - const serializeFunc = compiler({ schema: sampleSchema }) - expectType(serializeFunc); + const factory = SerializerSelector() + expectType(factory) + const compiler = factory(externalSchemas1, {}) + expectType(compiler) + const serializeFunc = compiler({ schema: sampleSchema }) + expectType(serializeFunc) - expectType(serializeFunc({ name: 'hello' })) - } + expectType(serializeFunc({ name: 'hello' })) } /** @@ -55,8 +53,8 @@ const reader = StandaloneSerializer({ expectAssignable(route) return {} as Serializer }, -}); -expectType(reader); +}) +expectType(reader) const writer = StandaloneSerializer({ readMode: false, @@ -64,8 +62,8 @@ const writer = StandaloneSerializer({ expectAssignable(route) expectAssignable(code) }, -}); -expectType(writer); +}) +expectType(writer) { const base = {