官术网_书友最值得收藏!

ESLint

We always try to write the best code possible, but sometimes errors happen, and spending a few hours catching a bug due to a typo is very frustrating. Luckily, some tools can help us check the correctness of our code as soon as we type it. These tools are not able to tell us if our code is going to do what it's supposed to do, but they can help us to avoid syntactical errors.

If you come from a static language, such as C#, you are used to getting that kind of warning inside your IDE. Douglas Crockford made linting popular in JavaScript with JSLint (initially released in 2002) a few years ago; then we had JSHint, and finally, the de-facto standard in the React world nowadays is ESLint.

ESLint is an open source project released in 2013 that became popular thanks to the fact that it is highly configurable and extensible.

In the JavaScript ecosystem, where libraries and techniques change very quickly, it is crucial to have a tool that can be easily extended with plugins, and rules that can be enabled and disabled when needed. Most importantly, nowadays we use transpilers, such as Babel, and experimental features that are not part of the standard version of JavaScript, so we need to be able to tell our linter which rules we are following in our source files. Not only does a linter help us to make fewer errors, or at least, find those errors sooner, but it enforces some common coding style guides, which is important, especially in big teams with many developers, each one with their favorite coding style.

It is very hard to read the code in a code base where different files, or even various functions, are written using inconsistent styles.

主站蜘蛛池模板: 东乡县| 岳阳市| 遂宁市| 郎溪县| 平湖市| 勃利县| 普洱| 南平市| 门源| 偃师市| 阜新| 拉萨市| 鄱阳县| 富平县| 射阳县| 日喀则市| 集贤县| 岐山县| 镇安县| 肃宁县| 巍山| 青海省| 万山特区| 郁南县| 萨嘎县| 阿坝| 大悟县| 博白县| 南丰县| 佛学| 银川市| 左权县| 阳江市| 闽清县| 黔江区| 高台县| 古浪县| 白河县| 洛南县| 伊通| 郁南县|