prettier 与 eslint 对比

Linters have two categories of rules:

代码修正一般有两种规则:

Formatting rules: eg: max-lenno-mixed-spaces-and-tabskeyword-spacingcomma-style...

格式化规则,例如:最大长,不允许空格和tab混合,关键字的spacing,冒号风格...

Prettier alleviates the need for this whole category of rules! Prettier is going to reprint the entire program from scratch in a consistent way, so it's not possible for the programmer to make a mistake there anymore :)

prettier就是做这个的,prettier会将整个项目保持在一个统一的风格。

Code-quality rules: eg no-unused-varsno-extra-bindno-implicit-globalsprefer-promise-reject-errors...

Prettier does nothing to help with those kind of rules. They are also the most important ones provided by linters as they are likely to catch real bugs with your code!

代码质量规则,例如:不能有未使用的变量,不能有无意义的bind,不能隐式定义全局变量,不能在promise中reject()空值

prettier不管这些,这些是更适合交给linter(eslint) 来做的。

原文地址:https://www.cnblogs.com/eret9616/p/10158726.html