From 0cd69e8a02d254577fac9ccd3ff8a1727a024cc8 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Mon, 9 Oct 2017 17:37:08 -0700 Subject: [PATCH] Run eslint --fix Summary: CI is currently failing because of a lint issue, this fixes it and a bunch of other warnings that are auto-fixable. **Test plan** Quick manual test, cosmetic changes only. Closes https://github.com/facebook/react-native/pull/16229 Differential Revision: D6009748 Pulled By: TheSavior fbshipit-source-id: cabd44fed99dd90bd0b35626492719c139c89f34 --- .../run-android-ci-instrumentation-tests.js | 14 +- IntegrationTests/AsyncStorageTest.js | 2 +- IntegrationTests/ImageCachePolicyTest.js | 2 +- Libraries/Components/ScrollResponder.js | 2 +- .../Touchable/TouchableHighlight.js | 2 +- Libraries/Components/WebView/WebView.ios.js | 2 +- .../Core/Devtools/symbolicateStackTrace.js | 12 +- Libraries/Utilities/Dimensions.js | 4 +- Libraries/Utilities/PixelRatio.js | 38 +- Libraries/Utilities/RCTLog.js | 2 +- .../Utilities/createStrictShapeTypeChecker.js | 6 +- Libraries/Vibration/Vibration.js | 2 +- RNTester/js/SwipeableFlatListExample.js | 4 +- RNTester/js/TVEventHandlerExample.js | 2 +- RNTester/js/TextInputExample.android.js | 5 +- RNTester/js/TextInputExample.ios.js | 6 +- .../androidTest/js/MeasureLayoutTestModule.js | 34 +- .../androidTest/js/ProgressBarTestModule.js | 2 +- .../js/TestJavaToJSArgumentsModule.js | 32 +- .../src/androidTest/js/TextInputTestModule.js | 10 +- .../androidTest/js/ViewRenderingTestModule.js | 6 +- local-cli/bundle/saveAssets.js | 2 +- local-cli/core/windows/generateGUID.js | 4 +- local-cli/core/windows/index.js | 10 +- local-cli/eject/eject.js | 14 +- .../copyProjectTemplateAndReplace.js | 2 +- local-cli/generator/promptSync.js | 38 +- .../__tests__/android/isInstalled.spec.js | 4 +- .../link/__tests__/ios/writePlist.spec.js | 2 +- .../link/android/patches/makeBuildPatch.js | 2 +- local-cli/link/commandStub.js | 2 +- local-cli/link/ios/unlinkAssets.js | 6 +- local-cli/link/promisify.js | 2 +- local-cli/link/unlink.js | 2 +- local-cli/link/windows/patches/applyPatch.js | 2 +- local-cli/link/windows/patches/revokePatch.js | 2 +- local-cli/runAndroid/adb.js | 4 +- .../__tests__/findMatchingSimulator-test.js | 458 +++++++++--------- local-cli/server/util/launchEditor.js | 2 +- local-cli/server/util/webSocketProxy.js | 2 +- .../HelloNavigation/components/ListItem.js | 2 +- .../HelloNavigation/views/chat/ChatScreen.js | 2 +- local-cli/util/findSymlinksPaths.js | 4 +- react-native-git-upgrade/cliEntry.js | 10 +- scripts/bump-oss-version.js | 34 +- scripts/publish-npm.js | 32 +- website/core/BlogPostFooter.js | 7 +- website/core/BlogPostHeader.js | 6 +- website/core/ExcerptLink.js | 6 +- website/jsdocs/TypeExpressionParser.js | 6 +- website/jsdocs/findExportDefinition.js | 2 +- website/jsdocs/generic-function-visitor.js | 10 +- website/jsdocs/jsdocs.js | 4 +- website/layout/AutodocsLayout.js | 4 +- website/layout/BlogPageLayout.js | 2 +- website/publish-gh-pages.js | 118 ++--- website/server/convert.js | 6 +- website/server/generate.js | 2 +- 58 files changed, 501 insertions(+), 505 deletions(-) diff --git a/ContainerShip/scripts/run-android-ci-instrumentation-tests.js b/ContainerShip/scripts/run-android-ci-instrumentation-tests.js index e7e89ea83..00a9f4955 100644 --- a/ContainerShip/scripts/run-android-ci-instrumentation-tests.js +++ b/ContainerShip/scripts/run-android-ci-instrumentation-tests.js @@ -45,7 +45,7 @@ const test_opts = { OFFSET: argv.offset, COUNT: argv.count -} +}; let max_test_class_length = Number.NEGATIVE_INFINITY; @@ -85,14 +85,14 @@ if (test_opts.COUNT != null && test_opts.OFFSET != null) { } return async.mapSeries(testClasses, (clazz, callback) => { - if(clazz.length > max_test_class_length) { + if (clazz.length > max_test_class_length) { max_test_class_length = clazz.length; } return async.retry(test_opts.RETRIES, (retryCb) => { const test_process = child_process.spawn('./ContainerShip/scripts/run-instrumentation-tests-via-adb-shell.sh', [test_opts.PACKAGE, clazz], { stdio: 'inherit' - }) + }); const timeout = setTimeout(() => { test_process.kill(); @@ -106,7 +106,7 @@ return async.mapSeries(testClasses, (clazz, callback) => { test_process.on('exit', (code) => { clearTimeout(timeout); - if(code !== 0) { + if (code !== 0) { return retryCb(new Error(`Process exited with code: ${code}`)); } @@ -138,16 +138,16 @@ function print_test_suite_results(results) { function pad_output(num_chars) { let i = 0; - while(i < num_chars) { + while (i < num_chars) { process.stdout.write(' '); i++; } } results.forEach((test) => { - if(test.status === 'success') { + if (test.status === 'success') { color = colors.GREEN; passing_suites++; - } else if(test.status === 'failure') { + } else if (test.status === 'failure') { color = colors.RED; failing_suites++; } diff --git a/IntegrationTests/AsyncStorageTest.js b/IntegrationTests/AsyncStorageTest.js index 044392eb6..ef7df1f1f 100644 --- a/IntegrationTests/AsyncStorageTest.js +++ b/IntegrationTests/AsyncStorageTest.js @@ -155,7 +155,7 @@ function testOptimizedMultiGet() { let keys = batch.map(([key, value]) => key); AsyncStorage.multiSet(batch, (err1) => { // yes, twice on purpose - ;[1, 2].forEach((i) => { + [1, 2].forEach((i) => { expectAsyncNoError(`${i} testOptimizedMultiGet/multiSet`, err1); AsyncStorage.multiGet(keys, (err2, result) => { expectAsyncNoError(`${i} testOptimizedMultiGet/multiGet`, err2); diff --git a/IntegrationTests/ImageCachePolicyTest.js b/IntegrationTests/ImageCachePolicyTest.js index 4d621dfc5..973260071 100644 --- a/IntegrationTests/ImageCachePolicyTest.js +++ b/IntegrationTests/ImageCachePolicyTest.js @@ -48,7 +48,7 @@ class ImageCachePolicyTest extends React.Component { const results: Array = TESTS.map(x => nextState[x]); if (!results.includes(undefined)) { - const result: boolean = results.reduce((x,y) => x === y === true, true) + const result: boolean = results.reduce((x,y) => x === y === true, true); TestModule.markTestPassed(result); } diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index dd4ca0cab..6017f8339 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -548,7 +548,7 @@ var ScrollResponderMixin = { warning( typeof keyboardShouldPersistTaps !== 'boolean', `'keyboardShouldPersistTaps={${keyboardShouldPersistTaps}}' is deprecated. ` - + `Use 'keyboardShouldPersistTaps="${keyboardShouldPersistTaps ? "always" : "never"}"' instead` + + `Use 'keyboardShouldPersistTaps="${keyboardShouldPersistTaps ? 'always' : 'never'}"' instead` ); this.keyboardWillOpenTo = null; diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 2de2777e9..1bcd162bb 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -138,7 +138,7 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; * * AppRegistry.registerComponent('App', () => App) * ``` - * + * */ var TouchableHighlight = createReactClass({ diff --git a/Libraries/Components/WebView/WebView.ios.js b/Libraries/Components/WebView/WebView.ios.js index d552dca08..33ca08cc6 100644 --- a/Libraries/Components/WebView/WebView.ios.js +++ b/Libraries/Components/WebView/WebView.ios.js @@ -377,7 +377,7 @@ class WebView extends React.Component { 'always', 'compatibility' ]), - + /** * Override the native component used to render the WebView. Enables a custom native * WebView which uses the same JavaScript as the original WebView. diff --git a/Libraries/Core/Devtools/symbolicateStackTrace.js b/Libraries/Core/Devtools/symbolicateStackTrace.js index 586034b47..283e4b78c 100644 --- a/Libraries/Core/Devtools/symbolicateStackTrace.js +++ b/Libraries/Core/Devtools/symbolicateStackTrace.js @@ -16,7 +16,7 @@ const getDevServer = require('getDevServer'); const {SourceCode} = require('NativeModules'); // Avoid requiring fetch on load of this module; see symbolicateStackTrace -let fetch; +let fetch; import type {StackFrame} from 'parseErrorStack'; @@ -25,13 +25,13 @@ function isSourcedFromDisk(sourcePath: string): boolean { } async function symbolicateStackTrace(stack: Array): Promise> { - // RN currently lazy loads whatwg-fetch using a custom fetch module, which, + // RN currently lazy loads whatwg-fetch using a custom fetch module, which, // when called for the first time, requires and re-exports 'whatwg-fetch'. - // However, when a dependency of the project tries to require whatwg-fetch - // either directly or indirectly, whatwg-fetch is required before + // However, when a dependency of the project tries to require whatwg-fetch + // either directly or indirectly, whatwg-fetch is required before // RN can lazy load whatwg-fetch. As whatwg-fetch checks - // for a fetch polyfill before loading, it will in turn try to load - // RN's fetch module, which immediately tries to import whatwg-fetch AGAIN. + // for a fetch polyfill before loading, it will in turn try to load + // RN's fetch module, which immediately tries to import whatwg-fetch AGAIN. // This causes a circular require which results in RN's fetch module // exporting fetch as 'undefined'. // The fix below postpones trying to load fetch until the first call to symbolicateStackTrace. diff --git a/Libraries/Utilities/Dimensions.js b/Libraries/Utilities/Dimensions.js index 76b4098b8..cbb33d41e 100644 --- a/Libraries/Utilities/Dimensions.js +++ b/Libraries/Utilities/Dimensions.js @@ -107,7 +107,7 @@ class Dimensions { handler: Function ) { invariant( - 'change' === type, + type === 'change', 'Trying to subscribe to unknown event: "%s"', type ); eventEmitter.addListener(type, handler); @@ -121,7 +121,7 @@ class Dimensions { handler: Function ) { invariant( - 'change' === type, + type === 'change', 'Trying to remove listener for unknown event: "%s"', type ); eventEmitter.removeListener(type, handler); diff --git a/Libraries/Utilities/PixelRatio.js b/Libraries/Utilities/PixelRatio.js index b2bbb0e0c..6d68ef03c 100644 --- a/Libraries/Utilities/PixelRatio.js +++ b/Libraries/Utilities/PixelRatio.js @@ -29,33 +29,33 @@ var Dimensions = require('Dimensions'); * }); * * ``` - * + * * ## Pixel grid snapping - * - * In iOS, you can specify positions and dimensions for elements with arbitrary + * + * In iOS, you can specify positions and dimensions for elements with arbitrary * precision, for example 29.674825. But, ultimately the physical display only * have a fixed number of pixels, for example 640×960 for iPhone 4 or 750×1334 - * for iPhone 6. iOS tries to be as faithful as possible to the user value by - * spreading one original pixel into multiple ones to trick the eye. The - * downside of this technique is that it makes the resulting element look + * for iPhone 6. iOS tries to be as faithful as possible to the user value by + * spreading one original pixel into multiple ones to trick the eye. The + * downside of this technique is that it makes the resulting element look * blurry. - * - * In practice, we found out that developers do not want this feature and they - * have to work around it by doing manual rounding in order to avoid having - * blurry elements. In React Native, we are rounding all the pixels + * + * In practice, we found out that developers do not want this feature and they + * have to work around it by doing manual rounding in order to avoid having + * blurry elements. In React Native, we are rounding all the pixels * automatically. - * - * We have to be careful when to do this rounding. You never want to work with - * rounded and unrounded values at the same time as you're going to accumulate - * rounding errors. Having even one rounding error is deadly because a one + * + * We have to be careful when to do this rounding. You never want to work with + * rounded and unrounded values at the same time as you're going to accumulate + * rounding errors. Having even one rounding error is deadly because a one * pixel border may vanish or be twice as big. - * + * * In React Native, everything in JavaScript and within the layout engine works - * with arbitrary precision numbers. It's only when we set the position and - * dimensions of the native element on the main thread that we round. Also, - * rounding is done relative to the root rather than the parent, again to avoid + * with arbitrary precision numbers. It's only when we set the position and + * dimensions of the native element on the main thread that we round. Also, + * rounding is done relative to the root rather than the parent, again to avoid * accumulating rounding errors. - * + * */ class PixelRatio { /** diff --git a/Libraries/Utilities/RCTLog.js b/Libraries/Utilities/RCTLog.js index 6d09e8a92..a51d38d2d 100644 --- a/Libraries/Utilities/RCTLog.js +++ b/Libraries/Utilities/RCTLog.js @@ -51,6 +51,6 @@ const RCTLog = { setWarningHandler(handler: typeof warningHandler): void { warningHandler = handler; } -} +}; module.exports = RCTLog; diff --git a/Libraries/Utilities/createStrictShapeTypeChecker.js b/Libraries/Utilities/createStrictShapeTypeChecker.js index 884e8a96b..078d103a3 100644 --- a/Libraries/Utilities/createStrictShapeTypeChecker.js +++ b/Libraries/Utilities/createStrictShapeTypeChecker.js @@ -47,8 +47,8 @@ function createStrictShapeTypeChecker( invariant( false, `Invalid props.${propName} key \`${key}\` supplied to \`${componentName}\`.` + - `\nBad object: ` + JSON.stringify(props[propName], null, ' ') + - `\nValid keys: ` + JSON.stringify(Object.keys(shapeTypes), null, ' ') + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') ); } var error = checker(propValue, key, componentName, location, ...rest); @@ -56,7 +56,7 @@ function createStrictShapeTypeChecker( invariant( false, error.message + - `\nBad object: ` + JSON.stringify(props[propName], null, ' ') + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') ); } } diff --git a/Libraries/Vibration/Vibration.js b/Libraries/Vibration/Vibration.js index 699f8da25..2f5d7d610 100644 --- a/Libraries/Vibration/Vibration.js +++ b/Libraries/Vibration/Vibration.js @@ -90,7 +90,7 @@ function vibrateScheduler(id, pattern: Array, repeat: boolean, nextIndex return; } } - setTimeout(() => vibrateScheduler(id, pattern, repeat, nextIndex+1), pattern[nextIndex]); + setTimeout(() => vibrateScheduler(id, pattern, repeat, nextIndex + 1), pattern[nextIndex]); } var Vibration = { diff --git a/RNTester/js/SwipeableFlatListExample.js b/RNTester/js/SwipeableFlatListExample.js index b34719383..ac69abec0 100644 --- a/RNTester/js/SwipeableFlatListExample.js +++ b/RNTester/js/SwipeableFlatListExample.js @@ -74,9 +74,7 @@ const SwipeableFlatListExample = createReactClass({ - - {item.data} - + {item.data} ); diff --git a/RNTester/js/TVEventHandlerExample.js b/RNTester/js/TVEventHandlerExample.js index f86a57b29..4d0aa3ae8 100644 --- a/RNTester/js/TVEventHandlerExample.js +++ b/RNTester/js/TVEventHandlerExample.js @@ -48,7 +48,7 @@ class TVEventHandlerView extends React.Component<$FlowFixMeProps, { this._tvEventHandler.enable(this, function(cmp, evt) { cmp.setState({ lastEventType: evt.eventType - }) + }); }); } diff --git a/RNTester/js/TextInputExample.android.js b/RNTester/js/TextInputExample.android.js index bf3afaf39..d682f2044 100644 --- a/RNTester/js/TextInputExample.android.js +++ b/RNTester/js/TextInputExample.android.js @@ -515,8 +515,7 @@ exports.examples = [ - + style={styles.singleLine} /> ); } @@ -746,7 +745,7 @@ exports.examples = [ ); diff --git a/RNTester/js/TextInputExample.ios.js b/RNTester/js/TextInputExample.ios.js index f1c20bca6..453bc269b 100644 --- a/RNTester/js/TextInputExample.ios.js +++ b/RNTester/js/TextInputExample.ios.js @@ -610,12 +610,12 @@ exports.examples = [ @@ -872,7 +872,7 @@ exports.examples = [ ); diff --git a/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js b/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js index 4eaf44b57..12ef60816 100644 --- a/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js +++ b/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js @@ -22,29 +22,29 @@ var assertEquals = require('Asserts').assertEquals; var styles = StyleSheet.create({ A: { - "width": 500, - "height": 500, + 'width': 500, + 'height': 500, }, B: { - backgroundColor: "rgb(255, 0, 0)", - "left": 50, - "top": 80, - "width": 200, - "height": 300, + backgroundColor: 'rgb(255, 0, 0)', + 'left': 50, + 'top': 80, + 'width': 200, + 'height': 300, }, C: { - backgroundColor: "rgb(0, 255, 0)", - "left": 100, - "top": 70, - "width": 50, - "height": 150, + backgroundColor: 'rgb(0, 255, 0)', + 'left': 100, + 'top': 70, + 'width': 50, + 'height': 150, }, D: { - backgroundColor: "rgb(0, 0, 255)", - "left": 400, - "top": 100, - "width": 50, - "height": 200, + backgroundColor: 'rgb(0, 0, 255)', + 'left': 400, + 'top': 100, + 'width': 50, + 'height': 200, }, }); diff --git a/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js b/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js index 70408854a..d27428049 100644 --- a/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js +++ b/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js @@ -9,7 +9,7 @@ * @providesModule ProgressBarTestModule */ -"use strict"; +'use strict'; var BatchedBridge = require('BatchedBridge'); var React = require('React'); diff --git a/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js b/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js index 4073d4d6a..3e18819dc 100644 --- a/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js +++ b/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js @@ -34,47 +34,47 @@ function assertStrictStringEquals(a, b) { var TestJavaToJSArgumentsModule = { receiveBasicTypes: function(str, dbl, bool, null_arg) { - assertEquals("foo", str); + assertEquals('foo', str); assertEquals(3.14, dbl); assertEquals(true, bool); assertEquals(null, null_arg); }, receiveArrayWithBasicTypes: function(arr) { assertEquals(4, arr.length); - assertEquals("red panda", arr[0]); + assertEquals('red panda', arr[0]); assertEquals(1.19, arr[1]); assertEquals(true, arr[2]); assertEquals(null, arr[3]); }, receiveNestedArray: function(arr) { assertEquals(2, arr.length); - assertEquals("level1", arr[0]); + assertEquals('level1', arr[0]); var arr2 = arr[1]; - assertEquals("level2", arr2[0]); + assertEquals('level2', arr2[0]); var arr3 = arr2[1]; - assertEquals("level3", arr3[0]); + assertEquals('level3', arr3[0]); }, receiveArrayWithMaps: function(arr) { assertEquals(2, arr.length); var m1 = arr[0]; var m2 = arr[1]; - assertEquals("m1v1", m1["m1k1"]); - assertEquals("m1v2", m1["m1k2"]); - assertEquals("m2v1", m2["m2k1"]); + assertEquals('m1v1', m1.m1k1); + assertEquals('m1v2', m1.m1k2); + assertEquals('m2v1', m2.m2k1); }, receiveMapWithBasicTypes: function(map) { - assertEquals("stringValue", map["stringKey"]); - assertEquals(3.14, map["doubleKey"]); - assertEquals(true, map["booleanKey"]); - assertEquals(null, map["nullKey"]); + assertEquals('stringValue', map.stringKey); + assertEquals(3.14, map.doubleKey); + assertEquals(true, map.booleanKey); + assertEquals(null, map.nullKey); }, receiveNestedMap: function(map) { - var nestedMap = map["nestedMap"]; - assertEquals("foxes", nestedMap["animals"]); + var nestedMap = map.nestedMap; + assertEquals('foxes', nestedMap.animals); }, receiveMapWithArrays: function(map) { - var a1 = map["array1"]; - var a2 = map["array2"]; + var a1 = map.array1; + var a2 = map.array2; assertEquals(3, a1.length); assertEquals(2, a2.length); assertEquals(3, a1[0]); diff --git a/ReactAndroid/src/androidTest/js/TextInputTestModule.js b/ReactAndroid/src/androidTest/js/TextInputTestModule.js index 924b7e119..058ef7e45 100644 --- a/ReactAndroid/src/androidTest/js/TextInputTestModule.js +++ b/ReactAndroid/src/androidTest/js/TextInputTestModule.js @@ -9,7 +9,7 @@ * @providesModule TextInputTestModule */ -"use strict"; +'use strict'; var BatchedBridge = require('BatchedBridge'); var React = require('React'); @@ -94,7 +94,7 @@ class TextInputTestApp extends React.Component { style={styles.textInputHeight} autoCorrect={true} autoFocus={true} - keyboardType='numeric' + keyboardType="numeric" multiline={true} secureTextEntry={true} defaultValue="This is text" @@ -102,13 +102,13 @@ class TextInputTestApp extends React.Component { /> - ) + ); } } diff --git a/local-cli/bundle/saveAssets.js b/local-cli/bundle/saveAssets.js index caa87b145..32b18c5de 100644 --- a/local-cli/bundle/saveAssets.js +++ b/local-cli/bundle/saveAssets.js @@ -41,7 +41,7 @@ function saveAssets( const src = asset.files[idx]; const dest = path.join(assetsDest, getAssetDestPath(asset, scale)); filesToCopy[src] = dest; - }) + }); }); return copyAll(filesToCopy); diff --git a/local-cli/core/windows/generateGUID.js b/local-cli/core/windows/generateGUID.js index 0bbdcdead..25eb456eb 100644 --- a/local-cli/core/windows/generateGUID.js +++ b/local-cli/core/windows/generateGUID.js @@ -2,9 +2,9 @@ const s4 = () => { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); -} +}; module.exports = function generateGUID() { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); -} +}; diff --git a/local-cli/core/windows/index.js b/local-cli/core/windows/index.js index 462fd31be..c535c4c3e 100644 --- a/local-cli/core/windows/index.js +++ b/local-cli/core/windows/index.js @@ -17,15 +17,15 @@ const generateGUID = require('./generateGUID'); const relativeProjectPath = (fullProjPath) => { const windowsPath = fullProjPath - .substring(fullProjPath.lastIndexOf("node_modules") - 1, fullProjPath.length) + .substring(fullProjPath.lastIndexOf('node_modules') - 1, fullProjPath.length) .replace(/\//g, '\\'); return '..' + windowsPath; -} +}; const getProjectName = (fullProjPath) => { return fullProjPath.split('/').slice(-1)[0].replace(/\.csproj/i, ''); -} +}; /** * Gets windows project config by analyzing given folder and taking some @@ -41,7 +41,7 @@ exports.projectConfig = function projectConfigWindows(folder, userConfig) { // expects solutions to be named the same as project folders const solutionPath = path.join(folder, csSolution); - const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf(".sln")); + const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf('.sln')); const src = userConfig.sourceDir || windowsAppFolder; const sourceDir = path.join(folder, src); const mainPage = path.join(sourceDir, 'MainPage.cs'); @@ -70,7 +70,7 @@ exports.dependencyConfig = function dependencyConfigWindows(folder, userConfig) } // expects solutions to be named the same as project folders - const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf(".sln")); + const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf('.sln')); const src = userConfig.sourceDir || windowsAppFolder; if (!src) { diff --git a/local-cli/eject/eject.js b/local-cli/eject/eject.js index b18a5176e..e49b5a5ec 100644 --- a/local-cli/eject/eject.js +++ b/local-cli/eject/eject.js @@ -38,11 +38,11 @@ function eject() { let appConfig = null; try { appConfig = require(path.resolve('app.json')); - } catch(e) { + } catch (e) { console.error( - `Eject requires an \`app.json\` config file to be located at ` + + 'Eject requires an `app.json` config file to be located at ' + `${path.resolve('app.json')}, and it must at least specify a \`name\` for the project ` + - `name, and a \`displayName\` for the app's home screen label.` + 'name, and a `displayName` for the app\'s home screen label.' ); process.exit(1); } @@ -50,16 +50,16 @@ function eject() { const appName = appConfig.name; if (!appName) { console.error( - `App \`name\` must be defined in the \`app.json\` config file to define the project name. `+ - `It must not contain any spaces or dashes.` + 'App `name` must be defined in the `app.json` config file to define the project name. ' + + 'It must not contain any spaces or dashes.' ); process.exit(1); } const displayName = appConfig.displayName; if (!displayName) { console.error( - `App \`displayName\` must be defined in the \`app.json\` config file, to define the label ` + - `of the app on the home screen.` + 'App `displayName` must be defined in the `app.json` config file, to define the label ' + + 'of the app on the home screen.' ); process.exit(1); } diff --git a/local-cli/generator/copyProjectTemplateAndReplace.js b/local-cli/generator/copyProjectTemplateAndReplace.js index 5adf70703..a7deff596 100644 --- a/local-cli/generator/copyProjectTemplateAndReplace.js +++ b/local-cli/generator/copyProjectTemplateAndReplace.js @@ -99,7 +99,7 @@ function copyProjectTemplateAndReplace(srcPath, destPath, newProjectName, option * behavior of automatically renaming .gitignore to .npmignore. */ function dotFilePath(path) { - if (!path) return path; + if (!path) {return path;} return path .replace('_gitignore', '.gitignore') .replace('_gitattributes', '.gitattributes') diff --git a/local-cli/generator/promptSync.js b/local-cli/generator/promptSync.js index 262764813..841af5054 100644 --- a/local-cli/generator/promptSync.js +++ b/local-cli/generator/promptSync.js @@ -25,7 +25,7 @@ function create() { var echo = opts.echo; var masked = 'echo' in opts; - var fd = (process.platform === 'win32') ? + var fd = (process.platform === 'win32') ? process.stdin.fd : fs.openSync('/dev/tty', 'rs'); @@ -51,15 +51,15 @@ function create() { str = str + buf.toString(); str = str.replace(/\0/g, ''); insert = str.length; - process.stdout.write('\u001b[2K\u001b[0G'+ ask + str); - process.stdout.write('\u001b[' + (insert+ask.length+1) + 'G'); + process.stdout.write('\u001b[2K\u001b[0G' + ask + str); + process.stdout.write('\u001b[' + (insert + ask.length + 1) + 'G'); buf = new Buffer(3); } continue; // any other 3 character sequence is ignored } // if it is not a control character seq, assume only one character is read - character = buf[read-1]; + character = buf[read - 1]; // catch a ^C and return null if (character == 3){ @@ -77,28 +77,28 @@ function create() { } if (character == 127 || (process.platform == 'win32' && character == 8)) { //backspace - if (!insert) continue; - str = str.slice(0, insert-1) + str.slice(insert); + if (!insert) {continue;} + str = str.slice(0, insert - 1) + str.slice(insert); insert--; process.stdout.write('\u001b[2D'); } else { if ((character < 32 ) || (character > 126)) - continue; + {continue;} str = str.slice(0, insert) + String.fromCharCode(character) + str.slice(insert); insert++; - }; + } if (masked) { - process.stdout.write('\u001b[2K\u001b[0G' + ask + Array(str.length+1).join(echo)); + process.stdout.write('\u001b[2K\u001b[0G' + ask + Array(str.length + 1).join(echo)); } else { process.stdout.write('\u001b[s'); if (insert == str.length) { - process.stdout.write('\u001b[2K\u001b[0G'+ ask + str); + process.stdout.write('\u001b[2K\u001b[0G' + ask + str); } else { if (ask) { - process.stdout.write('\u001b[2K\u001b[0G'+ ask + str); + process.stdout.write('\u001b[2K\u001b[0G' + ask + str); } else { - process.stdout.write('\u001b[2K\u001b[0G'+ str + '\u001b[' + (str.length - insert) + 'D'); + process.stdout.write('\u001b[2K\u001b[0G' + str + '\u001b[' + (str.length - insert) + 'D'); } } process.stdout.write('\u001b[u'); @@ -106,13 +106,13 @@ function create() { } } - - process.stdout.write('\n') + + process.stdout.write('\n'); process.stdin.setRawMode(wasRaw); - - return str || value || ''; - }; -}; -module.exports = create; \ No newline at end of file + return str || value || ''; + } +} + +module.exports = create; diff --git a/local-cli/link/__tests__/android/isInstalled.spec.js b/local-cli/link/__tests__/android/isInstalled.spec.js index 2d1db99a5..366e94dde 100644 --- a/local-cli/link/__tests__/android/isInstalled.spec.js +++ b/local-cli/link/__tests__/android/isInstalled.spec.js @@ -9,8 +9,8 @@ const projectConfig = { describe('android::isInstalled', () => { it('should return true when project is already in build.gradle', () => { - expect(isInstalled(projectConfig, 'test')).toBeTruthy() - expect(isInstalled(projectConfig, 'test2')).toBeTruthy() + expect(isInstalled(projectConfig, 'test')).toBeTruthy(); + expect(isInstalled(projectConfig, 'test2')).toBeTruthy(); }); it('should return false when project is not in build.gradle', () => diff --git a/local-cli/link/__tests__/ios/writePlist.spec.js b/local-cli/link/__tests__/ios/writePlist.spec.js index 95925ff8b..57ae0e1a5 100644 --- a/local-cli/link/__tests__/ios/writePlist.spec.js +++ b/local-cli/link/__tests__/ios/writePlist.spec.js @@ -14,7 +14,7 @@ jest.mock('fs'); let plistPath = null; jest.mock('../../ios/getPlistPath', () => () => plistPath); -const { readFileSync } = require.requireActual('fs') +const { readFileSync } = require.requireActual('fs'); const fs = require('fs'); const xcode = require('xcode'); diff --git a/local-cli/link/android/patches/makeBuildPatch.js b/local-cli/link/android/patches/makeBuildPatch.js index 4941186a9..b27b16829 100644 --- a/local-cli/link/android/patches/makeBuildPatch.js +++ b/local-cli/link/android/patches/makeBuildPatch.js @@ -1,7 +1,7 @@ module.exports = function makeBuildPatch(name) { const installPattern = new RegExp( `\\s{4}(compile)(\\(|\\s)(project)\\(\\\':${name}\\\'\\)(\\)|\\s)` - ) + ); return { installPattern, diff --git a/local-cli/link/commandStub.js b/local-cli/link/commandStub.js index 2914946a9..ab4718af9 100644 --- a/local-cli/link/commandStub.js +++ b/local-cli/link/commandStub.js @@ -1 +1 @@ -module.exports = (cb) => cb(); \ No newline at end of file +module.exports = (cb) => cb(); diff --git a/local-cli/link/ios/unlinkAssets.js b/local-cli/link/ios/unlinkAssets.js index 70ec9b211..c80e793a7 100644 --- a/local-cli/link/ios/unlinkAssets.js +++ b/local-cli/link/ios/unlinkAssets.js @@ -19,14 +19,14 @@ module.exports = function unlinkAssetsIOS(files, projectConfig) { if (!plist) { return log.error( 'ERRPLIST', - `Could not locate Info.plist file. Check if your project has 'INFOPLIST_FILE' set properly` + 'Could not locate Info.plist file. Check if your project has \'INFOPLIST_FILE\' set properly' ); } if (!project.pbxGroupByName('Resources')) { return log.error( 'ERRGROUP', - `Group 'Resources' does not exist in your Xcode project. There is nothing to unlink.` + 'Group \'Resources\' does not exist in your Xcode project. There is nothing to unlink.' ); } @@ -39,7 +39,7 @@ module.exports = function unlinkAssetsIOS(files, projectConfig) { ) ) .map(file => file.basename); - } + }; removeResourceFile(assets.image); diff --git a/local-cli/link/promisify.js b/local-cli/link/promisify.js index 94f912f1f..b5bca830b 100644 --- a/local-cli/link/promisify.js +++ b/local-cli/link/promisify.js @@ -1,3 +1,3 @@ module.exports = (func) => new Promise((resolve, reject) => func((err, res) => err ? reject(err) : resolve(res)) -); \ No newline at end of file +); diff --git a/local-cli/link/unlink.js b/local-cli/link/unlink.js index 0ac7c8b8a..c2763228d 100644 --- a/local-cli/link/unlink.js +++ b/local-cli/link/unlink.js @@ -156,7 +156,7 @@ function unlink(args, config) { ); throw err; }); -}; +} module.exports = { func: unlink, diff --git a/local-cli/link/windows/patches/applyPatch.js b/local-cli/link/windows/patches/applyPatch.js index 55f84edf6..81757076c 100644 --- a/local-cli/link/windows/patches/applyPatch.js +++ b/local-cli/link/windows/patches/applyPatch.js @@ -5,7 +5,7 @@ module.exports = function applyPatch(file, patch, flip = false) { fs.writeFileSync(file, fs .readFileSync(file, 'utf8') .replace(patch.pattern, match => { - return flip ? `${patch.patch}${match}` : `${match}${patch.patch}` + return flip ? `${patch.patch}${match}` : `${match}${patch.patch}`; }) ); }; diff --git a/local-cli/link/windows/patches/revokePatch.js b/local-cli/link/windows/patches/revokePatch.js index 5c708cadd..d6acbe3c3 100644 --- a/local-cli/link/windows/patches/revokePatch.js +++ b/local-cli/link/windows/patches/revokePatch.js @@ -1,7 +1,7 @@ const fs = require('fs'); module.exports = function revokePatch(file, patch) { - const unpatch = patch.unpatch || patch.patch + const unpatch = patch.unpatch || patch.patch; fs.writeFileSync(file, fs .readFileSync(file, 'utf8') .replace(unpatch, '') diff --git a/local-cli/runAndroid/adb.js b/local-cli/runAndroid/adb.js index 46ae8b393..221b710af 100644 --- a/local-cli/runAndroid/adb.js +++ b/local-cli/runAndroid/adb.js @@ -22,7 +22,7 @@ function parseDevicesResult(result: string): Array { const devices = []; const lines = result.trim().split(/\r?\n/); - for (let i=0; i < lines.length; i++) { + for (let i = 0; i < lines.length; i++) { let words = lines[i].split(/[ ,\t]+/).filter((w) => w !== ''); if (words[1] === 'device') { @@ -49,4 +49,4 @@ function getDevices(): Array { module.exports = { parseDevicesResult: parseDevicesResult, getDevices: getDevices -}; \ No newline at end of file +}; diff --git a/local-cli/runIOS/__tests__/findMatchingSimulator-test.js b/local-cli/runIOS/__tests__/findMatchingSimulator-test.js index 957f80cf6..d2fd1ee3a 100644 --- a/local-cli/runIOS/__tests__/findMatchingSimulator-test.js +++ b/local-cli/runIOS/__tests__/findMatchingSimulator-test.js @@ -16,37 +16,37 @@ const findMatchingSimulator = require('../findMatchingSimulator'); describe('findMatchingSimulator', () => { it('should find simulator', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ] } @@ -61,37 +61,37 @@ describe('findMatchingSimulator', () => { it('should return null if no simulators available', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ] } @@ -106,37 +106,37 @@ describe('findMatchingSimulator', () => { it('should return the first simulator in list if none is defined', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ] } @@ -151,63 +151,63 @@ describe('findMatchingSimulator', () => { it('should return the first simulator in list if none is defined', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ], - "iOS 10.0": [ + 'iOS 10.0': [ { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "2FF48AE5-CC3B-4C80-8D25-48966A6BE2C0" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': '2FF48AE5-CC3B-4C80-8D25-48966A6BE2C0' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "841E33FE-E8A1-4B65-9FF8-6EAA6442A3FC" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '841E33FE-E8A1-4B65-9FF8-6EAA6442A3FC' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "CBBB8FB8-77AB-49A9-8297-4CCFE3189C22" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'CBBB8FB8-77AB-49A9-8297-4CCFE3189C22' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 7", - "udid": "3A409DC5-5188-42A6-8598-3AA6F34607A5" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 7', + 'udid': '3A409DC5-5188-42A6-8598-3AA6F34607A5' } ] } @@ -222,37 +222,37 @@ describe('findMatchingSimulator', () => { it('should return the booted simulator in list if none is defined', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Booted", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Booted', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ] } @@ -267,42 +267,42 @@ describe('findMatchingSimulator', () => { it('should return the booted simulator in list even if another device is defined', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Booted", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Booted', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ] } }, - "iPhone 6" + 'iPhone 6' )).toEqual({ udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508', name: 'iPhone 6s', @@ -312,63 +312,63 @@ describe('findMatchingSimulator', () => { it('should return the booted simulator in list if none is defined (multi ios versions)', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ], - "iOS 10.0": [ + 'iOS 10.0': [ { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "2FF48AE5-CC3B-4C80-8D25-48966A6BE2C0" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': '2FF48AE5-CC3B-4C80-8D25-48966A6BE2C0' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "841E33FE-E8A1-4B65-9FF8-6EAA6442A3FC" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '841E33FE-E8A1-4B65-9FF8-6EAA6442A3FC' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "CBBB8FB8-77AB-49A9-8297-4CCFE3189C22" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'CBBB8FB8-77AB-49A9-8297-4CCFE3189C22' }, { - "state": "Booted", - "availability": "(available)", - "name": "iPhone 7", - "udid": "3A409DC5-5188-42A6-8598-3AA6F34607A5" + 'state': 'Booted', + 'availability': '(available)', + 'name': 'iPhone 7', + 'udid': '3A409DC5-5188-42A6-8598-3AA6F34607A5' } ] } @@ -383,68 +383,68 @@ describe('findMatchingSimulator', () => { it('should return the booted simulator in list even if another device is defined (multi ios versions)', () => { expect(findMatchingSimulator({ - "devices": { - "iOS 9.2": [ + 'devices': { + 'iOS 9.2': [ { - "state": "Shutdown", - "availability": "(unavailable, runtime profile not found)", - "name": "iPhone 4s", - "udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6" + 'state': 'Shutdown', + 'availability': '(unavailable, runtime profile not found)', + 'name': 'iPhone 4s', + 'udid': 'B9B5E161-416B-43C4-A78F-729CB96CC8C6' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 5", - "udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 5', + 'udid': '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': 'BA0D93BD-07E6-4182-9B0A-F60A2474139C' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '9564ABEE-9EC2-4B4A-B443-D3710929A45A' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'D0F29BE7-CC3C-4976-888D-C739B4F50508' } ], - "iOS 10.0": [ + 'iOS 10.0': [ { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6", - "udid": "2FF48AE5-CC3B-4C80-8D25-48966A6BE2C0" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6', + 'udid': '2FF48AE5-CC3B-4C80-8D25-48966A6BE2C0' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6 (Plus)", - "udid": "841E33FE-E8A1-4B65-9FF8-6EAA6442A3FC" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6 (Plus)', + 'udid': '841E33FE-E8A1-4B65-9FF8-6EAA6442A3FC' }, { - "state": "Shutdown", - "availability": "(available)", - "name": "iPhone 6s", - "udid": "CBBB8FB8-77AB-49A9-8297-4CCFE3189C22" + 'state': 'Shutdown', + 'availability': '(available)', + 'name': 'iPhone 6s', + 'udid': 'CBBB8FB8-77AB-49A9-8297-4CCFE3189C22' }, { - "state": "Booted", - "availability": "(available)", - "name": "iPhone 7", - "udid": "3A409DC5-5188-42A6-8598-3AA6F34607A5" + 'state': 'Booted', + 'availability': '(available)', + 'name': 'iPhone 7', + 'udid': '3A409DC5-5188-42A6-8598-3AA6F34607A5' } ] } }, - "iPhone 6s" + 'iPhone 6s' )).toEqual({ udid: '3A409DC5-5188-42A6-8598-3AA6F34607A5', name: 'iPhone 7', diff --git a/local-cli/server/util/launchEditor.js b/local-cli/server/util/launchEditor.js index 6e3eb7994..3ea5e9621 100644 --- a/local-cli/server/util/launchEditor.js +++ b/local-cli/server/util/launchEditor.js @@ -100,7 +100,7 @@ function guessEditor() { return [COMMON_EDITORS[processName]]; } } - } catch(error) { + } catch (error) { // Ignore... } } diff --git a/local-cli/server/util/webSocketProxy.js b/local-cli/server/util/webSocketProxy.js index 74c01f8ef..f862c34bf 100644 --- a/local-cli/server/util/webSocketProxy.js +++ b/local-cli/server/util/webSocketProxy.js @@ -24,7 +24,7 @@ function attachToServer(server, path) { try { dest.send(message); - } catch(e) { + } catch (e) { console.warn(e); // Sometimes this call throws 'not opened' } diff --git a/local-cli/templates/HelloNavigation/components/ListItem.js b/local-cli/templates/HelloNavigation/components/ListItem.js index a3a99b0d2..4e953214e 100644 --- a/local-cli/templates/HelloNavigation/components/ListItem.js +++ b/local-cli/templates/HelloNavigation/components/ListItem.js @@ -28,7 +28,7 @@ const Touchable = ({onPress, children}) => { ); } -} +}; const ListItem = ({label, onPress}) => ( diff --git a/local-cli/templates/HelloNavigation/views/chat/ChatScreen.js b/local-cli/templates/HelloNavigation/views/chat/ChatScreen.js index 04a9c62ef..7aed21db8 100644 --- a/local-cli/templates/HelloNavigation/views/chat/ChatScreen.js +++ b/local-cli/templates/HelloNavigation/views/chat/ChatScreen.js @@ -84,7 +84,7 @@ export default class ChatScreen extends Component { messages: messages, dataSource: prevState.dataSource.cloneWithRows(messages), myMessage: '', - } + }; }); this.textInput.clear(); } diff --git a/local-cli/util/findSymlinksPaths.js b/local-cli/util/findSymlinksPaths.js index e0b9ef9bb..61edda340 100644 --- a/local-cli/util/findSymlinksPaths.js +++ b/local-cli/util/findSymlinksPaths.js @@ -27,8 +27,8 @@ module.exports = function findSymlinksPaths(lookupFolder, ignoredRoots) { const index = visited.indexOf(symlink); if (index !== -1) { throw Error( - `Infinite symlink recursion detected:\n ` + - visited.slice(index).join(`\n `) + 'Infinite symlink recursion detected:\n ' + + visited.slice(index).join('\n ') ); } diff --git a/react-native-git-upgrade/cliEntry.js b/react-native-git-upgrade/cliEntry.js index 8c8d68c51..11542a946 100644 --- a/react-native-git-upgrade/cliEntry.js +++ b/react-native-git-upgrade/cliEntry.js @@ -59,7 +59,7 @@ function exec(command, logOutput) { stderr: ${stderr} stdout: ${stdout}`)); }); - }) + }); } function parseJsonFile(path, useYarn) { @@ -93,7 +93,7 @@ function readPackageFiles(useYarn) { reactNativeNodeModulesPak: parseJsonFile(reactNativeNodeModulesPakPath), reactNodeModulesPak: parseJsonFile(reactNodeModulesPakPath), pak: parseJsonFile(pakPath) - } + }; } function parseInformationJsonOutput(jsonOutput, requestedVersion) { @@ -105,7 +105,7 @@ function parseInformationJsonOutput(jsonOutput, requestedVersion) { assert(semver.valid(newVersion)); - return {newVersion, newReactVersionRange} + return {newVersion, newReactVersionRange}; } catch (err) { throw new Error( 'The specified version of React Native ' + requestedVersion + ' doesn\'t exist.\n' + @@ -147,7 +147,7 @@ function generateTemplates(generatorDir, appName, verbose) { // Try requiring the index.js (entry-point of Yeoman generators) fs.accessSync(yeomanGeneratorEntryPoint); return runYeomanGenerators(generatorDir, appName, verbose); - } catch(err) { + } catch (err) { return runCopyAndReplace(generatorDir, appName); } } @@ -280,7 +280,7 @@ async function run(requestedVersion, cliArgs) { log.info('Commit current project sources'); await exec('git commit -m "Project snapshot"', verbose); - log.info ('Create a tag before updating sources'); + log.info('Create a tag before updating sources'); await exec('git tag project-snapshot', verbose); projectBackupCreated = true; diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js index b6c7d0daa..3c91e6bee 100755 --- a/scripts/bump-oss-version.js +++ b/scripts/bump-oss-version.js @@ -32,15 +32,15 @@ let argv = minimist(process.argv.slice(2), { }); // - check we are in release branch, e.g. 0.33-stable -let branch = exec(`git symbolic-ref --short HEAD`, {silent: true}).stdout.trim(); +let branch = exec('git symbolic-ref --short HEAD', {silent: true}).stdout.trim(); -if (branch.indexOf(`-stable`) === -1) { - echo(`You must be in 0.XX-stable branch to bump a version`); +if (branch.indexOf('-stable') === -1) { + echo('You must be in 0.XX-stable branch to bump a version'); exit(1); } // e.g. 0.33 -let versionMajor = branch.slice(0, branch.indexOf(`-stable`)); +let versionMajor = branch.slice(0, branch.indexOf('-stable')); // - check that argument version matches branch // e.g. 0.33.1 or 0.33.0-rc4 @@ -79,13 +79,13 @@ cat('scripts/versiontemplates/ReactNativeVersion.js.template') .replace('${prerelease}', prerelease !== undefined ? `'${prerelease}'` : 'null') .to('Libraries/Core/ReactNativeVersion.js'); -let packageJson = JSON.parse(cat(`package.json`)); +let packageJson = JSON.parse(cat('package.json')); packageJson.version = version; -JSON.stringify(packageJson, null, 2).to(`package.json`); +JSON.stringify(packageJson, null, 2).to('package.json'); // - change ReactAndroid/gradle.properties -if (sed(`-i`, /^VERSION_NAME=.*/, `VERSION_NAME=${version}`, `ReactAndroid/gradle.properties`).code) { - echo(`Couldn't update version for Gradle`); +if (sed('-i', /^VERSION_NAME=.*/, `VERSION_NAME=${version}`, 'ReactAndroid/gradle.properties').code) { + echo('Couldn\'t update version for Gradle'); exit(1); } @@ -93,23 +93,23 @@ if (sed(`-i`, /^VERSION_NAME=.*/, `VERSION_NAME=${version}`, `ReactAndroid/gradl let numberOfChangedLinesWithNewVersion = exec(`git diff -U0 | grep '^[+]' | grep -c ${version} `, {silent: true}) .stdout.trim(); if (+numberOfChangedLinesWithNewVersion !== 2) { - echo(`Failed to update all the files. package.json and gradle.properties must have versions in them`); - echo(`Fix the issue, revert and try again`); - exec(`git diff`); + echo('Failed to update all the files. package.json and gradle.properties must have versions in them'); + echo('Fix the issue, revert and try again'); + exec('git diff'); exit(1); } // - make commit [0.21.0-rc] Bump version numbers if (exec(`git commit -a -m "[${version}] Bump version numbers"`).code) { - echo(`failed to commit`); + echo('failed to commit'); exit(1); } // - add tag v0.21.0-rc if (exec(`git tag v${version}`).code) { echo(`failed to tag the commit with v${version}, are you sure this release wasn't made earlier?`); - echo(`You may want to rollback the last commit`); - echo(`git reset --hard HEAD~1`); + echo('You may want to rollback the last commit'); + echo('git reset --hard HEAD~1'); exit(1); } @@ -118,10 +118,10 @@ let remote = argv.remote; exec(`git push ${remote} v${version}`); // Tag latest if doing stable release -if (version.indexOf(`rc`) === -1) { - exec(`git tag -d latest`); +if (version.indexOf('rc') === -1) { + exec('git tag -d latest'); exec(`git push ${remote} :latest`); - exec(`git tag latest`); + exec('git tag latest'); exec(`git push ${remote} latest`); } diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index c6c5ae876..96e373181 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -47,20 +47,20 @@ */ /*eslint-disable no-undef */ -require(`shelljs/global`); +require('shelljs/global'); const buildBranch = process.env.CIRCLE_BRANCH; let branchVersion; -if (buildBranch.indexOf(`-stable`) !== -1) { - branchVersion = buildBranch.slice(0, buildBranch.indexOf(`-stable`)); +if (buildBranch.indexOf('-stable') !== -1) { + branchVersion = buildBranch.slice(0, buildBranch.indexOf('-stable')); } else { - echo(`Error: We publish only from stable branches`); + echo('Error: We publish only from stable branches'); exit(0); } // 34c034298dc9cad5a4553964a5a324450fda0385 -const currentCommit = exec(`git rev-parse HEAD`, {silent: true}).stdout.trim(); +const currentCommit = exec('git rev-parse HEAD', {silent: true}).stdout.trim(); // [34c034298dc9cad5a4553964a5a324450fda0385, refs/heads/0.33-stable, refs/tags/latest, refs/tags/v0.33.1, refs/tags/v0.34.1-rc] const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, {silent: true}) .stdout.split(/\s/) @@ -69,14 +69,14 @@ const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, {si // ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2'] .filter(version => version.indexOf(branchVersion) !== -1) // ['v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2'] - .map(version => version.slice(`refs/tags/`.length)); + .map(version => version.slice('refs/tags/'.length)); if (tagsWithVersion.length === 0) { - echo(`Error: Can't find version tag in current commit. To deploy to NPM you must add tag v0.XY.Z[-rc] to your commit`); + echo('Error: Can\'t find version tag in current commit. To deploy to NPM you must add tag v0.XY.Z[-rc] to your commit'); exit(1); } let releaseVersion; -if (tagsWithVersion[0].indexOf(`-rc`) === -1) { +if (tagsWithVersion[0].indexOf('-rc') === -1) { // if first tag on this commit is non -rc then we are making a stable release // '0.33.0' releaseVersion = tagsWithVersion[0].slice(1); @@ -87,33 +87,33 @@ if (tagsWithVersion[0].indexOf(`-rc`) === -1) { } // -------- Generating Android Artifacts with JavaDoc -if (exec(`./gradlew :ReactAndroid:installArchives`).code) { - echo(`Couldn't generate artifacts`); +if (exec('./gradlew :ReactAndroid:installArchives').code) { + echo('Couldn\'t generate artifacts'); exit(1); } // undo uncommenting javadoc setting -exec(`git checkout ReactAndroid/gradle.properties`); +exec('git checkout ReactAndroid/gradle.properties'); -echo("Generated artifacts for Maven"); +echo('Generated artifacts for Maven'); let artifacts = ['-javadoc.jar', '-sources.jar', '.aar', '.pom'].map((suffix) => { return `react-native-${releaseVersion}${suffix}`; }); artifacts.forEach((name) => { - if (!test(`-e`, `./android/com/facebook/react/react-native/${releaseVersion}/${name}`)) { + if (!test('-e', `./android/com/facebook/react/react-native/${releaseVersion}/${name}`)) { echo(`file ${name} was not generated`); exit(1); } }); -if (releaseVersion.indexOf(`-rc`) === -1) { +if (releaseVersion.indexOf('-rc') === -1) { // release, package will be installed by default - exec(`npm publish`); + exec('npm publish'); } else { // RC release, package will be installed only if users specifically do it - exec(`npm publish --tag next`); + exec('npm publish --tag next'); } echo(`Published to npm ${releaseVersion}`); diff --git a/website/core/BlogPostFooter.js b/website/core/BlogPostFooter.js index dbfdd421a..938c141fd 100644 --- a/website/core/BlogPostFooter.js +++ b/website/core/BlogPostFooter.js @@ -31,7 +31,7 @@ class BlogPostFooter extends React.Component {
- Tweet + data-show-faces="false" /> + Tweet diff --git a/website/core/BlogPostHeader.js b/website/core/BlogPostHeader.js index a275d0de7..6707728c3 100644 --- a/website/core/BlogPostHeader.js +++ b/website/core/BlogPostHeader.js @@ -24,18 +24,18 @@ class BlogPostHeader extends React.Component { } var title = post.title; - var href = "/react-native/blog/" + post.path; + var href = '/react-native/blog/' + post.path; if (this.props.excerpt) { title = {post.title}; hero = {hero}; } if (post.youtubeVideoId) { - var embedURL = "https://www.youtube.com/embed/" + post.youtubeVideoId; + var embedURL = 'https://www.youtube.com/embed/' + post.youtubeVideoId; hero =
+ frameBorder="0" />
; } diff --git a/website/core/ExcerptLink.js b/website/core/ExcerptLink.js index b167bd8be..3cde26162 100644 --- a/website/core/ExcerptLink.js +++ b/website/core/ExcerptLink.js @@ -15,10 +15,10 @@ var React = require('React'); class ExcerptLink extends React.Component { render() { - var cta = "Read more"; + var cta = 'Read more'; - if (this.props.category === "videos") { - cta = "Watch video"; + if (this.props.category === 'videos') { + cta = 'Watch video'; } return ( diff --git a/website/jsdocs/TypeExpressionParser.js b/website/jsdocs/TypeExpressionParser.js index b84ec2e38..f7dadab3b 100644 --- a/website/jsdocs/TypeExpressionParser.js +++ b/website/jsdocs/TypeExpressionParser.js @@ -227,7 +227,7 @@ function parseSegmentType(stream, pos) { var segmentAst; if (stream[pos].type == TOKENS.OPENSEGMENT && (segmentAst = parseAnyType(stream, ++pos))) { - pos += segmentAst.length + pos += segmentAst.length; if (stream[pos].type == TOKENS.CLOSESEGMENT) { return createAst(SYMBOLS.SEGMENT, segmentAst, segmentAst.length + 2); } @@ -235,9 +235,9 @@ function parseSegmentType(stream, pos) { } function parseAnyType(stream, pos, parsers) { - if (!parsers) parsers = + if (!parsers) {parsers = PARSERS.SEGMENT | PARSERS.SIMPLE | PARSERS.UNION | PARSERS.GENERIC - | PARSERS.FUNCTION; + | PARSERS.FUNCTION;} var ast = (parsers & PARSERS.UNION && parseUnionType(stream, pos)) || diff --git a/website/jsdocs/findExportDefinition.js b/website/jsdocs/findExportDefinition.js index fd51eb43f..7533700bc 100644 --- a/website/jsdocs/findExportDefinition.js +++ b/website/jsdocs/findExportDefinition.js @@ -71,7 +71,7 @@ function isAssignmentStatement(node) { */ function expressionToArray(expr) { var parts = []; - switch(expr.type) { + switch (expr.type) { case Syntax.CallExpression: parts = expressionToArray(expr.callee); break; diff --git a/website/jsdocs/generic-function-visitor.js b/website/jsdocs/generic-function-visitor.js index 373798199..f08b47f79 100644 --- a/website/jsdocs/generic-function-visitor.js +++ b/website/jsdocs/generic-function-visitor.js @@ -48,7 +48,7 @@ function getTypeHintsFromDocBlock(node, docBlocksByLine) { }, {}); var param; - while(param = paramRe.exec(comments.value)) { + while (param = paramRe.exec(comments.value)) { if (!param[1]) { continue; @@ -80,7 +80,7 @@ function getTypeHintsFromDocBlock(node, docBlocksByLine) { var returnType = returnRe.exec(comments.value); if (returnType && returnType[1]) { throw new Error(util.format('Lines: %s-%s: Your @return declaration in' + - ' function %s is incorrectly written as @returns. Remove the trailing'+ + ' function %s is incorrectly written as @returns. Remove the trailing' + ' \'s\'.', comments.loc.start.line, comments.loc.end.line, functionName)); } @@ -107,7 +107,7 @@ function getTypeHintFromInline(node, commentsByLine) { */ function parseComments(programNode, state) { programNode.comments.forEach(function(c) { - if (c.type !== 'Block') return; + if (c.type !== 'Block') {return;} var comments; if (c.loc.start.line === c.loc.end.line && @@ -156,8 +156,8 @@ function normalizeTypeHintParams(node, state, typeHints) { if (typeHint[1]) { preCond.push([ typeHint[0], - '\''+ type.parseAndNormalize(typeHint[1], typeHint[0], node) +'\'', - '\''+ typeHint[0] +'\'' + '\'' + type.parseAndNormalize(typeHint[1], typeHint[0], node) + '\'', + '\'' + typeHint[0] + '\'' ]); } }); diff --git a/website/jsdocs/jsdocs.js b/website/jsdocs/jsdocs.js index 139dacdc8..c48ba118e 100644 --- a/website/jsdocs/jsdocs.js +++ b/website/jsdocs/jsdocs.js @@ -108,7 +108,7 @@ function getFileDocBlock(commentsForFile) { var lines = comment.value.split('\n'); var inCopyrightBlock = false; var filteredLines = lines.filter(function(line) { - if (!!line.match(/^\s*\*\s+Copyright \(c\)/)) { + if (line.match(/^\s*\*\s+Copyright \(c\)/)) { inCopyrightBlock = true; } @@ -474,7 +474,7 @@ function getRequireData(node) { || (callee.name !== 'require')) { return null; } - var args = node['arguments']; + var args = node.arguments; if (args.length === 0) { return null; } diff --git a/website/layout/AutodocsLayout.js b/website/layout/AutodocsLayout.js index d8d6e8921..d8d9baa4c 100644 --- a/website/layout/AutodocsLayout.js +++ b/website/layout/AutodocsLayout.js @@ -561,7 +561,7 @@ class APIDoc extends React.Component { ); - }; + } renderMainDescription(content) { if (content.docblock) { @@ -655,7 +655,7 @@ class Method extends React.Component { ); }); - }; + } renderMethodParameters(params) { if (!params || !params.length) { diff --git a/website/layout/BlogPageLayout.js b/website/layout/BlogPageLayout.js index 5b1c388c1..2241e8bff 100644 --- a/website/layout/BlogPageLayout.js +++ b/website/layout/BlogPageLayout.js @@ -47,7 +47,7 @@ class BlogPageLayout extends React.Component { .map((post) => { return ( - ) + ); }) }
diff --git a/website/publish-gh-pages.js b/website/publish-gh-pages.js index 59ec37514..d31c683c1 100644 --- a/website/publish-gh-pages.js +++ b/website/publish-gh-pages.js @@ -28,124 +28,124 @@ const CI_PULL_REQUEST = process.env.CI_PULL_REQUEST; const GIT_USER = process.env.GIT_USER; const remoteBranch = `https://${GIT_USER}@github.com/facebook/react-native.git`; -if (!which(`git`)) { - echo(`Sorry, this script requires git`); +if (!which('git')) { + echo('Sorry, this script requires git'); exit(1); } let version; let areVersionlessSectionsToBeDeployed = false; -if (CIRCLE_BRANCH.indexOf(`-stable`) !== -1) { - version = CIRCLE_BRANCH.slice(0, CIRCLE_BRANCH.indexOf(`-stable`)); -} else if (CIRCLE_BRANCH === `master`) { - version = `next`; +if (CIRCLE_BRANCH.indexOf('-stable') !== -1) { + version = CIRCLE_BRANCH.slice(0, CIRCLE_BRANCH.indexOf('-stable')); +} else if (CIRCLE_BRANCH === 'master') { + version = 'next'; areVersionlessSectionsToBeDeployed = true; } -rm(`-rf`, `build`); -mkdir(`-p`, `build`); +rm('-rf', 'build'); +mkdir('-p', 'build'); // if current commit is tagged "latest" we do a release to gh-pages root -const currentCommit = exec(`git rev-parse HEAD`).stdout.trim(); -const latestTagCommit = exec(`git ls-remote origin latest`).stdout.split(/\s/)[0]; +const currentCommit = exec('git rev-parse HEAD').stdout.trim(); +const latestTagCommit = exec('git ls-remote origin latest').stdout.split(/\s/)[0]; // pass along which branch contains latest version so that gh-pages root could mark it as latest const branchWithLatestTag = exec(`git branch -r --contains ${latestTagCommit}`).stdout.split('/')[1]; -let latestVersion = ``; -if (branchWithLatestTag.indexOf(`-stable`) !== -1) { - latestVersion = branchWithLatestTag.slice(0, branchWithLatestTag.indexOf(`-stable`)); +let latestVersion = ''; +if (branchWithLatestTag.indexOf('-stable') !== -1) { + latestVersion = branchWithLatestTag.slice(0, branchWithLatestTag.indexOf('-stable')); } -if (!CI_PULL_REQUEST && CIRCLE_PROJECT_USERNAME === `facebook`) { +if (!CI_PULL_REQUEST && CIRCLE_PROJECT_USERNAME === 'facebook') { echo(`Building branch ${version}, preparing to push to gh-pages`); // if code is running in a branch in CI, commit changes to gh-pages branch - cd(`build`); - rm(`-rf`, `react-native-gh-pages`); + cd('build'); + rm('-rf', 'react-native-gh-pages'); if (exec(`git clone ${remoteBranch} react-native-gh-pages`).code !== 0) { - echo(`Error: Git clone failed`); + echo('Error: Git clone failed'); exit(1); } - cd(`react-native-gh-pages`); + cd('react-native-gh-pages'); - if (exec(`git checkout origin/gh-pages`).code + - exec(`git checkout -b gh-pages`).code + - exec(`git branch --set-upstream-to=origin/gh-pages`).code !== 0 + if (exec('git checkout origin/gh-pages').code + + exec('git checkout -b gh-pages').code + + exec('git branch --set-upstream-to=origin/gh-pages').code !== 0 ) { - echo(`Error: Git checkout gh-pages failed`); + echo('Error: Git checkout gh-pages failed'); exit(1); } - cd(`releases`); - let releasesFolders = ls(`-d`, `*`); - cd(`..`); - let versions = releasesFolders.filter(name => name !== `next`); - if (version !== `next` && versions.indexOf(version) === -1) { + cd('releases'); + let releasesFolders = ls('-d', '*'); + cd('..'); + let versions = releasesFolders.filter(name => name !== 'next'); + if (version !== 'next' && versions.indexOf(version) === -1) { versions.push(version); } versions.sort(semverCmp).reverse(); // generate to releases/XX when branch name indicates that it is some sort of release - if (!!version) { + if (version) { echo(`------------ DEPLOYING /releases/${version}`); - rm(`-rf`, `releases/${version}`); - mkdir(`-p`, `releases/${version}`); - cd(`../..`); + rm('-rf', `releases/${version}`); + mkdir('-p', `releases/${version}`); + cd('../..'); if (exec(`RN_DEPLOYMENT_PATH=releases/${version} RN_VERSION=${version} RN_LATEST_VERSION=${latestVersion} \ RN_AVAILABLE_DOCS_VERSIONS=${versions.join(',')} node server/generate.js`).code !== 0) { - echo(`Error: Generating HTML failed`); + echo('Error: Generating HTML failed'); exit(1); } - cd(`build/react-native-gh-pages`); + cd('build/react-native-gh-pages'); // blog, showcase, support are copied separately - let toCopy = ls(`../react-native`) - .filter(file => (file !== `blog`) && (file !== `showcase.html`) && (file !== `support.html`)) + let toCopy = ls('../react-native') + .filter(file => (file !== 'blog') && (file !== 'showcase.html') && (file !== 'support.html')) .map(file => `../react-native/${file}`); - cp(`-R`, toCopy, `releases/${version}`); + cp('-R', toCopy, `releases/${version}`); // versions.html is located in root of website and updated with every release - cp(`../react-native/versions.html`, `.`); + cp('../react-native/versions.html', '.'); } // generate to root folder when commit is tagged as latest, i.e. stable and needs to be shown at the root of repo if (currentCommit === latestTagCommit) { - echo(`------------ DEPLOYING latest`); + echo('------------ DEPLOYING latest'); // leave only releases and blog folder - rm(`-rf`, ls(`*`).filter(name => (name !== 'releases') && (name !== 'blog') && (name !== 'showcase.html') && (name !== 'support.html'))); - cd(`../..`); + rm('-rf', ls('*').filter(name => (name !== 'releases') && (name !== 'blog') && (name !== 'showcase.html') && (name !== 'support.html'))); + cd('../..'); if (exec(`RN_VERSION=${version} RN_LATEST_VERSION=${latestVersion} \ RN_AVAILABLE_DOCS_VERSIONS=${versions} node server/generate.js`).code !== 0) { - echo(`Error: Generating HTML failed`); + echo('Error: Generating HTML failed'); exit(1); } - cd(`build/react-native-gh-pages`); + cd('build/react-native-gh-pages'); // blog, showcase, support are copied separately - let toCopy = ls(`../react-native`) - .filter(file => (file !== `blog`) && (file !== `showcase.html`) && (file !== `support.html`)) + let toCopy = ls('../react-native') + .filter(file => (file !== 'blog') && (file !== 'showcase.html') && (file !== 'support.html')) .map(file => `../react-native/${file}`); - cp(`-R`, toCopy, `.`); + cp('-R', toCopy, '.'); } // blog, showcase, support are versionless, we always build them in root file if (areVersionlessSectionsToBeDeployed) { - echo(`------------ COPYING blog`); - rm(`-rf`, `blog`); - cp(`-R`, `../react-native/blog`, `.`); - echo(`------------ COPYING showcase`); - cp(`../react-native/showcase.html`, `.`); - echo(`------------ COPYING support`); - cp(`../react-native/support.html`, `.`); + echo('------------ COPYING blog'); + rm('-rf', 'blog'); + cp('-R', '../react-native/blog', '.'); + echo('------------ COPYING showcase'); + cp('../react-native/showcase.html', '.'); + echo('------------ COPYING support'); + cp('../react-native/support.html', '.'); } if (currentCommit === latestTagCommit || version) { - exec(`git status`); - exec(`git add -A .`); - if (exec(`git diff-index --quiet HEAD --`).code !== 0) { + exec('git status'); + exec('git add -A .'); + if (exec('git diff-index --quiet HEAD --').code !== 0) { if (exec(`git commit -m "Updated docs for ${version}"`).code !== 0) { - echo(`Error: Git commit gh-pages failed`); + echo('Error: Git commit gh-pages failed'); exit(1); } - if (exec(`git push origin gh-pages`).code !== 0) { - echo(`Error: Git push gh-pages failed`); + if (exec('git push origin gh-pages').code !== 0) { + echo('Error: Git push gh-pages failed'); exit(1); } } - echo(`------------ gh-pages updated`); + echo('------------ gh-pages updated'); } } diff --git a/website/server/convert.js b/website/server/convert.js index a6f704836..59f2c8bb7 100644 --- a/website/server/convert.js +++ b/website/server/convert.js @@ -9,7 +9,7 @@ 'use strict'; -var fs = require('fs') +var fs = require('fs'); var glob = require('glob'); var mkdirp = require('mkdirp'); var optimist = require('optimist'); @@ -36,7 +36,7 @@ function splitHeader(content) { function rmFile(file) { try { fs.unlinkSync(file); - } catch(e) { + } catch (e) { /* seriously, unlink throws when the file doesn't exist :( */ } } @@ -63,7 +63,7 @@ function extractMetadata(content) { var key = keyvalue[0].trim(); var value = keyvalue.slice(1).join(':').trim(); // Handle the case where you have "Community #10" - try { value = JSON.parse(value); } catch(e) { } + try { value = JSON.parse(value); } catch (e) { } metadata[key] = value; } return {metadata: metadata, rawContent: both.content}; diff --git a/website/server/generate.js b/website/server/generate.js index c69365ea1..48593f433 100644 --- a/website/server/generate.js +++ b/website/server/generate.js @@ -61,7 +61,7 @@ queue = queue.then(function() { mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), '')); fs.writeFileSync(targetFile, feed.render('atom-1.0')); - console.log('Generated RSS feed') + console.log('Generated RSS feed'); resolve(); }); });