Skip to content

Instantly share code, notes, and snippets.

@gajus
Last active August 28, 2015 07:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gajus/81e6db50f987047ef35e to your computer and use it in GitHub Desktop.
Save gajus/81e6db50f987047ef35e to your computer and use it in GitHub Desktop.

File Name

File containing JavaScript must have ".js" extension.

Bad:

index.jsx

Good:

index.js

Importing Multiple Variables

  • Must be written on multiple lines.

Bad:

import {Component, PropTypes} from 'react';

Good:

import {
    Component,
    PropTypes
} from 'react';

Reason:

Consistent with variable declaration.

JSX Multiline Element Declaration

  • Must be written without using ().
  • Must start inline with the owner of the resuting object.

Bad:

return (
    <div>
        <p>Hello, World!</p>  
    </div>
);
let foo;

foo = 
    <div>
        <p>Hello, World!</p>  
    </div>;

Good:

return <div>
        <p>Hello, World!</p>  
    </div>;
let foo;

foo = <div>
        <p>Hello, World!</p>  
    </div>;

Declaring Static Properties

  • Must use ES7 static keyword to declara static properties.

Bad:

class Foo {}
Foo.bar = 'BAR';

Good:

class Foo {
    static bar = 'BAR';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment