问题
I changed my coding style from
function getParams(entity) {
"use strict";
var accountID = store.getItem('AccountID'),
switch (entity) {
case "Topic":
to
function getParams(entity)
{
"use strict";
var accountID = store.getItem('AccountID'),
switch (entity)
{
case "Topic":
Now I get any jslint errors such as:
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?
回答1:
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.
回答2:
Try this, jSLint uses string javascript coding rules to check your javascript..
var store = {};
function getParams(entity) {
"use strict";
var accountID = store.getItem('AccountID');
switch (entity) {
case "Topic":
accountID = '0';
break;
}
}
For a function it expects just 1 space between the )
and {
characters .. It is not an issue but it is a coding rule..
来源:https://stackoverflow.com/questions/12633434/is-there-a-way-i-can-make-jslint-work-with-curly-braces-on-the-next-line-of-my-j