gpt4 book ai didi

javascript - ESlint 强制将函数等的右括号与左括号放在同一列上

转载 作者:行者123 更新时间:2023-11-28 06:17:37 27 4
gpt4 key购买 nike

如何在左括号出现的同一列上强制执行函数等的右括号/括号

例如

// throws error
app.get('/', function (req, response) {

}); // bracket/parentheses is *not on same* column as opening


// this is valid
app.get('/', function (req, response) {

}); // bracket/parentheses is on *same* column as opening

最佳答案

indent rule 涵盖了您正在寻找的内容,但如果您只想检查这一种情况,那么它就有点矫枉过正了。尝试将以下内容粘贴到 online demo 中以查看它给出的错误:

/* eslint indent: 2 */

// throws error
app.get('/', function (req, response) {

}); // bracket/parentheses is *not on same* column as opening


// this is valid
app.get('/', function (req, response) {

}); // bracket/parentheses is on *same* column as opening

重要的部分是开头的 /* eslint indent: 2 */ 注释。它使用默认设置启用缩进规则,尽管该规则是可配置的,但恰好是四个空格。

关于javascript - ESlint 强制将函数等的右括号与左括号放在同一列上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35819585/

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