Skip to content

Latest commit

 

History

History

javascript

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

JavaScript

Sample

  • Use TypeScript
  • Use the latest stable JavaScript syntax with a transpiler, such as babel.
  • Use ESLint and Prettier for auto-formatting and auto-fixing
  • Use Jest for unit testing
  • Prefer ES6 classes over prototypes.
  • Use strict equality checks (=== and !==) except when comparing against (null or undefined).
  • Prefer arrow functions =>, over the function keyword except when defining classes or methods.
  • Prefer ES6 destructuring over object literal notation.
  • Use ES6 spread and rest operator wherever possible for a cleaner code.
  • Use PascalCase for classes, lowerCamelCase for variables and functions, SCREAMING_SNAKE_CASE for constants, _singleLeadingUnderscore for private variables and functions.
  • Prefer template strings over string concatenation.
  • Prefer promises over callbacks.
  • Prefer array functions like map and forEach over for loops.
  • Use const for declaring variables that will never be re-assigned, and let otherwise.
  • Avoid var to declare variables.

Formatting

  • Use Prettier defaults with the following additional configuration (.prettierrc):

     {
       "singleQuote": true
     }

    This configuration includes:

    • Use semicolons at the end of each statement (sample)
    • Prefer single quotes (sample)
    • Use a trailing comma after each item in a multi-line array or object literal, including the last item. (sample)

If ESLint is used along with Prettier, the ESLInt plugin eslint-config-prettier should also be used to turn off all ESLint style rules that are already handled by Prettier.