diff --git a/package.json b/package.json index a77d34ecfd..1d5311490a 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "eslint-plugin-flowtype": "^2.40.0", "eslint-plugin-header": "^1.0.0", "eslint-plugin-prettier": "^2.1.2", + "flow-bin": "^0.83.0", "flow-typed": "^2.3.0", "graceful-fs": "^4.1.11", "invariant": "^2.2.0", diff --git a/src/debugger/adapter/DebugAdapter.js b/src/debugger/adapter/DebugAdapter.js index e8e63d04d2..77baf71d15 100644 --- a/src/debugger/adapter/DebugAdapter.js +++ b/src/debugger/adapter/DebugAdapter.js @@ -25,7 +25,7 @@ import { DebuggerError } from "./../common/DebuggerError.js"; /* An implementation of an debugger adapter adhering to the VSCode Debug protocol * The adapter is responsible for communication between the UI and Prepack -*/ + */ class PrepackDebugSession extends DebugSession { /** * Creates a new debug adapter that is used for one debug session. diff --git a/src/debugger/mock-ui/UISession.js b/src/debugger/mock-ui/UISession.js index a9385913c1..ee577d4170 100644 --- a/src/debugger/mock-ui/UISession.js +++ b/src/debugger/mock-ui/UISession.js @@ -29,7 +29,7 @@ const TWO_CRLF = "\r\n\r\n"; /* Represents one debugging session in the CLI. * Read in user input from the command line, parses the input into commands, * sends the commands to the adapter and process any responses -*/ + */ export class UISession { constructor(proc: Process, args: DebuggerCLIArguments) { this._proc = proc; diff --git a/src/debugger/mock-ui/debugger-cli.js b/src/debugger/mock-ui/debugger-cli.js index 82b862e924..a9e3cbe04a 100644 --- a/src/debugger/mock-ui/debugger-cli.js +++ b/src/debugger/mock-ui/debugger-cli.js @@ -13,7 +13,7 @@ import { UISession } from "./UISession.js"; import type { DebuggerCLIArguments } from "./UISession.js"; /* The entry point to start up the debugger CLI * Reads in command line arguments and starts up a UISession -*/ + */ function run(process, console) { let args = readCLIArguments(process, console); diff --git a/src/methods/get.js b/src/methods/get.js index 3164d72d33..6f450c08e9 100644 --- a/src/methods/get.js +++ b/src/methods/get.js @@ -234,8 +234,8 @@ export function OrdinaryGet( let descValue = !desc ? realm.intrinsics.undefined : desc.value === undefined - ? realm.intrinsics.undefined - : desc.value; + ? realm.intrinsics.undefined + : desc.value; invariant(descValue instanceof Value); // 3. If desc is undefined, then diff --git a/src/methods/hash.js b/src/methods/hash.js index d2dd292702..1b67f2bc05 100644 --- a/src/methods/hash.js +++ b/src/methods/hash.js @@ -76,7 +76,9 @@ export function hashUnary(op: BabelUnaryOperator, x: Hashable): number { return (hashString(op) * 13) ^ x.getHash(); } -interface Equatable { equals(x: any): boolean } +interface Equatable { + equals(x: any): boolean; +} export class HashSet { constructor(expectedEntries?: number = 32 * 1024) { diff --git a/src/methods/properties.js b/src/methods/properties.js index dc44eba43e..405f5b83eb 100644 --- a/src/methods/properties.js +++ b/src/methods/properties.js @@ -407,8 +407,8 @@ export class PropertiesImplementation { let existingDescValue = !existingDescriptor ? realm.intrinsics.undefined : existingDescriptor.value === undefined - ? realm.intrinsics.undefined - : existingDescriptor.value; + ? realm.intrinsics.undefined + : existingDescriptor.value; invariant(existingDescValue instanceof Value); // d. If existingDescriptor is not undefined, then diff --git a/src/react/reconcilation.js b/src/react/reconcilation.js index 6e21398869..6e38f9e515 100644 --- a/src/react/reconcilation.js +++ b/src/react/reconcilation.js @@ -201,8 +201,8 @@ export class Reconciler { let effects; try { this.realm.react.activeReconciler = this; - effects = this.realm.wrapInGlobalEnv( - () => (this.realm.isInPureScope() ? funcCall() : this.realm.evaluateWithPureScope(funcCall)) + effects = this.realm.wrapInGlobalEnv(() => + this.realm.isInPureScope() ? funcCall() : this.realm.evaluateWithPureScope(funcCall) ); } catch (e) { this._handleComponentTreeRootFailure(e, evaluatedRootNode); diff --git a/src/types.js b/src/types.js index c3e7785adc..df57076336 100644 --- a/src/types.js +++ b/src/types.js @@ -368,7 +368,7 @@ export type PathType = { export class PathConditions { add(c: AbstractValue): void {} - equals(x: PathConditions): boolean { + equates(x: PathConditions): boolean { return false; } diff --git a/src/utils/generator.js b/src/utils/generator.js index 750c7c29e7..fa370cca68 100644 --- a/src/utils/generator.js +++ b/src/utils/generator.js @@ -1218,8 +1218,8 @@ export class Generator { let [entryGenerator1, entryGenerator2] = operationDescriptor.data.generators; let [thisLastEntryGenerator1, thisLastEntryGenerator2] = thisLastEntryOperationDescriptor.data.generators; if ( - entryGenerator1.pathConditions.equals(thisLastEntryGenerator1.pathConditions) && - entryGenerator2.pathConditions.equals(thisLastEntryGenerator2.pathConditions) + entryGenerator1.pathConditions.equates(thisLastEntryGenerator1.pathConditions) && + entryGenerator2.pathConditions.equates(thisLastEntryGenerator2.pathConditions) ) { if (!entryGenerator1.empty()) entryGenerator1._entries.forEach(e => thisLastEntryGenerator1._entries.push(e)); diff --git a/src/utils/logger.js b/src/utils/logger.js index 92042222e3..c7a643b54e 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -96,9 +96,9 @@ export class Logger { let message = object.properties.get("message"); console.error( message && - message.descriptor && - message.descriptor instanceof PropertyDescriptor && - message.descriptor.value instanceof StringValue + message.descriptor && + message.descriptor instanceof PropertyDescriptor && + message.descriptor.value instanceof StringValue ? message.descriptor.value.value : "(no message available)" ); diff --git a/src/utils/paths.js b/src/utils/paths.js index 208af12a85..f90ae3d1dc 100644 --- a/src/utils/paths.js +++ b/src/utils/paths.js @@ -41,30 +41,21 @@ export class PathConditionsImplementation extends PathConditions { this._failedNegativeImplications = undefined; } - // It makes the strong assumption that, in order for 2 path conditions to be equal, - // the number of values must be the same, as well as their order. - // This might not always be the case, yielding false negatives?! - equals(x: PathConditions): boolean { + // this <=> x + equates(x: PathConditions): boolean { invariant(x instanceof PathConditionsImplementation); - let conditionsAreEqual = () => { - if (this._assumedConditions.size !== x._assumedConditions.size) return false; - let thisConditions = Array.from(this._assumedConditions); - let xConditions = Array.from(x._assumedConditions); - let thisLength = thisConditions.length; - for (let i = 0; i < thisLength; i++) { - let thisCondition = thisConditions[i]; - let xCondition = xConditions[i]; - if (!thisCondition.equals(xCondition)) return false; - } - return true; - }; - let baseConditionsAreEqual = () => { - if (this._baseConditions && !x._baseConditions) return false; - if (!this._baseConditions && x._baseConditions) return false; - if (this._baseConditions && x._baseConditions) return this._baseConditions.equals(x._baseConditions); - return true; - }; - return this === x || (conditionsAreEqual() && baseConditionsAreEqual()); + if (this === x) return true; + function* assumedConditionsDeep(pc: PathConditionsImplementation) { + for (let condition of pc._assumedConditions) yield condition; + if (pc._baseConditions !== undefined) yield* assumedConditionsDeep(pc._baseConditions); + } + for (let xCondition of assumedConditionsDeep(x)) { + if (!this.implies(xCondition)) return false; + } + for (let thisCondition of assumedConditionsDeep(this)) { + if (!x.implies(thisCondition)) return false; + } + return true; } isReadOnly(): boolean { diff --git a/src/values/AbstractObjectValue.js b/src/values/AbstractObjectValue.js index d722ba27a2..405ceb40dc 100644 --- a/src/values/AbstractObjectValue.js +++ b/src/values/AbstractObjectValue.js @@ -417,8 +417,8 @@ export default class AbstractObjectValue extends AbstractValue { Desc.configurable !== undefined ? Desc.configurable : firstExistingDesc - ? firstExistingDesc.configurable - : false, + ? firstExistingDesc.configurable + : false, }); let newVal = desc.value; if (this.kind === "conditional") { diff --git a/test/react/FBMocks/fb8.js b/test/react/FBMocks/fb8.js index 5b91a177c8..793f4cf410 100644 --- a/test/react/FBMocks/fb8.js +++ b/test/react/FBMocks/fb8.js @@ -38,7 +38,8 @@ module.exports = this.__evaluatePureFunction(() => { function App() { return ( - This contains a ReactRelay container: + This contains a ReactRelay container: + ); } diff --git a/test/react/FBMocks/hacker-news.js b/test/react/FBMocks/hacker-news.js index 8781b313b9..877d323603 100644 --- a/test/react/FBMocks/hacker-news.js +++ b/test/react/FBMocks/hacker-news.js @@ -109,7 +109,9 @@ module.exports = this.__evaluatePureFunction(() => { {// we use Array.from to tell the compiler that this // is definitely an array object - Array.from(stories).map((story, i) => )} + Array.from(stories).map((story, i) => ( + + ))} diff --git a/test/react/FBMocks/repl-example.js b/test/react/FBMocks/repl-example.js index b9758186bb..b1968a05b4 100644 --- a/test/react/FBMocks/repl-example.js +++ b/test/react/FBMocks/repl-example.js @@ -25,7 +25,13 @@ function Foo(props: { href: string }) { { href: props.href, name: "Third Item" }, ]; - return
{collection.map(item => )}
; + return ( +
+ {collection.map(item => ( + + ))} +
+ ); } // this is a special Prepack function hook diff --git a/test/react/FirstRenderOnly/get-derived-state-from-props.js b/test/react/FirstRenderOnly/get-derived-state-from-props.js index a11eecd80c..1cf749f138 100644 --- a/test/react/FirstRenderOnly/get-derived-state-from-props.js +++ b/test/react/FirstRenderOnly/get-derived-state-from-props.js @@ -14,7 +14,9 @@ class Child2 extends React.Component { render() { return ( - {Array.from(this.props.items).map(item => )} + {Array.from(this.props.items).map(item => ( + + ))} {this.randomVar.text} ); diff --git a/test/react/FirstRenderOnly/get-derived-state-from-props2.js b/test/react/FirstRenderOnly/get-derived-state-from-props2.js index 3943d0a4ba..ba9b82337f 100644 --- a/test/react/FirstRenderOnly/get-derived-state-from-props2.js +++ b/test/react/FirstRenderOnly/get-derived-state-from-props2.js @@ -14,7 +14,9 @@ class Child2 extends React.Component { render() { return ( - {Array.from(this.props.items).map(item => )} + {Array.from(this.props.items).map(item => ( + + ))} {this.randomVar.text} ); diff --git a/test/react/FirstRenderOnly/get-derived-state-from-props3.js b/test/react/FirstRenderOnly/get-derived-state-from-props3.js index 0c6a0376fd..f8cd43ad96 100644 --- a/test/react/FirstRenderOnly/get-derived-state-from-props3.js +++ b/test/react/FirstRenderOnly/get-derived-state-from-props3.js @@ -14,7 +14,9 @@ class Child2 extends React.Component { render() { return ( - {Array.from(this.props.items).map(item => )} + {Array.from(this.props.items).map(item => ( + + ))} {this.randomVar.text} ); diff --git a/test/react/FirstRenderOnly/get-derived-state-from-props4.js b/test/react/FirstRenderOnly/get-derived-state-from-props4.js index 44bdf75642..65a721883b 100644 --- a/test/react/FirstRenderOnly/get-derived-state-from-props4.js +++ b/test/react/FirstRenderOnly/get-derived-state-from-props4.js @@ -14,7 +14,9 @@ class Child2 extends React.Component { render() { return ( - {Array.from(this.props.items).map(item => )} + {Array.from(this.props.items).map(item => ( + + ))} {this.randomVar.text} ); diff --git a/test/react/FirstRenderOnly/simple.js b/test/react/FirstRenderOnly/simple.js index 7d8b726d34..6e006504cc 100644 --- a/test/react/FirstRenderOnly/simple.js +++ b/test/react/FirstRenderOnly/simple.js @@ -14,7 +14,9 @@ class Child2 extends React.Component { render() { return ( - {Array.from(this.props.items).map(item => )} + {Array.from(this.props.items).map(item => ( + + ))} {this.randomVar.text} ); diff --git a/test/react/FirstRenderOnly/will-mount.js b/test/react/FirstRenderOnly/will-mount.js index 8b996a195e..21ae00957b 100644 --- a/test/react/FirstRenderOnly/will-mount.js +++ b/test/react/FirstRenderOnly/will-mount.js @@ -14,7 +14,9 @@ class Child2 extends React.Component { render() { return ( - {Array.from(this.props.items).map(item => )} + {Array.from(this.props.items).map(item => ( + + ))} {this.randomVar.text} ); diff --git a/test/react/FunctionalComponents/array-map.js b/test/react/FunctionalComponents/array-map.js index f74d3974dc..28c90bfb40 100644 --- a/test/react/FunctionalComponents/array-map.js +++ b/test/react/FunctionalComponents/array-map.js @@ -5,7 +5,13 @@ function A(props) { } function App(props) { - return
{Array.from(props.items).map(item => )}
; + return ( +
+ {Array.from(props.items).map(item => ( + + ))} +
+ ); } App.getTrials = function(renderer, Root) { diff --git a/test/react/FunctionalComponents/array-map2.js b/test/react/FunctionalComponents/array-map2.js index 541afbe7b9..3daec3a19b 100644 --- a/test/react/FunctionalComponents/array-map2.js +++ b/test/react/FunctionalComponents/array-map2.js @@ -5,7 +5,13 @@ function A(props) { } function App(props) { - return
{Array.from(props.items, item => )}
; + return ( +
+ {Array.from(props.items, item => ( + + ))} +
+ ); } App.getTrials = function(renderer, Root) { diff --git a/test/react/ServerRendering/hacker-news.js b/test/react/ServerRendering/hacker-news.js index 5c0ed04e6e..e2eb341567 100644 --- a/test/react/ServerRendering/hacker-news.js +++ b/test/react/ServerRendering/hacker-news.js @@ -103,7 +103,9 @@ function StoryList({ stories }) { {// we use Array.from to tell the compiler that this // is definitely an array object - Array.from(stories).map((story, i) => )} + Array.from(stories).map((story, i) => ( + + ))} diff --git a/test/serializer/abstract/ListOperationsCommentBubble.js b/test/serializer/abstract/ListOperationsCommentBubble.js index 8bee202e3f..290af8f022 100644 --- a/test/serializer/abstract/ListOperationsCommentBubble.js +++ b/test/serializer/abstract/ListOperationsCommentBubble.js @@ -4,11 +4,13 @@ function createAttributedComment(props) { let ranges; if (body && body.ranges) { - _ranges = body.ranges.filter(r => r.entity.__typename).map(r => ({ - location: Number(r.offset), - length: Number(r.length), - decorationLine: r.entity.__typename.includes("User") ? "none" : "underline", - })); + _ranges = body.ranges + .filter(r => r.entity.__typename) + .map(r => ({ + location: Number(r.offset), + length: Number(r.length), + decorationLine: r.entity.__typename.includes("User") ? "none" : "underline", + })); } else { _ranges = []; } diff --git a/yarn.lock b/yarn.lock index 2a32f90faa..45c23ea7fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4172,6 +4172,11 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" +flow-bin@^0.83.0: + version "0.83.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.83.0.tgz#fd26f5f95758d7701264b3f9a1e1a3d4cbcab1a9" + integrity sha512-1K83EL/U9Gh0BaXPKkZe6TRizSmNSKx9Wuws1c8gh7DJEwiburtCxYT+4o7in1+GnNEm3CZWnbnVV8n9HMpiDA== + flow-typed@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/flow-typed/-/flow-typed-2.3.0.tgz#0f8604faab60691b885024e16ec0e3256e3b680e"