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

style: fix new standard linting #3682

Merged
merged 2 commits into from Feb 6, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions fastify.js
Expand Up @@ -175,9 +175,9 @@ function fastify (options) {
// Default router
const router = buildRouting({
config: {
defaultRoute: defaultRoute,
onBadUrl: onBadUrl,
constraints: constraints,
defaultRoute,
onBadUrl,
constraints,
ignoreTrailingSlash: options.ignoreTrailingSlash || defaultInitOptions.ignoreTrailingSlash,
maxParamLength: options.maxParamLength || defaultInitOptions.maxParamLength,
caseSensitive: options.caseSensitive,
Expand Down Expand Up @@ -268,16 +268,16 @@ function fastify (options) {
// expose logger instance
log: logger,
// hooks
addHook: addHook,
addHook,
// schemas
addSchema: addSchema,
addSchema,
getSchema: schemaController.getSchema.bind(schemaController),
getSchemas: schemaController.getSchemas.bind(schemaController),
setValidatorCompiler: setValidatorCompiler,
setSerializerCompiler: setSerializerCompiler,
setSchemaController: setSchemaController,
setReplySerializer: setReplySerializer,
setSchemaErrorFormatter: setSchemaErrorFormatter,
setValidatorCompiler,
setSerializerCompiler,
setSchemaController,
setReplySerializer,
setSchemaErrorFormatter,
// custom parsers
addContentTypeParser: ContentTypeParser.helpers.addContentTypeParser,
hasContentTypeParser: ContentTypeParser.helpers.hasContentTypeParser,
Expand All @@ -293,8 +293,8 @@ function fastify (options) {
close: null,
printPlugins: null,
// http server
listen: listen,
server: server,
listen,
server,
// extend fastify objects
decorate: decorator.add,
hasDecorator: decorator.exist,
Expand All @@ -303,12 +303,12 @@ function fastify (options) {
hasRequestDecorator: decorator.existRequest,
hasReplyDecorator: decorator.existReply,
// fake http injection
inject: inject,
inject,
// pretty print of the registered routes
printRoutes,
// custom error handling
setNotFoundHandler: setNotFoundHandler,
setErrorHandler: setErrorHandler,
setNotFoundHandler,
setErrorHandler,
// Set fastify initial configuration options read-only object
initialConfig
}
Expand Down
4 changes: 2 additions & 2 deletions lib/decorate.js
Expand Up @@ -134,6 +134,6 @@ module.exports = {
existRequest: checkRequestExistence,
existReply: checkReplyExistence,
dependencies: checkDependencies,
decorateReply: decorateReply,
decorateRequest: decorateRequest
decorateReply,
decorateRequest
}
10 changes: 5 additions & 5 deletions lib/reply.js
Expand Up @@ -579,11 +579,11 @@ function handleError (reply, error, cb) {
const serializerFn = getSchemaSerializer(reply.context, statusCode)
payload = (serializerFn === false)
? serializeError({
error: statusCodes[statusCode + ''],
code: error.code,
message: error.message || '',
statusCode: statusCode
})
error: statusCodes[statusCode + ''],
code: error.code,
message: error.message || '',
statusCode
})
: serializerFn(Object.create(error, {
error: { value: statusCodes[statusCode + ''] },
message: { value: error.message || '' },
Expand Down
2 changes: 1 addition & 1 deletion lib/schema-controller.js
Expand Up @@ -25,7 +25,7 @@ function buildSchemaController (parentSchemaCtrl, opts) {

const option = {
bucket: (opts && opts.bucket) || buildSchemas,
compilersFactory: compilersFactory
compilersFactory
}

return new SchemaController(undefined, option)
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Expand Up @@ -52,7 +52,7 @@ function createServer (options, httpHandler) {
}

const cb = typeof args[args.length - 1] === 'function' ? args.pop() : undefined
const options = { cb: cb }
const options = { cb }

const firstArg = args[0]
const argsLength = args.length
Expand Down
19 changes: 9 additions & 10 deletions package.json
Expand Up @@ -12,7 +12,7 @@
"license-checker": "license-checker --production --onlyAllow=\"MIT;ISC;BSD-3-Clause;BSD-2-Clause\"",
"lint": "npm run lint:standard && npm run lint:typescript",
"lint:fix": "standard --fix",
"lint:standard": "standard --verbose | snazzy",
"lint:standard": "standard | snazzy",
"lint:typescript": "eslint -c types/.eslintrc.json types/**/*.d.ts test/types/**/*.test-d.ts",
"prepublishOnly": "tap --no-check-coverage test/internals/version.test.js",
"test": "npm run lint && npm run unit && npm run test:typescript",
Expand Down Expand Up @@ -127,8 +127,8 @@
"@sinonjs/fake-timers": "^8.1.0",
"@types/node": "^16.0.0",
"@types/pino": "^6.0.1",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"JSONStream": "^1.3.5",
"ajv": "^6.0.0",
"ajv-errors": "^1.0.1",
Expand All @@ -140,13 +140,12 @@
"cors": "^2.8.5",
"coveralls": "^3.1.0",
"dns-prefetch-control": "^0.3.0",
"eslint": "^7.11.0",
"eslint-config-standard": "^16.0.1",
"eslint": "^8.0.1",
"eslint-config-standard": "^17.0.0-1",
"eslint-import-resolver-node": "^0.3.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-n": "^14.0.0",
"eslint-plugin-promise": "^6.0.0",
"fast-json-body": "^1.1.0",
"fastify-plugin": "^3.0.0",
"fluent-json-schema": "^3.0.0",
Expand All @@ -167,7 +166,7 @@
"simple-get": "^4.0.0",
"snazzy": "^9.0.0",
"split2": "^4.1.0",
"standard": "^16.0.1",
"standard": "^17.0.0-2",
"tap": "^15.1.1",
"tap-mocha-reporter": "^5.0.1",
"then-sleep": "^1.0.1",
Expand Down
6 changes: 3 additions & 3 deletions test/async-await.test.js
Expand Up @@ -407,7 +407,7 @@ test('error is logged because promise was fulfilled with undefined', t => {
try {
fastify = Fastify({
logger: {
stream: stream,
stream,
level: 'error'
}
})
Expand Down Expand Up @@ -447,7 +447,7 @@ test('error is not logged because promise was fulfilled with undefined but statu
try {
fastify = Fastify({
logger: {
stream: stream,
stream,
level: 'error'
}
})
Expand Down Expand Up @@ -488,7 +488,7 @@ test('error is not logged because promise was fulfilled with undefined but respo
try {
fastify = Fastify({
logger: {
stream: stream,
stream,
level: 'error'
}
})
Expand Down
2 changes: 1 addition & 1 deletion test/close.test.js
Expand Up @@ -215,7 +215,7 @@ t.test('Current opened connection should continue to work after closing and retu
t.error(err)

const port = fastify.server.address().port
const client = net.createConnection({ port: port }, () => {
const client = net.createConnection({ port }, () => {
client.write('GET / HTTP/1.1\r\n\r\n')

client.once('data', data => {
Expand Down
8 changes: 4 additions & 4 deletions test/context-config.test.js
Expand Up @@ -29,15 +29,15 @@ test('config', t => {
method: 'GET',
url: '/route',
schema: schema.schema,
handler: handler,
handler,
config: Object.assign({}, schema.config)
})

fastify.route({
method: 'GET',
url: '/no-config',
schema: schema.schema,
handler: handler
handler
})

fastify.inject({
Expand Down Expand Up @@ -81,15 +81,15 @@ test('config with exposeHeadRoutes', t => {
method: 'GET',
url: '/route',
schema: schema.schema,
handler: handler,
handler,
config: Object.assign({}, schema.config)
})

fastify.route({
method: 'GET',
url: '/no-config',
schema: schema.schema,
handler: handler
handler
})

fastify.inject({
Expand Down
2 changes: 1 addition & 1 deletion test/inject.test.js
Expand Up @@ -186,7 +186,7 @@ test('inject post request', t => {
fastify.inject({
method: 'POST',
url: '/',
payload: payload
payload
}, (err, res) => {
t.error(err)
t.same(payload, JSON.parse(res.payload))
Expand Down
4 changes: 2 additions & 2 deletions test/internals/all.test.js
Expand Up @@ -19,7 +19,7 @@ test('fastify.all should add all the methods to the same url', t => {
function injectRequest (method) {
const options = {
url: '/',
method: method
method
}

if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
Expand All @@ -29,7 +29,7 @@ test('fastify.all should add all the methods to the same url', t => {
fastify.inject(options, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.same(payload, { method: method })
t.same(payload, { method })
})
}
})
8 changes: 4 additions & 4 deletions test/internals/contentTypeParser.test.js
Expand Up @@ -32,8 +32,8 @@ test('rawBody function', t => {

res.log = { error: () => { }, info: () => { } }
const context = {
Reply: Reply,
Request: Request,
Reply,
Request,
preHandler: [],
onSend: [],
_parserOptions: {
Expand Down Expand Up @@ -85,8 +85,8 @@ test('Should support Webpack and faux modules', t => {

res.log = { error: () => { }, info: () => { } }
const context = {
Reply: Reply,
Request: Request,
Reply,
Request,
preHandler: [],
onSend: [],
_parserOptions: {
Expand Down
16 changes: 8 additions & 8 deletions test/internals/handleRequest.test.js
Expand Up @@ -62,8 +62,8 @@ test('handler function - invalid schema', t => {
}
},
handler: () => {},
Reply: Reply,
Request: Request,
Reply,
Request,
preValidation: [],
preHandler: [],
onSend: [],
Expand Down Expand Up @@ -93,8 +93,8 @@ test('handler function - reply', t => {
reply.code(204)
reply.send(undefined)
},
Reply: Reply,
Request: Request,
Reply,
Request,
preValidation: [],
preHandler: [],
onSend: [],
Expand Down Expand Up @@ -123,8 +123,8 @@ test('handler function - preValidationCallback with finished response', t => {
t.fail()
reply.send(undefined)
},
Reply: Reply,
Request: Request,
Reply,
Request,
preValidation: null,
preHandler: [],
onSend: [],
Expand All @@ -150,8 +150,8 @@ test('handler function - preValidationCallback with finished response (< v12.9.0
t.fail()
reply.send(undefined)
},
Reply: Reply,
Request: Request,
Reply,
Request,
preValidation: null,
preHandler: [],
onSend: [],
Expand Down
2 changes: 1 addition & 1 deletion test/internals/logger.test.js
Expand Up @@ -103,7 +103,7 @@ test('The logger should error if both stream and file destination are given', t
Fastify({
logger: {
level: 'info',
stream: stream,
stream,
file: '/test'
}
})
Expand Down