Best Practices

Source files

  1. Use lowercase letters for directory names and filenames. Connect words with underscore, not blank space.
  2. Use .html or .htm as file extension for HTML, .css for style sheets, and .js for JavaScript.
  3. Encode files in UTF-8.

Formatting

  1. Use braces for all control structures.
  2. Use K&R style for nonempty blocks.
  3. Indent with 2 spaces.
  4. One statement per line, ending with a semicolon.
  5. Use 80 charcters as the column limit.
  6. Break a line at a higher syntactic level.
  7. Indent continued lines with 4 spaces.
  8. Use a space between reserved keywords with parenthesis and braces.
  9. Use a space after comma and colon.

Language features

  1. Do not mix quoted and unquoted keys.
  2. Use single quotes for ordinary strings.
  3. Use template literals over complex string concatenation.

Naming

  1. Use descriptive names for variables and functions.
  2. Use camelCase instead of snake_case or kebab-case.

Style guides

Linters