TreeviewCopyright © aleen42 all right reserved, powered by aleen42

Blocks Back

1. Use braces

  • To use braces with all multiple lines, but do not use when it's a single line.
/**
 * bad
 */
if (test)
    return false;

/**
 * good
 */
if (test) return false;
if (test) {
    return false;
}

/**
 * bad
 */
function () { return false; }

/**
 * good
 */
function () {
    return false;
}

2. Closing braces

  • If using multi-line blocks with if and else, then put else on the same line of if block's closing braces.
  • Eslint rules tags: brace-style
/**
 * bad
 */
if (test) {
}
else {
}

/**
 * good
 */
if (test) {
} else {
}

results matching ""

    No results matching ""