prettier 2
Summary:
Quick notes:
- This looks worse than it is. It adds mandatory parentheses to single argument lambdas. Lots of outrage on Twitter about it, personally I'm {emoji:1f937_200d_2642} about it.
- Space before function, e.g. `a = function ()` is now enforced. I like this because both were fine before.
- I added `eslint-config-prettier` to the config because otherwise a ton of rules conflict with eslint itself.
Close https://github.com/facebook/flipper/pull/915
Reviewed By: jknoxville
Differential Revision: D20594929
fbshipit-source-id: ca1c65376b90e009550dd6d1f4e0831d32cbff03
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d9d3be33b4
commit
fc9ed65762
@@ -29,7 +29,7 @@ function preludeBundle(
|
||||
) {
|
||||
const revisionStr =
|
||||
buildRevision == null ? '' : `global.__REVISION__="${buildRevision}";`;
|
||||
return new Promise(resolve =>
|
||||
return new Promise((resolve) =>
|
||||
lineReplace({
|
||||
file: path.join(dir, 'bundle.js'),
|
||||
line: 1,
|
||||
@@ -41,18 +41,18 @@ function preludeBundle(
|
||||
}
|
||||
|
||||
async function createZip(buildDir: string, distDir: string, targets: string[]) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
const zip = new yazl.ZipFile();
|
||||
|
||||
// add binaries for each target
|
||||
targets.forEach(target => {
|
||||
targets.forEach((target) => {
|
||||
const binary = `flipper-${target === 'mac' ? 'macos' : target}`;
|
||||
zip.addFile(path.join(buildDir, binary), binary);
|
||||
});
|
||||
|
||||
// add plugins
|
||||
const pluginDir = path.join(buildDir, PLUGINS_FOLDER_NAME);
|
||||
fs.readdirSync(pluginDir).forEach(file => {
|
||||
fs.readdirSync(pluginDir).forEach((file) => {
|
||||
zip.addFile(
|
||||
path.join(pluginDir, file),
|
||||
path.join(PLUGINS_FOLDER_NAME, file),
|
||||
|
||||
@@ -116,7 +116,7 @@ async function buildDist(buildFolder: string) {
|
||||
projectDir: buildFolder,
|
||||
targets,
|
||||
});
|
||||
return await Promise.all(postBuildCallbacks.map(p => p()));
|
||||
return await Promise.all(postBuildCallbacks.map((p) => p()));
|
||||
} catch (err) {
|
||||
return die(err);
|
||||
}
|
||||
@@ -138,8 +138,8 @@ function downloadIcons(buildFolder: string) {
|
||||
>((acc, [name, sizes]) => {
|
||||
acc.push(
|
||||
// get icons in @1x and @2x
|
||||
...sizes.map(size => ({name, size, density: 1})),
|
||||
...sizes.map(size => ({name, size, density: 2})),
|
||||
...sizes.map((size) => ({name, size, density: 1})),
|
||||
...sizes.map((size) => ({name, size, density: 2})),
|
||||
);
|
||||
return acc;
|
||||
}, []);
|
||||
@@ -148,7 +148,7 @@ function downloadIcons(buildFolder: string) {
|
||||
iconURLs.map(({name, size, density}) => {
|
||||
const url = getIconURL(name, size, density);
|
||||
return fetch(url)
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
if (res.status !== 200) {
|
||||
throw new Error(
|
||||
// eslint-disable-next-line prettier/prettier
|
||||
@@ -160,7 +160,7 @@ function downloadIcons(buildFolder: string) {
|
||||
return res;
|
||||
})
|
||||
.then(
|
||||
res =>
|
||||
(res) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const fileStream = fs.createWriteStream(
|
||||
path.join(buildFolder, buildLocalIconPath(name, size, density)),
|
||||
|
||||
@@ -26,7 +26,7 @@ async function mostRecentlyChanged(
|
||||
recursiveReaddir,
|
||||
)(dir, ignores);
|
||||
return files
|
||||
.map(f => fs.lstatSync(f).ctime)
|
||||
.map((f) => fs.lstatSync(f).ctime)
|
||||
.reduce((a, b) => (a > b ? a : b), new Date(0));
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export function compileDefaultPlugins(
|
||||
defaultPluginDir,
|
||||
{force: true, failSilently: false, recompileOnChanges: false},
|
||||
)
|
||||
.then(defaultPlugins =>
|
||||
.then((defaultPlugins) =>
|
||||
fs.writeFileSync(
|
||||
path.join(defaultPluginDir, 'index.json'),
|
||||
JSON.stringify(
|
||||
@@ -187,7 +187,7 @@ export function buildFolder(): Promise<string> {
|
||||
resolve(buildFolder);
|
||||
}
|
||||
});
|
||||
}).catch(e => {
|
||||
}).catch((e) => {
|
||||
die(e);
|
||||
return '';
|
||||
});
|
||||
@@ -205,7 +205,7 @@ export function getVersionNumber() {
|
||||
export function genMercurialRevision(): Promise<string | null> {
|
||||
return spawn('hg', ['log', '-r', '.', '-T', '{node}'], {encoding: 'utf8'})
|
||||
.then(
|
||||
res =>
|
||||
(res) =>
|
||||
(res &&
|
||||
(typeof res.stdout === 'string'
|
||||
? res.stdout
|
||||
|
||||
@@ -149,7 +149,7 @@ function startAssetServer(
|
||||
|
||||
app.use(express.static(staticDir));
|
||||
|
||||
app.use(function(err: any, req: any, res: any, _next: any) {
|
||||
app.use(function (err: any, req: any, res: any, _next: any) {
|
||||
knownErrors[req.url] = err;
|
||||
outputScreen();
|
||||
res.status(500).send('Something broke, check the console!');
|
||||
@@ -157,7 +157,7 @@ function startAssetServer(
|
||||
|
||||
const server = http.createServer(app);
|
||||
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
server.listen(port, 'localhost', () => resolve({app, server}));
|
||||
});
|
||||
}
|
||||
@@ -166,7 +166,7 @@ async function addWebsocket(server: http.Server) {
|
||||
const io = socketIo(server);
|
||||
|
||||
// notify connected clients that there's errors in the console
|
||||
io.on('connection', client => {
|
||||
io.on('connection', (client) => {
|
||||
if (hasErrors()) {
|
||||
client.emit('hasErrors', ansiToHtmlConverter.toHtml(buildErrorScreen()));
|
||||
}
|
||||
@@ -178,7 +178,7 @@ async function addWebsocket(server: http.Server) {
|
||||
const watchman = new Watchman(path.resolve(__dirname, '..'));
|
||||
await watchman.initialize();
|
||||
await Promise.all(
|
||||
['src', 'pkg', 'doctor'].map(dir =>
|
||||
['src', 'pkg', 'doctor'].map((dir) =>
|
||||
watchman.startWatchFiles(
|
||||
dir,
|
||||
() => {
|
||||
|
||||
@@ -21,11 +21,11 @@ const YARN_PATH =
|
||||
: 'yarn' + (WINDOWS ? '.cmd' : '');
|
||||
|
||||
Promise.all(
|
||||
PACKAGES.map(pattern =>
|
||||
PACKAGES.map((pattern) =>
|
||||
glob(path.join(__dirname, '..', pattern, 'package.json')),
|
||||
),
|
||||
)
|
||||
.then(async packages => {
|
||||
.then(async (packages) => {
|
||||
const flattenPackages = packages.reduce((acc, cv) => acc.concat(cv), []);
|
||||
console.log(
|
||||
`Installing dependencies for ${flattenPackages.length} plugins`,
|
||||
@@ -56,7 +56,7 @@ Promise.all(
|
||||
})
|
||||
// eslint-disable-next-line
|
||||
.then(() => console.log('📦 Installed all plugin dependencies!'))
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
console.error('❌ Installing plugin dependencies failed.');
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user