Some links why to use camelCase for constants:
// Bad
const SERVICE_URL = 'https://www.example.com';
// Good
const serviceUrl = 'https://www.example.com';| // Failing case | |
| // Concurrent test runs | |
| import test from 'ava'; | |
| import jsdom from 'jsdom'; | |
| // Angular dependencies | |
| global.document = jsdom.jsdom('<!doctype html><html ng-app="app"><head><meta charset="utf-8"></head><body></body></html>'); | |
| global.window = document.defaultView; | |
| global.Node = global.window.Node; |
| // require() some stuff from npm (like you were using browserify) | |
| // and then hit Rebuild to run it on the right | |
| var esformatter = require( 'esformatter' ); | |
| var esformatterJSX = require( 'esformatter-jsx' ); | |
| //var collapser = require( 'esformatter-collapse-objects' ) | |
| var throttle = require( 'lodash.throttle' ); | |
| var hash = window.location.hash.substr( 1 ); | |
| var extend = require('extend'); | |
| var params; |
Some links why to use camelCase for constants:
// Bad
const SERVICE_URL = 'https://www.example.com';
// Good
const serviceUrl = 'https://www.example.com';| function getOrderDetails(orderID) { | |
| return db.find( "orders", orderID ).then(order => | |
| db.find( "customers", order.customerID ).then(customer => ({order, customer})) | |
| ).then(({order, customer}) => | |
| Object.assign(order, {customer}) | |
| ); | |
| } | |
| getOrderDetails( 1234 ) | |
| .then( displayOrder, showError ); |
| // Produce new array from .reduce(), with map- and filter-like transformation in one step. | |
| // Example data courtesy of http://elijahmanor.com/reducing-filter-and-map-down-to-reduce/ | |
| const doctors = [ | |
| { number: 1, actor: "William Hartnell", begin: 1963, end: 1966 }, | |
| { number: 2, actor: "Patrick Troughton", begin: 1966, end: 1969 }, | |
| { number: 3, actor: "Jon Pertwee", begin: 1970, end: 1974 }, | |
| { number: 4, actor: "Tom Baker", begin: 1974, end: 1981 }, | |
| { number: 5, actor: "Peter Davison", begin: 1982, end: 1984 }, | |
| { number: 6, actor: "Colin Baker", begin: 1984, end: 1986 }, |
| let Loop = React.createClass({ | |
| getInitialState() { | |
| return { | |
| isMovingToEnd: true | |
| }; | |
| }, | |
| endValue(currVals) { | |
| let {endValueProp, isDone, startValue} = this.props; | |
| let {isMovingToEnd} = this.state; |
NOTE
You may not need local branches for all pull requests in a repo.
To fetch only the ref of a single pull request that you need, use this:
git fetch origin pull/7324/head:pr-7324
git checkout pr-7324
# ...| [alias] | |
| fetch-pr = "!f() { git fetch origin refs/pull/$1/head:pr/$1; } ; f" | |
| delete-prs = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done" |
| // Beware! Not tested. | |
| // open source library: `react-server-route-groups` | |
| // - function to generate routes based on array of things (in our case, translations) | |
| export default function ({groups, pages}) { | |
| return groups.reduce((acc, group) => { | |
| return { | |
| // All previous routes | |
| ...acc, |
| // Before | |
| module.exports = { | |
| getNamespace: getNamespace, | |
| getCountNamespaces: getCountNamespaces, | |
| startRequest: startRequest, | |
| bind: bind, | |
| patch: patch | |
| }; | |
| // After (singleton in global namespace) |