我有一些 javascript 在缩小之前通过了 linter,但之后没有。 我是否应该担心错误/警告,例如:
"Expected an assignment or function call and instead saw an expression"
"Use '!==' to compare with 'null'"
"Don't make functions within a loop"
"Missing '()' invoking a constructor."
"Expected a conditional expression and instead saw an assignment"
"Confusing use of '!'"
"A leading decimal point can be confused with a dot: '.5'"
"Expected an operator and instead saw ','"
"Expected an identifier and instead saw '}'"
"Expected ')' to match '(' from line 9 and instead saw '{'"
"Expected an identifier and instead saw '='"
最佳答案
我认为您对 lint-ing 代码的作用感到困惑。 linter 的目的是防止编程风格容易出现人为错误。压缩器的作用是将源代码压缩为尽可能少的字符。
缩小后的 linting 是没有意义的(你永远不应该手动更改缩小代码,所以不会有人为错误),如果你选择“修复”你的缩小代码甚至是有害的,因为它会增加大小。
使用这些工具的正确方法是对代码进行 lint 以删除容易出现人为错误的常见模式,然后将其缩小到尽可能小以用于生产。如果您想检查缩小器的正确性,您需要使用测试,在缩小过程之前和之后测试代码,结果应该是相同的。请记住,根据压缩器的积极程度,可以完全删除未使用的代码,可以内联函数等,因此测试压缩代码绝对不是一件容易的事。
关于javascript - 我应该在缩小后检查我的代码吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21161289/