Skip to content Skip to sidebar Skip to footer

Is There A Way I Can Make Jslint Work With Curly Braces On The Next Line Of My Javascript?

I changed my coding style from function getParams(entity) { 'use strict'; var accountID = store.getItem('AccountID'), switch (entity) { case 'Topic': to fun

Solution 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.

Solution 2:

Try this, jSLint uses string javascript coding rules to check your javascript..

var store = {};
functiongetParams(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..

Post a Comment for "Is There A Way I Can Make Jslint Work With Curly Braces On The Next Line Of My Javascript?"