Avoid Ternaries within Ternaries

Avoid nesting ternaries. Instead of nesting ternaries use if statements.

// Good
const x = condition ? "a" : "b";

// Avoid
const x = conditionA ? "a" : conditionB ? "b" : "c";
// Instead
let x = "c";
if (conditionA) {
  x = "a";
} else if (conditionB) {
  x = "b";
}

CamelCase Acronyms in Identifiers

Generally, acronyms should be considered a single word. This makes things easier to read. Most spell check tooling is designed for camel case, so this helps avoid awkward underlines.

// Good
const abcdThing = "a";
// Avoid
const ABCDThing = "a";

Place default last in a switch statement

// Good
switch(item) {
  case "a":
    break;
  default:
    break;
}
// Avoid
switch(item) {
  default:
    break;
  case "a":
    break;
}

Define functions before use

This helps avoid issues where a function accesses a constant that is defined after the function call, since this results in an error.

// Good
function f() {
}

f();
// Avoid
f();

function f() {
}
f(); // Error: Cannot access 'x' before initialization 

const x = "x";

function f() {
  console.log(x);
}

Automatically run pipelines against any dependency changes

Pipelines should be automatically run against PRs that impact their dependencies. This helps ensure that the pipeline is passes for any checked in changes and continues to work.

Enable TypeScript Rules

No Property Access From Index Signature

  • any is forbidden

TypeScript