有没有办法让jslint在我的javascript的下一行使用花括号? [英] Is there a way I can make jslint work with curly braces on the next line of my javascript?
问题描述
我改变了我的编码风格
function getParams(entity) {
"use strict";
var accountID = store.getItem('AccountID'),
switch (entity) {
case "Topic":
到
function getParams(entity)
{
"use strict";
var accountID = store.getItem('AccountID'),
switch (entity)
{
case "Topic":
现在我收到任何jslint错误,例如:
Now I get any jslint errors such as:
警告6 JS Lint:预计')'和'{'之间只有一个空格。
警告9 JS Lint:第9栏预计'var',而不是第5列。
Warning 6 JS Lint: Expected exactly one space between ')' and '{'. Warning 9 JS Lint: Expected 'var' at column 9, not column 5.
我检查了选项,但找不到任何取消选择的选项线位置。如果有,那么我可以将它添加到我的文件顶部吗?
I checked through the options but cannot find any option to unselect relating to line position. Also if there is one then could I add it to the top of my file?
推荐答案
在JavaScript中建议放置开口括号出于这个原因在同一行:
In JavaScript is recommended to put opening braces on the same line for this reason:
function foo()
{
return
{
a: 'foo'
}
}
foo().a // error
这不是一个建议而是解决方案,但如果没有换行,就无法在评论中解释。
This is more an advice than a solution but impossible to explain in a comment without new lines.
这篇关于有没有办法让jslint在我的javascript的下一行使用花括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!