Upgrade Prettier from 1.17 to 2.0.2.

Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
This commit is contained in:
Michael Bolin
2020-03-24 20:18:20 -07:00
committed by Facebook GitHub Bot
parent da89a92875
commit 8658fca4dd
25 changed files with 101 additions and 101 deletions

View File

@@ -33,7 +33,7 @@ beforeEach(() => {
test('dispatcher dispatches REGISTER_PLUGINS', () => { test('dispatcher dispatches REGISTER_PLUGINS', () => {
dispatcher(mockStore, logger); dispatcher(mockStore, logger);
const actions = mockStore.getActions(); const actions = mockStore.getActions();
expect(actions.map((a) => a.type)).toContain('REGISTER_PLUGINS'); expect(actions.map(a => a.type)).toContain('REGISTER_PLUGINS');
}); });
test('getDynamicPlugins returns empty array on errors', () => { test('getDynamicPlugins returns empty array on errors', () => {

View File

@@ -64,7 +64,7 @@ test('TestIdler can be controlled', async () => {
expect(idler.shouldIdle()).toBe(true); expect(idler.shouldIdle()).toBe(true);
let threw = false; let threw = false;
const p = idler.idle().catch((e) => { const p = idler.idle().catch(e => {
threw = true; threw = true;
expect(e).toMatchInlineSnapshot( expect(e).toMatchInlineSnapshot(
`[CancelledPromiseError: Idler got killed]`, `[CancelledPromiseError: Idler got killed]`,

View File

@@ -26,7 +26,7 @@ const storage = new JsonFileStorage(
test('A valid settings file gets parsed correctly', () => { test('A valid settings file gets parsed correctly', () => {
return storage return storage
.getItem('anykey') .getItem('anykey')
.then((result) => expect(result).toEqual(validDeserializedData)); .then(result => expect(result).toEqual(validDeserializedData));
}); });
test('deserialize works as expected', () => { test('deserialize works as expected', () => {

View File

@@ -72,7 +72,7 @@ export class FlipperConnection {
} }
receive(method: FlipperMethodID, receiver: FlipperReceiver<*>) { receive(method: FlipperMethodID, receiver: FlipperReceiver<*>) {
this._bridge.subscribe(this.pluginId, method, (data) => { this._bridge.subscribe(this.pluginId, method, data => {
receiver(data, new FlipperResponder(this.pluginId, method, this._bridge)); receiver(data, new FlipperResponder(this.pluginId, method, this._bridge));
}); });
} }

View File

@@ -83,7 +83,7 @@ export class FuryPlugin extends FlipperPlugin {
id: reqContext.currentSeqId + '/' + eventType, id: reqContext.currentSeqId + '/' + eventType,
time: new Date().getTime(), time: new Date().getTime(),
eventType: eventType, eventType: eventType,
callStack: stack.map((frame) => { callStack: stack.map(frame => {
return { return {
className: frame.getTypeName() || '', className: frame.getTypeName() || '',
methodName: frame.getFunctionName() || '', methodName: frame.getFunctionName() || '',

View File

@@ -39,7 +39,7 @@ class FlipperWebviewBridgeImpl extends FlipperBridge {
subscribe = ( subscribe = (
plugin: FlipperPluginID, plugin: FlipperPluginID,
method: FlipperMethodID, method: FlipperMethodID,
handler: (any) => void, handler: any => void,
) => { ) => {
this._subscriptions.set(plugin + method, handler); this._subscriptions.set(plugin + method, handler);
}; };

View File

@@ -18,7 +18,7 @@
"eslint-plugin-prettier": "^3.1.1", "eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0", "eslint-plugin-react": "^7.16.0",
"jest": "^24.9.0", "jest": "^24.9.0",
"prettier": "^2.0.0", "prettier": "2.0.2",
"ts-jest": "^24.1.0", "ts-jest": "^24.1.0",
"tslint-config-prettier": "^1.18.0", "tslint-config-prettier": "^1.18.0",
"typescript": "^3.7.2" "typescript": "^3.7.2"

View File

@@ -60,13 +60,13 @@ const runHeadless = memoize((args: Array<string>): Promise<{
console.info(`Running ${params.bin} ${args.join(' ')}`); console.info(`Running ${params.bin} ${args.join(' ')}`);
const process = spawn(params.bin, args, {}); const process = spawn(params.bin, args, {});
process.stdout.setEncoding('utf8'); process.stdout.setEncoding('utf8');
process.stdout.on('data', (chunk) => { process.stdout.on('data', chunk => {
stdoutChunks.push(chunk); stdoutChunks.push(chunk);
}); });
process.stderr.on('data', (chunk) => { process.stderr.on('data', chunk => {
stderrChunks.push(chunk); stderrChunks.push(chunk);
}); });
process.stdout.on('end', (chunk) => { process.stdout.on('end', chunk => {
const stdout = stdoutChunks.join(''); const stdout = stdoutChunks.join('');
const stderr = stderrChunks.join(''); const stderr = stderrChunks.join('');
try { try {
@@ -89,7 +89,7 @@ const runHeadless = memoize((args: Array<string>): Promise<{
}); });
function getPluginState(app: string, plugin: string): Promise<string> { function getPluginState(app: string, plugin: string): Promise<string> {
return runHeadless(basicArgs).then((result) => { return runHeadless(basicArgs).then(result => {
const pluginStates = result.output.store.pluginStates; const pluginStates = result.output.store.pluginStates;
for (const pluginId of Object.keys(pluginStates)) { for (const pluginId of Object.keys(pluginStates)) {
const matches = /([^#]+)#([^#]+)#([^#]+)#([^#]+)#([^#]+)/.exec(pluginId); const matches = /([^#]+)#([^#]+)#([^#]+)#([^#]+)#([^#]+)/.exec(pluginId);
@@ -110,10 +110,8 @@ function getPluginState(app: string, plugin: string): Promise<string> {
test( test(
'Flipper app appears in exported clients', 'Flipper app appears in exported clients',
() => { () => {
return runHeadless(basicArgs).then((result) => { return runHeadless(basicArgs).then(result => {
expect(result.output.clients.map((c) => c.query.app)).toContain( expect(result.output.clients.map(c => c.query.app)).toContain('Flipper');
'Flipper',
);
}); });
}, },
TEST_TIMEOUT_MS, TEST_TIMEOUT_MS,
@@ -122,7 +120,7 @@ test(
test( test(
'Output includes fileVersion', 'Output includes fileVersion',
() => { () => {
return runHeadless(basicArgs).then((result) => { return runHeadless(basicArgs).then(result => {
expect(result.output.fileVersion).toMatch(/[0-9]+\.[0-9]+\.[0-9]+/); expect(result.output.fileVersion).toMatch(/[0-9]+\.[0-9]+\.[0-9]+/);
}); });
}, },
@@ -132,7 +130,7 @@ test(
test( test(
'Output includes device', 'Output includes device',
() => { () => {
return runHeadless(basicArgs).then((result) => { return runHeadless(basicArgs).then(result => {
expect(result.output.device).toBeTruthy(); expect(result.output.device).toBeTruthy();
}); });
}, },
@@ -142,7 +140,7 @@ test(
test( test(
'Output includes flipperReleaseRevision', 'Output includes flipperReleaseRevision',
() => { () => {
return runHeadless(basicArgs).then((result) => { return runHeadless(basicArgs).then(result => {
expect(result.output.flipperReleaseRevision).toBeTruthy(); expect(result.output.flipperReleaseRevision).toBeTruthy();
}); });
}, },
@@ -152,7 +150,7 @@ test(
test( test(
'Output includes store', 'Output includes store',
() => { () => {
return runHeadless(basicArgs).then((result) => { return runHeadless(basicArgs).then(result => {
expect(result.output.store).toBeTruthy(); expect(result.output.store).toBeTruthy();
}); });
}, },
@@ -174,7 +172,7 @@ function stripNode(node: any, path: Array<string>) {
} }
if (path[0] === '*') { if (path[0] === '*') {
if (Array.isArray(node)) { if (Array.isArray(node)) {
return node.map((e) => stripNode(e, path.slice(1))); return node.map(e => stripNode(e, path.slice(1)));
} }
return Object.entries(node).reduce((acc, [key, val]) => { return Object.entries(node).reduce((acc, [key, val]) => {
acc[key] = stripNode(val, path.slice(1)); acc[key] = stripNode(val, path.slice(1));
@@ -228,12 +226,12 @@ test('test layout snapshot stripping', () => {
}); });
test('Sample app layout hierarchy matches snapshot', () => { test('Sample app layout hierarchy matches snapshot', () => {
return getPluginState('Flipper', 'Inspector').then((result) => { return getPluginState('Flipper', 'Inspector').then(result => {
const state = JSON.parse(result); const state = JSON.parse(result);
expect(state.rootAXElement).toBe('com.facebook.flipper.sample'); expect(state.rootAXElement).toBe('com.facebook.flipper.sample');
expect(state.rootElement).toBe('com.facebook.flipper.sample'); expect(state.rootElement).toBe('com.facebook.flipper.sample');
const canonicalizedElements = Object.values(state.elements) const canonicalizedElements = Object.values(state.elements)
.map((e) => { .map(e => {
const stableizedElements = stripUnstableLayoutAttributes(e); const stableizedElements = stripUnstableLayoutAttributes(e);
return stringify(stableizedElements); return stringify(stableizedElements);
}) })

View File

@@ -156,7 +156,7 @@
"jest-fetch-mock": "^3.0.0", "jest-fetch-mock": "^3.0.0",
"metro": "^0.58.0", "metro": "^0.58.0",
"metro-resolver": "^0.58.0", "metro-resolver": "^0.58.0",
"prettier": "^2.0.0", "prettier": "2.0.2",
"react-async": "^10.0.0", "react-async": "^10.0.0",
"recursive-readdir": "^2.2.2", "recursive-readdir": "^2.2.2",
"redux-mock-store": "^1.5.3", "redux-mock-store": "^1.5.3",

View File

@@ -31,8 +31,8 @@
"@types/node": "^13.7.5", "@types/node": "^13.7.5",
"cli-ux": "^5.4.5", "cli-ux": "^5.4.5",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"metro": "^0.58.0",
"inquirer": "^7.0.5", "inquirer": "^7.0.5",
"metro": "^0.58.0",
"tslib": "^1" "tslib": "^1"
}, },
"devDependencies": { "devDependencies": {
@@ -40,7 +40,7 @@
"@types/jest": "^24.0.21", "@types/jest": "^24.0.21",
"globby": "^10", "globby": "^10",
"jest": "^24.9.0", "jest": "^24.9.0",
"prettier": "^2.0.0", "prettier": "2.0.2",
"ts-jest": "^24.1.0", "ts-jest": "^24.1.0",
"ts-node": "^8", "ts-node": "^8",
"typescript": "^3.7.2" "typescript": "^3.7.2"

View File

@@ -80,7 +80,7 @@ module.exports = function (babel) {
if ( if (
BUILTINS.includes(source) || BUILTINS.includes(source) ||
BUILTINS.some((moduleName) => source.startsWith(`${moduleName}/`)) BUILTINS.some(moduleName => source.startsWith(`${moduleName}/`))
) { ) {
path.node.callee.name = 'electronRequire'; path.node.callee.name = 'electronRequire';
} }

View File

@@ -12,7 +12,7 @@ const path = require('path');
const replaceFBStubs = fs.existsSync( const replaceFBStubs = fs.existsSync(
path.join(__dirname, '..', '..', 'app', 'src', 'fb'), path.join(__dirname, '..', '..', 'app', 'src', 'fb'),
); );
const isFBFile = (filePath) => filePath.includes(`${path.sep}fb${path.sep}`); const isFBFile = filePath => filePath.includes(`${path.sep}fb${path.sep}`);
const requireFromFolder = (folder, path) => const requireFromFolder = (folder, path) =>
new RegExp(folder + '/[A-Za-z0-9.-_]+(.js)?$', 'g').test(path); new RegExp(folder + '/[A-Za-z0-9.-_]+(.js)?$', 'g').test(path);

View File

@@ -378,7 +378,7 @@ function addFileWatcherForiOSCrashLogs(
return; return;
} }
const filepath = path.join(dir, filename); const filepath = path.join(dir, filename);
promisify(fs.exists)(filepath).then((exists) => { promisify(fs.exists)(filepath).then(exists => {
if (!exists) { if (!exists) {
return; return;
} }
@@ -572,7 +572,7 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin<
static getActiveNotifications = ( static getActiveNotifications = (
persistedState: PersistedState, persistedState: PersistedState,
): Array<Notification> => { ): Array<Notification> => {
const filteredCrashes = persistedState.crashes.filter((crash) => { const filteredCrashes = persistedState.crashes.filter(crash => {
const ignore = !crash.name && !crash.reason; const ignore = !crash.name && !crash.reason;
const unknownCrashCause = crash.reason === UNKNOWN_CRASH_REASON; const unknownCrashCause = crash.reason === UNKNOWN_CRASH_REASON;
if (ignore || unknownCrashCause) { if (ignore || unknownCrashCause) {
@@ -679,7 +679,7 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin<
let deeplinkedCrash = null; let deeplinkedCrash = null;
if (this.props.deepLinkPayload) { if (this.props.deepLinkPayload) {
const id = this.props.deepLinkPayload; const id = this.props.deepLinkPayload;
const index = this.props.persistedState.crashes.findIndex((elem) => { const index = this.props.persistedState.crashes.findIndex(elem => {
return elem.notificationID === id; return elem.notificationID === id;
}); });
if (index >= 0) { if (index >= 0) {
@@ -714,18 +714,18 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin<
); );
const orderedIDs = crashes.map( const orderedIDs = crashes.map(
(persistedCrash) => persistedCrash.notificationID, persistedCrash => persistedCrash.notificationID,
); );
const selectedCrashID = crash.notificationID; const selectedCrashID = crash.notificationID;
const onCrashChange = (id) => { const onCrashChange = id => {
const newSelectedCrash = crashes.find( const newSelectedCrash = crashes.find(
(element) => element.notificationID === id, element => element.notificationID === id,
); );
this.setState({crash: newSelectedCrash}); this.setState({crash: newSelectedCrash});
}; };
const callstackString = crash.callstack || ''; const callstackString = crash.callstack || '';
const children = callstackString.split('\n').map((str) => { const children = callstackString.split('\n').map(str => {
return {message: str}; return {message: str};
}); });
const crashSelector: CrashSelectorProps = { const crashSelector: CrashSelectorProps = {
@@ -767,7 +767,7 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin<
}, },
]}> ]}>
<Line /> <Line />
{children.map((child) => { {children.map(child => {
return ( return (
<StackTraceComponent <StackTraceComponent
key={child.message} key={child.message}

View File

@@ -9,7 +9,7 @@
import type {PluginClient, Value} from 'flipper'; import type {PluginClient, Value} from 'flipper';
type ClientCall<Params, Response> = (Params) => Promise<Response>; type ClientCall<Params, Response> = Params => Promise<Response>;
type DatabaseListRequest = {}; type DatabaseListRequest = {};
@@ -78,22 +78,24 @@ export class DatabaseClient {
this.client = pluginClient; this.client = pluginClient;
} }
getDatabases: ClientCall<DatabaseListRequest, DatabaseListResponse> = ( getDatabases: ClientCall<
params, DatabaseListRequest,
) => this.client.call('databaseList', {}); DatabaseListResponse,
> = params => this.client.call('databaseList', {});
getTableData: ClientCall<QueryTableRequest, QueryTableResponse> = (params) => getTableData: ClientCall<QueryTableRequest, QueryTableResponse> = params =>
this.client.call('getTableData', params); this.client.call('getTableData', params);
getTableStructure: ClientCall< getTableStructure: ClientCall<
GetTableStructureRequest, GetTableStructureRequest,
GetTableStructureResponse, GetTableStructureResponse,
> = (params) => this.client.call('getTableStructure', params); > = params => this.client.call('getTableStructure', params);
getExecution: ClientCall<ExecuteSqlRequest, ExecuteSqlResponse> = (params) => getExecution: ClientCall<ExecuteSqlRequest, ExecuteSqlResponse> = params =>
this.client.call('execute', params); this.client.call('execute', params);
getTableInfo: ClientCall<GetTableInfoRequest, GetTableInfoResponse> = ( getTableInfo: ClientCall<
params, GetTableInfoRequest,
) => this.client.call('getTableInfo', params); GetTableInfoResponse,
> = params => this.client.call('getTableInfo', params);
} }

View File

@@ -250,7 +250,7 @@ function renderTable(page: ?Page, component: DatabasesPlugin) {
<ManagedTable <ManagedTable
tableKey={`databases-${page.databaseId}-${page.table}`} tableKey={`databases-${page.databaseId}-${page.table}`}
floating={false} floating={false}
columnOrder={page.columns.map((name) => ({ columnOrder={page.columns.map(name => ({
key: name, key: name,
visible: true, visible: true,
}))} }))}
@@ -281,7 +281,7 @@ function renderDatabaseColumns(structure: ?Structure) {
<FlexRow grow={true}> <FlexRow grow={true}>
<ManagedTable <ManagedTable
floating={false} floating={false}
columnOrder={structure.columns.map((name) => ({ columnOrder={structure.columns.map(name => ({
key: name, key: name,
visible: true, visible: true,
}))} }))}
@@ -305,7 +305,7 @@ function renderDatabaseIndexes(structure: ?Structure) {
<FlexRow grow={true}> <FlexRow grow={true}>
<ManagedTable <ManagedTable
floating={false} floating={false}
columnOrder={structure.indexesColumns.map((name) => ({ columnOrder={structure.indexesColumns.map(name => ({
key: name, key: name,
visible: true, visible: true,
}))} }))}
@@ -686,7 +686,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
databaseId: state.selectedDatabase, databaseId: state.selectedDatabase,
value: this.state.query.value, value: this.state.query.value,
}) })
.then((data) => { .then(data => {
this.setState({ this.setState({
error: null, error: null,
executionTime: Date.now() - timeBefore, executionTime: Date.now() - timeBefore,
@@ -709,7 +709,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
}); });
} }
}) })
.catch((e) => { .catch(e => {
this.setState({error: e}); this.setState({error: e});
}); });
} }
@@ -864,7 +864,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
table: table, table: table,
start: newState.pageRowNumber, start: newState.pageRowNumber,
}) })
.then((data) => { .then(data => {
this.dispatchAction({ this.dispatchAction({
type: 'UpdatePage', type: 'UpdatePage',
databaseId: databaseId, databaseId: databaseId,
@@ -876,7 +876,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
total: data.total, total: data.total,
}); });
}) })
.catch((e) => { .catch(e => {
this.setState({error: e}); this.setState({error: e});
}); });
} }
@@ -891,7 +891,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
databaseId: databaseId, databaseId: databaseId,
table: table, table: table,
}) })
.then((data) => { .then(data => {
this.dispatchAction({ this.dispatchAction({
type: 'UpdateStructure', type: 'UpdateStructure',
databaseId: databaseId, databaseId: databaseId,
@@ -902,7 +902,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
indexesValues: data.indexesValues, indexesValues: data.indexesValues,
}); });
}) })
.catch((e) => { .catch(e => {
this.setState({error: e}); this.setState({error: e});
}); });
} }
@@ -917,19 +917,19 @@ export default class DatabasesPlugin extends FlipperPlugin<
databaseId: databaseId, databaseId: databaseId,
table: table, table: table,
}) })
.then((data) => { .then(data => {
this.dispatchAction({ this.dispatchAction({
type: 'UpdateTableInfo', type: 'UpdateTableInfo',
tableInfo: data.definition, tableInfo: data.definition,
}); });
}) })
.catch((e) => { .catch(e => {
this.setState({error: e}); this.setState({error: e});
}); });
} }
if (!previousState.outdatedDatabaseList && newState.outdatedDatabaseList) { if (!previousState.outdatedDatabaseList && newState.outdatedDatabaseList) {
this.databaseClient.getDatabases({}).then((databases) => { this.databaseClient.getDatabases({}).then(databases => {
this.dispatchAction({ this.dispatchAction({
type: 'UpdateDatabases', type: 'UpdateDatabases',
databases, databases,
@@ -940,7 +940,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
init() { init() {
this.databaseClient = new DatabaseClient(this.client); this.databaseClient = new DatabaseClient(this.client);
this.databaseClient.getDatabases({}).then((databases) => { this.databaseClient.getDatabases({}).then(databases => {
this.dispatchAction({ this.dispatchAction({
type: 'UpdateDatabases', type: 'UpdateDatabases',
databases, databases,
@@ -987,7 +987,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
}; };
onDatabaseSelected = (selected: string) => { onDatabaseSelected = (selected: string) => {
const dbId = this.state.databases.find((x) => x.name === selected)?.id || 0; const dbId = this.state.databases.find(x => x.name === selected)?.id || 0;
this.dispatchAction({ this.dispatchAction({
database: dbId, database: dbId,
type: 'UpdateSelectedDatabase', type: 'UpdateSelectedDatabase',
@@ -1164,7 +1164,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
<ManagedTable <ManagedTable
floating={false} floating={false}
multiline={true} multiline={true}
columnOrder={columns.map((name) => ({ columnOrder={columns.map(name => ({
key: name, key: name,
visible: true, visible: true,
}))} }))}
@@ -1175,7 +1175,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
zebra={true} zebra={true}
rows={rows} rows={rows}
horizontallyScrollable={true} horizontallyScrollable={true}
onRowHighlighted={(highlightedRows) => { onRowHighlighted={highlightedRows => {
this.setState({ this.setState({
queryResult: { queryResult: {
table: { table: {
@@ -1267,7 +1267,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
<BoldSpan style={{marginRight: 16}}>Database</BoldSpan> <BoldSpan style={{marginRight: 16}}>Database</BoldSpan>
<Select <Select
options={this.state.databases options={this.state.databases
.map((x) => x.name) .map(x => x.name)
.reduce((obj, item) => { .reduce((obj, item) => {
obj[item] = item; obj[item] = item;
return obj; return obj;
@@ -1293,7 +1293,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
<BoldSpan style={{marginRight: 16}}>Database</BoldSpan> <BoldSpan style={{marginRight: 16}}>Database</BoldSpan>
<Select <Select
options={this.state.databases options={this.state.databases
.map((x) => x.name) .map(x => x.name)
.reduce((obj, item) => { .reduce((obj, item) => {
obj[item] = item; obj[item] = item;
return obj; return obj;
@@ -1343,7 +1343,7 @@ export default class DatabasesPlugin extends FlipperPlugin<
/> />
{this.state.favorites !== null ? ( {this.state.favorites !== null ? (
<Button <Button
dropdown={this.state.favorites.map((option) => { dropdown={this.state.favorites.map(option => {
return { return {
click: () => { click: () => {
this.setState({ this.setState({

View File

@@ -64,7 +64,7 @@ export default class DetailsPanel extends Component<Props> {
floating={false} floating={false}
heading={'Changesets'}> heading={'Changesets'}>
<MarkerTimeline <MarkerTimeline
points={changeSets.map((p) => ({ points={changeSets.map(p => ({
label: label:
p.type === 'CHANGESET_GENERATED' ? 'Generated' : 'Rendered', p.type === 'CHANGESET_GENERATED' ? 'Generated' : 'Rendered',
time: Math.round((p.timestamp || 0) - firstChangeSet), time: Math.round((p.timestamp || 0) - firstChangeSet),
@@ -72,9 +72,9 @@ export default class DetailsPanel extends Component<Props> {
p.type === 'CHANGESET_GENERATED' ? colors.lemon : colors.teal, p.type === 'CHANGESET_GENERATED' ? colors.lemon : colors.teal,
key: p.identifier, key: p.identifier,
}))} }))}
onClick={(ids) => onClick={ids =>
this.props.onFocusChangeSet( this.props.onFocusChangeSet(
changeSets.find((c) => c.identifier === ids[0]), changeSets.find(c => c.identifier === ids[0]),
) )
} }
selected={this.props.focusedChangeSet?.identifier} selected={this.props.focusedChangeSet?.identifier}

View File

@@ -29,7 +29,7 @@ const Container = styled(FlexRow)({
flexGrow: 1, flexGrow: 1,
}); });
const SurfaceContainer = styled(FlexColumn)((props) => ({ const SurfaceContainer = styled(FlexColumn)(props => ({
position: 'relative', position: 'relative',
'::after': { '::after': {
display: props.scrolled ? 'block' : 'none', display: props.scrolled ? 'block' : 'none',
@@ -50,7 +50,7 @@ const TimeContainer = styled(FlexColumn)({
flexShrink: 1, flexShrink: 1,
}); });
const Row = styled(FlexRow)((props) => ({ const Row = styled(FlexRow)(props => ({
alignItems: 'center', alignItems: 'center',
paddingBottom: 3, paddingBottom: 3,
marginTop: 3, marginTop: 3,
@@ -174,7 +174,7 @@ export default class extends Component<Props, State> {
let nextGenerationId = null; let nextGenerationId = null;
const index = this.props.generations.findIndex( const index = this.props.generations.findIndex(
(g) => g.id === this.props.focusedGenerationId, g => g.id === this.props.focusedGenerationId,
); );
const direction = e.key === 'ArrowRight' ? 1 : -1; const direction = e.key === 'ArrowRight' ? 1 : -1;
@@ -206,14 +206,14 @@ export default class extends Component<Props, State> {
return ( return (
<Container> <Container>
<SurfaceContainer scrolled={this.state.scrolled}> <SurfaceContainer scrolled={this.state.scrolled}>
{[...surfaces].map((surface) => ( {[...surfaces].map(surface => (
<Row key={surface}> <Row key={surface}>
<Label title={surface}>{surface}</Label> <Label title={surface}>{surface}</Label>
</Row> </Row>
))} ))}
</SurfaceContainer> </SurfaceContainer>
<TimeContainer onScroll={this.onScroll}> <TimeContainer onScroll={this.onScroll}>
{[...surfaces].map((surface) => ( {[...surfaces].map(surface => (
<Row key={surface} showTimeline> <Row key={surface} showTimeline>
{this.props.generations.map((record: TreeGeneration) => {this.props.generations.map((record: TreeGeneration) =>
record.surface_key === surface ? ( record.surface_key === surface ? (

View File

@@ -30,7 +30,7 @@ export default class extends React.Component<Props> {
if (this.props.skipStackTraceFormat) { if (this.props.skipStackTraceFormat) {
return ( return (
<StackTrace backgroundColor={colors.white}> <StackTrace backgroundColor={colors.white}>
{this.props.data.map((stack_trace_line) => { {this.props.data.map(stack_trace_line => {
return { return {
caller: stack_trace_line, caller: stack_trace_line,
}; };
@@ -43,10 +43,10 @@ export default class extends React.Component<Props> {
<StackTrace backgroundColor={colors.white}> <StackTrace backgroundColor={colors.white}>
{/* We need to filter out from the stack trace any reference to the plugin such that the information is more coincised and focused */} {/* We need to filter out from the stack trace any reference to the plugin such that the information is more coincised and focused */}
{this.props.data {this.props.data
.filter((stack_trace_line) => { .filter(stack_trace_line => {
return !stack_trace_line.includes('FlipperKitSectionsPlugin'); return !stack_trace_line.includes('FlipperKitSectionsPlugin');
}) })
.map((stack_trace_line) => { .map(stack_trace_line => {
const trace = REGEX.exec(stack_trace_line)?.groups; const trace = REGEX.exec(stack_trace_line)?.groups;
return { return {
bold: !isSystemLibrary(trace?.library), bold: !isSystemLibrary(trace?.library),

View File

@@ -13,7 +13,7 @@ import {Glyph, PureComponent, styled, Toolbar, Spacer, colors} from 'flipper';
import {Tree} from 'react-d3-tree'; import {Tree} from 'react-d3-tree';
import {Fragment} from 'react'; import {Fragment} from 'react';
const Legend = styled.div((props) => ({ const Legend = styled.div(props => ({
color: colors.dark50, color: colors.dark50,
marginLeft: 20, marginLeft: 20,
'&::before': { '&::before': {
@@ -98,7 +98,7 @@ class NodeLabel extends PureComponent<Props, State> {
collapsed: false, collapsed: false,
}; };
showNodeData = (e) => { showNodeData = e => {
e.stopPropagation(); e.stopPropagation();
this.props.onLabelClicked(this.props?.nodeData); this.props.onLabelClicked(this.props?.nodeData);
}; };
@@ -136,7 +136,7 @@ class NodeLabel extends PureComponent<Props, State> {
export default class extends PureComponent<Props, State> { export default class extends PureComponent<Props, State> {
treeFromFlatArray = (data: TreeData) => { treeFromFlatArray = (data: TreeData) => {
const tree = data.map((n) => { const tree = data.map(n => {
let fill = colors.blueGreyTint70; let fill = colors.blueGreyTint70;
if (n.didTriggerStateUpdate) { if (n.didTriggerStateUpdate) {
fill = colors.lemon; fill = colors.lemon;
@@ -184,12 +184,12 @@ export default class extends PureComponent<Props, State> {
} }
}, new Map()); }, new Map());
tree.forEach((n) => { tree.forEach(n => {
n.children = parentMap.get(n.attributes.identifier) || []; n.children = parentMap.get(n.attributes.identifier) || [];
}); });
// find the root node // find the root node
return tree.find((node) => !node.attributes.parent); return tree.find(node => !node.attributes.parent);
}; };
treeFromHierarchy = (data: SectionComponentHierarchy): Object => { treeFromHierarchy = (data: SectionComponentHierarchy): Object => {
@@ -244,7 +244,7 @@ export default class extends PureComponent<Props, State> {
return ( return (
<Fragment> <Fragment>
<Container <Container
innerRef={(ref) => { innerRef={ref => {
this.treeContainer = ref; this.treeContainer = ref;
}}> }}>
<style> <style>

View File

@@ -35,7 +35,7 @@ import {
DetailSidebar, DetailSidebar,
} from 'flipper'; } from 'flipper';
const Waiting = styled(FlexBox)((props) => ({ const Waiting = styled(FlexBox)(props => ({
width: '100%', width: '100%',
height: '100%', height: '100%',
flexGrow: 1, flexGrow: 1,
@@ -45,14 +45,14 @@ const Waiting = styled(FlexBox)((props) => ({
textAlign: 'center', textAlign: 'center',
})); }));
const InfoText = styled.div((props) => ({ const InfoText = styled.div(props => ({
marginTop: 10, marginTop: 10,
marginBottom: 10, marginBottom: 10,
fontWeight: '500', fontWeight: '500',
color: colors.light30, color: colors.light30,
})); }));
const InfoBox = styled.div((props) => ({ const InfoBox = styled.div(props => ({
maxWidth: 400, maxWidth: 400,
margin: 'auto', margin: 'auto',
textAlign: 'center', textAlign: 'center',

View File

@@ -9,11 +9,11 @@
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require('electron');
global.sendToHost = (message) => { global.sendToHost = message => {
ipcRenderer.sendToHost(message); ipcRenderer.sendToHost(message);
}; };
global.setupToReceiveHostMessage = (callback) => { global.setupToReceiveHostMessage = callback => {
ipcRenderer.on('hostMessage', (event, message) => { ipcRenderer.on('hostMessage', (event, message) => {
callback(message); callback(message);
}); });

View File

@@ -21,5 +21,5 @@ test('transform electron requires to inlined stubs', () => {
const transformed = transform(src, babelOptions).ast; const transformed = transform(src, babelOptions).ast;
const body = transformed.program.body[0]; const body = transformed.program.body[0];
expect(body.type).toBe('ExpressionStatement'); expect(body.type).toBe('ExpressionStatement');
expect(body.expression.properties.map((p) => p.key.name)).toContain('remote'); expect(body.expression.properties.map(p => p.key.name)).toContain('remote');
}); });

View File

@@ -80,7 +80,7 @@ module.exports = function (babel) {
if ( if (
BUILTINS.includes(source) || BUILTINS.includes(source) ||
BUILTINS.some((moduleName) => source.startsWith(`${moduleName}/`)) BUILTINS.some(moduleName => source.startsWith(`${moduleName}/`))
) { ) {
path.node.callee.name = 'electronRequire'; path.node.callee.name = 'electronRequire';
} }

View File

@@ -12,7 +12,7 @@ const path = require('path');
const replaceFBStubs = fs.existsSync( const replaceFBStubs = fs.existsSync(
path.join(__dirname, '..', '..', 'app', 'src', 'fb'), path.join(__dirname, '..', '..', 'app', 'src', 'fb'),
); );
const isFBFile = (filePath) => filePath.includes(`${path.sep}fb${path.sep}`); const isFBFile = filePath => filePath.includes(`${path.sep}fb${path.sep}`);
const requireFromFolder = (folder, path) => const requireFromFolder = (folder, path) =>
new RegExp(folder + '/[A-Za-z0-9.-_]+(.js)?$', 'g').test(path); new RegExp(folder + '/[A-Za-z0-9.-_]+(.js)?$', 'g').test(path);

View File

@@ -2951,7 +2951,7 @@
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
"@types/react-dom@*", "@types/react-dom@16.9.4", "@types/react-dom@^16.9.4": "@types/react-dom@*", "@types/react-dom@^16.9.4":
version "16.9.4" version "16.9.4"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.4.tgz#0b58df09a60961dcb77f62d4f1832427513420df" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.4.tgz#0b58df09a60961dcb77f62d4f1832427513420df"
integrity sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw== integrity sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw==
@@ -3004,7 +3004,7 @@
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
"@types/react@*", "@types/react@16.9.17", "@types/react@^16.9.17": "@types/react@*", "@types/react@^16.9.17":
version "16.9.17" version "16.9.17"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.17.tgz#58f0cc0e9ec2425d1441dd7b623421a867aa253e" resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.17.tgz#58f0cc0e9ec2425d1441dd7b623421a867aa253e"
integrity sha512-UP27In4fp4sWF5JgyV6pwVPAQM83Fj76JOcg02X5BZcpSu5Wx+fP9RMqc2v0ssBoQIFvD5JdKY41gjJJKmw6Bg== integrity sha512-UP27In4fp4sWF5JgyV6pwVPAQM83Fj76JOcg02X5BZcpSu5Wx+fP9RMqc2v0ssBoQIFvD5JdKY41gjJJKmw6Bg==
@@ -3346,16 +3346,16 @@ acorn@^7.1.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c"
integrity sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ== integrity sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==
adbkit-logcat@2, adbkit-logcat@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/adbkit-logcat/-/adbkit-logcat-2.0.1.tgz#d4986b9fc7cfda42733389d46a52124abef43ca5"
integrity sha512-MznVzzEzcrWhIaIyblll+a0AL1TICJe/yuaia7HDYTAtiNabR/9amJkAnLt30U8/W7MVBc3mvU1jB/6MJ/TYHw==
adbkit-logcat@^1.1.0: adbkit-logcat@^1.1.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/adbkit-logcat/-/adbkit-logcat-1.1.0.tgz#01d7f9b0cef9093a30bcb3b007efff301508962f" resolved "https://registry.yarnpkg.com/adbkit-logcat/-/adbkit-logcat-1.1.0.tgz#01d7f9b0cef9093a30bcb3b007efff301508962f"
integrity sha1-Adf5sM75CTowvLOwB+//MBUIli8= integrity sha1-Adf5sM75CTowvLOwB+//MBUIli8=
adbkit-logcat@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/adbkit-logcat/-/adbkit-logcat-2.0.1.tgz#d4986b9fc7cfda42733389d46a52124abef43ca5"
integrity sha512-MznVzzEzcrWhIaIyblll+a0AL1TICJe/yuaia7HDYTAtiNabR/9amJkAnLt30U8/W7MVBc3mvU1jB/6MJ/TYHw==
adbkit-monkey@~1.0.1: adbkit-monkey@~1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/adbkit-monkey/-/adbkit-monkey-1.0.1.tgz#f291be701a2efc567a63fc7aa6afcded31430be1" resolved "https://registry.yarnpkg.com/adbkit-monkey/-/adbkit-monkey-1.0.1.tgz#f291be701a2efc567a63fc7aa6afcded31430be1"
@@ -10438,16 +10438,16 @@ prettier-linter-helpers@^1.0.0:
dependencies: dependencies:
fast-diff "^1.1.2" fast-diff "^1.1.2"
prettier@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.2.tgz#1ba8f3eb92231e769b7fcd7cb73ae1b6b74ade08"
integrity sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==
prettier@^1.14.2: prettier@^1.14.2:
version "1.18.2" version "1.18.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==
prettier@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.0.tgz#9c8fdba0aeae3faf0d9d9391623ac4f9321a4455"
integrity sha512-vI55PC+GFLOVtpwr2di1mYhJF36v+kztJov8sx3AmqbfdA+2Dhozxb+3e1hTgoV9lyhnVJFF3Z8GCVeMBOS1bA==
pretty-format@^24.3.0, pretty-format@^24.7.0, pretty-format@^24.9.0: pretty-format@^24.3.0, pretty-format@^24.7.0, pretty-format@^24.9.0:
version "24.9.0" version "24.9.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9"