Prettier 与 Linter
它与 ESLint/TSLint/stylelint 等相比如何?
¥How does it compare to ESLint/TSLint/stylelint, etc.?
Linter 有两类规则:
¥Linters have two categories of rules:
格式规则:例如:max-len、no-mixed-spaces-and-tabs、keyword-spacing、comma-style…
¥Formatting rules: eg: max-len, no-mixed-spaces-and-tabs, keyword-spacing, comma-style…
Prettier 减轻了对这一整类规则的需求!Prettier 将以一致的方式从头开始重新打印整个程序,因此程序员不可能再犯错误了:)
¥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 :)
代码质量规则:例如 no-unused-vars、no-extra-bind、no-implicit-globals、prefer-promise-reject-errors……
¥Code-quality rules: eg no-unused-vars, no-extra-bind, no-implicit-globals, prefer-promise-reject-errors…
Prettier 对这些规则没有任何帮助。它们也是 linters 提供的最重要的东西,因为它们很可能会捕获你代码中的真正错误!
¥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!
换句话说,使用 Prettier 进行格式化,使用 linter 捕获错误!
¥In other words, use Prettier for formatting and linters for catching bugs!