From 771e7bd602a06a2dabedfa241fb060774bc60c75 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 8 Dec 2024 10:44:03 +0000 Subject: [PATCH 1/2] build(deps-dev): replace standard with neostandard --- README.md | 2 +- index.d.ts | 20 +- package.json | 6 +- test/types/index.ts | 560 ++++++++++++++++++++++---------------------- 4 files changed, 294 insertions(+), 294 deletions(-) diff --git a/README.md b/README.md index 75c15dd..a31e3af 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI](https://github.com/fastify/avvio/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/avvio/actions/workflows/ci.yml) [![NPM version](https://img.shields.io/npm/v/avvio.svg?style=flat)](https://www.npmjs.com/package/avvio) -[![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) Asynchronous bootstrapping is hard, different things can go wrong, *error handling* and *load order* just to name a few. The aim of this module is to make it simple. diff --git a/index.d.ts b/index.d.ts index cd3ba01..7cae7da 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,19 +1,19 @@ -import { EventEmitter } from "events"; +import { EventEmitter } from 'events' -declare function avvio(done?: Function): avvio.Avvio; -declare function avvio( +declare function avvio (done?: Function): avvio.Avvio +declare function avvio ( instance: I, options?: avvio.Options, done?: Function -): avvio.Avvio; +): avvio.Avvio /** * Typescript cannot manage changes related to options "expose" * because undefined before runtime */ declare namespace avvio { - type context = I extends null ? Avvio : mixedInstance; - type mixedInstance = I & Server; + type context = I extends null ? Avvio : mixedInstance + type mixedInstance = I & Server interface Options { expose?: { @@ -40,9 +40,9 @@ declare namespace avvio { } interface Avvio extends EventEmitter, Server { - on(event: "start", listener: () => void): this; - on(event: "preReady", listener: () => void): this; - on(event: "close", listener: () => void): this; + on(event: 'start', listener: () => void): this; + on(event: 'preReady', listener: () => void): this; + on(event: 'close', listener: () => void): this; start(): this; @@ -89,4 +89,4 @@ declare namespace avvio { } } -export = avvio; +export = avvio diff --git a/package.json b/package.json index 34b97f1..61b0211 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "main": "boot.js", "type": "commonjs", "scripts": { - "lint": "standard", - "lint:fix": "standard --fix", + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:typescript", "test:unit": "tap", "test:typescript": "tsc --project ./test/types/tsconfig.json" @@ -40,7 +40,7 @@ "devDependencies": { "@fastify/pre-commit": "^2.1.0", "@types/node": "^22.0.0", - "standard": "^17.1.0", + "neostandard": "^0.11.9", "tap": "^18.7.1", "typescript": "~5.7.2" }, diff --git a/test/types/index.ts b/test/types/index.ts index 43497d0..1182622 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -1,411 +1,411 @@ -import * as avvio from "../../"; +import * as avvio from '../../' { // avvio with no argument - const app = avvio(); + const app = avvio() - app.override = (server, fn, options) => server; + app.override = (server, fn, options) => server app.use( (server, opts, done) => { - server.use; - server.after; - server.ready; - server.on; - server.start; - server.override; - server.onClose; - server.close; - - opts.mySuper; - - done(); + server.use + server.after + server.ready + server.on + server.start + server.override + server.onClose + server.close + + opts.mySuper + + done() }, - { mySuper: "option" } - ); + { mySuper: 'option' } + ) app.use(async (server, options) => { - server.use; - server.after; - server.ready; - server.on; - server.start; - server.override; - server.onClose; - server.close; - }); + server.use + server.after + server.ready + server.on + server.start + server.override + server.onClose + server.close + }) app.use(async (server, options) => {}, (server) => { - server.use; - server.after; - server.ready; - server.on; - server.start; - server.override; - server.onClose; - server.close; - }); + server.use + server.after + server.ready + server.on + server.start + server.override + server.onClose + server.close + }) app.after(err => { - if (err) throw err; - }); + if (err) throw err + }) app.after((err: Error, done: Function) => { - done(); - }); + done() + }) app.after((err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) app.ready().then(context => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + }) app.ready(err => { - if (err) throw err; - }); + if (err) throw err + }) app.ready((err: Error, done: Function) => { - done(); - }); + done() + }) app.ready((err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) app.close(err => { - if (err) throw err; - }); + if (err) throw err + }) app.close((err: Error, done: Function) => { - done(); - }); + done() + }) app.close((err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) app.onClose((context, done) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) } { // avvio with done - const app = avvio(() => undefined); + const app = avvio(() => undefined) app.use( (server, opts, done) => { - server.use; - server.after; - server.ready; - server.on; - server.start; - server.override; - server.onClose; - server.close; - - opts.mySuper; - - done(); + server.use + server.after + server.ready + server.on + server.start + server.override + server.onClose + server.close + + opts.mySuper + + done() }, - { mySuper: "option" } - ); + { mySuper: 'option' } + ) app.use(async (server, options) => { - server.use; - server.after; - server.ready; - server.on; - server.start; - server.override; - server.onClose; - server.close; - }); + server.use + server.after + server.ready + server.on + server.start + server.override + server.onClose + server.close + }) app.use(async (server, options) => {}, (server) => { - server.use; - server.after; - server.ready; - server.on; - server.start; - server.override; - server.onClose; - server.close; - }); + server.use + server.after + server.ready + server.on + server.start + server.override + server.onClose + server.close + }) app.after(err => { - if (err) throw err; - }); + if (err) throw err + }) app.after((err: Error, done: Function) => { - done(); - }); + done() + }) app.after((err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) app.ready().then(context => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + }) app.ready(err => { - if (err) throw err; - }); + if (err) throw err + }) app.ready((err: Error, done: Function) => { - done(); - }); + done() + }) app.ready((err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) app.close(err => { - if (err) throw err; - }); + if (err) throw err + }) app.close((err: Error, done: Function) => { - done(); - }); + done() + }) app.close((err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) app.onClose((context, done) => { - context.use; - context.after; - context.ready; - context.on; - context.start; - context.override; - context.onClose; - context.close; - - done(); - }); + context.use + context.after + context.ready + context.on + context.start + context.override + context.onClose + context.close + + done() + }) } { - const server = { typescriptIs: "amazing" }; + const server = { typescriptIs: 'amazing' } // avvio with server - const app = avvio(server); + const app = avvio(server) app.use( (server, opts, done) => { - server.use; - server.after; - server.ready; - server.typescriptIs; + server.use + server.after + server.ready + server.typescriptIs - opts.mySuper; + opts.mySuper - done(); + done() }, - { mySuper: "option" } - ); + { mySuper: 'option' } + ) app.use(async (server, options) => { - server.use; - server.after; - server.ready; - server.typescriptIs; - }); + server.use + server.after + server.ready + server.typescriptIs + }) app.use(async (server, options) => {}, - ((server) => { - server.use; - server.after; - server.ready; - server.typescriptIs; - })); + (server) => { + server.use + server.after + server.ready + server.typescriptIs + }) app.after(err => { - if (err) throw err; - }); + if (err) throw err + }) app.after((err: Error, done: Function) => { - done(); - }); + done() + }) app.after( (err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.typescriptIs; + context.use + context.after + context.ready + context.typescriptIs - done(); + done() } - ); + ) app.ready().then(context => { - context.use; - context.after; - context.ready; - context.typescriptIs; - }); + context.use + context.after + context.ready + context.typescriptIs + }) app.ready(err => { - if (err) throw err; - }); + if (err) throw err + }) app.ready((err: Error, done: Function) => { - done(); - }); + done() + }) app.ready( (err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.close; - context.onClose; - context.typescriptIs; - - done(); + context.use + context.after + context.ready + context.close + context.onClose + context.typescriptIs + + done() } - ); + ) app.close(err => { - if (err) throw err; - }); + if (err) throw err + }) app.close((err: Error, done: Function) => { - done(); - }); + done() + }) app.close( (err: Error, context: avvio.context, done: Function) => { - context.use; - context.after; - context.ready; - context.close; - context.onClose; - context.typescriptIs; - - done(); + context.use + context.after + context.ready + context.close + context.onClose + context.typescriptIs + + done() } - ); + ) app.onClose((context, done) => { - context.use; - context.after; - context.ready; - context.close; - context.onClose; - context.typescriptIs; - - done(); - }); + context.use + context.after + context.ready + context.close + context.onClose + context.typescriptIs + + done() + }) } { - const server = { hello: "world" }; + const server = { hello: 'world' } const options = { autostart: false, - expose: { after: "after", ready: "ready", use: "use", close: "close", onClose : "onClose" }, + expose: { after: 'after', ready: 'ready', use: 'use', close: 'close', onClose: 'onClose' }, timeout: 50000 - }; + } // avvio with server and options - const app = avvio(server, options); + const app = avvio(server, options) } { - const server = { hello: "world" }; + const server = { hello: 'world' } const options = { autostart: false, - expose: { after: "after", ready: "ready", use: "use" } - }; + expose: { after: 'after', ready: 'ready', use: 'use' } + } // avvio with server, options and done callback - const app = avvio(server, options, () => undefined); + const app = avvio(server, options, () => undefined) } { - const app = avvio(); - const plugin: avvio.Plugin = async (): Promise => {}; + const app = avvio() + const plugin: avvio.Plugin = async (): Promise => {} const promise = plugin(app, {}, undefined as any); - (promise instanceof Promise); + (promise instanceof Promise) } From c4376b20cba2803b73853265f4cad3310e2b5066 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 8 Dec 2024 10:52:59 +0000 Subject: [PATCH 2/2] chore: add eslint.config.js --- eslint.config.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 eslint.config.js 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 +})