TypeScript style guide used internally on Fueled projects.
This guide focuses specifically on code quality based rules for TypeScript, rather than formatting rules. We utilize Prettier for code formatting. It uses and extends upon @typescript-eslint/recommended rule set, as well as Prettier ESLint config to turn off rules that may conflict with Prettier.
Note: this is intended to be used with TypeScript strict mode enabled.
Enforce T[] syntax for arrays over Array.
Enforce explicit function return types.
Enforce explicit return & argument types on exported functions & public class methods.
Disallow explicit any
types. Use unknown
instead.
Require Promise-like statements to be handled appropriately.
Disable using non-null assertions as they cancel the benefits of strict null-checking mode. Prefer explicit null checks for safety.
Restrict use of labels and with statements.
Avoid unnecessary conditionals.
Warn against unnecessary type assertions.
Enforce no unused variables.
Warn against useless class constructors.
Prefer nullish coalescing operator.
Prefer optional chaining operator.
Ensure all functions that return a promise are marked as async.
Restrict template expressions to allow for string & number types only.
Other types must be checked explicitly.
Disallow async functions which have no await expression and do not return a promise.
Enforce covering all cases in a switch statement.