Linting

Linting is the process of running a program that will analyse code for potential errors.

Oded - StackOverflow

Checking code before running it can prevent many errors. A missing bracket can prevent an entiry application from working. This is where linting comes in handy. There are many diffrent linters for all kinds of languages. CSSLint, ESLint, JSHint and Pylint to name a few. They can not only help by pointing out mistakes while typing, they can also enforce different code styles, so the codebase stays consistent. That can be especially helpful for projects that are being built by more than one developer.

Code-styles for ESLint

This section will focus on the different style-guides available for ESlint.

Airbnb

Airbnb's style-guide is the most popular out of these three. Semicolons are required and one indentation equals two spaces. It also works with React. One of the downsides of the Airbnb config is, that its not very is to implement in a new project. It has a lot of peer dependencies which makes it hard to update.

XO

XO is not only a style-guide, it's also a CLI tool which makes adding XO to a project very is. The command xo --init is enough and XO is ready to go. React is also supported, but only in combination with another package. It also possible to choose between indentation and semicolon styles.

Standard

Standard is another approach to streamline JavaScript code. It doesn't even allow changes to its linting rules. The reasoning behind this is, that they want to maintain a standard JavaScript style (hence the name Standard) to avoid bike-shedding. Some of their rules include two spaces as indentation, single quotes for strings and no semicolons.

results matching ""

    No results matching ""