Skip to content

Commit e248931

Browse files
authored
build(deps-dev): replace standard with neostandard (#779)
* build(deps-dev): replace standard with neostandard * chore: add eslint.config.js * chore: rebase * Update package.json Signed-off-by: Frazer Smith <[email protected]> * chore: ignore voids --------- Signed-off-by: Frazer Smith <[email protected]>
1 parent 09c53d7 commit e248931

File tree

19 files changed

+109
-96
lines changed

19 files changed

+109
-96
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![CI](https://github.com/fastify/fastify-cli/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-cli/actions/workflows/ci.yml)
44
[![NPM version](https://img.shields.io/npm/v/fastify-cli.svg?style=flat)](https://www.npmjs.com/package/fastify-cli)
5-
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
5+
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
66

77
Command line tools for [Fastify](https://github.com/fastify/fastify).
88
Generate, write, and run an application with one single command!
@@ -326,15 +326,15 @@ if your project uses `@fastify/swagger`, `fastify-cli` can generate and write ou
326326

327327
```diff
328328
"devDependencies": {
329-
+ "standard": "^11.0.1",
329+
+ "neostandard": "^0.11.9",
330330
}
331331

332332
"scripts": {
333-
+ "pretest": "standard",
333+
+ "pretest": "eslint",
334334
"test": "node --test test/**/*.test.js",
335335
"start": "fastify start -l info app.js",
336336
"dev": "fastify start -l info -P app.js",
337-
+ "lint": "standard --fix"
337+
+ "lint": "eslint --fix"
338338
},
339339
```
340340

eslint.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
module.exports = require('neostandard')({
4+
ignores: [
5+
...require('neostandard').resolveIgnoresFromGitignore(),
6+
'test/data/parsing-error.js',
7+
'test/data/undefinedVariable.js',
8+
],
9+
ts: true
10+
})

helper.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import fastify from 'fastify'
22

33
declare module 'fastify-cli/helper.js' {
4-
module helper {
5-
export function build(args: Array<string>, additionalOptions?: Object, serverOptions?: Object): ReturnType<typeof fastify>;
6-
}
4+
module helper {
5+
export function build (args: Array<string>, additionalOptions?: Object, serverOptions?: Object): ReturnType<typeof fastify>
6+
}
77

8-
export = helper;
8+
export = helper
99
}

package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"fastify": "cli.js"
99
},
1010
"scripts": {
11-
"lint": "standard",
12-
"lint:fix": "standard --fix",
11+
"lint": "eslint",
12+
"lint:fix": "eslint --fix",
1313
"pretest": "xcopy /e /k /i . \"..\\node_modules\\fastify-cli\" || rsync -r --exclude=node_modules ./ node_modules/fastify-cli || echo 'this is fine'",
1414
"test": "npm run unit:suites && c8 --clean npm run test:cli-and-typescript",
1515
"unit:cjs": "node suite-runner.js \"templates/app/test/**/*.test.js\"",
@@ -46,12 +46,6 @@
4646
"url": "https://github.com/fastify/fastify-cli/issues"
4747
},
4848
"homepage": "https://github.com/fastify/fastify-cli#readme",
49-
"standard": {
50-
"ignore": [
51-
"test/data/parsing-error.js",
52-
"test/data/undefinedVariable.js"
53-
]
54-
},
5549
"dependencies": {
5650
"@fastify/deepmerge": "^2.0.0",
5751
"chalk": "^4.1.2",
@@ -79,14 +73,15 @@
7973
"c8": "^10.1.2",
8074
"concurrently": "^9.0.0",
8175
"cross-env": "^7.0.3",
76+
"eslint": "^9.17.0",
8277
"fastify-tsconfig": "^3.0.0",
8378
"glob": "^11.0.1",
8479
"minimatch": "^9.0.5",
80+
"neostandard": "^0.12.0",
8581
"proxyquire": "^2.1.3",
8682
"rimraf": "^3.0.2",
8783
"simple-get": "^4.0.0",
8884
"sinon": "^19.0.2",
89-
"standard": "^17.0.0",
9085
"strip-ansi": "^6.0.1",
9186
"tap": "^16.1.0",
9287
"ts-node": "^10.4.0",

templates/app-ts-esm/src/app.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
import * as path from 'node:path';
2-
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
3-
import { FastifyPluginAsync } from 'fastify';
1+
import * as path from 'node:path'
2+
import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
3+
import { FastifyPluginAsync } from 'fastify'
44
import { fileURLToPath } from 'node:url'
55

66
const __filename = fileURLToPath(import.meta.url)
77
const __dirname = path.dirname(__filename)
88

99
export type AppOptions = {
1010
// Place your custom options for app below here.
11-
} & Partial<AutoloadPluginOptions>;
12-
11+
} & Partial<AutoloadPluginOptions>
1312

1413
// Pass --options via CLI arguments in command to enable these options.
1514
const options: AppOptions = {
1615
}
1716

1817
const app: FastifyPluginAsync<AppOptions> = async (
19-
fastify,
20-
opts
18+
fastify,
19+
opts
2120
): Promise<void> => {
2221
// Place here your custom code!
2322

@@ -26,6 +25,7 @@ const app: FastifyPluginAsync<AppOptions> = async (
2625
// This loads all plugins defined in plugins
2726
// those should be support plugins that are reused
2827
// through your application
28+
// eslint-disable-next-line no-void
2929
void fastify.register(AutoLoad, {
3030
dir: path.join(__dirname, 'plugins'),
3131
options: opts,
@@ -34,13 +34,13 @@ const app: FastifyPluginAsync<AppOptions> = async (
3434

3535
// This loads all plugins defined in routes
3636
// define your routes in one of these
37+
// eslint-disable-next-line no-void
3738
void fastify.register(AutoLoad, {
3839
dir: path.join(__dirname, 'routes'),
3940
options: opts,
4041
forceESM: true
4142
})
43+
}
4244

43-
};
44-
45-
export default app;
45+
export default app
4646
export { app, options }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { FastifyPluginAsync } from "fastify"
1+
import { FastifyPluginAsync } from 'fastify'
22

33
const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
44
fastify.get('/', async function (request, reply) {
55
return 'this is an example'
66
})
77
}
88

9-
export default example;
9+
export default example

templates/app-ts-esm/src/routes/root.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ const root: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
66
})
77
}
88

9-
export default root;
9+
export default root

templates/app-ts-esm/test/helper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url'
66

77
export type TestContext = {
88
after: typeof test.after
9-
};
9+
}
1010

1111
const __filename = fileURLToPath(import.meta.url)
1212
const __dirname = path.dirname(__filename)
@@ -31,6 +31,7 @@ async function build (t: TestContext) {
3131
const app = await helper.build(argv, config())
3232

3333
// Tear down our app after we are done
34+
// eslint-disable-next-line no-void
3435
t.after(() => void app.close())
3536

3637
return app

templates/app-ts-esm/test/plugins/support.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Support from '../../src/plugins/support.js'
55

66
test('support works standalone', async (t) => {
77
const fastify = Fastify()
8+
// eslint-disable-next-line no-void
89
void fastify.register(Support)
910
await fastify.ready()
1011

templates/app-ts/src/app.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { join } from 'node:path';
2-
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
3-
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify';
1+
import { join } from 'node:path'
2+
import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
3+
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify'
44

55
export interface AppOptions extends FastifyServerOptions, Partial<AutoloadPluginOptions> {
66

@@ -10,8 +10,8 @@ const options: AppOptions = {
1010
}
1111

1212
const app: FastifyPluginAsync<AppOptions> = async (
13-
fastify,
14-
opts
13+
fastify,
14+
opts
1515
): Promise<void> => {
1616
// Place here your custom code!
1717

@@ -20,18 +20,20 @@ const app: FastifyPluginAsync<AppOptions> = async (
2020
// This loads all plugins defined in plugins
2121
// those should be support plugins that are reused
2222
// through your application
23+
// eslint-disable-next-line no-void
2324
void fastify.register(AutoLoad, {
2425
dir: join(__dirname, 'plugins'),
2526
options: opts
2627
})
2728

2829
// This loads all plugins defined in routes
2930
// define your routes in one of these
31+
// eslint-disable-next-line no-void
3032
void fastify.register(AutoLoad, {
3133
dir: join(__dirname, 'routes'),
3234
options: opts
3335
})
34-
};
36+
}
3537

36-
export default app;
38+
export default app
3739
export { app, options }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { FastifyPluginAsync } from "fastify"
1+
import { FastifyPluginAsync } from 'fastify'
22

33
const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
44
fastify.get('/', async function (request, reply) {
55
return 'this is an example'
66
})
77
}
88

9-
export default example;
9+
export default example

templates/app-ts/src/routes/root.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ const root: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
66
})
77
}
88

9-
export default root;
9+
export default root

templates/app-ts/test/helper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// This file contains code that we reuse between our tests.
2-
const helper = require('fastify-cli/helper.js')
32
import * as path from 'node:path'
43
import * as test from 'node:test'
4+
const helper = require('fastify-cli/helper.js')
55

66
export type TestContext = {
77
after: typeof test.after
8-
};
8+
}
99

1010
const AppPath = path.join(__dirname, '..', 'src', 'app.ts')
1111

@@ -28,6 +28,7 @@ async function build (t: TestContext) {
2828
const app = await helper.build(argv, config())
2929

3030
// Tear down our app after we are done
31+
// eslint-disable-next-line no-void
3132
t.after(() => void app.close())
3233

3334
return app

templates/app-ts/test/plugins/support.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Support from '../../src/plugins/support'
66

77
test('support works standalone', async (t) => {
88
const fastify = Fastify()
9+
// eslint-disable-next-line no-void
910
void fastify.register(Support)
1011
await fastify.ready()
1112

templates/eject-ts/server.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// Read the .env file.
2-
import * as dotenv from "dotenv";
3-
dotenv.config();
2+
import * as dotenv from 'dotenv'
43

54
// Require the framework
6-
import Fastify from "fastify";
5+
import Fastify from 'fastify'
76

87
// Require library to exit fastify process, gracefully (if possible)
9-
import closeWithGrace from "close-with-grace";
8+
import closeWithGrace from 'close-with-grace'
9+
dotenv.config()
1010

1111
// Instantiate Fastify with some config
1212
const app = Fastify({
1313
logger: true,
14-
});
14+
})
1515

1616
// Register your application as a normal plugin.
17-
app.register(import("./app"));
17+
app.register(import('./app'))
1818

1919
// delay is the number of milliseconds for the graceful close to finish
2020
closeWithGrace({ delay: parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY) || 500 }, async function ({ signal, err, manual }) {
@@ -27,7 +27,7 @@ closeWithGrace({ delay: parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY) || 500 }
2727
// Start listening.
2828
app.listen({ port: parseInt(process.env.PORT) || 3000 }, (err: any) => {
2929
if (err) {
30-
app.log.error(err);
31-
process.exit(1);
30+
app.log.error(err)
31+
process.exit(1)
3232
}
33-
});
33+
})

templates/plugin/test/index.test-d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { expectType } from 'tsd'
55
let app
66
try {
77
app = fastify()
8+
// eslint-disable-next-line no-void
89
void app.ready()
10+
// eslint-disable-next-line no-void
911
void app.register(example)
1012
expectType<() => string>(app.exampleDecorator)
1113
} catch (err) {

test/data/custom-import.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* global GLOBAL_MODULE_3 */
2-
globalThis.GLOBAL_MODULE_3 = true // eslint-disable-line
2+
globalThis.GLOBAL_MODULE_3 = true
33
console.log('this is module to be preloaded that sets GLOBAL_MODULE_3=', GLOBAL_MODULE_3)

test/data/custom-import2.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* global GLOBAL_MODULE_4 */
2-
globalThis.GLOBAL_MODULE_4 = true // eslint-disable-line
2+
globalThis.GLOBAL_MODULE_4 = true
33
console.log('this is module to be preloaded that sets GLOBAL_MODULE_4=', GLOBAL_MODULE_4)

0 commit comments

Comments
 (0)