From dac3c2a19effe6fe3a7f535a12de453eefe05594 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Thu, 12 Dec 2024 20:46:09 +0000 Subject: [PATCH] build(deps-dev): replace standard with neostandard (#158) * build(deps-dev): replace standard with neostandard * chore: add eslint.config.js * test(types): remove unused import --- README.md | 2 +- eslint.config.js | 6 ++++++ package.json | 7 ++++--- types/index.d.ts | 2 +- types/index.test-d.ts | 34 +++++++++++++++++----------------- 5 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 eslint.config.js diff --git a/README.md b/README.md index d908bdb..667e536 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![NPM Version][npm-image]][npm-url] [![CI](https://github.com/fastify/fastify-funky/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify-funky/actions/workflows/ci.yml) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) +[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard) Support for Fastify routes returning functional structures, such as `fp-ts` Either, Task, TaskEither, or plain JavaScript parameterless functions. Let's go funky, let's go functional! 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 5c24a2c..ad2cc7c 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,11 @@ "type": "commonjs", "types": "types/index.d.ts", "scripts": { + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:typescript", "test:unit": "c8 --100 node --test", - "test:typescript": "tsd", - "lint": "standard" + "test:typescript": "tsd" }, "dependencies": { "fastify-plugin": "^5.0.0" @@ -27,7 +28,7 @@ "c8": "^10.1.2", "fastify": "^5.0.0", "fp-ts": "^2.11.2", - "standard": "^17.0.0", + "neostandard": "^0.11.9", "tsd": "^0.31.1" }, "homepage": "https://github.com/fastify/fastify-funky", diff --git a/types/index.d.ts b/types/index.d.ts index 852475d..c50e96c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -32,5 +32,5 @@ declare namespace fastifyFunky { export { fastifyFunky as default } } -declare function fastifyFunky(...params: Parameters): ReturnType +declare function fastifyFunky (...params: Parameters): ReturnType export = fastifyFunky diff --git a/types/index.test-d.ts b/types/index.test-d.ts index c3c7f20..39c1439 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -1,7 +1,7 @@ import { FastifyInstance, FastifyPluginCallback, FastifyReply, FastifyRequest } from 'fastify' import fastify from 'fastify' import { either, task, taskEither } from 'fp-ts' -import { expectType, expectError, expectAssignable } from 'tsd' +import { expectType, expectAssignable } from 'tsd' import { fastifyFunky as fastifyFunkyNamed } from '..' import fastifyFunkyDefault from '..' @@ -53,38 +53,38 @@ app.get('/func', (req, reply) => { }) // this is allowed -app.get("/", (req, reply) => { +app.get('/', (req, reply) => { expectAssignable(req) expectAssignable(reply) - return { right: { id: 1 } }; -}); -app.get("/", (req, reply) => { + return { right: { id: 1 } } +}) +app.get('/', (req, reply) => { expectAssignable(req) expectAssignable(reply) - return { left: new Error('error') }; -}); -app.get("/", (req, reply) => { + return { left: new Error('error') } +}) +app.get('/', (req, reply) => { expectAssignable(req) expectAssignable(reply) return taskEither.fromEither(either.left(new Error('Invalid state'))) -}); -app.get("/", (req, reply) => { +}) +app.get('/', (req, reply) => { expectAssignable(req) expectAssignable(reply) return taskEither.fromTask(task.of(Promise.resolve({}))) -}); -app.get("/", (req, reply) => { +}) +app.get('/', (req, reply) => { expectAssignable(req) expectAssignable(reply) return either.of(Promise.resolve({})) -}); -app.get("/", (req, reply) => { +}) +app.get('/', (req, reply) => { expectAssignable(req) expectAssignable(reply) return task.of(Promise.resolve({})) -}); -app.get("/", (req, reply) => { +}) +app.get('/', (req, reply) => { expectAssignable(req) expectAssignable(reply) return taskEither.of(Promise.resolve({})) -}); +})