Serverless function linting and quality


#1

Hello!

While developing serverless code, I would like to ensure the code is readable and code quality is maintained specificlly for nodejs. Are there any best practices for maintaining nodejs serverless code? Us eslint or prettier whatever it takes. The serverless plugins for eslint and jshint seem unmaintained since 2016


#2

I have used both ESLint and Prettier in serverless projects as standalone tools without any problem. You can configure them as you prefer.

I think it is really difficult to talk about best practices regarding code linting and formatting, as each developer tends to have a personal opinion based on preferences and experience, and on the programming language itself.

As long as you and your team can agree on a set of rules and that you are following them, it should ensure consistency across your code base. I hope it helps. :slight_smile:


#3

I agree with @teddy-gustiaux. I just use ESLINT with my teams and then configure the rules based on the project. No need to have something specific to Serverless. Serverless does a pretty good job decoupling your business logic from the framework, so as long as you don’t have anything too specific to a serverless implementation, ESLINT should work just fine.


#4

Best way to improve quality of your code is going with 1. Typescript 2. Write lots of unit test. I found these important and works for my middle sized project. Itt enables it to grow further.


#5

As far as linting I came into Serverless development without any Node experience and limited JS in the browser experience. For me, using a predefined set of rules primarily for consistency made sense regardless of what they actually were. I ended up picking Standard, but only because that’s whats seemed one of the easiest to deploy in Web Storm at the time.

Just pick one that provides the tooling you desire and stick to it. There is no benefit, in my humble opinion, getting technical about your linters exact rules, etc. As long as they remain consistent.