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

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.

主站蜘蛛池模板: 潮安县| 遵化市| 河南省| 兰州市| 鹿泉市| 睢宁县| 溧水县| 文安县| 贺兰县| 邛崃市| 象山县| 新晃| 民和| 马尔康县| 营山县| 乌兰浩特市| 祁东县| 乐安县| 吉木乃县| 恭城| 华安县| 银川市| 曲沃县| 巩留县| 桂林市| 福泉市| 射阳县| 马边| 铜陵市| 长宁县| 赫章县| 宜丰县| 麟游县| 陈巴尔虎旗| 洛扎县| 徐水县| 盘山县| 凤阳县| 滨州市| 资溪县| 呼和浩特市|