gpt4 book ai didi

javascript - 为什么 eslint 的标准配置中不鼓励使用分号?

转载 作者:行者123 更新时间:2023-12-01 02:44:56 29 4
gpt4 key购买 nike

我的项目在 .eslintrc.js 文件中扩展了 javascript 的“标准”规则,并且根据该 Javascript 代码不应在行尾有分号。我从来没有见过这样的事情。就这样留下有用吗?还是我误解了整件事?

来自standard的“半”规则eslint 规则:

"semi": ["error", "never"]

来自eslint documentation的使用:

/*eslint semi: ["error", "never"]*/

var name = "ESLint"

object.method = function() {
// ...
}

var name = "ESLint"

;(function() {
// ...
})()

最佳答案

正如 standardjs docs 中所述,重点不是说用分号好还是不用分号好,而只是一劳永逸地定下一个规则

I disagree with rule X, can you change it?

No. The whole point of standard is to save you time by avoiding bikeshedding about code style. There are lots of debates online about tabs vs. spaces, etc. that will never be resolved. These debates just distract from getting stuff done. At the end of the day you have to 'just pick something', and that's the whole philosophy of standard -- its a bunch of sensible 'just pick something' opinions. Hopefully, users see the value in that over defending their own opinions.

If you really want to configure hundreds of ESLint rules individually, you can always use eslint directly with eslint-config-standard to layer your changes on top. standard-eject can help you migrate from standard to eslint and eslint-config-standard.

Pro tip: Just use standard and move on. There are actual real problems that you could spend your time solving! :P

讨论它是固执己见的,会引发无休止的辩论,这不是我们想要的。

关于javascript - 为什么 eslint 的标准配置中不鼓励使用分号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47307838/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com