From 2da60a8f45c5bc4d498b9ef87eb754aafb93af01 Mon Sep 17 00:00:00 2001 From: empyrical Date: Tue, 25 Sep 2018 19:37:32 -0700 Subject: [PATCH] Prettify remaining unprettified files (#21327) Summary: This PR is the result of running `yarn prettify` on the codebase - which caught a few files that were not prettified. This will make instructing people to run prettify a bit less complicated, since unrelated files will not show up in diffs. Pull Request resolved: https://github.com/facebook/react-native/pull/21327 Differential Revision: D10046057 Pulled By: TheSavior fbshipit-source-id: 2c771a3c758c72816c707e32ee2f4587e466f277 --- Libraries/Components/ScrollView/ScrollView.js | 6 +- Libraries/Components/TextInput/TextInput.js | 3 +- Libraries/Image/Image.ios.js | 4 +- RNTester/js/ImageExample.js | 41 +- flow/jest.js | 721 +++++++++--------- .../__tests__/getAssetDestPathAndroid-test.js | 4 +- .../__tests__/getAssetDestPathIOS-test.js | 12 +- local-cli/generator/templates.js | 6 +- local-cli/init/init.js | 4 +- 9 files changed, 418 insertions(+), 383 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 0030ac329..a8b462911 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -218,9 +218,9 @@ type IOSProps = $ReadOnly<{| */ scrollsToTop?: ?boolean, /** - * Fires when the scroll view scrolls to top after the status bar has been tapped - * @platform ios - */ + * Fires when the scroll view scrolls to top after the status bar has been tapped + * @platform ios + */ onScrollToTop?: ?Function, /** * When true, shows a horizontal scroll indicator. diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 43a545881..97590c9ab 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -949,8 +949,7 @@ const TextInput = createReactClass({ + maxFontSizeMultiplier={props.maxFontSizeMultiplier}> {children} ); diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index c318c8049..07e34b922 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -45,7 +45,9 @@ function prefetch(url: string) { return ImageViewManager.prefetchImage(url); } -async function queryCache(urls: Array): Promise> { +async function queryCache( + urls: Array, +): Promise> { return await ImageViewManager.queryCache(urls); } diff --git a/RNTester/js/ImageExample.js b/RNTester/js/ImageExample.js index f342d1a5a..830978f46 100644 --- a/RNTester/js/ImageExample.js +++ b/RNTester/js/ImageExample.js @@ -77,11 +77,12 @@ var NetworkImageCallbackExample = createReactClass({ this._loadEventFired( `✔ Prefetch OK (+${new Date() - mountTime}ms)`, ); - Image.queryCache([IMAGE_PREFETCH_URL]).then((map) => { + Image.queryCache([IMAGE_PREFETCH_URL]).then(map => { var result = map.get(IMAGE_PREFETCH_URL); if (result) { this._loadEventFired( - `✔ queryCache "${result}" (+${new Date() - mountTime}ms)`, + `✔ queryCache "${result}" (+${new Date() - + mountTime}ms)`, ); } else { this._loadEventFired( @@ -460,23 +461,31 @@ exports.examples = [ source={fullImage} /> diff --git a/flow/jest.js b/flow/jest.js index b1e62053a..d26ab844e 100644 --- a/flow/jest.js +++ b/flow/jest.js @@ -32,7 +32,7 @@ type JestMockFn, TReturn> = { * An array that contains all the object results that have been * returned by this mock function call */ - results: Array<{ isThrow: boolean, value: TReturn }> + results: Array<{isThrow: boolean, value: TReturn}>, }, /** * Resets all information stored in the mockFn.mock.calls and @@ -60,7 +60,7 @@ type JestMockFn, TReturn> = { * will also be executed when the mock is called. */ mockImplementation( - fn: (...args: TArguments) => TReturn + fn: (...args: TArguments) => TReturn, ): JestMockFn, /** * Accepts a function that will be used as an implementation of the mock for @@ -68,7 +68,7 @@ type JestMockFn, TReturn> = { * calls produce different results. */ mockImplementationOnce( - fn: (...args: TArguments) => TReturn + fn: (...args: TArguments) => TReturn, ): JestMockFn, /** * Accepts a string to use in test result output in place of "jest.fn()" to @@ -94,7 +94,9 @@ type JestMockFn, TReturn> = { /** * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) */ - mockResolvedValueOnce(value: TReturn): JestMockFn>, + mockResolvedValueOnce( + value: TReturn, + ): JestMockFn>, /** * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) */ @@ -102,14 +104,14 @@ type JestMockFn, TReturn> = { /** * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) */ - mockRejectedValueOnce(value: TReturn): JestMockFn> + mockRejectedValueOnce(value: TReturn): JestMockFn>, }; type JestAsymmetricEqualityType = { /** * A custom Jasmine equality tester */ - asymmetricMatch(value: mixed): boolean + asymmetricMatch(value: mixed): boolean, }; type JestCallsType = { @@ -119,24 +121,25 @@ type JestCallsType = { count(): number, first(): mixed, mostRecent(): mixed, - reset(): void + reset(): void, }; type JestClockType = { install(): void, mockDate(date: Date): void, tick(milliseconds?: number): void, - uninstall(): void + uninstall(): void, }; type JestMatcherResult = { message?: string | (() => string), - pass: boolean + pass: boolean, }; -type JestMatcher = (actual: any, expected: any) => - | JestMatcherResult - | Promise; +type JestMatcher = ( + actual: any, + expected: any, +) => JestMatcherResult | Promise; type JestPromiseType = { /** @@ -148,7 +151,7 @@ type JestPromiseType = { * Use resolves to unwrap the value of a fulfilled promise so any other * matcher can be chained. If the promise is rejected the assertion fails. */ - resolves: JestExpectType + resolves: JestExpectType, }; /** @@ -168,16 +171,16 @@ type JestStyledComponentsMatcherValue = | typeof undefined; type JestStyledComponentsMatcherOptions = { - media?: string; - modifier?: string; - supports?: string; -} + media?: string, + modifier?: string, + supports?: string, +}; type JestStyledComponentsMatchersType = { toHaveStyleRule( property: string, value: JestStyledComponentsMatcherValue, - options?: JestStyledComponentsMatcherOptions + options?: JestStyledComponentsMatcherOptions, ): void, }; @@ -194,23 +197,26 @@ type EnzymeMatchersType = { toExist(): void, toHaveClassName(className: string): void, toHaveHTML(html: string): void, - toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), + toHaveProp: ((propKey: string, propValue?: any) => void) & + ((props: Object) => void), toHaveRef(refName: string): void, - toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), - toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), + toHaveState: ((stateKey: string, stateValue?: any) => void) & + ((state: Object) => void), + toHaveStyle: ((styleKey: string, styleValue?: any) => void) & + ((style: Object) => void), toHaveTagName(tagName: string): void, toHaveText(text: string): void, toIncludeText(text: string): void, toHaveValue(value: any): void, toMatchElement(element: React$Element): void, - toMatchSelector(selector: string): void + toMatchSelector(selector: string): void, }; // DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers type DomTestingLibraryType = { toBeInTheDOM(): void, toHaveTextContent(content: string): void, - toHaveAttribute(name: string, expectedValue?: string): void + toHaveAttribute(name: string, expectedValue?: string): void, }; // Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers @@ -236,409 +242,407 @@ type JestJQueryMatchersType = { toBeInDom(): void, toBeMatchedBy(sel: string): void, toHaveDescendant(sel: string): void, - toHaveDescendantWithText(sel: string, text: string | RegExp): void + toHaveDescendantWithText(sel: string, text: string | RegExp): void, }; - // Jest Extended Matchers: https://github.com/jest-community/jest-extended type JestExtendedMatchersType = { /** - * Note: Currently unimplemented - * Passing assertion - * - * @param {String} message - */ + * Note: Currently unimplemented + * Passing assertion + * + * @param {String} message + */ // pass(message: string): void; - /** - * Note: Currently unimplemented - * Failing assertion - * - * @param {String} message - */ + /** + * Note: Currently unimplemented + * Failing assertion + * + * @param {String} message + */ // fail(message: string): void; - /** - * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. - */ - toBeEmpty(): void; + /** + * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. + */ + toBeEmpty(): void, - /** - * Use .toBeOneOf when checking if a value is a member of a given Array. - * @param {Array.<*>} members - */ - toBeOneOf(members: any[]): void; + /** + * Use .toBeOneOf when checking if a value is a member of a given Array. + * @param {Array.<*>} members + */ + toBeOneOf(members: any[]): void, - /** - * Use `.toBeNil` when checking a value is `null` or `undefined`. - */ - toBeNil(): void; + /** + * Use `.toBeNil` when checking a value is `null` or `undefined`. + */ + toBeNil(): void, - /** - * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. - * @param {Function} predicate - */ - toSatisfy(predicate: (n: any) => boolean): void; + /** + * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. + * @param {Function} predicate + */ + toSatisfy(predicate: (n: any) => boolean): void, - /** - * Use `.toBeArray` when checking if a value is an `Array`. - */ - toBeArray(): void; + /** + * Use `.toBeArray` when checking if a value is an `Array`. + */ + toBeArray(): void, - /** - * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. - * @param {Number} x - */ - toBeArrayOfSize(x: number): void; + /** + * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. + * @param {Number} x + */ + toBeArrayOfSize(x: number): void, - /** - * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. - * @param {Array.<*>} members - */ - toIncludeAllMembers(members: any[]): void; + /** + * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. + * @param {Array.<*>} members + */ + toIncludeAllMembers(members: any[]): void, - /** - * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. - * @param {Array.<*>} members - */ - toIncludeAnyMembers(members: any[]): void; + /** + * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. + * @param {Array.<*>} members + */ + toIncludeAnyMembers(members: any[]): void, - /** - * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. - * @param {Function} predicate - */ - toSatisfyAll(predicate: (n: any) => boolean): void; + /** + * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. + * @param {Function} predicate + */ + toSatisfyAll(predicate: (n: any) => boolean): void, - /** - * Use `.toBeBoolean` when checking if a value is a `Boolean`. - */ - toBeBoolean(): void; + /** + * Use `.toBeBoolean` when checking if a value is a `Boolean`. + */ + toBeBoolean(): void, - /** - * Use `.toBeTrue` when checking a value is equal (===) to `true`. - */ - toBeTrue(): void; + /** + * Use `.toBeTrue` when checking a value is equal (===) to `true`. + */ + toBeTrue(): void, - /** - * Use `.toBeFalse` when checking a value is equal (===) to `false`. - */ - toBeFalse(): void; + /** + * Use `.toBeFalse` when checking a value is equal (===) to `false`. + */ + toBeFalse(): void, - /** - * Use .toBeDate when checking if a value is a Date. - */ - toBeDate(): void; + /** + * Use .toBeDate when checking if a value is a Date. + */ + toBeDate(): void, - /** - * Use `.toBeFunction` when checking if a value is a `Function`. - */ - toBeFunction(): void; + /** + * Use `.toBeFunction` when checking if a value is a `Function`. + */ + toBeFunction(): void, - /** - * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. - * - * Note: Required Jest version >22 - * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same - * - * @param {Mock} mock - */ - toHaveBeenCalledBefore(mock: JestMockFn): void; + /** + * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. + * + * Note: Required Jest version >22 + * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same + * + * @param {Mock} mock + */ + toHaveBeenCalledBefore(mock: JestMockFn): void, - /** - * Use `.toBeNumber` when checking if a value is a `Number`. - */ - toBeNumber(): void; + /** + * Use `.toBeNumber` when checking if a value is a `Number`. + */ + toBeNumber(): void, - /** - * Use `.toBeNaN` when checking a value is `NaN`. - */ - toBeNaN(): void; + /** + * Use `.toBeNaN` when checking a value is `NaN`. + */ + toBeNaN(): void, - /** - * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. - */ - toBeFinite(): void; + /** + * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. + */ + toBeFinite(): void, - /** - * Use `.toBePositive` when checking if a value is a positive `Number`. - */ - toBePositive(): void; + /** + * Use `.toBePositive` when checking if a value is a positive `Number`. + */ + toBePositive(): void, - /** - * Use `.toBeNegative` when checking if a value is a negative `Number`. - */ - toBeNegative(): void; + /** + * Use `.toBeNegative` when checking if a value is a negative `Number`. + */ + toBeNegative(): void, - /** - * Use `.toBeEven` when checking if a value is an even `Number`. - */ - toBeEven(): void; + /** + * Use `.toBeEven` when checking if a value is an even `Number`. + */ + toBeEven(): void, - /** - * Use `.toBeOdd` when checking if a value is an odd `Number`. - */ - toBeOdd(): void; + /** + * Use `.toBeOdd` when checking if a value is an odd `Number`. + */ + toBeOdd(): void, - /** - * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). - * - * @param {Number} start - * @param {Number} end - */ - toBeWithin(start: number, end: number): void; + /** + * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). + * + * @param {Number} start + * @param {Number} end + */ + toBeWithin(start: number, end: number): void, - /** - * Use `.toBeObject` when checking if a value is an `Object`. - */ - toBeObject(): void; + /** + * Use `.toBeObject` when checking if a value is an `Object`. + */ + toBeObject(): void, - /** - * Use `.toContainKey` when checking if an object contains the provided key. - * - * @param {String} key - */ - toContainKey(key: string): void; + /** + * Use `.toContainKey` when checking if an object contains the provided key. + * + * @param {String} key + */ + toContainKey(key: string): void, - /** - * Use `.toContainKeys` when checking if an object has all of the provided keys. - * - * @param {Array.} keys - */ - toContainKeys(keys: string[]): void; + /** + * Use `.toContainKeys` when checking if an object has all of the provided keys. + * + * @param {Array.} keys + */ + toContainKeys(keys: string[]): void, - /** - * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. - * - * @param {Array.} keys - */ - toContainAllKeys(keys: string[]): void; + /** + * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. + * + * @param {Array.} keys + */ + toContainAllKeys(keys: string[]): void, - /** - * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. - * - * @param {Array.} keys - */ - toContainAnyKeys(keys: string[]): void; + /** + * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. + * + * @param {Array.} keys + */ + toContainAnyKeys(keys: string[]): void, - /** - * Use `.toContainValue` when checking if an object contains the provided value. - * - * @param {*} value - */ - toContainValue(value: any): void; + /** + * Use `.toContainValue` when checking if an object contains the provided value. + * + * @param {*} value + */ + toContainValue(value: any): void, - /** - * Use `.toContainValues` when checking if an object contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainValues(values: any[]): void; + /** + * Use `.toContainValues` when checking if an object contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainValues(values: any[]): void, - /** - * Use `.toContainAllValues` when checking if an object only contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainAllValues(values: any[]): void; + /** + * Use `.toContainAllValues` when checking if an object only contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainAllValues(values: any[]): void, - /** - * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. - * - * @param {Array.<*>} values - */ - toContainAnyValues(values: any[]): void; + /** + * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. + * + * @param {Array.<*>} values + */ + toContainAnyValues(values: any[]): void, - /** - * Use `.toContainEntry` when checking if an object contains the provided entry. - * - * @param {Array.} entry - */ - toContainEntry(entry: [string, string]): void; + /** + * Use `.toContainEntry` when checking if an object contains the provided entry. + * + * @param {Array.} entry + */ + toContainEntry(entry: [string, string]): void, - /** - * Use `.toContainEntries` when checking if an object contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainEntries(entries: [string, string][]): void; + /** + * Use `.toContainEntries` when checking if an object contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainEntries(entries: [string, string][]): void, - /** - * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainAllEntries(entries: [string, string][]): void; + /** + * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainAllEntries(entries: [string, string][]): void, - /** - * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. - * - * @param {Array.>} entries - */ - toContainAnyEntries(entries: [string, string][]): void; + /** + * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. + * + * @param {Array.>} entries + */ + toContainAnyEntries(entries: [string, string][]): void, - /** - * Use `.toBeExtensible` when checking if an object is extensible. - */ - toBeExtensible(): void; + /** + * Use `.toBeExtensible` when checking if an object is extensible. + */ + toBeExtensible(): void, - /** - * Use `.toBeFrozen` when checking if an object is frozen. - */ - toBeFrozen(): void; + /** + * Use `.toBeFrozen` when checking if an object is frozen. + */ + toBeFrozen(): void, - /** - * Use `.toBeSealed` when checking if an object is sealed. - */ - toBeSealed(): void; + /** + * Use `.toBeSealed` when checking if an object is sealed. + */ + toBeSealed(): void, - /** - * Use `.toBeString` when checking if a value is a `String`. - */ - toBeString(): void; + /** + * Use `.toBeString` when checking if a value is a `String`. + */ + toBeString(): void, - /** - * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. - * - * @param {String} string - */ - toEqualCaseInsensitive(string: string): void; + /** + * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. + * + * @param {String} string + */ + toEqualCaseInsensitive(string: string): void, - /** - * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. - * - * @param {String} prefix - */ - toStartWith(prefix: string): void; + /** + * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. + * + * @param {String} prefix + */ + toStartWith(prefix: string): void, - /** - * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. - * - * @param {String} suffix - */ - toEndWith(suffix: string): void; + /** + * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. + * + * @param {String} suffix + */ + toEndWith(suffix: string): void, - /** - * Use `.toInclude` when checking if a `String` includes the given `String` substring. - * - * @param {String} substring - */ - toInclude(substring: string): void; + /** + * Use `.toInclude` when checking if a `String` includes the given `String` substring. + * + * @param {String} substring + */ + toInclude(substring: string): void, - /** - * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. - * - * @param {String} substring - * @param {Number} times - */ - toIncludeRepeated(substring: string, times: number): void; + /** + * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. + * + * @param {String} substring + * @param {Number} times + */ + toIncludeRepeated(substring: string, times: number): void, - /** - * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. - * - * @param {Array.} substring - */ - toIncludeMultiple(substring: string[]): void; + /** + * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. + * + * @param {Array.} substring + */ + toIncludeMultiple(substring: string[]): void, }; interface JestExpectType { - not: - & JestExpectType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, + not: JestExpectType & + EnzymeMatchersType & + DomTestingLibraryType & + JestJQueryMatchersType & + JestStyledComponentsMatchersType & + JestExtendedMatchersType; /** * If you have a mock function, you can use .lastCalledWith to test what * arguments it was last called with. */ - lastCalledWith(...args: Array): void, + lastCalledWith(...args: Array): void; /** * toBe just checks that a value is what you expect. It uses === to check * strict equality. */ - toBe(value: any): void, + toBe(value: any): void; /** * Use .toBeCalledWith to ensure that a mock function was called with * specific arguments. */ - toBeCalledWith(...args: Array): void, + toBeCalledWith(...args: Array): void; /** * Using exact equality with floating point numbers is a bad idea. Rounding * means that intuitive things fail. */ - toBeCloseTo(num: number, delta: any): void, + toBeCloseTo(num: number, delta: any): void; /** * Use .toBeDefined to check that a variable is not undefined. */ - toBeDefined(): void, + toBeDefined(): void; /** * Use .toBeFalsy when you don't care what a value is, you just want to * ensure a value is false in a boolean context. */ - toBeFalsy(): void, + toBeFalsy(): void; /** * To compare floating point numbers, you can use toBeGreaterThan. */ - toBeGreaterThan(number: number): void, + toBeGreaterThan(number: number): void; /** * To compare floating point numbers, you can use toBeGreaterThanOrEqual. */ - toBeGreaterThanOrEqual(number: number): void, + toBeGreaterThanOrEqual(number: number): void; /** * To compare floating point numbers, you can use toBeLessThan. */ - toBeLessThan(number: number): void, + toBeLessThan(number: number): void; /** * To compare floating point numbers, you can use toBeLessThanOrEqual. */ - toBeLessThanOrEqual(number: number): void, + toBeLessThanOrEqual(number: number): void; /** * Use .toBeInstanceOf(Class) to check that an object is an instance of a * class. */ - toBeInstanceOf(cls: Class<*>): void, + toBeInstanceOf(cls: Class<*>): void; /** * .toBeNull() is the same as .toBe(null) but the error messages are a bit * nicer. */ - toBeNull(): void, + toBeNull(): void; /** * Use .toBeTruthy when you don't care what a value is, you just want to * ensure a value is true in a boolean context. */ - toBeTruthy(): void, + toBeTruthy(): void; /** * Use .toBeUndefined to check that a variable is undefined. */ - toBeUndefined(): void, + toBeUndefined(): void; /** * Use .toContain when you want to check that an item is in a list. For * testing the items in the list, this uses ===, a strict equality check. */ - toContain(item: any): void, + toContain(item: any): void; /** * Use .toContainEqual when you want to check that an item is in a list. For * testing the items in the list, this matcher recursively checks the * equality of all fields, rather than checking for object identity. */ - toContainEqual(item: any): void, + toContainEqual(item: any): void; /** * Use .toEqual when you want to check that two objects have the same value. * This matcher recursively checks the equality of all fields, rather than * checking for object identity. */ - toEqual(value: any): void, + toEqual(value: any): void; /** * Use .toHaveBeenCalled to ensure that a mock function got called. */ - toHaveBeenCalled(): void, + toHaveBeenCalled(): void; toBeCalled(): void; /** * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact * number of times. */ - toHaveBeenCalledTimes(number: number): void, + toHaveBeenCalledTimes(number: number): void; toBeCalledTimes(number: number): void; /** * @@ -674,46 +678,52 @@ interface JestExpectType { * Use .toHaveBeenCalledWith to ensure that a mock function was called with * specific arguments. */ - toHaveBeenCalledWith(...args: Array): void, - toBeCalledWith(...args: Array): void, + toHaveBeenCalledWith(...args: Array): void; + toBeCalledWith(...args: Array): void; /** * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called * with specific arguments. */ - toHaveBeenLastCalledWith(...args: Array): void, - lastCalledWith(...args: Array): void, + toHaveBeenLastCalledWith(...args: Array): void; + lastCalledWith(...args: Array): void; /** * Check that an object has a .length property and it is set to a certain * numeric value. */ - toHaveLength(number: number): void, + toHaveLength(number: number): void; /** * */ - toHaveProperty(propPath: string, value?: any): void, + toHaveProperty(propPath: string, value?: any): void; /** * Use .toMatch to check that a string matches a regular expression or string. */ - toMatch(regexpOrString: RegExp | string): void, + toMatch(regexpOrString: RegExp | string): void; /** * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. */ - toMatchObject(object: Object | Array): void, + toMatchObject(object: Object | Array): void; /** * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. */ - toStrictEqual(value: any): void, + toStrictEqual(value: any): void; /** * This ensures that an Object matches the most recent snapshot. */ - toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void, + toMatchSnapshot( + propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, + name?: string, + ): void; /** * This ensures that an Object matches the most recent snapshot. */ - toMatchSnapshot(name: string): void, + toMatchSnapshot(name: string): void; - toMatchInlineSnapshot(snapshot?: string): void, - toMatchInlineSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, snapshot?: string): void, + toMatchInlineSnapshot(snapshot?: string): void; + toMatchInlineSnapshot( + propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, + snapshot?: string, + ): void; /** * Use .toThrow to test that a function throws when it is called. * If you want to test that a specific error gets thrown, you can provide an @@ -722,14 +732,14 @@ interface JestExpectType { * * Alias: .toThrowError */ - toThrow(message?: string | Error | Class | RegExp): void, - toThrowError(message?: string | Error | Class | RegExp): void, + toThrow(message?: string | Error | Class | RegExp): void; + toThrowError(message?: string | Error | Class | RegExp): void; /** * Use .toThrowErrorMatchingSnapshot to test that a function throws a error * matching the most recent snapshot when it is called. */ - toThrowErrorMatchingSnapshot(): void, - toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, + toThrowErrorMatchingSnapshot(): void; + toThrowErrorMatchingInlineSnapshot(snapshot?: string): void; } type JestObjectType = { @@ -785,7 +795,7 @@ type JestObjectType = { * implementation. */ fn, TReturn>( - implementation?: (...args: TArguments) => TReturn + implementation?: (...args: TArguments) => TReturn, ): JestMockFn, /** * Determines if the given function is a mocked function. @@ -808,7 +818,7 @@ type JestObjectType = { mock( moduleName: string, moduleFactory?: any, - options?: Object + options?: Object, ): JestObjectType, /** * Returns the actual module instead of a mock, bypassing all checks on @@ -883,37 +893,41 @@ type JestObjectType = { * Creates a mock function similar to jest.fn but also tracks calls to * object[methodName]. */ - spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, + spyOn( + object: Object, + methodName: string, + accessType?: 'get' | 'set', + ): JestMockFn, /** * Set the default timeout interval for tests and before/after hooks in milliseconds. * Note: The default timeout interval is 5 seconds if this method is not called. */ - setTimeout(timeout: number): JestObjectType + setTimeout(timeout: number): JestObjectType, }; type JestSpyType = { - calls: JestCallsType + calls: JestCallsType, }; /** Runs this function after every test inside this context */ declare function afterEach( fn: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void; /** Runs this function before every test inside this context */ declare function beforeEach( fn: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void; /** Runs this function after all tests have finished inside this context */ declare function afterAll( fn: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void; /** Runs this function before any tests have started inside this context */ declare function beforeAll( fn: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void; /** A context for grouping tests together */ @@ -939,10 +953,10 @@ declare var describe: { * @param {table} table of Test */ each( - table: Array | mixed> + table: Array | mixed>, ): ( name: JestTestName, - fn?: (...args: Array) => ?Promise + fn?: (...args: Array) => ?Promise, ) => void, }; @@ -958,7 +972,7 @@ declare var it: { ( name: JestTestName, fn?: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void, /** * each runs this test against array of argument arrays per each run @@ -966,10 +980,10 @@ declare var it: { * @param {table} table of Test */ each( - table: Array | mixed> + table: Array | mixed>, ): ( name: JestTestName, - fn?: (...args: Array) => ?Promise + fn?: (...args: Array) => ?Promise, ) => void, /** * Only run this test @@ -981,13 +995,13 @@ declare var it: { only( name: JestTestName, fn?: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): { each( - table: Array | mixed> + table: Array | mixed>, ): ( name: JestTestName, - fn?: (...args: Array) => ?Promise + fn?: (...args: Array) => ?Promise, ) => void, }, /** @@ -1000,7 +1014,7 @@ declare var it: { skip( name: JestTestName, fn?: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void, /** * Run the test concurrently @@ -1012,7 +1026,7 @@ declare var it: { concurrent( name: JestTestName, fn?: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void, /** * each runs this test against array of argument arrays per each run @@ -1020,16 +1034,16 @@ declare var it: { * @param {table} table of Test */ each( - table: Array | mixed> + table: Array | mixed>, ): ( name: JestTestName, - fn?: (...args: Array) => ?Promise + fn?: (...args: Array) => ?Promise, ) => void, }; declare function fit( name: JestTestName, fn: (done: () => void) => ?Promise, - timeout?: number + timeout?: number, ): void; /** An individual test unit */ declare var test: typeof it; @@ -1043,11 +1057,11 @@ declare var xit: typeof it; declare var xtest: typeof it; type JestPrettyFormatColors = { - comment: { close: string, open: string }, - content: { close: string, open: string }, - prop: { close: string, open: string }, - tag: { close: string, open: string }, - value: { close: string, open: string }, + comment: {close: string, open: string}, + content: {close: string, open: string}, + prop: {close: string, open: string}, + tag: {close: string, open: string}, + value: {close: string, open: string}, }; type JestPrettyFormatIndent = string => string; @@ -1091,17 +1105,18 @@ type JestPrettyFormatPlugins = Array; /** The expect function is used every time you want to test a value */ declare var expect: { /** The object that you want to make assertions against */ - (value: any): - & JestExpectType - & JestPromiseType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, + ( + value: any, + ): JestExpectType & + JestPromiseType & + EnzymeMatchersType & + DomTestingLibraryType & + JestJQueryMatchersType & + JestStyledComponentsMatchersType & + JestExtendedMatchersType, /** Add additional Jasmine matchers to Jest's roster */ - extend(matchers: { [name: string]: JestMatcher }): void, + extend(matchers: {[name: string]: JestMatcher}): void, /** Add a module that formats application-specific data structures. */ addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, assertions(expectedAssertions: number): void, @@ -1141,8 +1156,8 @@ declare var jasmine: { createSpy(name: string): JestSpyType, createSpyObj( baseName: string, - methodNames: Array - ): { [methodName: string]: JestSpyType }, + methodNames: Array, + ): {[methodName: string]: JestSpyType}, objectContaining(value: Object): Object, - stringMatching(value: string): string + stringMatching(value: string): string, }; diff --git a/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js b/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js index 6cdbc7d18..792e2676c 100644 --- a/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js +++ b/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js @@ -68,6 +68,8 @@ describe('getAssetDestPathAndroid', () => { httpServerLocation: '/assets/app/test', }; - expect(getAssetDestPathAndroid(asset, 1)).toBe(path.normalize('raw/app_test_video.mp4')); + expect(getAssetDestPathAndroid(asset, 1)).toBe( + path.normalize('raw/app_test_video.mp4'), + ); }); }); diff --git a/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js b/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js index 85768396b..fb05ba3fb 100644 --- a/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js +++ b/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js @@ -23,7 +23,9 @@ describe('getAssetDestPathIOS', () => { httpServerLocation: '/assets/test', }; - expect(getAssetDestPathIOS(asset, 1)).toBe(path.normalize('assets/test/icon.png')); + expect(getAssetDestPathIOS(asset, 1)).toBe( + path.normalize('assets/test/icon.png'), + ); }); it('should consider scale', () => { @@ -33,7 +35,11 @@ describe('getAssetDestPathIOS', () => { httpServerLocation: '/assets/test', }; - expect(getAssetDestPathIOS(asset, 2)).toBe(path.normalize('assets/test/icon@2x.png')); - expect(getAssetDestPathIOS(asset, 3)).toBe(path.normalize('assets/test/icon@3x.png')); + expect(getAssetDestPathIOS(asset, 2)).toBe( + path.normalize('assets/test/icon@2x.png'), + ); + expect(getAssetDestPathIOS(asset, 3)).toBe( + path.normalize('assets/test/icon@3x.png'), + ); }); }); diff --git a/local-cli/generator/templates.js b/local-cli/generator/templates.js index d36d17289..54a09613b 100644 --- a/local-cli/generator/templates.js +++ b/local-cli/generator/templates.js @@ -98,7 +98,11 @@ function createFromRemoteTemplate( // only for publishing the template to npm. // We want to ignore this dummy file, otherwise it would overwrite // our project's package.json file. - ignorePaths: ['package.json', 'dependencies.json','devDependencies.json'], + ignorePaths: [ + 'package.json', + 'dependencies.json', + 'devDependencies.json', + ], }); installTemplateDependencies(templatePath, yarnVersion); installTemplateDevDependencies(templatePath, yarnVersion); diff --git a/local-cli/init/init.js b/local-cli/init/init.js index 8929f4dc1..cbb189533 100644 --- a/local-cli/init/init.js +++ b/local-cli/init/init.js @@ -9,9 +9,7 @@ 'use strict'; -const { - createProjectFromTemplate, -} = require('../generator/templates'); +const {createProjectFromTemplate} = require('../generator/templates'); const execSync = require('child_process').execSync; const fs = require('fs'); const minimist = require('minimist');