Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
Summary: as title

Differential Revision: D60856257

fbshipit-source-id: ef6b646d36878eefc6577caee6b149e16000367a
  • Loading branch information
Andre Quispesaravia authored and facebook-github-bot committed Aug 7, 2024
1 parent b784ca0 commit a19aabc
Show file tree
Hide file tree
Showing 32 changed files with 178 additions and 97 deletions.
17 changes: 9 additions & 8 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ module.exports = api => {
}
return {
plugins,
sourceType: "unambiguous",
ignore: [
/\/node_modules\//,
],
sourceType: 'unambiguous',
ignore: [/\/node_modules\//],
presets: [
['@babel/preset-env', {
useBuiltIns: 'entry',
targets,
}],
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
targets,
},
],
'@babel/preset-react',
'@babel/preset-flow',
],
Expand Down
12 changes: 10 additions & 2 deletions packages/relay-devtools-core/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ installHook(window);

const hook: DevToolsHook = window.__RELAY_DEVTOOLS_HOOK__;

function debug(methodName: string, ...args: [] | [any] | [string] | [Array<WallEvent>]) {
function debug(
methodName: string,
...args: [] | [any] | [string] | [Array<WallEvent>]
) {
if (__DEBUG__) {
console.log(
`%c[core/backend] %c${methodName}`,
Expand All @@ -40,7 +43,12 @@ function debug(methodName: string, ...args: [] | [any] | [string] | [Array<WallE
}

export function connectToDevTools(options: ?ConnectOptions) {
const {host = 'localhost', port = 8097, websocket, isAppActive = () => true} = options || {};
const {
host = 'localhost',
port = 8097,
websocket,
isAppActive = () => true,
} = options || {};

let retryTimeoutID: TimeoutID | null = null;

Expand Down
4 changes: 2 additions & 2 deletions packages/relay-devtools-core/webpack.backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ module.exports = {

// This name is important; standalone references it in order to connect.
library: {
name:'RelayDevToolsBackend',
name: 'RelayDevToolsBackend',
type: 'umd',
}
},
},
resolve: {
alias: {
Expand Down
46 changes: 29 additions & 17 deletions shells/dev/relay-app/FriendsList/createInBrowserNetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
* @flow
*/

import type { INetwork } from "../../../../node_modules/relay-runtime/network/RelayNetworkTypes";import type { Variables } from "../../../../node_modules/relay-runtime/util/RelayRuntimeTypes";
import type { RequestParameters } from "../../../../node_modules/relay-runtime/util/RelayConcreteNode";/**
import type { INetwork } from '../../../../node_modules/relay-runtime/network/RelayNetworkTypes';
import type { Variables } from '../../../../node_modules/relay-runtime/util/RelayRuntimeTypes';
import type { RequestParameters } from '../../../../node_modules/relay-runtime/util/RelayConcreteNode';
/**
* This file implements the Relay "network" as a server running in the browser.
* This allows the test app to send network requests that can be observed without
* running a separate server.
Expand Down Expand Up @@ -102,17 +104,17 @@ function createInBrowserNetwork(): INetwork {
}

friends(): {
count: number,
edges: Array<{ cursor: number, node: User, ... }>,
pageInfo: () => {
endCursor: string,
hasNextPage: boolean,
hasPreviousPage: boolean,
startCursor: string,
...
},
...
} {
count: number,
edges: Array<{ cursor: number, node: User, ... }>,
pageInfo: () => {
endCursor: string,
hasNextPage: boolean,
hasPreviousPage: boolean,
startCursor: string,
...
},
...
} {
if (!this._friends) {
this._friends = [];
for (let i = 0; i < 4; i++) {
Expand Down Expand Up @@ -146,25 +148,35 @@ function createInBrowserNetwork(): INetwork {
}

const userMap = new Map<string, User>();
function createUser(id: string |void) {
function createUser(id: string | void) {
const user = new User(id);
userMap.set(user.id, user);
return user;
}

const root = {
node: ({ id }: {id : string | void}) => {
node: ({ id }: { id: string | void }) => {
if (id == null || !userMap.has(id)) {
return createUser(id);
}
return userMap.get(id);
},
};

function fetchQuery(request: RequestParameters, variables: Variables): $FlowFixMe {
function fetchQuery(
request: RequestParameters,
variables: Variables
): $FlowFixMe {
return new Promise(resolve => {
setTimeout(() => {
resolve(graphql({schema, source: request.text, rootValue:root, variableValues: variables}));
resolve(
graphql({
schema,
source: request.text,
rootValue: root,
variableValues: variables,
})
);
}, 1000 + Math.round(Math.random() * 1000));
});
}
Expand Down
2 changes: 1 addition & 1 deletion shells/dev/relay-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import './styles.css';

const roots = [];

function mountHelper(App: ((_: mixed) => React$MixedElement)) {
function mountHelper(App: (_: mixed) => React$MixedElement) {
const container = document.createElement('div');

((document.body: any): HTMLBodyElement).appendChild(container);
Expand Down
2 changes: 1 addition & 1 deletion shells/dev/src/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ inject('dist/app.js', () => {
connect(cb) {
const bridge = new Bridge<any, any>({
listen(fn) {
const listener = ({data}: any) => {
const listener = ({ data }: any) => {
fn(data);
};
// Preserve the reference to the window we subscribe to, so we can unsubscribe from it when required.
Expand Down
7 changes: 5 additions & 2 deletions shells/dev/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ const config = {
resolve: {
alias: {
src: path.resolve(__dirname, '../../src'),
'@babel/runtime': path.resolve(__dirname, '../../node_modules/@babel/runtime'),
'@babel/runtime': path.resolve(
__dirname,
'../../node_modules/@babel/runtime'
),
},
},
plugins: [
Expand Down Expand Up @@ -93,7 +96,7 @@ config.output = {
if (TARGET === 'local') {
config.devServer = {
static: {
directory:path.join(__dirname, '/'),
directory: path.join(__dirname, '/'),
},
hot: true,
port: 8080,
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/bridge-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* @flow
*/

import type { WallEvent } from "../types";describe('Bridge', () => {
import type { WallEvent } from '../types';
describe('Bridge', () => {
let Bridge;

beforeEach(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* @flow
*/

import type { WallEvent } from "../types";describe('Store', () => {
import type { WallEvent } from '../types';
describe('Store', () => {
let Store;
let Bridge;

Expand Down
23 changes: 9 additions & 14 deletions src/backend/EnvironmentWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,14 @@ export function attach(
function flushInitialOperations() {
// TODO(damassart): Make this a modular function
if (pendingEventsQueue != null) {
pendingEventsQueue.forEach(
pendingEvent => {
hook.emit(
'environment.event',
{
id: rendererID,
envName: environment.configName,
data: pendingEvent,
eventType: 'environment',
},
);
},
);
pendingEventsQueue.forEach(pendingEvent => {
hook.emit('environment.event', {
id: rendererID,
envName: environment.configName,
data: pendingEvent,
eventType: 'environment',
});
});
pendingEventsQueue = null;
}
sendStoreRecords();
Expand All @@ -111,6 +106,6 @@ export function attach(
return {
cleanup,
sendStoreRecords,
flushInitialOperations
flushInitialOperations,
};
}
4 changes: 3 additions & 1 deletion src/devtools/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ function getEntriesForResource(
if (entriesForResource === undefined) {
const config = resourceConfigs.get(resource);
entriesForResource =
config !== undefined && config.useWeakMap ? (new WeakMap(): $FlowFixMe) : new Map();
config !== undefined && config.useWeakMap
? (new WeakMap(): $FlowFixMe)
: new Map();
entries.set(resource, entriesForResource);
}
return entriesForResource;
Expand Down
5 changes: 4 additions & 1 deletion src/devtools/views/ButtonIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ function getPathData(type: IconType) {
}
}

export default function ButtonIcon({ className = '', type }: Props): React$MixedElement {
export default function ButtonIcon({
className = '',
type,
}: Props): React$MixedElement {
const pathData = getPathData(type);
return (
<svg
Expand Down
15 changes: 10 additions & 5 deletions src/devtools/views/Components/KeyValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* @flow
*/

import type { Element as $IMPORTED_TYPE$_Element } from "react";import React, { useState } from 'react';
import type { Element as $IMPORTED_TYPE$_Element } from 'react';
import React, { useState } from 'react';
import type { Element } from 'react';
// import EditableValue from './EditableValue';
import ExpandCollapseToggle from './ExpandCollapseToggle';
Expand All @@ -32,9 +33,9 @@ export default function KeyValue({
value,
}: KeyValueProps):
| any
| $IMPORTED_TYPE$_Element<"div">
| $IMPORTED_TYPE$_Element<'div'>
| Array<Element<any>>
| Array<any | $IMPORTED_TYPE$_Element<"div">> {
| Array<any | $IMPORTED_TYPE$_Element<'div'>> {
const [isOpen, setIsOpen] = useState<boolean>(false);
const [wasOpen, setWasOpen] = useState<boolean>(isOpen);
if (isOpen && !wasOpen) {
Expand Down Expand Up @@ -77,7 +78,9 @@ export default function KeyValue({
if (Array.isArray(value)) {
const hasChildren = value.length > 0;

const children: any | Array<any | $IMPORTED_TYPE$_Element<"div">> = wasOpen
const children:
| any
| Array<any | $IMPORTED_TYPE$_Element<'div'>> = wasOpen
? value.map((innerValue, index) => (
<KeyValue
key={index}
Expand Down Expand Up @@ -125,7 +128,9 @@ export default function KeyValue({
const hasChildren = entries.length > 0;
const displayName = 'Object';

const children: Array<Element<any>> | Array<any | $IMPORTED_TYPE$_Element<"div">> = wasOpen
const children:
| Array<Element<any>>
| Array<any | $IMPORTED_TYPE$_Element<'div'>> = wasOpen
? entries.map(([entriesName, entriesVal]) => (
<KeyValue
key={entriesName}
Expand Down
5 changes: 4 additions & 1 deletion src/devtools/views/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ function getPathData(type: IconType) {
}
}

export default function Icon({ className = '', type }: Props): React$MixedElement {
export default function Icon({
className = '',
type,
}: Props): React$MixedElement {
const pathData = getPathData(type);
const circlePathData =
pathData === PATH_GITHUB_FEEDBACK ? PATH_GITHUB_CIRCLE : null;
Expand Down
2 changes: 1 addition & 1 deletion src/devtools/views/ModalDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function ModalDialogContextController({ children }: Props): React$MixedElement {
);
}

function ModalDialog(_: {||}): React$MixedElement | null {
function ModalDialog(_: {||}): React$MixedElement | null {
const { isVisible } = useContext(ModalDialogContext);
return isVisible ? <ModalDialogImpl /> : null;
}
Expand Down
5 changes: 4 additions & 1 deletion src/devtools/views/Network/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ function appearsInResponse(searchText: string, response: Object): boolean {
return false;
}

function Network(props: {| +portalContainer: mixed, currentEnvID: ?number |}): React$MixedElement | null {
function Network(props: {|
+portalContainer: mixed,
currentEnvID: ?number,
|}): React$MixedElement | null {
const store = useContext(StoreContext);

const [, forceUpdate] = useState({});
Expand Down
4 changes: 2 additions & 2 deletions src/devtools/views/Settings/GeneralSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default function GeneralSettings(_: {||}): React$MixedElement {
);

const updateDisplayDensity = useCallback(
({currentTarget}: any) => {
({ currentTarget }: any) => {
setDisplayDensity(currentTarget.value);
},
[setDisplayDensity]
);
const updateTheme = useCallback(
({currentTarget}: any) => {
({ currentTarget }: any) => {
setTheme(currentTarget.value);
},
[setTheme]
Expand Down
4 changes: 3 additions & 1 deletion src/devtools/views/Settings/SettingsContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ type Context = {|
setTheme(value: Theme): void,
|};

const SettingsContext: $FlowFixMe = createContext<Context>(((null: any): Context));
const SettingsContext: $FlowFixMe = createContext<Context>(
((null: any): Context)
);
SettingsContext.displayName = 'SettingsContext';

type DocumentElements = Array<HTMLElement>;
Expand Down
4 changes: 3 additions & 1 deletion src/devtools/views/Settings/SettingsModalContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ type Context = {
setIsModalShowing: (value: boolean) => void,
};

const SettingsModalContext: $FlowFixMe = createContext<Context>(((null: any): Context));
const SettingsModalContext: $FlowFixMe = createContext<Context>(
((null: any): Context)
);
SettingsModalContext.displayName = 'SettingsModalContext';

function SettingsModalContextController({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ const networkEventNames = [
'network.unsubscribe',
];

function eventsAreLinked(events: any | $ReadOnlyArray<LogEvent>, selectedEventID: any | number, index: any | number) {
function eventsAreLinked(
events: any | $ReadOnlyArray<LogEvent>,
selectedEventID: any | number,
index: any | number
) {
const currentEvent = events[index];
const selectedEvent = events[selectedEventID];
return (
Expand Down Expand Up @@ -81,7 +85,7 @@ function StoreEventDisplay({
events: $ReadOnlyArray<LogEvent>,
index: number,
selectedEventID: number,
setSelectedEventID: (number) => void,
setSelectedEventID: number => void,
|}) {
return (
<div
Expand Down
Loading

0 comments on commit a19aabc

Please sign in to comment.