Skip to content

Commit 6b30832

Browse files
authored
Upgrade prettier (facebook#26081)
The old version of prettier we were using didn't support the Flow syntax to access properties in a type using `SomeType['prop']`. This updates `prettier` and `rollup-plugin-prettier` to the latest versions. I added the prettier config `arrowParens: "avoid"` to reduce the diff size as the default has changed in Prettier 2.0. The largest amount of changes comes from function expressions now having a space. This doesn't have an option to preserve the old behavior, so we have to update this.
1 parent 1f5ce59 commit 6b30832

File tree

421 files changed

+3448
-4261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

421 files changed

+3448
-4261
lines changed

.prettierrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module.exports = {
88
jsxBracketSameLine: true,
99
trailingComma: 'es5',
1010
printWidth: 80,
11-
parser: 'babel',
12-
11+
parser: 'flow',
12+
arrowParens: 'avoid',
1313
overrides: [
1414
{
1515
files: esNextPaths,

dangerfile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function row(result, baseSha, headSha) {
9797
return rowArr.join(' | ');
9898
}
9999

100-
(async function() {
100+
(async function () {
101101
// Use git locally to grab the commit which represents the place
102102
// where the branches differ
103103

@@ -241,8 +241,9 @@ Comparing: ${baseSha}...${headSha}
241241
242242
## Critical size changes
243243
244-
Includes critical production bundles, as well as any change greater than ${CRITICAL_THRESHOLD *
245-
100}%:
244+
Includes critical production bundles, as well as any change greater than ${
245+
CRITICAL_THRESHOLD * 100
246+
}%:
246247
247248
${header}
248249
${criticalResults.join('\n')}

fixtures/attribute-behavior/src/App.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,9 @@ class App extends React.Component {
902902

903903
let log = '';
904904
for (let attribute of attributes) {
905-
log += `## \`${attribute.name}\` (on \`<${attribute.tagName ||
906-
'div'}>\` inside \`<${attribute.containerTagName || 'div'}>\`)\n`;
905+
log += `## \`${attribute.name}\` (on \`<${
906+
attribute.tagName || 'div'
907+
}>\` inside \`<${attribute.containerTagName || 'div'}>\`)\n`;
907908
log += '| Test Case | Flags | Result |\n';
908909
log += '| --- | --- | --- |\n';
909910

fixtures/devtools/scheduling-profiler/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function initServer() {
3939
const host = 'localhost';
4040
const port = 8000;
4141

42-
const requestListener = function(request, response) {
42+
const requestListener = function (request, response) {
4343
let contents;
4444
switch (request.url) {
4545
case '/react.js':

fixtures/dom/public/renderer.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
'use strict';
66

7-
(function() {
7+
(function () {
88
var Fixture = null;
99
var output = document.getElementById('output');
1010
var status = document.getElementById('status');
@@ -60,7 +60,7 @@
6060
setStatus('Generating markup');
6161

6262
return Promise.resolve()
63-
.then(function() {
63+
.then(function () {
6464
const element = createElement(Fixture);
6565

6666
// Server rendering moved to a separate package along with ReactDOM
@@ -80,11 +80,11 @@
8080
}
8181

8282
// Finally, React 0.4 and lower emits markup in a callback
83-
return new Promise(function(resolve) {
83+
return new Promise(function (resolve) {
8484
React.renderComponentToString(element, resolve);
8585
});
8686
})
87-
.then(function(string) {
87+
.then(function (string) {
8888
output.innerHTML = string;
8989
setStatus('Markup only (No React)');
9090
})
@@ -124,13 +124,13 @@
124124
}
125125

126126
function loadScript(src) {
127-
return new Promise(function(resolve, reject) {
127+
return new Promise(function (resolve, reject) {
128128
var script = document.createElement('script');
129129
script.async = true;
130130
script.src = src;
131131

132132
script.onload = resolve;
133-
script.onerror = function(error) {
133+
script.onerror = function (error) {
134134
reject(new Error('Unable to load ' + src));
135135
};
136136

@@ -145,7 +145,7 @@
145145
setStatus('Failed');
146146
output.innerHTML = 'Please name your root component "Fixture"';
147147
} else {
148-
prerender().then(function() {
148+
prerender().then(function () {
149149
if (getBooleanQueryParam('hydrate')) {
150150
render();
151151
}
@@ -161,27 +161,27 @@
161161

162162
window.onerror = handleError;
163163

164-
reload.onclick = function() {
164+
reload.onclick = function () {
165165
window.location.reload();
166166
};
167167

168168
hydrate.onclick = render;
169169

170170
loadScript(getQueryParam('reactPath'))
171-
.then(function() {
171+
.then(function () {
172172
if (needsReactDOM) {
173173
return Promise.all([
174174
loadScript(getQueryParam('reactDOMPath')),
175175
loadScript(getQueryParam('reactDOMServerPath')),
176176
]);
177177
}
178178
})
179-
.then(function() {
179+
.then(function () {
180180
if (failed) {
181181
return;
182182
}
183183

184-
window.addEventListener('message', function(event) {
184+
window.addEventListener('message', function (event) {
185185
var data = JSON.parse(event.data);
186186

187187
switch (data.type) {

fixtures/dom/src/components/fixtures/error-handling/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,15 @@ class TrySilenceFatalError extends React.Component {
243243

244244
function naiveMemoize(fn) {
245245
let memoizedEntry;
246-
return function() {
246+
return function () {
247247
if (!memoizedEntry) {
248248
memoizedEntry = {result: null};
249249
memoizedEntry.result = fn();
250250
}
251251
return memoizedEntry.result;
252252
};
253253
}
254-
let memoizedFunction = naiveMemoize(function() {
254+
let memoizedFunction = naiveMemoize(function () {
255255
throw new Error('Passed');
256256
});
257257

fixtures/dom/src/components/fixtures/hydration/Code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class CodeEditor extends React.Component {
3434
lineNumbers: true,
3535
});
3636

37-
this.editor.on('change', function(doc) {
37+
this.editor.on('change', function (doc) {
3838
onChange(doc.getValue());
3939
});
4040
}

fixtures/dom/src/components/fixtures/mouse-events/mouse-enter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ReactDOM = window.ReactDOM;
66
const MouseEnter = () => {
77
const containerRef = React.useRef();
88

9-
React.useEffect(function() {
9+
React.useEffect(function () {
1010
const hostEl = containerRef.current;
1111
ReactDOM.render(<MouseEnterDetect />, hostEl, () => {
1212
ReactDOM.render(<MouseEnterDetect />, hostEl.childNodes[1]);

fixtures/dom/src/polyfills.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'core-js/es6/map';
88

99
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
1010
// MIT license
11-
(function() {
11+
(function () {
1212
var lastTime = 0;
1313
var vendors = ['ms', 'moz', 'webkit', 'o'];
1414
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@@ -19,18 +19,18 @@ import 'core-js/es6/map';
1919
}
2020

2121
if (!window.requestAnimationFrame)
22-
window.requestAnimationFrame = function(callback, element) {
22+
window.requestAnimationFrame = function (callback, element) {
2323
var currTime = new Date().getTime();
2424
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
25-
var id = window.setTimeout(function() {
25+
var id = window.setTimeout(function () {
2626
callback(currTime + timeToCall);
2727
}, timeToCall);
2828
lastTime = currTime + timeToCall;
2929
return id;
3030
};
3131

3232
if (!window.cancelAnimationFrame)
33-
window.cancelAnimationFrame = function(id) {
33+
window.cancelAnimationFrame = function (id) {
3434
clearTimeout(id);
3535
};
3636
})();

fixtures/fiber-debugger/src/Fibers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Graph(props) {
2929
});
3030

3131
var edgeLabels = {};
32-
React.Children.forEach(props.children, function(child) {
32+
React.Children.forEach(props.children, function (child) {
3333
if (!child) {
3434
return;
3535
}

fixtures/fizz/server/server.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ const app = express();
3030
app.use(compress());
3131
app.get(
3232
'/',
33-
handleErrors(async function(req, res) {
33+
handleErrors(async function (req, res) {
3434
await waitForWebpack();
3535
renderToStream(req.url, res);
3636
})
3737
);
3838
app.get(
3939
'/string',
40-
handleErrors(async function(req, res) {
40+
handleErrors(async function (req, res) {
4141
await waitForWebpack();
4242
renderToString(req.url, res);
4343
})
4444
);
4545
app.get(
4646
'/stream',
47-
handleErrors(async function(req, res) {
47+
handleErrors(async function (req, res) {
4848
await waitForWebpack();
4949
renderToStream(req.url, res);
5050
})
5151
);
5252
app.get(
5353
'/buffer',
54-
handleErrors(async function(req, res) {
54+
handleErrors(async function (req, res) {
5555
await waitForWebpack();
5656
renderToBuffer(req.url, res);
5757
})
@@ -63,7 +63,7 @@ app
6363
.listen(PORT, () => {
6464
console.log(`Listening at ${PORT}...`);
6565
})
66-
.on('error', function(error) {
66+
.on('error', function (error) {
6767
if (error.syscall !== 'listen') {
6868
throw error;
6969
}
@@ -84,7 +84,7 @@ app
8484
});
8585

8686
function handleErrors(fn) {
87-
return async function(req, res, next) {
87+
return async function (req, res, next) {
8888
try {
8989
return await fn(req, res);
9090
} catch (x) {

fixtures/flight/config/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const hasJsxRuntime = (() => {
9191

9292
// This is the production and development configuration.
9393
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
94-
module.exports = function(webpackEnv) {
94+
module.exports = function (webpackEnv) {
9595
const isEnvDevelopment = webpackEnv === 'development';
9696
const isEnvProduction = webpackEnv === 'production';
9797

fixtures/flight/config/webpackDevServer.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const sockHost = process.env.WDS_SOCKET_HOST;
1313
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
1414
const sockPort = process.env.WDS_SOCKET_PORT;
1515

16-
module.exports = function(proxy, allowedHost) {
16+
module.exports = function (proxy, allowedHost) {
1717
const disableFirewall =
1818
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
1919
return {

fixtures/flight/scripts/start.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ checkBrowsers(paths.appPath, isInteractive)
131131
openBrowser(urls.localUrlForBrowser);
132132
});
133133

134-
['SIGINT', 'SIGTERM'].forEach(function(sig) {
135-
process.on(sig, function() {
134+
['SIGINT', 'SIGTERM'].forEach(function (sig) {
135+
process.on(sig, function () {
136136
devServer.close();
137137
process.exit();
138138
});
139139
});
140140

141141
if (process.env.CI !== 'true') {
142142
// Gracefully exit when stdin ends
143-
process.stdin.on('end', function() {
143+
process.stdin.on('end', function () {
144144
devServer.close();
145145
process.exit();
146146
});

fixtures/flight/server/cli.server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ babelRegister({
1010
babelrc: false,
1111
ignore: [
1212
/\/(build|node_modules)\//,
13-
function(file) {
13+
function (file) {
1414
if ((path.dirname(file) + '/').startsWith(__dirname + '/')) {
1515
// Ignore everything in this folder
1616
// because it's a mix of CJS and ESM
@@ -28,11 +28,11 @@ const express = require('express');
2828
const app = express();
2929

3030
// Application
31-
app.get('/', function(req, res) {
31+
app.get('/', function (req, res) {
3232
require('./handler.server.js')(req, res);
3333
});
3434

35-
app.get('/todos', function(req, res) {
35+
app.get('/todos', function (req, res) {
3636
res.setHeader('Access-Control-Allow-Origin', '*');
3737
res.json([
3838
{
@@ -50,7 +50,7 @@ app.listen(3001, () => {
5050
console.log('Flight Server listening on port 3001...');
5151
});
5252

53-
app.on('error', function(error) {
53+
app.on('error', function (error) {
5454
if (error.syscall !== 'listen') {
5555
throw error;
5656
}

fixtures/flight/server/handler.server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {readFile} = require('fs');
55
const {resolve} = require('path');
66
const React = require('react');
77

8-
module.exports = function(req, res) {
8+
module.exports = function (req, res) {
99
// const m = require('../src/App.server.js');
1010
import('../src/App.server.js').then(m => {
1111
const dist = process.env.NODE_ENV === 'development' ? 'dist' : 'build';

0 commit comments

Comments
 (0)