From c1989115613242ea35504744f37cc1f03dd641f1 Mon Sep 17 00:00:00 2001 From: Eli White Date: Wed, 12 Jul 2017 15:56:48 -0700 Subject: [PATCH] Convert easy files to Prettier Reviewed By: zertosh Differential Revision: D5409825 fbshipit-source-id: 81f67be174cc8ecfcd0955dfec83955ebdc84622 --- babel-preset/configs/hmr.js | 22 +++-- babel-preset/configs/internal.js | 4 +- babel-preset/configs/main.js | 12 ++- babel-preset/index.js | 2 + babel-preset/lib/resolvePlugins.js | 2 + babel-preset/plugins.js | 4 +- ...transform-regenerator-runtime-insertion.js | 8 +- .../transforms/transform-symbol-member.js | 20 ++--- bots/code-analysis-bot.js | 39 +++++---- cli.js | 2 + jest/mockComponent.js | 4 +- jest/preprocessor.js | 18 ++-- jest/setup.js | 84 ++++++++++--------- lib/InitializeJavaScriptAppEngine.js | 1 + lib/RCTEventEmitter.js | 1 + lib/TextInputState.js | 1 + lib/UIManager.js | 1 + lib/UIManagerStatTracker.js | 1 + lib/View.js | 1 + lib/deepDiffer.js | 1 + lib/deepFreezeAndThrowOnMutationInDev.js | 1 + lib/flattenStyle.js | 1 + react-native-cli/index.js | 2 + react-native-git-upgrade/cli.js | 6 +- react-native-git-upgrade/index.js | 43 +++++----- react-native-git-upgrade/yarn.js | 5 +- rn-cli.config.js | 2 + 27 files changed, 166 insertions(+), 122 deletions(-) diff --git a/babel-preset/configs/hmr.js b/babel-preset/configs/hmr.js index 0fff0fc9a..c3145477f 100644 --- a/babel-preset/configs/hmr.js +++ b/babel-preset/configs/hmr.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -16,8 +18,8 @@ var transformPath = require.resolve(hmrTransform); module.exports = function(options, filename) { var transform = filename - ? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths - : hmrTransform; + ? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths + : hmrTransform; // Fix the module path to use '/' on Windows. if (path.sep === '\\') { @@ -29,13 +31,15 @@ module.exports = function(options, filename) { [ 'react-transform', { - transforms: [{ - transform: transform, - imports: ['react'], - locals: ['module'], - }] + transforms: [ + { + transform: transform, + imports: ['react'], + locals: ['module'], + }, + ], }, - ] - ]) + ], + ]), }; }; diff --git a/babel-preset/configs/internal.js b/babel-preset/configs/internal.js index 53830b0d6..5bddba1d3 100644 --- a/babel-preset/configs/internal.js +++ b/babel-preset/configs/internal.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -13,4 +15,4 @@ var resolvePlugins = require('../lib/resolvePlugins'); module.exports = function(options) { // For future internal pipeline usage return null; -} +}; diff --git a/babel-preset/configs/main.js b/babel-preset/configs/main.js index eb814e6eb..6491694a7 100644 --- a/babel-preset/configs/main.js +++ b/babel-preset/configs/main.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -25,7 +27,10 @@ var base = { 'transform-es2015-computed-properties', 'check-es2015-constants', 'transform-es2015-destructuring', - ['transform-es2015-modules-commonjs', { strict: false, allowTopLevelThis: true }], + [ + 'transform-es2015-modules-commonjs', + {strict: false, allowTopLevelThis: true}, + ], 'transform-es2015-parameters', 'transform-es2015-shorthand-properties', 'transform-es2015-spread', @@ -37,7 +42,7 @@ var base = { 'transform-react-display-name', 'transform-react-jsx', 'transform-regenerator', - ['transform-es2015-for-of', { loose: true }], + ['transform-es2015-for-of', {loose: true}], require('../transforms/transform-regenerator-runtime-insertion'), require('../transforms/transform-symbol-member'), ]), @@ -45,10 +50,9 @@ var base = { var devTools = Object.assign({}, base); devTools.plugins = devTools.plugins.concat( - resolvePlugins(['transform-react-jsx-source']) + resolvePlugins(['transform-react-jsx-source']), ); - module.exports = function(options) { var withDevTools = options.withDevTools; if (withDevTools == null) { diff --git a/babel-preset/index.js b/babel-preset/index.js index a1e2956ed..c5bf83dce 100644 --- a/babel-preset/index.js +++ b/babel-preset/index.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; diff --git a/babel-preset/lib/resolvePlugins.js b/babel-preset/lib/resolvePlugins.js index 742ea0a78..b2058df2b 100644 --- a/babel-preset/lib/resolvePlugins.js +++ b/babel-preset/lib/resolvePlugins.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; diff --git a/babel-preset/plugins.js b/babel-preset/plugins.js index 07e3ec3a6..f79d0fd89 100644 --- a/babel-preset/plugins.js +++ b/babel-preset/plugins.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -26,7 +28,7 @@ module.exports = { 'babel-plugin-transform-es2015-shorthand-properties': require('babel-plugin-transform-es2015-shorthand-properties'), 'babel-plugin-transform-es2015-spread': require('babel-plugin-transform-es2015-spread'), 'babel-plugin-transform-es2015-template-literals': require('babel-plugin-transform-es2015-template-literals'), - 'babel-plugin-transform-es2015-literals' : require('babel-plugin-transform-es2015-literals'), + 'babel-plugin-transform-es2015-literals': require('babel-plugin-transform-es2015-literals'), 'babel-plugin-transform-flow-strip-types': require('babel-plugin-transform-flow-strip-types'), 'babel-plugin-transform-object-assign': require('babel-plugin-transform-object-assign'), 'babel-plugin-transform-object-rest-spread': require('babel-plugin-transform-object-rest-spread'), diff --git a/babel-preset/transforms/transform-regenerator-runtime-insertion.js b/babel-preset/transforms/transform-regenerator-runtime-insertion.js index a8d661814..a9f5f2d4e 100644 --- a/babel-preset/transforms/transform-regenerator-runtime-insertion.js +++ b/babel-preset/transforms/transform-regenerator-runtime-insertion.js @@ -6,6 +6,8 @@ * 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. * + * + * @format */ 'use strict'; @@ -98,9 +100,9 @@ module.exports = function() { t.identifier('regeneratorRuntime'), t.callExpression(t.identifier('require'), [ t.stringLiteral(NAME), - ]) - ) - ]) + ]), + ), + ]), ); } }, diff --git a/babel-preset/transforms/transform-symbol-member.js b/babel-preset/transforms/transform-symbol-member.js index 5962918dc..841ead9f6 100644 --- a/babel-preset/transforms/transform-symbol-member.js +++ b/babel-preset/transforms/transform-symbol-member.js @@ -1,5 +1,7 @@ /** * Copyright 2004-present Facebook. All Rights Reserved. + * + * @format */ 'use strict'; @@ -34,16 +36,12 @@ module.exports = function symbolMember(babel) { t.conditionalExpression( t.binaryExpression( '===', - t.unaryExpression( - 'typeof', - t.identifier('Symbol'), - true - ), - t.stringLiteral('function') + t.unaryExpression('typeof', t.identifier('Symbol'), true), + t.stringLiteral('function'), ), node, - t.stringLiteral(`@@${node.property.name}`) - ) + t.stringLiteral(`@@${node.property.name}`), + ), ); // We should stop to avoid infinite recursion, since Babel @@ -57,8 +55,10 @@ module.exports = function symbolMember(babel) { function isAppropriateMember(path) { let node = path.node; - return path.parentPath.type !== 'AssignmentExpression' && + return ( + path.parentPath.type !== 'AssignmentExpression' && node.object.type === 'Identifier' && node.object.name === 'Symbol' && - node.property.type === 'Identifier'; + node.property.type === 'Identifier' + ); } diff --git a/bots/code-analysis-bot.js b/bots/code-analysis-bot.js index 0c3a8bdda..2bd4323d7 100644 --- a/bots/code-analysis-bot.js +++ b/bots/code-analysis-bot.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -17,7 +19,9 @@ if (!process.env.CI_REPO) { process.exit(1); } if (!process.env.GITHUB_TOKEN) { - console.error('Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e'); + console.error( + 'Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e', + ); process.exit(1); } if (!process.env.PULL_REQUEST_NUMBER) { @@ -92,7 +96,7 @@ var converters = { }); }); }); - } + }, }; function getShaFromPullRequest(user, repo, number, callback) { @@ -120,7 +124,6 @@ function getFilesFromCommit(user, repo, sha, callback) { }); } - /** * Sadly we can't just give the line number to github, we have to give the * line number relative to the patch file which is super annoying. This @@ -132,7 +135,7 @@ function getLineMapFromPatch(patchString) { var fileLineIndex = 0; var lineMap = {}; - patchString.split('\n').forEach((line) => { + patchString.split('\n').forEach(line => { if (line.match(/^@@/)) { fileLineIndex = line.match(/\+([0-9]+)/)[1] - 1; return; @@ -181,27 +184,27 @@ function main(messages, user, repo, number) { return; } - getShaFromPullRequest(user, repo, number, (sha) => { - getFilesFromCommit(user, repo, sha, (files) => { - files - .filter((file) => messages[file.filename]) - .forEach((file) => { - // github api sometimes does not return a patch on large commits - if (!file.patch) { - return; - } - var lineMap = getLineMapFromPatch(file.patch); - messages[file.filename].forEach((message) => { - sendComment(user, repo, number, sha, file.filename, lineMap, message); - }); + getShaFromPullRequest(user, repo, number, sha => { + getFilesFromCommit(user, repo, sha, files => { + files.filter(file => messages[file.filename]).forEach(file => { + // github api sometimes does not return a patch on large commits + if (!file.patch) { + return; + } + var lineMap = getLineMapFromPatch(file.patch); + messages[file.filename].forEach(message => { + sendComment(user, repo, number, sha, file.filename, lineMap, message); }); + }); }); }); } var content = ''; process.stdin.resume(); -process.stdin.on('data', function(buf) { content += buf.toString(); }); +process.stdin.on('data', function(buf) { + content += buf.toString(); +}); process.stdin.on('end', function() { var messages = {}; diff --git a/cli.js b/cli.js index 88837275f..197e49350 100644 --- a/cli.js +++ b/cli.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; diff --git a/jest/mockComponent.js b/jest/mockComponent.js index bb63a3e3e..5cbd4fcf9 100644 --- a/jest/mockComponent.js +++ b/jest/mockComponent.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -17,7 +19,7 @@ module.exports = moduleName => { const name = RealComponent.displayName || RealComponent.name; return React.createElement( - name.replace(/^(RCT|RK)/,''), + name.replace(/^(RCT|RK)/, ''), this.props, this.props.children, ); diff --git a/jest/preprocessor.js b/jest/preprocessor.js index 50962fd12..3d57b421a 100644 --- a/jest/preprocessor.js +++ b/jest/preprocessor.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. * - * @flow + * @format */ /* eslint-env node */ @@ -17,22 +17,18 @@ const babel = require('babel-core'); const babelRegisterOnly = require('metro-bundler/src/babelRegisterOnly'); const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction'); -const nodeFiles = RegExp([ - '/local-cli/', - '/metro-bundler/', -].join('|')); +const nodeFiles = RegExp(['/local-cli/', '/metro-bundler/'].join('|')); const nodeOptions = babelRegisterOnly.config([nodeFiles]); babelRegisterOnly([]); const transformer = require('metro-bundler/src/transformer.js'); module.exports = { - process(src/*: string*/, file/*: string*/) { - if (nodeFiles.test(file)) { // node specific transforms only - return babel.transform( - src, - Object.assign({filename: file}, nodeOptions) - ).code; + process(src, file) { + if (nodeFiles.test(file)) { + // node specific transforms only + return babel.transform(src, Object.assign({filename: file}, nodeOptions)) + .code; } return transformer.transform({ diff --git a/jest/setup.js b/jest/setup.js index a24fbd6ea..b2f6db83b 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -17,7 +19,9 @@ require.requireActual('metro-bundler/src/Resolver/polyfills/error-guard'); global.__DEV__ = true; global.Promise = require.requireActual('promise'); -global.regeneratorRuntime = require.requireActual('regenerator-runtime/runtime'); +global.regeneratorRuntime = require.requireActual( + 'regenerator-runtime/runtime', +); global.requestAnimationFrame = function(callback) { setTimeout(callback, 0); @@ -26,9 +30,7 @@ global.cancelAnimationFrame = function(id) { clearTimeout(id); }; -jest - .mock('setupDevtools') - .mock('npmlog'); +jest.mock('setupDevtools').mock('npmlog'); // there's a __mock__ for it. jest.setMock('ErrorUtils', require('ErrorUtils')); @@ -42,10 +44,7 @@ jest .mock('View', () => mockComponent('View')) .mock('RefreshControl', () => require.requireMock('RefreshControlMock')) .mock('ScrollView', () => require.requireMock('ScrollViewMock')) - .mock( - 'ActivityIndicator', - () => mockComponent('ActivityIndicator'), - ) + .mock('ActivityIndicator', () => mockComponent('ActivityIndicator')) .mock('ListView', () => require.requireMock('ListViewMock')) .mock('ListViewDataSource', () => { const DataSource = require.requireActual('ListViewDataSource'); @@ -55,9 +54,9 @@ jest // Ensure this doesn't throw. try { Object.keys(dataBlob).forEach(key => { - this.items += dataBlob[key] && ( - dataBlob[key].length || dataBlob[key].size || 0 - ); + this.items += + dataBlob[key] && + (dataBlob[key].length || dataBlob[key].size || 0); }); } catch (e) { this.items = 'unknown'; @@ -79,10 +78,18 @@ const mockNativeModules = { addEventListener: jest.fn(), }, AsyncLocalStorage: { - multiGet: jest.fn((keys, callback) => process.nextTick(() => callback(null, []))), - multiSet: jest.fn((entries, callback) => process.nextTick(() => callback(null))), - multiRemove: jest.fn((keys, callback) => process.nextTick(() => callback(null))), - multiMerge: jest.fn((entries, callback) => process.nextTick(() => callback(null))), + multiGet: jest.fn((keys, callback) => + process.nextTick(() => callback(null, [])), + ), + multiSet: jest.fn((entries, callback) => + process.nextTick(() => callback(null)), + ), + multiRemove: jest.fn((keys, callback) => + process.nextTick(() => callback(null)), + ), + multiMerge: jest.fn((entries, callback) => + process.nextTick(() => callback(null)), + ), clear: jest.fn(callback => process.nextTick(() => callback(null))), getAllKeys: jest.fn(callback => process.nextTick(() => callback(null, []))), }, @@ -123,14 +130,12 @@ const mockNativeModules = { }), }, ImageLoader: { - getSize: jest.fn( - (url) => new Promise(() => ({width: 320, height: 240})) - ), + getSize: jest.fn(url => new Promise(() => ({width: 320, height: 240}))), prefetchImage: jest.fn(), }, ImageViewManager: { - getSize: jest.fn( - (uri, success) => process.nextTick(() => success(320, 240)) + getSize: jest.fn((uri, success) => + process.nextTick(() => success(320, 240)), ), prefetchImage: jest.fn(), }, @@ -140,13 +145,9 @@ const mockNativeModules = { }, Linking: { openURL: jest.fn(), - canOpenURL: jest.fn( - () => new Promise((resolve) => resolve(true)) - ), + canOpenURL: jest.fn(() => new Promise(resolve => resolve(true))), addEventListener: jest.fn(), - getInitialURL: jest.fn( - () => new Promise((resolve) => resolve()) - ), + getInitialURL: jest.fn(() => new Promise(resolve => resolve())), removeEventListener: jest.fn(), }, LocationObserver: { @@ -156,14 +157,10 @@ const mockNativeModules = { }, ModalFullscreenViewManager: {}, NetInfo: { - fetch: jest.fn( - () => new Promise((resolve) => resolve()) - ), + fetch: jest.fn(() => new Promise(resolve => resolve())), addEventListener: jest.fn(), isConnected: { - fetch: jest.fn( - () => new Promise((resolve) => resolve()) - ), + fetch: jest.fn(() => new Promise(resolve => resolve())), addEventListener: jest.fn(), }, }, @@ -181,12 +178,20 @@ const mockNativeModules = { getDeliveredNotifications: jest.fn(callback => process.nextTick(() => [])), removeDeliveredNotifications: jest.fn(), setApplicationIconBadgeNumber: jest.fn(), - getApplicationIconBadgeNumber: jest.fn(callback => process.nextTick(() => callback(0))), + getApplicationIconBadgeNumber: jest.fn(callback => + process.nextTick(() => callback(0)), + ), cancelLocalNotifications: jest.fn(), - getScheduledLocalNotifications: jest.fn(callback => process.nextTick(() => callback())), - requestPermissions: jest.fn(() => Promise.resolve({alert: true, badge: true, sound: true})), + getScheduledLocalNotifications: jest.fn(callback => + process.nextTick(() => callback()), + ), + requestPermissions: jest.fn(() => + Promise.resolve({alert: true, badge: true, sound: true}), + ), abandonPermissions: jest.fn(), - checkPermissions: jest.fn(callback => process.nextTick(() => callback({alert: true, badge: true, sound: true}))), + checkPermissions: jest.fn(callback => + process.nextTick(() => callback({alert: true, badge: true, sound: true})), + ), getInitialNotification: jest.fn(() => Promise.resolve(null)), addListener: jest.fn(), removeListeners: jest.fn(), @@ -266,9 +271,6 @@ jest jest.doMock('requireNativeComponent', () => { const React = require('react'); - return viewName => props => React.createElement( - viewName, - props, - props.children, - ); + return viewName => props => + React.createElement(viewName, props, props.children); }); diff --git a/lib/InitializeJavaScriptAppEngine.js b/lib/InitializeJavaScriptAppEngine.js index c560dccac..2b2cd1f51 100644 --- a/lib/InitializeJavaScriptAppEngine.js +++ b/lib/InitializeJavaScriptAppEngine.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/RCTEventEmitter.js b/lib/RCTEventEmitter.js index b48677174..c4ef5c7cd 100644 --- a/lib/RCTEventEmitter.js +++ b/lib/RCTEventEmitter.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/TextInputState.js b/lib/TextInputState.js index 74f58bb27..bbdeddb96 100644 --- a/lib/TextInputState.js +++ b/lib/TextInputState.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/UIManager.js b/lib/UIManager.js index bf87c346c..29b41c155 100644 --- a/lib/UIManager.js +++ b/lib/UIManager.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/UIManagerStatTracker.js b/lib/UIManagerStatTracker.js index 6c66a0420..36a0cd507 100644 --- a/lib/UIManagerStatTracker.js +++ b/lib/UIManagerStatTracker.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/View.js b/lib/View.js index 5174bdea4..5ac346b8b 100644 --- a/lib/View.js +++ b/lib/View.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/deepDiffer.js b/lib/deepDiffer.js index e7584bc64..67eb9f5b3 100644 --- a/lib/deepDiffer.js +++ b/lib/deepDiffer.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/deepFreezeAndThrowOnMutationInDev.js b/lib/deepFreezeAndThrowOnMutationInDev.js index acee5bff5..e33feeabb 100644 --- a/lib/deepFreezeAndThrowOnMutationInDev.js +++ b/lib/deepFreezeAndThrowOnMutationInDev.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/lib/flattenStyle.js b/lib/flattenStyle.js index e4dfd4670..58a043cbb 100644 --- a/lib/flattenStyle.js +++ b/lib/flattenStyle.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @flow + * @format */ 'use strict'; diff --git a/react-native-cli/index.js b/react-native-cli/index.js index 4de761a7f..32eb42118 100755 --- a/react-native-cli/index.js +++ b/react-native-cli/index.js @@ -7,6 +7,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @noformat */ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/react-native-git-upgrade/cli.js b/react-native-git-upgrade/cli.js index f664d9583..fdd7351c8 100644 --- a/react-native-git-upgrade/cli.js +++ b/react-native-git-upgrade/cli.js @@ -5,16 +5,18 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; require('babel-register')({ presets: [ require('babel-preset-es2015-node'), - require('babel-preset-stage-3') + require('babel-preset-stage-3'), ], // Enable transpiling for react-native-git-upgrade AND the generator, just like the upgrade CLI command does - only: /(react-native-git-upgrade\/(?!(node_modules)))|(local-cli\/generator)/ + only: /(react-native-git-upgrade\/(?!(node_modules)))|(local-cli\/generator)/, }); var cliEntry = require('./cliEntry'); diff --git a/react-native-git-upgrade/index.js b/react-native-git-upgrade/index.js index c676a7a65..4a11ef96b 100644 --- a/react-native-git-upgrade/index.js +++ b/react-native-git-upgrade/index.js @@ -7,30 +7,34 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ var argv = require('minimist')(process.argv.slice(2)); var cli = require('./cli'); if (argv._.length === 0 && (argv.h || argv.help)) { - console.log([ - '', - ' Usage: react-native-git-upgrade [version] [options]', - '', - '', - ' Commands:', - '', - ' [Version] upgrades React Native and app templates to the desired version', - ' (latest, if not specified)', - '', - ' Options:', - '', - ' -h, --help output usage information', - ' -v, --version output the version number', - ' --verbose output debugging info', - ' --npm force using the npm client even if your project uses yarn', - '', - ].join('\n')); + console.log( + [ + '', + ' Usage: react-native-git-upgrade [version] [options]', + '', + '', + ' Commands:', + '', + ' [Version] upgrades React Native and app templates to the desired version', + ' (latest, if not specified)', + '', + ' Options:', + '', + ' -h, --help output usage information', + ' -v, --version output the version number', + ' --verbose output debugging info', + ' --npm force using the npm client even if your project uses yarn', + '', + ].join('\n'), + ); process.exit(0); } @@ -39,5 +43,4 @@ if (argv._.length === 0 && (argv.v || argv.version)) { process.exit(0); } -cli.run(argv._[0], argv) - .catch(console.error); +cli.run(argv._[0], argv).catch(console.error); diff --git a/react-native-git-upgrade/yarn.js b/react-native-git-upgrade/yarn.js index 7dda2501d..cc30739b0 100644 --- a/react-native-git-upgrade/yarn.js +++ b/react-native-git-upgrade/yarn.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict'; @@ -24,7 +26,8 @@ function getYarnVersionIfAvailable() { if (process.platform.startsWith('win')) { yarnVersion = (execSync('yarn --version').toString() || '').trim(); } else { - yarnVersion = (execSync('yarn --version 2>/dev/null').toString() || '').trim(); + yarnVersion = (execSync('yarn --version 2>/dev/null').toString() || '') + .trim(); } } catch (error) { return null; diff --git a/rn-cli.config.js b/rn-cli.config.js index a03254b8b..41705e60e 100644 --- a/rn-cli.config.js +++ b/rn-cli.config.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * 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. + * + * @format */ 'use strict';