2. JavaScript Style Guide is a set of rules , guidelines,
programming style, practices, and methods used when writing
the source code in JavaScript .
What is JavaScript Style Guide ?
3. • Improves code readability
• Make code maintenance easier
• Easily shared among developers
• Naming and declaration rules for variables and functions.
• Rules for the use of white space, indentation, and comments.
• Programming practices and principles.
Style guidelines typically cover:
Coding conventions secure quality:
5. JavaScript style guide has linter & automatic code fixer !
Why JavaScript Standard Style ?
6. Advantages of JavaScript Standard Style ?
• No configuration, The easiest way to enforce consistent style
in your project.
• Automatically format code. Just run standard --fix and avoid
messy or inconsistent code.
• Catch style issues & programmer errors early. Saves code
review time by eliminating back-and-forth between reviewer
& contributor.
7. Rules
• Use 2 spaces for indentation.
• Use single quotes for strings
console.log('hello there')
• No unused variables.
8. • Add a space after keywords.
Rules,…
if (condition) { ... } // ✓ ok
if(condition) { ... } // ✗ avoid
• Add a space before a function declaration's parentheses
• Always use === instead of ==.
if (name === 'John') // ✓ ok
if (name == 'John') // ✗ avoid
function name (arg) { ... } // ✓ ok
function name(arg) { ... } // ✗ avoid
10. Checking the style of all JavaScript files in the current working
directory
Usage
$ standard
Error: Use JavaScript Standard Style
lib/torrent.js:950:11: Expected '===' and instead saw '=='.