dsheiko / jscodesniffer

⛔️ [DEPRECATED] Tool to ensure that your JavaScript code does not violate the specified coding standard (Idiomatic Style Manifesto or JQuery Core Style Guidelines)
http://dsheiko.github.io/jscodesniffer/
42 stars 8 forks source link

Certain keywords preceded or followed by a new line. #7

Open viskenxp opened 10 years ago

viskenxp commented 10 years ago

It would be nice if you could configure certain lines that start with a keyword (if/return/etc) to have either an empty line preceding and/or following that line/construct.

Good:

  val = 1;  

  return val;
}

Bad:

  val = 1;
  return val;
}

Good:


if (val === 1) {
  console.log(val);
}

With an override for all first lines in a function/if/switch/... block.

function() {
  if (val === 1) {
    console.log(val);
  }
}();

Bad:

if (val === 1) {
  console.log(val);
}
dsheiko commented 10 years ago

Trying to get this logic.Within a specified block statement (compound statement if/else/for/while/try/.. or function scope) the ReturnStatement must be always preceding by a line-break?

viskenxp commented 10 years ago

Yes, unless it is the first line in that block statement.