Skip to content

SaundersB/eslint-plugin-enforce-return-on-reply

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-enforce-return-on-reply

This ESLint plugin provides a rule to enforce that a return statement is used when utilizing Fastify's reply object.

Installation

First, you'll need to install ESLint:

npm install eslint --save-dev

Next, install eslint-plugin-enforce-return-on-reply:

npm install eslint-plugin-enforce-return-on-reply --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-enforce-return-on-reply globally.

Usage

Add enforce-return-on-reply to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "enforce-return-on-reply"
    ]
}

Then configure the rule under the rules section.

{
    "rules": {
        "enforce-return-on-reply/enforce-return-on-fastify-reply": "error"
    }
}

Supported Rules

  • enforce-return-on-fastify-reply: Enforces the use of a return statement when utilizing Fastify's reply object.

Example

With this rule, the following code would result in an error:

fastify.get('/', async (request, reply) => {
    reply.code(200).send({ hello: 'world' });
});

A valid example:

fastify.get('/', async (request, reply) => {
    return reply.code(200).send({ hello: 'world' });
});

Contributing

Feel free to open issues or PRs!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published