From 333182363a3f8501fda6bd0596503f761b2d89d9 Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Mon, 15 Jan 2018 05:28:22 -0800 Subject: [PATCH] Add @flow to bunch of (mostly test-) files that trivially pass Reviewed By: rafeca Differential Revision: D6712326 fbshipit-source-id: 44ef8506664f92a34f8e3ca124bd6167a20fbade --- packages/metro-core/src/Logger/__mocks__/chalk.js | 3 ++- packages/metro-core/src/Logger/__tests__/Logger-test.js | 3 +++ packages/metro-source-map/src/Generator.js | 2 +- packages/metro-source-map/src/__tests__/B64Builder-test.js | 3 ++- packages/metro-source-map/src/__tests__/Generator-test.js | 1 + packages/metro-source-map/src/__tests__/source-map-test.js | 2 +- .../JSTransformer/worker/__tests__/constant-folding-test.js | 4 ++++ packages/metro/src/ModuleGraph/__tests__/ModuleGraph-test.js | 1 + packages/metro/src/ModuleGraph/silent-console.js | 1 + .../metro/src/Server/__tests__/MultipartResponse-test.js | 1 + packages/metro/src/__mocks__/debug.js | 1 + packages/metro/src/__tests__/index-test.js | 1 + .../src/integration_tests/basic_bundle/AssetRegistry.js | 1 + packages/metro/src/integration_tests/basic_bundle/Bar.js | 1 + packages/metro/src/integration_tests/basic_bundle/Foo.js | 1 + .../metro/src/integration_tests/basic_bundle/TestBundle.js | 1 + packages/metro/src/lib/__mocks__/declareOpts.js | 5 +++-- packages/metro/src/lib/__tests__/BatchProcessor-test.js | 1 + .../metro/src/lib/__tests__/addParamsToDefineCall-test.js | 1 + packages/metro/src/lib/__tests__/getMaxWorkers-test.js | 1 + .../metro/src/lib/__tests__/getTransformCacheKeyFn-test.js | 1 + .../src/node-haste/DependencyGraph/assets/empty-module.js | 1 + packages/metro/src/node-haste/__mocks__/graceful-fs.js | 1 + .../src/node-haste/__tests__/AssetResolutionCache-test.js | 1 + .../metro/src/node-haste/lib/__tests__/AssetPaths-test.js | 1 + .../src/node-haste/lib/__tests__/MapWithDefaults-test.js | 1 + .../node-haste/lib/__tests__/parsePlatformFilePath-test.js | 1 + packages/metro/src/rn-cli.config.js | 1 + packages/metro/src/setupNodePolyfills.js | 1 + packages/metro/src/shared/output/__tests__/meta-test.js | 1 + 30 files changed, 39 insertions(+), 6 deletions(-) diff --git a/packages/metro-core/src/Logger/__mocks__/chalk.js b/packages/metro-core/src/Logger/__mocks__/chalk.js index 6c8b4fc9..15b25a9f 100644 --- a/packages/metro-core/src/Logger/__mocks__/chalk.js +++ b/packages/metro-core/src/Logger/__mocks__/chalk.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; @@ -27,7 +28,7 @@ mockColor.bgRed = function() { }; module.exports = { - dim: s => s, + dim: (s: T) => s, // (elaborate way of saying "any", fine for this case) magenta: mockColor, white: mockColor, blue: mockColor, diff --git a/packages/metro-core/src/Logger/__tests__/Logger-test.js b/packages/metro-core/src/Logger/__tests__/Logger-test.js index 5119c01b..236d846b 100644 --- a/packages/metro-core/src/Logger/__tests__/Logger-test.js +++ b/packages/metro-core/src/Logger/__tests__/Logger-test.js @@ -11,6 +11,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; @@ -24,10 +25,12 @@ describe('Logger', () => { const originalConsoleLog = console.log; beforeEach(() => { + // $FlowFixMe don't worry, state restored below console.log = jest.fn(); }); afterEach(() => { + // $FlowFixMe console.log = originalConsoleLog; }); diff --git a/packages/metro-source-map/src/Generator.js b/packages/metro-source-map/src/Generator.js index 1895795d..df8b1d24 100644 --- a/packages/metro-source-map/src/Generator.js +++ b/packages/metro-source-map/src/Generator.js @@ -173,7 +173,7 @@ class Generator { * * This is ~2.5x faster than calling `JSON.stringify(generator.toMap())` */ - toString(file?: string, options: {excludeSource?: boolean}): string { + toString(file?: string, options?: {excludeSource?: boolean}): string { let content; if (options && options.excludeSource) { diff --git a/packages/metro-source-map/src/__tests__/B64Builder-test.js b/packages/metro-source-map/src/__tests__/B64Builder-test.js index ce4ee3dd..b619387c 100644 --- a/packages/metro-source-map/src/__tests__/B64Builder-test.js +++ b/packages/metro-source-map/src/__tests__/B64Builder-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; @@ -22,7 +23,7 @@ beforeEach(() => { it('exposes a fluent interface', () => { expect(builder.markLines(0)).toBe(builder); expect(builder.markLines(3)).toBe(builder); - expect(builder.startSegment()).toBe(builder); + expect(builder.startSegment(0)).toBe(builder); expect(builder.append(4)).toBe(builder); }); diff --git a/packages/metro-source-map/src/__tests__/Generator-test.js b/packages/metro-source-map/src/__tests__/Generator-test.js index 3ebf0bfd..ae02aaf1 100644 --- a/packages/metro-source-map/src/__tests__/Generator-test.js +++ b/packages/metro-source-map/src/__tests__/Generator-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro-source-map/src/__tests__/source-map-test.js b/packages/metro-source-map/src/__tests__/source-map-test.js index aa76672f..d002dfcd 100644 --- a/packages/metro-source-map/src/__tests__/source-map-test.js +++ b/packages/metro-source-map/src/__tests__/source-map-test.js @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @emails oncal+javascript_foundation + * @emails oncall+javascript_foundation * @flow * @format */ diff --git a/packages/metro/src/JSTransformer/worker/__tests__/constant-folding-test.js b/packages/metro/src/JSTransformer/worker/__tests__/constant-folding-test.js index 5a148a22..92f2c132 100644 --- a/packages/metro/src/JSTransformer/worker/__tests__/constant-folding-test.js +++ b/packages/metro/src/JSTransformer/worker/__tests__/constant-folding-test.js @@ -8,6 +8,7 @@ * * @emails oncall+javascript_foundation * @format + * @flow */ 'use strict'; @@ -25,6 +26,9 @@ const babelOptions = { }; function normalize({code}) { + if (code === undefined || code === null) { + return 'FAIL'; + } return babel.transform(code, babelOptions).code; } diff --git a/packages/metro/src/ModuleGraph/__tests__/ModuleGraph-test.js b/packages/metro/src/ModuleGraph/__tests__/ModuleGraph-test.js index 26b048c3..8702cc27 100644 --- a/packages/metro/src/ModuleGraph/__tests__/ModuleGraph-test.js +++ b/packages/metro/src/ModuleGraph/__tests__/ModuleGraph-test.js @@ -20,6 +20,7 @@ const FILE_TYPE = 'module'; describe('build setup', () => { const buildSetup = ModuleGraph.createBuildSetup(graph, mds => { + // TODO: the .sort() function returns -1 1 or 0 for sorting, not boolean return [...mds].sort((l, r) => l.file.path > r.file.path); }); const polyfillOptions = {getPolyfills: () => ['polyfill-a', 'polyfill-b']}; diff --git a/packages/metro/src/ModuleGraph/silent-console.js b/packages/metro/src/ModuleGraph/silent-console.js index 8c29e2de..958ab23b 100644 --- a/packages/metro/src/ModuleGraph/silent-console.js +++ b/packages/metro/src/ModuleGraph/silent-console.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/Server/__tests__/MultipartResponse-test.js b/packages/metro/src/Server/__tests__/MultipartResponse-test.js index caa82fdc..6fd1bd40 100644 --- a/packages/metro/src/Server/__tests__/MultipartResponse-test.js +++ b/packages/metro/src/Server/__tests__/MultipartResponse-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/__mocks__/debug.js b/packages/metro/src/__mocks__/debug.js index f3958a0f..7a86fe80 100644 --- a/packages/metro/src/__mocks__/debug.js +++ b/packages/metro/src/__mocks__/debug.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/__tests__/index-test.js b/packages/metro/src/__tests__/index-test.js index ef1863b5..4e6677cb 100644 --- a/packages/metro/src/__tests__/index-test.js +++ b/packages/metro/src/__tests__/index-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/integration_tests/basic_bundle/AssetRegistry.js b/packages/metro/src/integration_tests/basic_bundle/AssetRegistry.js index 084f7c0c..d1d904c6 100644 --- a/packages/metro/src/integration_tests/basic_bundle/AssetRegistry.js +++ b/packages/metro/src/integration_tests/basic_bundle/AssetRegistry.js @@ -3,6 +3,7 @@ * All rights reserved. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/integration_tests/basic_bundle/Bar.js b/packages/metro/src/integration_tests/basic_bundle/Bar.js index e8df83a3..da583074 100644 --- a/packages/metro/src/integration_tests/basic_bundle/Bar.js +++ b/packages/metro/src/integration_tests/basic_bundle/Bar.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/integration_tests/basic_bundle/Foo.js b/packages/metro/src/integration_tests/basic_bundle/Foo.js index a4e685ec..3f739afd 100644 --- a/packages/metro/src/integration_tests/basic_bundle/Foo.js +++ b/packages/metro/src/integration_tests/basic_bundle/Foo.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/integration_tests/basic_bundle/TestBundle.js b/packages/metro/src/integration_tests/basic_bundle/TestBundle.js index a6cbce5a..5e73a238 100644 --- a/packages/metro/src/integration_tests/basic_bundle/TestBundle.js +++ b/packages/metro/src/integration_tests/basic_bundle/TestBundle.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/lib/__mocks__/declareOpts.js b/packages/metro/src/lib/__mocks__/declareOpts.js index 594855a2..7da975a0 100644 --- a/packages/metro/src/lib/__mocks__/declareOpts.js +++ b/packages/metro/src/lib/__mocks__/declareOpts.js @@ -7,12 +7,13 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; -module.exports = function(declared) { - return function(opts) { +module.exports = function(declared: Object) { + return function(opts: Object) { for (var p in declared) { if (opts[p] == null && declared[p].default != null) { opts[p] = declared[p].default; diff --git a/packages/metro/src/lib/__tests__/BatchProcessor-test.js b/packages/metro/src/lib/__tests__/BatchProcessor-test.js index a2739835..da321506 100644 --- a/packages/metro/src/lib/__tests__/BatchProcessor-test.js +++ b/packages/metro/src/lib/__tests__/BatchProcessor-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/lib/__tests__/addParamsToDefineCall-test.js b/packages/metro/src/lib/__tests__/addParamsToDefineCall-test.js index b186bc6d..0621eb83 100644 --- a/packages/metro/src/lib/__tests__/addParamsToDefineCall-test.js +++ b/packages/metro/src/lib/__tests__/addParamsToDefineCall-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/lib/__tests__/getMaxWorkers-test.js b/packages/metro/src/lib/__tests__/getMaxWorkers-test.js index d157385e..c69d32fd 100644 --- a/packages/metro/src/lib/__tests__/getMaxWorkers-test.js +++ b/packages/metro/src/lib/__tests__/getMaxWorkers-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/lib/__tests__/getTransformCacheKeyFn-test.js b/packages/metro/src/lib/__tests__/getTransformCacheKeyFn-test.js index 7e4043e8..93ccd891 100644 --- a/packages/metro/src/lib/__tests__/getTransformCacheKeyFn-test.js +++ b/packages/metro/src/lib/__tests__/getTransformCacheKeyFn-test.js @@ -8,6 +8,7 @@ * * @emails oncall+javascript_foundation * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/node-haste/DependencyGraph/assets/empty-module.js b/packages/metro/src/node-haste/DependencyGraph/assets/empty-module.js index c98058af..9cee0f4a 100644 --- a/packages/metro/src/node-haste/DependencyGraph/assets/empty-module.js +++ b/packages/metro/src/node-haste/DependencyGraph/assets/empty-module.js @@ -7,4 +7,5 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ diff --git a/packages/metro/src/node-haste/__mocks__/graceful-fs.js b/packages/metro/src/node-haste/__mocks__/graceful-fs.js index fc222a8b..8423ab46 100644 --- a/packages/metro/src/node-haste/__mocks__/graceful-fs.js +++ b/packages/metro/src/node-haste/__mocks__/graceful-fs.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/node-haste/__tests__/AssetResolutionCache-test.js b/packages/metro/src/node-haste/__tests__/AssetResolutionCache-test.js index abfd6210..f9719316 100644 --- a/packages/metro/src/node-haste/__tests__/AssetResolutionCache-test.js +++ b/packages/metro/src/node-haste/__tests__/AssetResolutionCache-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/node-haste/lib/__tests__/AssetPaths-test.js b/packages/metro/src/node-haste/lib/__tests__/AssetPaths-test.js index 266a1bda..a1ec140d 100644 --- a/packages/metro/src/node-haste/lib/__tests__/AssetPaths-test.js +++ b/packages/metro/src/node-haste/lib/__tests__/AssetPaths-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/node-haste/lib/__tests__/MapWithDefaults-test.js b/packages/metro/src/node-haste/lib/__tests__/MapWithDefaults-test.js index e4bd66bc..af01042b 100644 --- a/packages/metro/src/node-haste/lib/__tests__/MapWithDefaults-test.js +++ b/packages/metro/src/node-haste/lib/__tests__/MapWithDefaults-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/node-haste/lib/__tests__/parsePlatformFilePath-test.js b/packages/metro/src/node-haste/lib/__tests__/parsePlatformFilePath-test.js index 1ffb76e3..9b27a0bf 100644 --- a/packages/metro/src/node-haste/lib/__tests__/parsePlatformFilePath-test.js +++ b/packages/metro/src/node-haste/lib/__tests__/parsePlatformFilePath-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict'; diff --git a/packages/metro/src/rn-cli.config.js b/packages/metro/src/rn-cli.config.js index f14a7d33..4c1cb96e 100644 --- a/packages/metro/src/rn-cli.config.js +++ b/packages/metro/src/rn-cli.config.js @@ -9,6 +9,7 @@ * React Native CLI configuration file * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/setupNodePolyfills.js b/packages/metro/src/setupNodePolyfills.js index d9a71126..af1a4fd6 100644 --- a/packages/metro/src/setupNodePolyfills.js +++ b/packages/metro/src/setupNodePolyfills.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @format + * @flow */ 'use strict'; diff --git a/packages/metro/src/shared/output/__tests__/meta-test.js b/packages/metro/src/shared/output/__tests__/meta-test.js index 4ddbbc1b..6bc57156 100644 --- a/packages/metro/src/shared/output/__tests__/meta-test.js +++ b/packages/metro/src/shared/output/__tests__/meta-test.js @@ -8,6 +8,7 @@ * * @format * @emails oncall+js_foundation + * @flow */ 'use strict';