Advertise here

NEW  Video tutorials for jQuery and Javascript are now on Videos page.

JavaScript Standard Style

June 13, 2016     842     Others
JavaScript Standard Style

The beauty of JavaScript Standard Style is that it's simple. No one wants to maintain multiple hundred-line style configuration files for every module/project they work on. 

This module saves you time in two ways:

  • No configuration. The easiest way to enforce consistent style in your project. Just drop it in.
  • Catch style errors before they're submitted in PRs. Saves precious code review time by eliminating back-and-forth between maintainer and contributor.

Rules

  • 2 spaces – for indentation
  • Single quotes for strings – except to avoid escaping
  • No unused variables – this one catches tons of bugs!
  • No semicolons – It's fine. Really!
  • Never start a line with (, [, or `
    • This is the only gotcha with omitting semicolons – automatically checked for you!
    • More details
  • Space after keywords if (condition) { ... }
  • Space after function name function name (arg) { ... }
  • Always use === instead of == – but obj == null is allowed to check null || undefined.
  • Always handle the node.js err function parameter
  • Always prefix browser globals with window – except document and navigator are okay
    • Prevents accidental use of poorly-named browser globals like open, length, event, and name.
  • And more goodnessgive standard a try today!

Related Plugins

Latest Plugins


Subscribe to Newsletter

Subscribe to email newsletter for latest jQuery plugins & tutorials.



Comments

AdvertisementAdvertise with us!
Angular, React and Javascript MV* Frameworks | MVish