Skip to content

Instantly share code, notes, and snippets.

@anthonyalvarez
Last active October 24, 2018 18:21
Show Gist options
  • Select an option

  • Save anthonyalvarez/bf5668b4f6610cc702af6dbdf09d1264 to your computer and use it in GitHub Desktop.

Select an option

Save anthonyalvarez/bf5668b4f6610cc702af6dbdf09d1264 to your computer and use it in GitHub Desktop.
Style Guidelines

Style Guidelines

The term "Style Guidelines" amd "code conventions" are pften used interchangeably. Style guidelines are a type of code convention aimed at the layout of code within a file. Code conventions can also include programming practices, file directory layout, and commenting.

Having all code look the same is incredibly important on a team, because it allows:

  • Any developer to work on any file regardless of who wrote it. There's no need to spend time reformatting or deciphering the logic of the file, because it looks the same as everything else.

  • Errors becomes more obvious. If all the code looks the same, and you come across some code that does not, you have likely found a problem.

Useful Tools

  • JSLint incorporates Crockford's style preferences directly.

  • JSHint is a fork of JSLint and its goal is to provide more customization.

  • ESLint, The pluggable linting utility for JavaScript and JSX

Basic Formatting Style Guides

  1. jQuery Core Style Guide
  2. Douglas Crockford's Code Conventions for the JavaScript Programming Language
  3. SproutCore Style Guide
  4. Google JavaScript Style Guide
  5. Dojo Style Guide
  6. Android Code Style Guide
  7. Unofficial Ruby Usage Style Guide
  8. Python Style Guide
  9. AirBnB
  10. Udacidty Code Guidelines for JavaScript, HTML, CSS and Git

References

JSLint written by Douglas Crockford and a general code quality tool for JavaScript. Douglas wrote his ideas in three pieces.

  1. "The Elements of JavaScript Style, Part 1" which covers basic patterns and syntax

  2. "The Elements of JavaScript Style, Part 2" which covers common JavaScript idioms.

  3. "Code Conventions for the JavaScript Programming Language", a more robust resource that highlights pieces from the first two with the addition of smaller style guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment