update to modern code style (#1738)

* mv create-react-app/index.js -> create-react-app/creteReactApp.js

* update to modern code style

* var -> cosnt

* set trailing-coma to es5 for prettier
This commit is contained in:
Valerii Sorokobatko
2017-03-07 21:46:10 +02:00
committed by Dan Abramov
parent 43873dc9b8
commit fe7b5c212b
66 changed files with 2011 additions and 1637 deletions

View File

@@ -46,7 +46,7 @@ function createOverlayIframe(onIframeLoad) {
}
function addOverlayDivTo(iframe) {
var div = iframe.contentDocument.createElement('div');
var div = iframe.contentDocument.createElement('div');
div.id = 'react-dev-utils-webpack-hot-dev-client-overlay-div';
div.style.position = 'fixed';
div.style.boxSizing = 'border-box';
@@ -104,8 +104,9 @@ function ensureOverlayDivExists(onOverlayDivReady) {
function showErrorOverlay(message) {
ensureOverlayDivExists(function onOverlayDivReady(overlayDiv) {
// Make it look similar to our terminal.
overlayDiv.innerHTML =
'<span style="color: ' + red + '">Failed to compile.</span><br><br>' +
overlayDiv.innerHTML = '<span style="color: ' +
red +
'">Failed to compile.</span><br><br>' +
ansiHTML(entities.encode(message));
});
}
@@ -124,13 +125,15 @@ function destroyErrorOverlay() {
}
// Connect to WebpackDevServer via a socket.
var connection = new SockJS(url.format({
protocol: window.location.protocol,
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node'
}));
var connection = new SockJS(
url.format({
protocol: window.location.protocol,
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node',
})
);
// Unlike WebpackDevServer client, we won't try to reconnect
// to avoid spamming the console. Disconnect usually happens
@@ -207,7 +210,7 @@ function handleErrors(errors) {
// "Massage" webpack messages.
var formatted = formatWebpackMessages({
errors: errors,
warnings: []
warnings: [],
});
// Only show the first error.
@@ -232,27 +235,27 @@ function handleAvailableHash(hash) {
connection.onmessage = function(e) {
var message = JSON.parse(e.data);
switch (message.type) {
case 'hash':
handleAvailableHash(message.data);
break;
case 'still-ok':
case 'ok':
handleSuccess();
break;
case 'content-changed':
// Triggered when a file from `contentBase` changed.
window.location.reload();
break;
case 'warnings':
handleWarnings(message.data);
break;
case 'errors':
handleErrors(message.data);
break;
default:
case 'hash':
handleAvailableHash(message.data);
break;
case 'still-ok':
case 'ok':
handleSuccess();
break;
case 'content-changed':
// Triggered when a file from `contentBase` changed.
window.location.reload();
break;
case 'warnings':
handleWarnings(message.data);
break;
case 'errors':
handleErrors(message.data);
break;
default:
// Do nothing.
}
}
};
// Is there a newer version of this code available?
function isUpdateAvailable() {
@@ -297,7 +300,7 @@ function tryApplyUpdates(onHotUpdateSuccess) {
}
// https://webpack.github.io/docs/hot-module-replacement.html#check
var result = module.hot.check(/* autoApply */true, handleApplyUpdates);
var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);
// // Webpack 2 returns a Promise instead of invoking a callback
if (result && result.then) {