From 885f2c28d4e8ed66e334fd7bd0174173b2a394e1 Mon Sep 17 00:00:00 2001 From: Drapich Piotr Date: Tue, 5 Mar 2019 20:52:51 +0100 Subject: [PATCH] chore: use @react-native-community/eslint-config (#205) Summary: --------- I changed @callstack/eslint-config to @react-native-community/eslint-config and fixed all lint issues. Test Plan: ---------- Green CI --- babel.config.js | 7 +- package.json | 18 +- packages/cli/src/__mocks__/fs.js | 12 +- packages/cli/src/__mocks__/path.js | 2 +- packages/cli/src/cliEntry.js | 24 +- .../__tests__/getAssetDestPathAndroid-test.js | 6 +- .../__tests__/getAssetDestPathIOS-test.js | 6 +- .../cli/src/commands/bundle/assetPathUtils.js | 4 +- .../cli/src/commands/bundle/buildBundle.js | 6 +- packages/cli/src/commands/bundle/bundle.js | 2 +- .../bundle/filterPlatformAssetScales.js | 2 +- .../bundle/getAssetDestPathAndroid.js | 4 +- .../commands/bundle/getAssetDestPathIOS.js | 2 +- packages/cli/src/commands/bundle/ramBundle.js | 2 +- .../cli/src/commands/bundle/saveAssets.js | 2 +- .../src/commands/dependencies/dependencies.js | 6 +- packages/cli/src/commands/eject/eject.js | 21 +- packages/cli/src/commands/index.js | 8 +- packages/cli/src/commands/info/info.js | 4 +- packages/cli/src/commands/init/init.js | 13 +- packages/cli/src/commands/install/install.js | 7 +- .../cli/src/commands/install/uninstall.js | 4 +- packages/cli/src/commands/library/library.js | 6 +- .../link/__tests__/android/applyPatch-test.js | 6 +- .../__tests__/android/isInstalled-test.js | 4 +- .../__tests__/android/makeBuildPatch-test.js | 14 +- .../__tests__/android/makeImportPatch-test.js | 4 +- .../android/makePackagePatch-test.js | 4 +- .../android/makeSettingsPatch-test.js | 12 +- .../android/makeStringsPatch-test.js | 2 +- .../__tests__/getDependencyConfig-test.js | 10 +- .../__tests__/getProjectDependencies-test.js | 2 +- .../__tests__/ios/addFileToProject-test.js | 8 +- .../ios/addProjectToLibraries-test.js | 4 +- .../__tests__/ios/addSharedLibraries-test.js | 2 +- .../link/__tests__/ios/createGroup-test.js | 6 +- .../__tests__/ios/getBuildProperty-test.js | 2 +- .../link/__tests__/ios/getGroup-test.js | 2 +- .../__tests__/ios/getHeaderSearchPath-test.js | 22 +- .../link/__tests__/ios/getPlist-test.js | 2 +- .../link/__tests__/ios/getPlistPath-test.js | 2 +- .../link/__tests__/ios/getTargets-test.js | 2 +- .../__tests__/ios/hasLibraryImported-test.js | 2 +- .../link/__tests__/ios/isInstalled-test.js | 6 +- .../ios/mapHeaderSearchPaths-test.js | 2 +- .../ios/removeProjectFromLibraries-test.js | 6 +- .../ios/removeProjectFromProject-test.js | 4 +- .../__tests__/ios/removeSharedLibrary-test.js | 2 +- .../link/__tests__/ios/writePlist-test.js | 8 +- .../src/commands/link/__tests__/link-test.js | 58 ++- .../__tests__/pods/findLineToAddPod-test.js | 16 +- .../pods/findMarkedLinesInPodfile-test.js | 8 +- .../link/__tests__/pods/isInstalled-test.js | 14 +- .../__tests__/pods/removePodEntry-test.js | 10 +- .../link/__tests__/promiseWaterfall-test.js | 2 +- .../src/commands/link/android/copyAssets.js | 4 +- .../cli/src/commands/link/android/index.js | 2 +- .../link/android/patches/applyParams.js | 2 +- .../link/android/patches/applyPatch.js | 2 +- .../link/android/patches/makeBuildPatch.js | 2 +- .../link/android/patches/makeSettingsPatch.js | 4 +- .../link/android/patches/makeStringsPatch.js | 2 +- .../link/android/patches/revokePatch.js | 2 +- .../link/android/registerNativeModule.js | 8 +- .../src/commands/link/android/unlinkAssets.js | 2 +- .../link/android/unregisterNativeModule.js | 12 +- .../src/commands/link/getDependencyConfig.js | 6 +- .../cli/src/commands/link/getProjectConfig.js | 6 +- .../commands/link/getProjectDependencies.js | 2 +- .../cli/src/commands/link/groupFilesByType.js | 2 +- .../commands/link/ios/addSharedLibraries.js | 2 +- .../link/ios/common/registerNativeModule.js | 2 +- .../link/ios/common/unregisterNativeModule.js | 4 +- .../cli/src/commands/link/ios/copyAssets.js | 2 +- .../link/ios/createGroupWithMessage.js | 2 +- .../commands/link/ios/getHeaderSearchPath.js | 4 +- .../cli/src/commands/link/ios/getPlistPath.js | 2 +- .../cli/src/commands/link/ios/getTargets.js | 2 +- packages/cli/src/commands/link/ios/index.js | 2 +- .../commands/link/ios/mapHeaderSearchPaths.js | 2 +- .../commands/link/ios/registerNativeModule.js | 10 +- .../link/ios/removeFromHeaderSearchPaths.js | 2 +- .../link/ios/removeFromProjectReferences.js | 6 +- .../link/ios/removeProjectFromLibraries.js | 3 +- .../link/ios/removeSharedLibraries.js | 2 +- .../cli/src/commands/link/ios/unlinkAssets.js | 10 +- .../link/ios/unregisterNativeModule.js | 12 +- .../cli/src/commands/link/ios/writePlist.js | 2 +- packages/cli/src/commands/link/link.js | 12 +- packages/cli/src/commands/link/linkAll.js | 16 +- packages/cli/src/commands/link/linkAssets.js | 6 +- .../cli/src/commands/link/linkDependency.js | 14 +- .../cli/src/commands/link/pods/addPodEntry.js | 8 +- .../link/pods/findMarkedLinesInPodfile.js | 2 +- .../cli/src/commands/link/pods/isInstalled.js | 2 +- .../link/pods/registerNativeModule.js | 4 +- .../src/commands/link/pods/removePodEntry.js | 2 +- .../cli/src/commands/link/promiseWaterfall.js | 2 +- packages/cli/src/commands/link/promisify.js | 2 +- packages/cli/src/commands/link/unlink.js | 32 +- .../cli/src/commands/logAndroid/logAndroid.js | 4 +- packages/cli/src/commands/logIOS/logIOS.js | 8 +- .../__tests__/runOnAllDevices.test.js | 4 +- packages/cli/src/commands/runAndroid/adb.js | 6 +- .../cli/src/commands/runAndroid/runAndroid.js | 48 ++- .../commands/runAndroid/runOnAllDevices.js | 26 +- .../runAndroid/tryLaunchAppOnDevice.js | 8 +- .../commands/runAndroid/tryRunAdbReverse.js | 2 +- .../__tests__/findMatchingSimulator-test.js | 50 +-- .../runIOS/__tests__/findXcodeProject-test.js | 6 +- .../__tests__/parseIOSDevicesList-test.js | 4 +- .../commands/runIOS/findMatchingSimulator.js | 9 +- .../commands/runIOS/parseIOSDevicesList.js | 2 +- packages/cli/src/commands/runIOS/runIOS.js | 63 ++-- .../src/commands/server/copyToClipBoard.js | 2 +- .../server/debugger-ui/DeltaPatcher.js | 4 +- .../server/debugger-ui/debuggerWorker.js | 6 +- .../src/commands/server/jsPackagerClient.js | 16 +- .../cli/src/commands/server/launchChrome.js | 6 +- .../cli/src/commands/server/launchEditor.js | 16 +- .../cli/src/commands/server/messageSocket.js | 33 +- .../server/middleware/MiddlewareManager.js | 4 +- .../middleware/getDevToolsMiddleware.js | 8 +- .../openStackFrameInEditorMiddleware.js | 2 +- .../middleware/systraceProfileMiddleware.js | 6 +- packages/cli/src/commands/server/runServer.js | 8 +- .../cli/src/commands/server/webSocketProxy.js | 8 +- .../upgrade/__tests__/upgrade.test.js | 31 +- packages/cli/src/commands/upgrade/helpers.js | 2 +- .../cli/src/commands/upgrade/legacyUpgrade.js | 34 +- packages/cli/src/commands/upgrade/upgrade.js | 70 ++-- packages/cli/src/tools/PackageManager.js | 10 +- .../cli/src/tools/__fixtures__/android.js | 10 +- packages/cli/src/tools/__fixtures__/ios.js | 4 +- .../cli/src/tools/__fixtures__/projects.js | 2 +- .../tools/__tests__/PackageManager-test.js | 36 +- .../android/findPackageClassName-test.js | 6 +- .../src/tools/__tests__/findAssets-test.js | 4 +- .../src/tools/__tests__/findPlugins-test.js | 20 +- .../tools/__tests__/ios/findProject-test.js | 8 +- .../__tests__/ios/getProjectConfig-test.js | 2 +- .../src/tools/__tests__/makeCommand-test.js | 2 +- .../src/tools/android/findPackageClassName.js | 2 +- packages/cli/src/tools/android/index.js | 12 +- .../cli/src/tools/assertRequiredOptions.js | 4 +- packages/cli/src/tools/copyAndReplace.js | 2 +- packages/cli/src/tools/findPlugins.js | 14 +- .../cli/src/tools/findReactNativeScripts.js | 2 +- .../cli/src/tools/findSymlinkedModules.js | 12 +- .../copyProjectTemplateAndReplace.js | 18 +- .../tools/generator/printRunInstructions.js | 4 +- .../cli/src/tools/generator/promptSync.js | 6 +- packages/cli/src/tools/generator/templates.js | 32 +- packages/cli/src/tools/getAssets.js | 4 +- packages/cli/src/tools/getHooks.js | 5 +- packages/cli/src/tools/getLegacyConfig.js | 2 +- .../cli/src/tools/getPackageConfiguration.js | 4 +- packages/cli/src/tools/getPlatforms.js | 6 +- packages/cli/src/tools/ios/findPodspecName.js | 6 +- packages/cli/src/tools/ios/findProject.js | 2 +- packages/cli/src/tools/isPackagerRunning.js | 7 +- packages/cli/src/tools/loadMetroConfig.js | 24 +- packages/cli/src/tools/types.flow.js | 12 +- packages/cli/src/tools/yarn.js | 2 +- packages/global-cli/index.js | 35 +- scripts/build.js | 16 +- scripts/watch.js | 12 +- yarn.lock | 332 ++++++------------ 168 files changed, 820 insertions(+), 1004 deletions(-) diff --git a/babel.config.js b/babel.config.js index 2621b5d72..fd9551e17 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,7 @@ module.exports = { [ require.resolve('@babel/preset-env'), { - targets: { node: 8 }, + targets: {node: 8}, useBuiltIns: 'entry', }, ], @@ -12,9 +12,6 @@ module.exports = { ], plugins: [ require.resolve('@babel/plugin-transform-strict-mode'), - [ - require.resolve('@babel/plugin-transform-modules-commonjs'), - { lazy: true }, - ], + [require.resolve('@babel/plugin-transform-modules-commonjs'), {lazy: true}], ], }; diff --git a/package.json b/package.json index d03f91bc2..4689b5538 100644 --- a/package.json +++ b/package.json @@ -19,32 +19,26 @@ "@babel/plugin-transform-strict-mode": "^7.0.0", "@babel/preset-env": "^7.0.0", "@babel/preset-flow": "^7.0.0", - "@callstack/eslint-config": "^3.0.2", + "@react-native-community/eslint-config": "^0.0.2", "babel-jest": "^24.0.0", "chalk": "^2.4.2", "eslint": "^5.10.0", - "eslint-plugin-prettier": "^3.0.1", "flow-bin": "^0.94.0", "glob": "^7.1.3", "jest": "^24.0.0", "lerna": "^3.10.6", "micromatch": "^3.1.10", "mkdirp": "^0.5.1", - "prettier": "^1.16.0", "string-length": "^2.0.0" }, "eslintConfig": { - "extends": "@callstack", - "rules": { - "global-require": 0, - "no-console": 0 + "extends": "@react-native-community", + "env": { + "es6": true, + "jest": true, + "node": true } }, - "prettier": { - "proseWrap": "never", - "singleQuote": true, - "trailingComma": "es5" - }, "jest": { "projects": [ "packages/*" diff --git a/packages/cli/src/__mocks__/fs.js b/packages/cli/src/__mocks__/fs.js index f6cde8d67..2220206cf 100644 --- a/packages/cli/src/__mocks__/fs.js +++ b/packages/cli/src/__mocks__/fs.js @@ -14,7 +14,7 @@ let fs; function setMockFilesystem(object, platform) { reset(platform); const root = platform === 'win32' ? 'c:\\' : '/'; - mockDir(root, { ...object }); + mockDir(root, {...object}); return root; } @@ -24,14 +24,14 @@ function mockDir(dirPath, desc) { const entPath = path.join(dirPath, entName); if (typeof ent === 'string' || ent instanceof Buffer) { fs.writeFileSync(entPath, ent); - continue; // eslint-disable-line no-continue + continue; } if (typeof ent !== 'object') { throw new Error(util.format('invalid entity:', ent)); } if (ent.SYMLINK != null) { fs.symlinkSync(ent.SYMLINK, entPath); - continue; // eslint-disable-line no-continue + continue; } fs.mkdirSync(entPath); mockDir(entPath, ent); @@ -41,18 +41,18 @@ function mockDir(dirPath, desc) { function reset(platform) { if (path.mock == null) { throw new Error( - 'to use this "fs" module mock, you must also mock the "path" module' + 'to use this "fs" module mock, you must also mock the "path" module', ); } path.mock.reset(platform); const cwd = () => (platform === 'win32' ? 'c:\\' : '/'); - fs = new MemoryFS({ platform, cwd }); + fs = new MemoryFS({platform, cwd}); Object.assign(mockFs, fs); } const mockFs = {}; mockFs.__setMockFilesystem = setMockFilesystem; -mockFs.mock = { clear: reset }; +mockFs.mock = {clear: reset}; reset('posix'); diff --git a/packages/cli/src/__mocks__/path.js b/packages/cli/src/__mocks__/path.js index 884f26590..b19d3d3b4 100644 --- a/packages/cli/src/__mocks__/path.js +++ b/packages/cli/src/__mocks__/path.js @@ -13,7 +13,7 @@ function reset(platform) { Object.assign(mockPath, jest.requireActual('path')[platform]); } -mockPath.mock = { reset }; +mockPath.mock = {reset}; reset('posix'); diff --git a/packages/cli/src/cliEntry.js b/packages/cli/src/cliEntry.js index 8e8efe5ca..90ee8dea5 100644 --- a/packages/cli/src/cliEntry.js +++ b/packages/cli/src/cliEntry.js @@ -12,9 +12,9 @@ import childProcess from 'child_process'; import commander from 'commander'; import minimist from 'minimist'; import path from 'path'; -import type { CommandT, ContextT } from './tools/types.flow'; +import type {CommandT, ContextT} from './tools/types.flow'; import getLegacyConfig from './tools/getLegacyConfig'; -import { getCommands } from './commands'; +import {getCommands} from './commands'; import init from './commands/init/init'; import assertRequiredOptions from './tools/assertRequiredOptions'; import logger from './tools/logger'; @@ -81,8 +81,8 @@ function printUnknownCommand(cmdName) { logger.error(`Unrecognized command "${chalk.bold(cmdName)}".`); logger.info( `Run ${chalk.bold( - '"react-native --help"' - )} to see a list of all available commands.` + '"react-native --help"', + )} to see a list of all available commands.`, ); } else { commander.outputHelp(); @@ -119,8 +119,8 @@ const addCommand = (command: CommandT, ctx: ContextT) => { opt.command, opt.description, opt.parse || defaultOptParser, - opt.default - ) + opt.default, + ), ); // Redefined here to appear in the `--help` section @@ -144,15 +144,15 @@ async function setupAndRun() { const absolutePath = path.join(__dirname, '..', scriptName); try { - childProcess.execFileSync(absolutePath, { stdio: 'pipe' }); + childProcess.execFileSync(absolutePath, {stdio: 'pipe'}); } catch (error) { logger.warn( `Failed to run environment setup script "${scriptName}"\n\n${chalk.red( - error - )}` + error, + )}`, ); logger.info( - `React Native CLI will continue to run if your local environment matches what React Native expects. If it does fail, check out "${absolutePath}" and adjust your environment to match it.` + `React Native CLI will continue to run if your local environment matches what React Native expects. If it does fail, check out "${absolutePath}" and adjust your environment to match it.`, ); } } @@ -177,11 +177,11 @@ async function setupAndRun() { // $FlowIssue: Wrong `require.resolve` type definition require.resolve('react-native/package.json', { paths: [root], - }) + }), ); } catch (_ignored) { throw new Error( - 'Unable to find React Native files. Make sure "react-native" module is installed in your project dependencies.' + 'Unable to find React Native files. Make sure "react-native" module is installed in your project dependencies.', ); } })(); diff --git a/packages/cli/src/commands/bundle/__tests__/getAssetDestPathAndroid-test.js b/packages/cli/src/commands/bundle/__tests__/getAssetDestPathAndroid-test.js index c169e0a3c..2670f14cd 100644 --- a/packages/cli/src/commands/bundle/__tests__/getAssetDestPathAndroid-test.js +++ b/packages/cli/src/commands/bundle/__tests__/getAssetDestPathAndroid-test.js @@ -25,7 +25,7 @@ describe('getAssetDestPathAndroid', () => { const expectDestPathForScaleToStartWith = (scale, location) => { if (!getAssetDestPathAndroid(asset, scale).startsWith(location)) { throw new Error( - `asset for scale ${scale} should start with path '${location}'` + `asset for scale ${scale} should start with path '${location}'`, ); } }; @@ -45,7 +45,7 @@ describe('getAssetDestPathAndroid', () => { }; expect(getAssetDestPathAndroid(asset, 1)).toBe( - path.normalize('drawable-mdpi/app_test_icon.png') + path.normalize('drawable-mdpi/app_test_icon.png'), ); }); @@ -67,7 +67,7 @@ describe('getAssetDestPathAndroid', () => { }; expect(getAssetDestPathAndroid(asset, 1)).toBe( - path.normalize('raw/app_test_video.mp4') + path.normalize('raw/app_test_video.mp4'), ); }); }); diff --git a/packages/cli/src/commands/bundle/__tests__/getAssetDestPathIOS-test.js b/packages/cli/src/commands/bundle/__tests__/getAssetDestPathIOS-test.js index 37878875a..7a820b617 100644 --- a/packages/cli/src/commands/bundle/__tests__/getAssetDestPathIOS-test.js +++ b/packages/cli/src/commands/bundle/__tests__/getAssetDestPathIOS-test.js @@ -23,7 +23,7 @@ describe('getAssetDestPathIOS', () => { }; expect(getAssetDestPathIOS(asset, 1)).toBe( - path.normalize('assets/test/icon.png') + path.normalize('assets/test/icon.png'), ); }); @@ -35,10 +35,10 @@ describe('getAssetDestPathIOS', () => { }; expect(getAssetDestPathIOS(asset, 2)).toBe( - path.normalize('assets/test/icon@2x.png') + path.normalize('assets/test/icon@2x.png'), ); expect(getAssetDestPathIOS(asset, 3)).toBe( - path.normalize('assets/test/icon@3x.png') + path.normalize('assets/test/icon@3x.png'), ); }); }); diff --git a/packages/cli/src/commands/bundle/assetPathUtils.js b/packages/cli/src/commands/bundle/assetPathUtils.js index 7778684de..32334dd72 100644 --- a/packages/cli/src/commands/bundle/assetPathUtils.js +++ b/packages/cli/src/commands/bundle/assetPathUtils.js @@ -56,8 +56,8 @@ function getAndroidResourceFolderName(asset: PackagerAsset, scale: number) { if (!suffix) { throw new Error( `Don't know which android drawable suffix to use for asset: ${JSON.stringify( - asset - )}` + asset, + )}`, ); } const androidFolder = `drawable-${suffix}`; diff --git a/packages/cli/src/commands/bundle/buildBundle.js b/packages/cli/src/commands/bundle/buildBundle.js index a10dc2457..fc9088354 100644 --- a/packages/cli/src/commands/bundle/buildBundle.js +++ b/packages/cli/src/commands/bundle/buildBundle.js @@ -11,8 +11,8 @@ import Server from 'metro/src/Server'; import outputBundle from 'metro/src/shared/output/bundle'; import path from 'path'; -import type { CommandLineArgs } from './bundleCommandLineArgs'; -import type { ContextT } from '../../tools/types.flow'; +import type {CommandLineArgs} from './bundleCommandLineArgs'; +import type {ContextT} from '../../tools/types.flow'; import saveAssets from './saveAssets'; import loadMetroConfig from '../../tools/loadMetroConfig'; import logger from '../../tools/logger'; @@ -20,7 +20,7 @@ import logger from '../../tools/logger'; async function buildBundle( args: CommandLineArgs, ctx: ContextT, - output: typeof outputBundle = outputBundle + output: typeof outputBundle = outputBundle, ) { const config = await loadMetroConfig(ctx, { resetCache: args.resetCache, diff --git a/packages/cli/src/commands/bundle/bundle.js b/packages/cli/src/commands/bundle/bundle.js index 5c5788209..dc9790ec5 100644 --- a/packages/cli/src/commands/bundle/bundle.js +++ b/packages/cli/src/commands/bundle/bundle.js @@ -28,4 +28,4 @@ export default { const withOutput = bundleWithOutput; -export { withOutput }; +export {withOutput}; diff --git a/packages/cli/src/commands/bundle/filterPlatformAssetScales.js b/packages/cli/src/commands/bundle/filterPlatformAssetScales.js index c34d6b4cd..94c6bd9fa 100644 --- a/packages/cli/src/commands/bundle/filterPlatformAssetScales.js +++ b/packages/cli/src/commands/bundle/filterPlatformAssetScales.js @@ -14,7 +14,7 @@ const ALLOWED_SCALES = { function filterPlatformAssetScales( platform: string, - scales: $ReadOnlyArray + scales: $ReadOnlyArray, ): $ReadOnlyArray { const whitelist = ALLOWED_SCALES[platform]; if (!whitelist) { diff --git a/packages/cli/src/commands/bundle/getAssetDestPathAndroid.js b/packages/cli/src/commands/bundle/getAssetDestPathAndroid.js index d331b2f19..510d6ab48 100644 --- a/packages/cli/src/commands/bundle/getAssetDestPathAndroid.js +++ b/packages/cli/src/commands/bundle/getAssetDestPathAndroid.js @@ -9,14 +9,14 @@ */ import path from 'path'; -import type { PackagerAsset } from './assetPathUtils'; +import type {PackagerAsset} from './assetPathUtils'; import assetPathUtils from './assetPathUtils'; function getAssetDestPathAndroid(asset: PackagerAsset, scale: number): string { const androidFolder = assetPathUtils.getAndroidResourceFolderName( asset, - scale + scale, ); const fileName = assetPathUtils.getAndroidResourceIdentifier(asset); return path.join(androidFolder, `${fileName}.${asset.type}`); diff --git a/packages/cli/src/commands/bundle/getAssetDestPathIOS.js b/packages/cli/src/commands/bundle/getAssetDestPathIOS.js index e8e153d03..cc50c2be1 100644 --- a/packages/cli/src/commands/bundle/getAssetDestPathIOS.js +++ b/packages/cli/src/commands/bundle/getAssetDestPathIOS.js @@ -9,7 +9,7 @@ */ import path from 'path'; -import type { PackagerAsset } from './assetPathUtils'; +import type {PackagerAsset} from './assetPathUtils'; function getAssetDestPathIOS(asset: PackagerAsset, scale: number): string { const suffix = scale === 1 ? '' : `@${scale}x`; diff --git a/packages/cli/src/commands/bundle/ramBundle.js b/packages/cli/src/commands/bundle/ramBundle.js index c4fdbd732..6b5e5a1af 100644 --- a/packages/cli/src/commands/bundle/ramBundle.js +++ b/packages/cli/src/commands/bundle/ramBundle.js @@ -8,7 +8,7 @@ */ import outputUnbundle from 'metro/src/shared/output/RamBundle'; -import { withOutput as bundleWithOutput } from './bundle'; +import {withOutput as bundleWithOutput} from './bundle'; import bundleCommandLineArgs from './bundleCommandLineArgs'; /** diff --git a/packages/cli/src/commands/bundle/saveAssets.js b/packages/cli/src/commands/bundle/saveAssets.js index c98bbb315..257cf111e 100644 --- a/packages/cli/src/commands/bundle/saveAssets.js +++ b/packages/cli/src/commands/bundle/saveAssets.js @@ -28,7 +28,7 @@ function saveAssets(assets, platform, assetsDest) { const filesToCopy = Object.create(null); // Map src -> dest assets.forEach(asset => { const validScales = new Set( - filterPlatformAssetScales(platform, asset.scales) + filterPlatformAssetScales(platform, asset.scales), ); asset.scales.forEach((scale, idx) => { if (!validScales.has(scale)) { diff --git a/packages/cli/src/commands/dependencies/dependencies.js b/packages/cli/src/commands/dependencies/dependencies.js index c7a4e5d46..2004e04e9 100644 --- a/packages/cli/src/commands/dependencies/dependencies.js +++ b/packages/cli/src/commands/dependencies/dependencies.js @@ -18,7 +18,7 @@ async function dependencies(argv, configPromise, args, packagerInstance) { const config = await configPromise; if (!fs.existsSync(rootModuleAbsolutePath)) { return Promise.reject( - new Error(`File ${rootModuleAbsolutePath} does not exist`) + new Error(`File ${rootModuleAbsolutePath} does not exist`), ); } @@ -26,7 +26,7 @@ async function dependencies(argv, configPromise, args, packagerInstance) { const relativePath = path.relative( config.projectRoot, - rootModuleAbsolutePath + rootModuleAbsolutePath, ); const options = { @@ -69,7 +69,7 @@ export default { description: 'lists dependencies', func: util.deprecate( dependencies, - 'dependencies command was moved to metro, and will be removed from cli in next release' + 'dependencies command was moved to metro, and will be removed from cli in next release', ), options: [ { diff --git a/packages/cli/src/commands/eject/eject.js b/packages/cli/src/commands/eject/eject.js index c8c970eb6..c746193fb 100644 --- a/packages/cli/src/commands/eject/eject.js +++ b/packages/cli/src/commands/eject/eject.js @@ -29,7 +29,7 @@ function eject() { if (doesIOSExist && doesAndroidExist) { logger.error( 'Both the iOS and Android folders already exist! Please delete `ios` and/or `android` ' + - 'before ejecting.' + 'before ejecting.', ); process.exit(1); } @@ -41,9 +41,9 @@ function eject() { logger.error( 'Eject requires an `app.json` config file to be located at ' + `${path.resolve( - 'app.json' + '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); } @@ -52,22 +52,21 @@ function eject() { if (!appName) { logger.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.' + 'It must not contain any spaces or dashes.', ); process.exit(1); } - // eslint-disable-next-line prefer-destructuring const displayName = appConfig.displayName; if (!displayName) { logger.error( 'App `displayName` must be defined in the `app.json` config file, to define the label ' + - 'of the app on the home screen.' + 'of the app on the home screen.', ); process.exit(1); } - const templateOptions = { displayName }; + const templateOptions = {displayName}; if (!doesIOSExist) { logger.info('Generating the iOS folder.'); @@ -79,11 +78,11 @@ function eject() { 'cli', 'templates', 'HelloWorld', - 'ios' + 'ios', ), path.resolve('ios'), appName, - templateOptions + templateOptions, ); } @@ -97,11 +96,11 @@ function eject() { 'cli', 'templates', 'HelloWorld', - 'android' + 'android', ), path.resolve('android'), appName, - templateOptions + templateOptions, ); } } diff --git a/packages/cli/src/commands/index.js b/packages/cli/src/commands/index.js index bab984b73..b35c831fb 100644 --- a/packages/cli/src/commands/index.js +++ b/packages/cli/src/commands/index.js @@ -85,16 +85,16 @@ const loadProjectCommands = (root: string): Array => { | Array = require(path.join( root, 'node_modules', - pathToCommands + pathToCommands, )); if (Array.isArray(requiredCommands)) { return acc.concat( - requiredCommands.map(requiredCommand => ({ ...requiredCommand, pkg })) + requiredCommands.map(requiredCommand => ({...requiredCommand, pkg})), ); } - return acc.concat({ ...requiredCommands }); + return acc.concat({...requiredCommands}); }, []); }; @@ -111,7 +111,7 @@ export function getCommands(root: string): Array { [ 'Looks like a React Native project already exists in the current', 'folder. Run this command from a different folder or remove node_modules/react-native', - ].join('\n') + ].join('\n'), ); }, }, diff --git a/packages/cli/src/commands/info/info.js b/packages/cli/src/commands/info/info.js index 9b6bffaca..aef9b2e64 100644 --- a/packages/cli/src/commands/info/info.js +++ b/packages/cli/src/commands/info/info.js @@ -24,7 +24,7 @@ const info = function getInfo(argv, ctx, options) { !options.packages.includes('*')) || !options.packages ? ['react', 'react-native'].concat( - (options.packages || '').split(',') + (options.packages || '').split(','), ) : options.packages, npmGlobalPackages: '*react-native*', @@ -32,7 +32,7 @@ const info = function getInfo(argv, ctx, options) { { clipboard: !!options.clipboard, title: 'React Native Environment Info', - } + }, ) .then(logger.info) .catch(err => { diff --git a/packages/cli/src/commands/init/init.js b/packages/cli/src/commands/init/init.js index c904c4d09..97dfedd18 100644 --- a/packages/cli/src/commands/init/init.js +++ b/packages/cli/src/commands/init/init.js @@ -12,7 +12,7 @@ import minimist from 'minimist'; import path from 'path'; import process from 'process'; import printRunInstructions from '../../tools/generator/printRunInstructions'; -import { createProjectFromTemplate } from '../../tools/generator/templates'; +import {createProjectFromTemplate} from '../../tools/generator/templates'; import PackageManager from '../../tools/PackageManager'; import logger from '../../tools/logger'; @@ -49,12 +49,11 @@ function init(projectDir, argsOrName) { * @param options Command line arguments parsed by minimist. */ function generateProject(destinationRoot, newProjectName, options) { - // eslint-disable-next-line import/no-unresolved const reactNativePackageJson = require('react-native/package.json'); - const { peerDependencies } = reactNativePackageJson; + const {peerDependencies} = reactNativePackageJson; if (!peerDependencies) { logger.error( - "Missing React peer dependency in React Native's package.json. Aborting." + "Missing React peer dependency in React Native's package.json. Aborting.", ); return; } @@ -62,7 +61,7 @@ function generateProject(destinationRoot, newProjectName, options) { const reactVersion = peerDependencies.react; if (!reactVersion) { logger.error( - "Missing React peer dependency in React Native's package.json. Aborting." + "Missing React peer dependency in React Native's package.json. Aborting.", ); return; } @@ -76,7 +75,7 @@ function generateProject(destinationRoot, newProjectName, options) { destinationRoot, newProjectName, options.template, - destinationRoot + destinationRoot, ); logger.info('Adding required dependencies'); @@ -109,7 +108,7 @@ function addJestToPackageJson(destinationRoot) { }; fs.writeFileSync( packageJSONPath, - `${JSON.stringify(packageJSON, null, 2)}\n` + `${JSON.stringify(packageJSON, null, 2)}\n`, ); } diff --git a/packages/cli/src/commands/install/install.js b/packages/cli/src/commands/install/install.js index ce575841e..cb514c606 100644 --- a/packages/cli/src/commands/install/install.js +++ b/packages/cli/src/commands/install/install.js @@ -7,7 +7,7 @@ * @flow */ -import type { ContextT } from '../../tools/types.flow'; +import type {ContextT} from '../../tools/types.flow'; import logger from '../../tools/logger'; import PackageManager from '../../tools/PackageManager'; import link from '../link/link'; @@ -16,11 +16,10 @@ async function install(args: Array, ctx: ContextT) { const name = args[0]; logger.info(`Installing "${name}"...`); - new PackageManager({ projectDir: ctx.root }).install([name]); + new PackageManager({projectDir: ctx.root}).install([name]); logger.info(`Linking "${name}"...`); - // eslint-disable-next-line import/no-named-as-default-member - await link.func([name], ctx, { platforms: undefined }); + await link.func([name], ctx, {platforms: undefined}); logger.success(`Successfully installed and linked "${name}"`); } diff --git a/packages/cli/src/commands/install/uninstall.js b/packages/cli/src/commands/install/uninstall.js index fb10f4754..4300387b1 100644 --- a/packages/cli/src/commands/install/uninstall.js +++ b/packages/cli/src/commands/install/uninstall.js @@ -7,7 +7,7 @@ * @flow */ -import type { ContextT } from '../../tools/types.flow'; +import type {ContextT} from '../../tools/types.flow'; import logger from '../../tools/logger'; import PackageManager from '../../tools/PackageManager'; import link from '../link/unlink'; @@ -19,7 +19,7 @@ async function uninstall(args: Array, ctx: ContextT) { await link.func([name], ctx); logger.info(`Uninstalling "${name}"...`); - new PackageManager({ projectDir: ctx.root }).uninstall([name]); + new PackageManager({projectDir: ctx.root}).uninstall([name]); logger.success(`Successfully uninstalled and unlinked "${name}"`); } diff --git a/packages/cli/src/commands/library/library.js b/packages/cli/src/commands/library/library.js index f98978f00..5a1b13c85 100644 --- a/packages/cli/src/commands/library/library.js +++ b/packages/cli/src/commands/library/library.js @@ -21,7 +21,7 @@ async function library(argv, ctx, args) { if (!isValidPackageName(args.name)) { throw new Error( `${args.name} is not a valid name for a project. Please use a valid ` + - `identifier name (alphanumeric).` + 'identifier name (alphanumeric).', ); } @@ -31,7 +31,7 @@ async function library(argv, ctx, args) { 'node_modules', 'react-native', 'Libraries', - 'Sample' + 'Sample', ); if (!fs.existsSync(libraries)) { @@ -52,7 +52,7 @@ async function library(argv, ctx, args) { const dest = path.relative( source, - f.replace(/Sample/g, args.name).replace(/^_/, '.') + f.replace(/Sample/g, args.name).replace(/^_/, '.'), ); copyAndReplace(path.resolve(source, f), path.resolve(libraryDest, dest), { Sample: args.name, diff --git a/packages/cli/src/commands/link/__tests__/android/applyPatch-test.js b/packages/cli/src/commands/link/__tests__/android/applyPatch-test.js index c298513ae..a088303ff 100644 --- a/packages/cli/src/commands/link/__tests__/android/applyPatch-test.js +++ b/packages/cli/src/commands/link/__tests__/android/applyPatch-test.js @@ -5,14 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -/* eslint-disable no-template-curly-in-string */ - import applyParams from '../../android/patches/applyParams'; describe('applyParams', () => { it('apply params to the string', () => { - expect(applyParams('${foo}', { foo: 'foo' }, 'react-native')).toEqual( - 'getResources().getString(R.string.reactNative_foo)' + expect(applyParams('${foo}', {foo: 'foo'}, 'react-native')).toEqual( + 'getResources().getString(R.string.reactNative_foo)', ); }); diff --git a/packages/cli/src/commands/link/__tests__/android/isInstalled-test.js b/packages/cli/src/commands/link/__tests__/android/isInstalled-test.js index fac2114d7..151ed63d9 100644 --- a/packages/cli/src/commands/link/__tests__/android/isInstalled-test.js +++ b/packages/cli/src/commands/link/__tests__/android/isInstalled-test.js @@ -15,7 +15,7 @@ const path = require('path'); const projectConfig = { buildGradlePath: path.join( __dirname, - '../../__fixtures__/android/patchedBuild.gradle' + '../../__fixtures__/android/patchedBuild.gradle', ), }; @@ -37,6 +37,6 @@ describe('android::isInstalled', () => { 'properly detects if %p project is already in build.gradle', (project, isPresent) => { expect(isInstalled(projectConfig, project)).toBe(isPresent); - } + }, ); }); diff --git a/packages/cli/src/commands/link/__tests__/android/makeBuildPatch-test.js b/packages/cli/src/commands/link/__tests__/android/makeBuildPatch-test.js index fc00ead44..44b5ac3fe 100644 --- a/packages/cli/src/commands/link/__tests__/android/makeBuildPatch-test.js +++ b/packages/cli/src/commands/link/__tests__/android/makeBuildPatch-test.js @@ -18,33 +18,33 @@ const normalizedScopedName = normalizeProjectName('@scoped/test'); describe('makeBuildPatch', () => { it('should build a patch function', () => { expect(Object.prototype.toString(makeBuildPatch(name))).toBe( - '[object Object]' + '[object Object]', ); }); it('should make a correct patch', () => { - const { patch } = makeBuildPatch(name); + const {patch} = makeBuildPatch(name); expect(patch).toBe(` implementation project(':${name}')\n`); }); it('should make a correct install check pattern', () => { - const { installPattern } = makeBuildPatch(name); + const {installPattern} = makeBuildPatch(name); expect(installPattern.toString()).toEqual(expect.stringContaining(name)); }); }); describe('makeBuildPatchWithScopedPackage', () => { it('should make a correct patch', () => { - const { patch } = makeBuildPatch(scopedName); + const {patch} = makeBuildPatch(scopedName); expect(patch).toBe( - ` implementation project(':${normalizedScopedName}')\n` + ` implementation project(':${normalizedScopedName}')\n`, ); }); it('should make a correct install check pattern', () => { - const { installPattern } = makeBuildPatch(scopedName); + const {installPattern} = makeBuildPatch(scopedName); expect(installPattern.toString()).toEqual( - expect.stringContaining(normalizedScopedName) + expect.stringContaining(normalizedScopedName), ); }); }); diff --git a/packages/cli/src/commands/link/__tests__/android/makeImportPatch-test.js b/packages/cli/src/commands/link/__tests__/android/makeImportPatch-test.js index 165230c41..13de71114 100644 --- a/packages/cli/src/commands/link/__tests__/android/makeImportPatch-test.js +++ b/packages/cli/src/commands/link/__tests__/android/makeImportPatch-test.js @@ -15,12 +15,12 @@ const packageImportPath = 'import some.example.project'; describe('makeImportPatch', () => { it('should build a patch', () => { expect(Object.prototype.toString(makeImportPatch(packageImportPath))).toBe( - '[object Object]' + '[object Object]', ); }); it('MainActivity contains a correct import patch', () => { - const { patch } = makeImportPatch(packageImportPath); + const {patch} = makeImportPatch(packageImportPath); expect(patch).toBe(`\n${packageImportPath}`); }); diff --git a/packages/cli/src/commands/link/__tests__/android/makePackagePatch-test.js b/packages/cli/src/commands/link/__tests__/android/makePackagePatch-test.js index 409f3894c..457426497 100644 --- a/packages/cli/src/commands/link/__tests__/android/makePackagePatch-test.js +++ b/packages/cli/src/commands/link/__tests__/android/makePackagePatch-test.js @@ -5,8 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -/* eslint-disable no-template-curly-in-string */ - import makePackagePatch from '../../android/patches/makePackagePatch'; import applyParams from '../../android/patches/applyParams'; @@ -24,7 +22,7 @@ describe('makePackagePatch@0.20', () => { }); it('MainActivity contains a correct 0.20 import patch', () => { - const { patch } = makePackagePatch(packageInstance, params, name); + const {patch} = makePackagePatch(packageInstance, params, name); const processedInstance = applyParams(packageInstance, params, name); expect(patch).toBe(`,\n ${processedInstance}`); diff --git a/packages/cli/src/commands/link/__tests__/android/makeSettingsPatch-test.js b/packages/cli/src/commands/link/__tests__/android/makeSettingsPatch-test.js index 429076827..2fc77b2fc 100644 --- a/packages/cli/src/commands/link/__tests__/android/makeSettingsPatch-test.js +++ b/packages/cli/src/commands/link/__tests__/android/makeSettingsPatch-test.js @@ -22,7 +22,7 @@ describe('makeSettingsPatch with package "test"', () => { it('should build a patch function', () => { expect( - makeSettingsPatch(name, dependencyConfig, projectConfig) + makeSettingsPatch(name, dependencyConfig, projectConfig), ).toMatchObject({ pattern: '\n', patch: expect.any(String), @@ -30,7 +30,7 @@ describe('makeSettingsPatch with package "test"', () => { }); it('includes project with correct path', () => { - const { patch } = makeSettingsPatch(name, dependencyConfig, projectConfig); + const {patch} = makeSettingsPatch(name, dependencyConfig, projectConfig); expect(patch).toMatchInlineSnapshot(` "include ':test' @@ -59,10 +59,10 @@ project(':test').projectDir = new File(rootProject.projectDir, '../node_modules/ const dependencyConfigWindows = { sourceDir: `C:\\home\\project\\node_modules\\${name}\\android`, }; - const { patch } = makeSettingsPatch( + const {patch} = makeSettingsPatch( name, dependencyConfigWindows, - projectConfigWindows + projectConfigWindows, ); jest.dontMock('path'); @@ -83,7 +83,7 @@ describe('makeSettingsPatch with scoped package "@scoped/test"', () => { it('should build a patch function', () => { expect( - makeSettingsPatch(name, dependencyConfig, projectConfig) + makeSettingsPatch(name, dependencyConfig, projectConfig), ).toMatchObject({ pattern: '\n', patch: expect.any(String), @@ -91,7 +91,7 @@ describe('makeSettingsPatch with scoped package "@scoped/test"', () => { }); it('includes project with correct path', () => { - const { patch } = makeSettingsPatch(name, dependencyConfig, projectConfig); + const {patch} = makeSettingsPatch(name, dependencyConfig, projectConfig); expect(patch).toMatchInlineSnapshot(` "include ':@scoped_test' diff --git a/packages/cli/src/commands/link/__tests__/android/makeStringsPatch-test.js b/packages/cli/src/commands/link/__tests__/android/makeStringsPatch-test.js index 9b0c6ec16..f62b9c191 100644 --- a/packages/cli/src/commands/link/__tests__/android/makeStringsPatch-test.js +++ b/packages/cli/src/commands/link/__tests__/android/makeStringsPatch-test.js @@ -17,7 +17,7 @@ describe('makeStringsPatch', () => { }; expect(makeStringsPatch(params, 'module').patch).toContain( - 'valueA' + 'valueA', ); }); diff --git a/packages/cli/src/commands/link/__tests__/getDependencyConfig-test.js b/packages/cli/src/commands/link/__tests__/getDependencyConfig-test.js index 26f8eb4c1..73cd1f7a2 100644 --- a/packages/cli/src/commands/link/__tests__/getDependencyConfig-test.js +++ b/packages/cli/src/commands/link/__tests__/getDependencyConfig-test.js @@ -10,10 +10,10 @@ const platforms = { ios: { - dependencyConfig: () => ({ sampleiOSKey: '' }), + dependencyConfig: () => ({sampleiOSKey: ''}), }, android: { - dependencyConfig: () => ({ sampleAndroidKey: '' }), + dependencyConfig: () => ({sampleAndroidKey: ''}), }, }; @@ -29,9 +29,9 @@ const getDependencyConfig = require('../getDependencyConfig').default; describe('getDependencyConfig', () => { it("should return an array of dependencies' config", () => { const dependencies = getDependencyConfig( - { root: '/root' }, + {root: '/root'}, platforms, - 'react-native-windows' + 'react-native-windows', ); expect(dependencies).toMatchSnapshot(); @@ -39,7 +39,7 @@ describe('getDependencyConfig', () => { it('should throw on invalid react-native dependency', () => { expect(() => - getDependencyConfig({ root: '/root' }, platforms, 'abcd') + getDependencyConfig({root: '/root'}, platforms, 'abcd'), ).toThrowError(); }); }); diff --git a/packages/cli/src/commands/link/__tests__/getProjectDependencies-test.js b/packages/cli/src/commands/link/__tests__/getProjectDependencies-test.js index d1892eaf8..5eac43b0b 100644 --- a/packages/cli/src/commands/link/__tests__/getProjectDependencies-test.js +++ b/packages/cli/src/commands/link/__tests__/getProjectDependencies-test.js @@ -29,7 +29,7 @@ describe('getProjectDependencies', () => { '@react-native-community/cli': '*', }, }), - { virtual: true } + {virtual: true}, ); expect(getProjectDependencies(CWD)).toEqual(['lodash']); diff --git a/packages/cli/src/commands/link/__tests__/ios/addFileToProject-test.js b/packages/cli/src/commands/link/__tests__/ios/addFileToProject-test.js index 05366ae80..e318c9419 100644 --- a/packages/cli/src/commands/link/__tests__/ios/addFileToProject-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/addFileToProject-test.js @@ -15,7 +15,7 @@ const path = require('path'); const _ = require('lodash'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::addFileToProject', () => { @@ -24,12 +24,12 @@ describe('ios::addFileToProject', () => { }); it('should add file to a project', () => { - const { fileRef } = addFileToProject( + const {fileRef} = addFileToProject( project, - '../../__fixtures__/linearGradient.pbxproj' + '../../__fixtures__/linearGradient.pbxproj', ); expect( - _.includes(Object.keys(project.pbxFileReferenceSection()), fileRef) + _.includes(Object.keys(project.pbxFileReferenceSection()), fileRef), ).toBeTruthy(); }); }); diff --git a/packages/cli/src/commands/link/__tests__/ios/addProjectToLibraries-test.js b/packages/cli/src/commands/link/__tests__/ios/addProjectToLibraries-test.js index 294195d3f..ee043e301 100644 --- a/packages/cli/src/commands/link/__tests__/ios/addProjectToLibraries-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/addProjectToLibraries-test.js @@ -13,10 +13,10 @@ import addProjectToLibraries from '../../ios/addProjectToLibraries'; const xcode = require('xcode'); const path = require('path'); const PbxFile = require('xcode/lib/pbxFile'); -const { last } = require('lodash'); +const {last} = require('lodash'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::addProjectToLibraries', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/addSharedLibraries-test.js b/packages/cli/src/commands/link/__tests__/ios/addSharedLibraries-test.js index c1742a4a4..d6bc90c89 100644 --- a/packages/cli/src/commands/link/__tests__/ios/addSharedLibraries-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/addSharedLibraries-test.js @@ -15,7 +15,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::addSharedLibraries', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/createGroup-test.js b/packages/cli/src/commands/link/__tests__/ios/createGroup-test.js index 924d2731e..da718cd0f 100644 --- a/packages/cli/src/commands/link/__tests__/ios/createGroup-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/createGroup-test.js @@ -13,10 +13,10 @@ import getGroup from '../../ios/getGroup'; const xcode = require('xcode'); const path = require('path'); -const { last } = require('lodash'); +const {last} = require('lodash'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::createGroup', () => { @@ -49,7 +49,7 @@ describe('ios::createGroup', () => { const mainGroup = getGroup(project); expect( - mainGroup.children.filter(group => group.comment === 'Libraries') + mainGroup.children.filter(group => group.comment === 'Libraries'), ).toHaveLength(1); expect(last(outerGroup.children).comment).toBe(createdGroup.name); }); diff --git a/packages/cli/src/commands/link/__tests__/ios/getBuildProperty-test.js b/packages/cli/src/commands/link/__tests__/ios/getBuildProperty-test.js index ca42a07be..b66b2b98c 100644 --- a/packages/cli/src/commands/link/__tests__/ios/getBuildProperty-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/getBuildProperty-test.js @@ -14,7 +14,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::getBuildProperty', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/getGroup-test.js b/packages/cli/src/commands/link/__tests__/ios/getGroup-test.js index 0312036c6..d100318d1 100644 --- a/packages/cli/src/commands/link/__tests__/ios/getGroup-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/getGroup-test.js @@ -14,7 +14,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::getGroup', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/getHeaderSearchPath-test.js b/packages/cli/src/commands/link/__tests__/ios/getHeaderSearchPath-test.js index 15860797e..0c0755f55 100644 --- a/packages/cli/src/commands/link/__tests__/ios/getHeaderSearchPath-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/getHeaderSearchPath-test.js @@ -24,7 +24,7 @@ describe('ios::getHeaderSearchPath', () => { 'react-native-project', 'node_modules', 'package', - 'Gradient.h' + 'Gradient.h', ), path.join('react-native-project', 'node_modules', 'package', 'Manager.h'), ]; @@ -32,7 +32,7 @@ describe('ios::getHeaderSearchPath', () => { const searchPath = getHeaderSearchPath(SRC_DIR, files); expect(searchPath).toBe( - `"${['$(SRCROOT)', '..', 'node_modules', 'package'].join(path.sep)}"` + `"${['$(SRCROOT)', '..', 'node_modules', 'package'].join(path.sep)}"`, ); }); @@ -47,7 +47,7 @@ describe('ios::getHeaderSearchPath', () => { 'package', 'src', 'folderA', - 'Gradient.h' + 'Gradient.h', ), path.join( 'react-native-project', @@ -55,7 +55,7 @@ describe('ios::getHeaderSearchPath', () => { 'package', 'src', 'folderB', - 'Manager.h' + 'Manager.h', ), ]; @@ -63,8 +63,8 @@ describe('ios::getHeaderSearchPath', () => { expect(searchPath).toBe( `"${['$(SRCROOT)', '..', 'node_modules', 'package', 'src'].join( - path.sep - )}/**"` + path.sep, + )}/**"`, ); }); @@ -79,7 +79,7 @@ describe('ios::getHeaderSearchPath', () => { 'package', 'src', 'folderA', - 'Gradient.h' + 'Gradient.h', ), path.join( 'react-native-project', @@ -87,14 +87,14 @@ describe('ios::getHeaderSearchPath', () => { 'package', 'src', 'folderB', - 'Manager.h' + 'Manager.h', ), path.join( 'react-native-project', 'node_modules', 'package', 'src', - 'Manager.h' + 'Manager.h', ), ]; @@ -102,8 +102,8 @@ describe('ios::getHeaderSearchPath', () => { expect(searchPath).toBe( `"${['$(SRCROOT)', '..', 'node_modules', 'package', 'src'].join( - path.sep - )}/**"` + path.sep, + )}/**"`, ); }); }); diff --git a/packages/cli/src/commands/link/__tests__/ios/getPlist-test.js b/packages/cli/src/commands/link/__tests__/ios/getPlist-test.js index aa92dae2d..d28d06b2c 100644 --- a/packages/cli/src/commands/link/__tests__/ios/getPlist-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/getPlist-test.js @@ -14,7 +14,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::getPlist', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/getPlistPath-test.js b/packages/cli/src/commands/link/__tests__/ios/getPlistPath-test.js index f5fa6c6b6..ff5b5f4ad 100644 --- a/packages/cli/src/commands/link/__tests__/ios/getPlistPath-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/getPlistPath-test.js @@ -14,7 +14,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::getPlistPath', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/getTargets-test.js b/packages/cli/src/commands/link/__tests__/ios/getTargets-test.js index aad25bf60..a18758576 100644 --- a/packages/cli/src/commands/link/__tests__/ios/getTargets-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/getTargets-test.js @@ -14,7 +14,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::getTargets', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/hasLibraryImported-test.js b/packages/cli/src/commands/link/__tests__/ios/hasLibraryImported-test.js index 80ba7f8df..0b2e9d32a 100644 --- a/packages/cli/src/commands/link/__tests__/ios/hasLibraryImported-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/hasLibraryImported-test.js @@ -14,7 +14,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::hasLibraryImported', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/isInstalled-test.js b/packages/cli/src/commands/link/__tests__/ios/isInstalled-test.js index d8ca549b0..eb51a9aef 100644 --- a/packages/cli/src/commands/link/__tests__/ios/isInstalled-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/isInstalled-test.js @@ -19,17 +19,17 @@ const baseProjectConfig = { describe('ios::isInstalled', () => { it('should return true when .xcodeproj in Libraries', () => { - const dependencyConfig = { projectName: 'React.xcodeproj' }; + const dependencyConfig = {projectName: 'React.xcodeproj'}; expect(isInstalled(baseProjectConfig, dependencyConfig)).toBeTruthy(); }); it('should return false when .xcodeproj not in Libraries', () => { - const dependencyConfig = { projectName: 'Missing.xcodeproj' }; + const dependencyConfig = {projectName: 'Missing.xcodeproj'}; expect(isInstalled(baseProjectConfig, dependencyConfig)).toBeFalsy(); }); it('should return false when `LibraryFolder` is missing', () => { - const dependencyConfig = { projectName: 'React.xcodeproj' }; + const dependencyConfig = {projectName: 'React.xcodeproj'}; const projectConfig = Object.assign({}, baseProjectConfig, { libraryFolder: 'Missing', }); diff --git a/packages/cli/src/commands/link/__tests__/ios/mapHeaderSearchPaths-test.js b/packages/cli/src/commands/link/__tests__/ios/mapHeaderSearchPaths-test.js index d0bbe75a1..b53e35f63 100644 --- a/packages/cli/src/commands/link/__tests__/ios/mapHeaderSearchPaths-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/mapHeaderSearchPaths-test.js @@ -14,7 +14,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::mapHeaderSearchPaths', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/removeProjectFromLibraries-test.js b/packages/cli/src/commands/link/__tests__/ios/removeProjectFromLibraries-test.js index 4e06f59b4..a56c57b66 100644 --- a/packages/cli/src/commands/link/__tests__/ios/removeProjectFromLibraries-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/removeProjectFromLibraries-test.js @@ -14,10 +14,10 @@ import removeProjectFromLibraries from '../../ios/removeProjectFromLibraries'; const xcode = require('xcode'); const PbxFile = require('xcode/lib/pbxFile'); const path = require('path'); -const { last } = require('lodash'); +const {last} = require('lodash'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::removeProjectFromLibraries', () => { @@ -26,7 +26,7 @@ describe('ios::removeProjectFromLibraries', () => { addProjectToLibraries( project.pbxGroupByName('Libraries'), - new PbxFile('fakePath') + new PbxFile('fakePath'), ); }); diff --git a/packages/cli/src/commands/link/__tests__/ios/removeProjectFromProject-test.js b/packages/cli/src/commands/link/__tests__/ios/removeProjectFromProject-test.js index c0eb81af7..c8164bc78 100644 --- a/packages/cli/src/commands/link/__tests__/ios/removeProjectFromProject-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/removeProjectFromProject-test.js @@ -16,7 +16,7 @@ const pbxFile = require('xcode/lib/pbxFile'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); const filePath = '../../__fixtures__/linearGradient.pbxproj'; @@ -28,7 +28,7 @@ describe('ios::addFileToProject', () => { it('should return removed file', () => { expect( - removeProjectFromProject(project, filePath) instanceof pbxFile + removeProjectFromProject(project, filePath) instanceof pbxFile, ).toBeTruthy(); }); diff --git a/packages/cli/src/commands/link/__tests__/ios/removeSharedLibrary-test.js b/packages/cli/src/commands/link/__tests__/ios/removeSharedLibrary-test.js index f23ceeee1..e81639de7 100644 --- a/packages/cli/src/commands/link/__tests__/ios/removeSharedLibrary-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/removeSharedLibrary-test.js @@ -16,7 +16,7 @@ const xcode = require('xcode'); const path = require('path'); const project = xcode.project( - path.join(__dirname, '../../__fixtures__/project.pbxproj') + path.join(__dirname, '../../__fixtures__/project.pbxproj'), ); describe('ios::removeSharedLibraries', () => { diff --git a/packages/cli/src/commands/link/__tests__/ios/writePlist-test.js b/packages/cli/src/commands/link/__tests__/ios/writePlist-test.js index e10077a99..c74582609 100644 --- a/packages/cli/src/commands/link/__tests__/ios/writePlist-test.js +++ b/packages/cli/src/commands/link/__tests__/ios/writePlist-test.js @@ -15,7 +15,7 @@ jest.mock('path'); jest.mock('fs'); jest.mock('../../ios/getPlistPath', () => jest.fn(() => null)); -const { readFileSync } = jest.requireActual('fs'); +const {readFileSync} = jest.requireActual('fs'); const fs = require('fs'); const xcode = require('xcode'); @@ -23,13 +23,13 @@ const xcode = require('xcode'); const realPath = jest.requireActual('path'); const projectPath = realPath.join( __dirname, - '../../__fixtures__/project.pbxproj' + '../../__fixtures__/project.pbxproj', ); const infoPlistPath = realPath.join(__dirname, '../../__fixtures__/Info.plist'); fs.readFileSync = jest.fn(() => readFileSync(projectPath).toString()); -const { writeFileSync } = fs; +const {writeFileSync} = fs; fs.writeFileSync = jest.fn(writeFileSync); const project = xcode.project('/Basic/project.pbxproj'); @@ -51,7 +51,7 @@ describe('ios::writePlist', () => { const infoPlist = readFileSync(infoPlistPath).toString(); expect(fs.writeFileSync).toHaveBeenCalledWith( '/Basic/Info.plist', - infoPlist + infoPlist, ); }); diff --git a/packages/cli/src/commands/link/__tests__/link-test.js b/packages/cli/src/commands/link/__tests__/link-test.js index d8f2560dc..59e905d9f 100644 --- a/packages/cli/src/commands/link/__tests__/link-test.js +++ b/packages/cli/src/commands/link/__tests__/link-test.js @@ -8,7 +8,7 @@ * @emails oncall+javascript_foundation */ -jest.mock('chalk', () => ({ grey: str => str })); +jest.mock('chalk', () => ({grey: str => str})); jest.mock('../../../tools/logger'); const context = { @@ -22,7 +22,7 @@ describe('link', () => { it('should reject when run in a folder without package.json', done => { const link = require('../link').func; - link([], { root: '/' }, {}).catch(() => done()); + link([], {root: '/'}, {}).catch(() => done()); }); it('should accept a name of a dependency to link', done => { @@ -40,7 +40,7 @@ describe('link', () => { const link = require('../link').func; link(['react-native-gradient'], context, {}).then(() => { expect(getDependencyConfig.mock.calls[0][2]).toEqual( - 'react-native-gradient' + 'react-native-gradient', ); done(); }); @@ -79,7 +79,7 @@ describe('link', () => { android: {}, }, assets: [], - commands: { prelink, postlink }, + commands: {prelink, postlink}, })); jest.doMock('../getDependencyConfig', () => getDependencyConfig); @@ -87,15 +87,15 @@ describe('link', () => { const registerNativeModule = jest.fn(); jest.doMock('../android/isInstalled.js', () => - jest.fn().mockReturnValue(false) + jest.fn().mockReturnValue(false), ); jest.doMock( '../android/registerNativeModule.js', - () => registerNativeModule + () => registerNativeModule, ); jest.doMock('../ios/isInstalled.js', () => - jest.fn().mockReturnValue(false) + jest.fn().mockReturnValue(false), ); jest.doMock('../ios/registerNativeModule.js', () => registerNativeModule); @@ -106,11 +106,11 @@ describe('link', () => { expect(registerNativeModule.mock.calls).toHaveLength(2); expect(prelink.mock.invocationCallOrder[0]).toBeLessThan( - registerNativeModule.mock.invocationCallOrder[0] + registerNativeModule.mock.invocationCallOrder[0], ); expect(postlink.mock.invocationCallOrder[0]).toBeGreaterThan( - registerNativeModule.mock.invocationCallOrder[0] + registerNativeModule.mock.invocationCallOrder[0], ); done(); @@ -136,12 +136,12 @@ describe('link', () => { })); jest.doMock('../android/isInstalled.js', () => - jest.fn().mockReturnValue(false) + jest.fn().mockReturnValue(false), ); jest.doMock('../android/registerNativeModule.js', () => jest.fn()); jest.doMock('../ios/isInstalled.js', () => - jest.fn().mockReturnValue(false) + jest.fn().mockReturnValue(false), ); jest.doMock('../ios/registerNativeModule.js', () => jest.fn()); @@ -182,11 +182,11 @@ describe('link', () => { const registerNativeModule = jest.fn(); jest.doMock('../android/isInstalled.js', () => - jest.fn().mockReturnValue(true) + jest.fn().mockReturnValue(true), ); jest.doMock( '../android/registerNativeModule.js', - () => registerNativeModule + () => registerNativeModule, ); jest.doMock('../ios/isInstalled.js', () => jest.fn().mockReturnValue(true)); @@ -226,9 +226,9 @@ describe('link', () => { jest.doMock('../../../tools/getPlatforms', () => { const fn = () => ({ - ios: { linkConfig: require('../ios').default }, - android: { linkConfig: require('../android').default }, - windows: { linkConfig: genericLinkConfig }, + ios: {linkConfig: require('../ios').default}, + android: {linkConfig: require('../android').default}, + windows: {linkConfig: genericLinkConfig}, }); fn.getPlatformName = jest.fn(); return fn; @@ -237,11 +237,11 @@ describe('link', () => { jest.doMock('../getDependencyConfig', () => getDependencyConfig); jest.doMock('../android/isInstalled.js', () => - jest.fn().mockReturnValue(true) + jest.fn().mockReturnValue(true), ); jest.doMock( '../android/registerNativeModule.js', - () => registerNativeModule + () => registerNativeModule, ); jest.doMock('../ios/isInstalled.js', () => jest.fn().mockReturnValue(true)); @@ -275,8 +275,8 @@ describe('link', () => { jest.doMock('../../../tools/getPlatforms', () => { const fn = () => ({ - android: { linkConfig: genericAndroidLinkConfig }, - ios: { linkConfig: genericIOSLinkConfig }, + android: {linkConfig: genericAndroidLinkConfig}, + ios: {linkConfig: genericIOSLinkConfig}, }); fn.getPlatformName = jest.fn(); return fn; @@ -284,11 +284,11 @@ describe('link', () => { jest.doMock( '../android/registerNativeModule.js', - () => registerAndroidNativeModule + () => registerAndroidNativeModule, ); jest.doMock( '../ios/registerNativeModule.js', - () => registerIOSNativeModule + () => registerIOSNativeModule, ); const link = require('../link').func; @@ -301,22 +301,18 @@ describe('link', () => { await link( ['react-native-gradient'], - { root: '/' }, - { platforms: ['android'] } + {root: '/'}, + {platforms: ['android']}, ); assertPlaftormsCalledTimes(1, 0); - await link( - ['react-native-gradient'], - { root: '/' }, - { platforms: ['ios'] } - ); + await link(['react-native-gradient'], {root: '/'}, {platforms: ['ios']}); assertPlaftormsCalledTimes(0, 1); await link( ['react-native-gradient'], - { root: '/' }, - { platforms: ['android', 'ios'] } + {root: '/'}, + {platforms: ['android', 'ios']}, ); assertPlaftormsCalledTimes(1, 1); }); diff --git a/packages/cli/src/commands/link/__tests__/pods/findLineToAddPod-test.js b/packages/cli/src/commands/link/__tests__/pods/findLineToAddPod-test.js index df1285937..7c76885fc 100644 --- a/packages/cli/src/commands/link/__tests__/pods/findLineToAddPod-test.js +++ b/packages/cli/src/commands/link/__tests__/pods/findLineToAddPod-test.js @@ -20,30 +20,30 @@ describe('pods::findLineToAddPod', () => { it('returns null if file is not Podfile', () => { const podfile = readPodfile(path.join(PODFILES_PATH, '../Info.plist')); expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE) + findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), ).toBeNull(); }); it('returns correct line number for Simple Podfile', () => { const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE) - ).toEqual({ line: 7, indentation: 2 }); + findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), + ).toEqual({line: 7, indentation: 2}); }); it('returns correct line number for Podfile with target', () => { const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileWithTarget')); expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE) - ).toEqual({ line: 21, indentation: 2 }); + findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), + ).toEqual({line: 21, indentation: 2}); }); it('returns correct line number for Podfile with function', () => { const podfile = readPodfile( - path.join(PODFILES_PATH, 'PodfileWithFunction') + path.join(PODFILES_PATH, 'PodfileWithFunction'), ); expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE) - ).toEqual({ line: 26, indentation: 2 }); + findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), + ).toEqual({line: 26, indentation: 2}); }); }); diff --git a/packages/cli/src/commands/link/__tests__/pods/findMarkedLinesInPodfile-test.js b/packages/cli/src/commands/link/__tests__/pods/findMarkedLinesInPodfile-test.js index 0b5c99eeb..ae98a21c3 100644 --- a/packages/cli/src/commands/link/__tests__/pods/findMarkedLinesInPodfile-test.js +++ b/packages/cli/src/commands/link/__tests__/pods/findMarkedLinesInPodfile-test.js @@ -25,18 +25,18 @@ describe('pods::findMarkedLinesInPodfile', () => { it('returns empty array for Simple Podfile', () => { const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); expect( - findMarkedLinesInPodfile(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE) + findMarkedLinesInPodfile(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), ).toEqual([]); }); it('returns correct line numbers for Podfile with marker', () => { const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileWithMarkers')); const expectedObject = [ - { line: 18, indentation: 2 }, - { line: 31, indentation: 4 }, + {line: 18, indentation: 2}, + {line: 31, indentation: 4}, ]; expect( - findMarkedLinesInPodfile(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE) + findMarkedLinesInPodfile(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), ).toEqual(expectedObject); }); }); diff --git a/packages/cli/src/commands/link/__tests__/pods/isInstalled-test.js b/packages/cli/src/commands/link/__tests__/pods/isInstalled-test.js index 86fa1da48..f0538bfb0 100644 --- a/packages/cli/src/commands/link/__tests__/pods/isInstalled-test.js +++ b/packages/cli/src/commands/link/__tests__/pods/isInstalled-test.js @@ -16,20 +16,20 @@ const PODFILES_PATH = path.join(__dirname, '../../__fixtures__/pods'); describe('pods::isInstalled', () => { it('returns false if pod is missing', () => { - const project = { podfile: path.join(PODFILES_PATH, 'PodfileSimple') }; - const podspecName = { podspec: 'NotExisting' }; + const project = {podfile: path.join(PODFILES_PATH, 'PodfileSimple')}; + const podspecName = {podspec: 'NotExisting'}; expect(isInstalled(project, podspecName)).toBe(false); }); it('returns true for existing pod with version number', () => { - const project = { podfile: path.join(PODFILES_PATH, 'PodfileSimple') }; - const podspecName = { podspec: 'TestPod' }; + const project = {podfile: path.join(PODFILES_PATH, 'PodfileSimple')}; + const podspecName = {podspec: 'TestPod'}; expect(isInstalled(project, podspecName)).toBe(true); }); it('returns true for existing pod with path', () => { - const project = { podfile: path.join(PODFILES_PATH, 'PodfileWithTarget') }; - const podspecName = { podspec: 'Yoga' }; + const project = {podfile: path.join(PODFILES_PATH, 'PodfileWithTarget')}; + const podspecName = {podspec: 'Yoga'}; expect(isInstalled(project, podspecName)).toBe(true); }); @@ -37,7 +37,7 @@ describe('pods::isInstalled', () => { const project = { podfile: path.join(PODFILES_PATH, 'PodfileWithFunction'), }; - const podspecName = { podspec: 'React' }; + const podspecName = {podspec: 'React'}; expect(isInstalled(project, podspecName)).toBe(true); }); }); diff --git a/packages/cli/src/commands/link/__tests__/pods/removePodEntry-test.js b/packages/cli/src/commands/link/__tests__/pods/removePodEntry-test.js index a403c4776..b980cc2a9 100644 --- a/packages/cli/src/commands/link/__tests__/pods/removePodEntry-test.js +++ b/packages/cli/src/commands/link/__tests__/pods/removePodEntry-test.js @@ -17,15 +17,15 @@ const PODFILES_PATH = path.join(__dirname, '../../__fixtures__/pods'); describe('pods::removePodEntry', () => { it('should remove one line from Podfile with TestPod', () => { - const { podfileContent, podLinesCount } = readTestPodFile('PodfileSimple'); + const {podfileContent, podLinesCount} = readTestPodFile('PodfileSimple'); const podFileWithRemoved = removePodEntry(podfileContent, 'TestPod'); const newLineCount = podFileWithRemoved.split('\n').length; expect(newLineCount).toBe(podLinesCount - 1); }); it('should remove one line from Podfile with Yoga', () => { - const { podfileContent, podLinesCount } = readTestPodFile( - 'PodfileWithTarget' + const {podfileContent, podLinesCount} = readTestPodFile( + 'PodfileWithTarget', ); const podFileWithRemoved = removePodEntry(podfileContent, 'Yoga'); const newLineCount = podFileWithRemoved.split('\n').length; @@ -33,8 +33,8 @@ describe('pods::removePodEntry', () => { }); it('should remove whole reference to React pod from Podfile', () => { - const { podfileContent, podLinesCount } = readTestPodFile( - 'PodfileWithTarget' + const {podfileContent, podLinesCount} = readTestPodFile( + 'PodfileWithTarget', ); const podFileWithRemoved = removePodEntry(podfileContent, 'React'); const newLineCount = podFileWithRemoved.split('\n').length; diff --git a/packages/cli/src/commands/link/__tests__/promiseWaterfall-test.js b/packages/cli/src/commands/link/__tests__/promiseWaterfall-test.js index 1056989c0..917977355 100644 --- a/packages/cli/src/commands/link/__tests__/promiseWaterfall-test.js +++ b/packages/cli/src/commands/link/__tests__/promiseWaterfall-test.js @@ -18,7 +18,7 @@ describe('promiseWaterfall', () => { // Check that tasks[0] is executed before tasks[1]. expect(tasks[0].mock.invocationCallOrder[0]).toBeLessThan( - tasks[1].mock.invocationCallOrder[0] + tasks[1].mock.invocationCallOrder[0], ); }); diff --git a/packages/cli/src/commands/link/android/copyAssets.js b/packages/cli/src/commands/link/android/copyAssets.js index 08d184d1c..8e894b7d6 100644 --- a/packages/cli/src/commands/link/android/copyAssets.js +++ b/packages/cli/src/commands/link/android/copyAssets.js @@ -23,7 +23,7 @@ export default function copyAssetsAndroid(files, project) { (assets.font || []).forEach(asset => fs.copySync( asset, - path.join(project.assetsPath, 'fonts', path.basename(asset)) - ) + path.join(project.assetsPath, 'fonts', path.basename(asset)), + ), ); } diff --git a/packages/cli/src/commands/link/android/index.js b/packages/cli/src/commands/link/android/index.js index 3114a8f90..df7ae3332 100644 --- a/packages/cli/src/commands/link/android/index.js +++ b/packages/cli/src/commands/link/android/index.js @@ -14,7 +14,7 @@ import copyAssets from './copyAssets'; import unlinkAssets from './unlinkAssets'; export function getAndroidLinkConfig() { - return { isInstalled, register, unregister, copyAssets, unlinkAssets }; + return {isInstalled, register, unregister, copyAssets, unlinkAssets}; } export default getAndroidLinkConfig; diff --git a/packages/cli/src/commands/link/android/patches/applyParams.js b/packages/cli/src/commands/link/android/patches/applyParams.js index 40862280e..b3981c05d 100644 --- a/packages/cli/src/commands/link/android/patches/applyParams.js +++ b/packages/cli/src/commands/link/android/patches/applyParams.js @@ -7,7 +7,7 @@ * @format */ -import { camelCase as toCamelCase } from 'lodash'; +import {camelCase as toCamelCase} from 'lodash'; export default function applyParams(str, params, prefix) { return str.replace(/\$\{(\w+)\}/g, (pattern, param) => { diff --git a/packages/cli/src/commands/link/android/patches/applyPatch.js b/packages/cli/src/commands/link/android/patches/applyPatch.js index 2fe518cc8..eb8f0d863 100644 --- a/packages/cli/src/commands/link/android/patches/applyPatch.js +++ b/packages/cli/src/commands/link/android/patches/applyPatch.js @@ -14,6 +14,6 @@ export default function applyPatch(file, patch) { file, fs .readFileSync(file, 'utf8') - .replace(patch.pattern, match => `${match}${patch.patch}`) + .replace(patch.pattern, match => `${match}${patch.patch}`), ); } diff --git a/packages/cli/src/commands/link/android/patches/makeBuildPatch.js b/packages/cli/src/commands/link/android/patches/makeBuildPatch.js index 9bdf22447..9966d0705 100644 --- a/packages/cli/src/commands/link/android/patches/makeBuildPatch.js +++ b/packages/cli/src/commands/link/android/patches/makeBuildPatch.js @@ -12,7 +12,7 @@ import normalizeProjectName from './normalizeProjectName'; export default function makeBuildPatch(name) { const normalizedProjectName = normalizeProjectName(name); const installPattern = new RegExp( - `(implementation|api|compile)\\w*\\s*\\(*project\\(['"]:${normalizedProjectName}['"]\\)` + `(implementation|api|compile)\\w*\\s*\\(*project\\(['"]:${normalizedProjectName}['"]\\)`, ); return { diff --git a/packages/cli/src/commands/link/android/patches/makeSettingsPatch.js b/packages/cli/src/commands/link/android/patches/makeSettingsPatch.js index 3944d2968..c73603f3f 100644 --- a/packages/cli/src/commands/link/android/patches/makeSettingsPatch.js +++ b/packages/cli/src/commands/link/android/patches/makeSettingsPatch.js @@ -16,8 +16,8 @@ export default function makeSettingsPatch(name, androidConfig, projectConfig) { const projectDir = slash( path.relative( path.dirname(projectConfig.settingsGradlePath), - androidConfig.sourceDir - ) + androidConfig.sourceDir, + ), ); const normalizedProjectName = normalizeProjectName(name); diff --git a/packages/cli/src/commands/link/android/patches/makeStringsPatch.js b/packages/cli/src/commands/link/android/patches/makeStringsPatch.js index 592d5d818..e99a190de 100644 --- a/packages/cli/src/commands/link/android/patches/makeStringsPatch.js +++ b/packages/cli/src/commands/link/android/patches/makeStringsPatch.js @@ -7,7 +7,7 @@ * @format */ -import { camelCase as toCamelCase } from 'lodash'; +import {camelCase as toCamelCase} from 'lodash'; export default function makeStringsPatch(params, prefix) { const values = Object.keys(params).map(param => { diff --git a/packages/cli/src/commands/link/android/patches/revokePatch.js b/packages/cli/src/commands/link/android/patches/revokePatch.js index d7ae0db9e..ed410953d 100644 --- a/packages/cli/src/commands/link/android/patches/revokePatch.js +++ b/packages/cli/src/commands/link/android/patches/revokePatch.js @@ -12,6 +12,6 @@ import fs from 'fs'; export default function revokePatch(file, patch) { fs.writeFileSync( file, - fs.readFileSync(file, 'utf8').replace(patch.patch, '') + fs.readFileSync(file, 'utf8').replace(patch.patch, ''), ); } diff --git a/packages/cli/src/commands/link/android/registerNativeModule.js b/packages/cli/src/commands/link/android/registerNativeModule.js index 6d03e3da3..9388d82de 100644 --- a/packages/cli/src/commands/link/android/registerNativeModule.js +++ b/packages/cli/src/commands/link/android/registerNativeModule.js @@ -18,13 +18,13 @@ export default function registerNativeAndroidModule( name, androidConfig, params, - projectConfig + projectConfig, ) { const buildPatch = makeBuildPatch(name); applyPatch( projectConfig.settingsGradlePath, - makeSettingsPatch(name, androidConfig, projectConfig) + makeSettingsPatch(name, androidConfig, projectConfig), ); applyPatch(projectConfig.buildGradlePath, buildPatch); @@ -32,11 +32,11 @@ export default function registerNativeAndroidModule( applyPatch( projectConfig.mainFilePath, - makePackagePatch(androidConfig.packageInstance, params, name) + makePackagePatch(androidConfig.packageInstance, params, name), ); applyPatch( projectConfig.mainFilePath, - makeImportPatch(androidConfig.packageImportPath) + makeImportPatch(androidConfig.packageImportPath), ); } diff --git a/packages/cli/src/commands/link/android/unlinkAssets.js b/packages/cli/src/commands/link/android/unlinkAssets.js index 6b42071e2..ff1f2e869 100644 --- a/packages/cli/src/commands/link/android/unlinkAssets.js +++ b/packages/cli/src/commands/link/android/unlinkAssets.js @@ -24,7 +24,7 @@ export default function unlinkAssetsAndroid(files, project) { const filePath = path.join( project.assetsPath, 'fonts', - path.basename(file) + path.basename(file), ); if (fs.existsSync(filePath)) { fs.unlinkSync(filePath); diff --git a/packages/cli/src/commands/link/android/unregisterNativeModule.js b/packages/cli/src/commands/link/android/unregisterNativeModule.js index 7620414cb..29680eaae 100644 --- a/packages/cli/src/commands/link/android/unregisterNativeModule.js +++ b/packages/cli/src/commands/link/android/unregisterNativeModule.js @@ -8,7 +8,7 @@ */ import fs from 'fs'; -import { camelCase as toCamelCase } from 'lodash'; +import {camelCase as toCamelCase} from 'lodash'; import revokePatch from './patches/revokePatch'; import makeSettingsPatch from './patches/makeSettingsPatch'; @@ -20,7 +20,7 @@ import makePackagePatch from './patches/makePackagePatch'; export default function unregisterNativeAndroidModule( name, androidConfig, - projectConfig + projectConfig, ) { const buildPatch = makeBuildPatch(name); const strings = fs.readFileSync(projectConfig.stringsPath, 'utf8'); @@ -30,12 +30,12 @@ export default function unregisterNativeAndroidModule( /moduleConfig="true" name="(\w+)">(.*) { params[param.slice(toCamelCase(name).length + 1)] = value; - } + }, ); revokePatch( projectConfig.settingsGradlePath, - makeSettingsPatch(name, androidConfig, projectConfig) + makeSettingsPatch(name, androidConfig, projectConfig), ); revokePatch(projectConfig.buildGradlePath, buildPatch); @@ -43,11 +43,11 @@ export default function unregisterNativeAndroidModule( revokePatch( projectConfig.mainFilePath, - makePackagePatch(androidConfig.packageInstance, params, name) + makePackagePatch(androidConfig.packageInstance, params, name), ); revokePatch( projectConfig.mainFilePath, - makeImportPatch(androidConfig.packageImportPath) + makeImportPatch(androidConfig.packageImportPath), ); } diff --git a/packages/cli/src/commands/link/getDependencyConfig.js b/packages/cli/src/commands/link/getDependencyConfig.js index 0588c4036..3cc2e1af2 100644 --- a/packages/cli/src/commands/link/getDependencyConfig.js +++ b/packages/cli/src/commands/link/getDependencyConfig.js @@ -17,18 +17,18 @@ import getAssets from '../../tools/getAssets'; export default function getDependencyConfig( ctx: ContextT, availablePlatforms: PlatformsT, - dependency: string + dependency: string, ): DependenciesConfig { try { const folder = path.join(ctx.root, 'node_modules', dependency); const config = getPackageConfiguration(folder); - const platformConfigs = { ios: undefined, android: undefined }; + const platformConfigs = {ios: undefined, android: undefined}; Object.keys(availablePlatforms).forEach(platform => { platformConfigs[platform] = availablePlatforms[platform].dependencyConfig( folder, - config[platform] || {} + config[platform] || {}, ); }); diff --git a/packages/cli/src/commands/link/getProjectConfig.js b/packages/cli/src/commands/link/getProjectConfig.js index b9305b232..f5095315a 100644 --- a/packages/cli/src/commands/link/getProjectConfig.js +++ b/packages/cli/src/commands/link/getProjectConfig.js @@ -12,16 +12,16 @@ import getPackageConfiguration from '../../tools/getPackageConfiguration'; export default function getProjectConfig( ctx: ContextT, - availablePlatforms: PlatformsT + availablePlatforms: PlatformsT, ): ProjectConfigT { const config = getPackageConfiguration(ctx.root); - const platformConfigs = { ios: undefined, android: undefined }; + const platformConfigs = {ios: undefined, android: undefined}; Object.keys(availablePlatforms).forEach(platform => { platformConfigs[platform] = availablePlatforms[platform].projectConfig( ctx.root, - config[platform] || {} + config[platform] || {}, ); }); diff --git a/packages/cli/src/commands/link/getProjectDependencies.js b/packages/cli/src/commands/link/getProjectDependencies.js index 70cdb6659..9d6c3d4f3 100644 --- a/packages/cli/src/commands/link/getProjectDependencies.js +++ b/packages/cli/src/commands/link/getProjectDependencies.js @@ -26,6 +26,6 @@ const EXCLUDED_PROJECTS = [ export default function getProjectDependencies(cwd: string) { const pkgJson = require(path.join(cwd, './package.json')); return (Object.keys(pkgJson.dependencies || {}).filter( - name => EXCLUDED_PROJECTS.includes(name) === false + name => EXCLUDED_PROJECTS.includes(name) === false, ): Array); } diff --git a/packages/cli/src/commands/link/groupFilesByType.js b/packages/cli/src/commands/link/groupFilesByType.js index 4de668bdb..f40830451 100644 --- a/packages/cli/src/commands/link/groupFilesByType.js +++ b/packages/cli/src/commands/link/groupFilesByType.js @@ -7,7 +7,7 @@ * @format */ -import { groupBy } from 'lodash'; +import {groupBy} from 'lodash'; import mime from 'mime'; /** diff --git a/packages/cli/src/commands/link/ios/addSharedLibraries.js b/packages/cli/src/commands/link/ios/addSharedLibraries.js index 3c42aa9e4..13d611b20 100644 --- a/packages/cli/src/commands/link/ios/addSharedLibraries.js +++ b/packages/cli/src/commands/link/ios/addSharedLibraries.js @@ -20,6 +20,6 @@ export default function addSharedLibraries(project, libraries) { const target = project.getFirstTarget().uuid; for (const name of libraries) { - project.addFramework(name, { target }); + project.addFramework(name, {target}); } } diff --git a/packages/cli/src/commands/link/ios/common/registerNativeModule.js b/packages/cli/src/commands/link/ios/common/registerNativeModule.js index bddfd14b6..e68aa11d7 100644 --- a/packages/cli/src/commands/link/ios/common/registerNativeModule.js +++ b/packages/cli/src/commands/link/ios/common/registerNativeModule.js @@ -14,7 +14,7 @@ export default function registerNativeModule( name, dependencyConfig, params, - projectConfig + projectConfig, ) { if (projectConfig.podfile && dependencyConfig.podspec) { registerDependencyPods(name, dependencyConfig, projectConfig); diff --git a/packages/cli/src/commands/link/ios/common/unregisterNativeModule.js b/packages/cli/src/commands/link/ios/common/unregisterNativeModule.js index 65db4aa9d..482f3ef67 100644 --- a/packages/cli/src/commands/link/ios/common/unregisterNativeModule.js +++ b/packages/cli/src/commands/link/ios/common/unregisterNativeModule.js @@ -7,7 +7,7 @@ * @format */ -import { compact } from 'lodash'; +import {compact} from 'lodash'; import isInstalledIOS from '../isInstalled'; import isInstalledPods from '../../pods/isInstalled'; import unregisterDependencyIOS from '../unregisterNativeModule'; @@ -17,7 +17,7 @@ export default function unregisterNativeModule( name, dependencyConfig, projectConfig, - otherDependencies + otherDependencies, ) { const isIosInstalled = isInstalledIOS(projectConfig, dependencyConfig); const isPodInstalled = isInstalledPods(projectConfig, dependencyConfig); diff --git a/packages/cli/src/commands/link/ios/copyAssets.js b/packages/cli/src/commands/link/ios/copyAssets.js index 231973500..58dbec83c 100644 --- a/packages/cli/src/commands/link/ios/copyAssets.js +++ b/packages/cli/src/commands/link/ios/copyAssets.js @@ -31,7 +31,7 @@ export default function linkAssetsIOS(files, projectConfig) { .map(asset => project.addResourceFile(path.relative(projectConfig.sourceDir, asset), { target: project.getFirstTarget().uuid, - }) + }), ) .filter(file => file) // xcode returns false if file is already there .map(file => file.basename); diff --git a/packages/cli/src/commands/link/ios/createGroupWithMessage.js b/packages/cli/src/commands/link/ios/createGroupWithMessage.js index cd2c85bac..2524aef0d 100644 --- a/packages/cli/src/commands/link/ios/createGroupWithMessage.js +++ b/packages/cli/src/commands/link/ios/createGroupWithMessage.js @@ -24,7 +24,7 @@ export default function createGroupWithMessage(project, path) { group = createGroup(project, path); log.warn( - `Group '${path}' does not exist in your Xcode project. We have created it automatically for you.` + `Group '${path}' does not exist in your Xcode project. We have created it automatically for you.`, ); } diff --git a/packages/cli/src/commands/link/ios/getHeaderSearchPath.js b/packages/cli/src/commands/link/ios/getHeaderSearchPath.js index b7c053694..3518620b3 100644 --- a/packages/cli/src/commands/link/ios/getHeaderSearchPath.js +++ b/packages/cli/src/commands/link/ios/getHeaderSearchPath.js @@ -8,7 +8,7 @@ */ import path from 'path'; -import { last, union } from 'lodash'; +import {last, union} from 'lodash'; /** * Given an array of directories, it returns the one that contains @@ -56,6 +56,6 @@ export default function getHeaderSearchPath(sourceDir, headers) { ? `"$(SRCROOT)${path.sep}${path.relative(sourceDir, directories[0])}"` : `"$(SRCROOT)${path.sep}${path.relative( sourceDir, - getOuterDirectory(directories) + getOuterDirectory(directories), )}/**"`; } diff --git a/packages/cli/src/commands/link/ios/getPlistPath.js b/packages/cli/src/commands/link/ios/getPlistPath.js index 64b348453..b0e613309 100644 --- a/packages/cli/src/commands/link/ios/getPlistPath.js +++ b/packages/cli/src/commands/link/ios/getPlistPath.js @@ -19,6 +19,6 @@ export default function getPlistPath(project, sourceDir) { return path.join( sourceDir, - plistFile.replace(/"/g, '').replace('$(SRCROOT)', '') + plistFile.replace(/"/g, '').replace('$(SRCROOT)', ''), ); } diff --git a/packages/cli/src/commands/link/ios/getTargets.js b/packages/cli/src/commands/link/ios/getTargets.js index 2e8147dc2..3c8a84146 100644 --- a/packages/cli/src/commands/link/ios/getTargets.js +++ b/packages/cli/src/commands/link/ios/getTargets.js @@ -12,7 +12,7 @@ */ export default function getTargets(project) { const { - firstProject: { targets }, + firstProject: {targets}, } = project.getFirstProject(); const nativeTargetSection = project.pbxNativeTargetSection(); return targets diff --git a/packages/cli/src/commands/link/ios/index.js b/packages/cli/src/commands/link/ios/index.js index b68f83b57..cb7d49142 100644 --- a/packages/cli/src/commands/link/ios/index.js +++ b/packages/cli/src/commands/link/ios/index.js @@ -14,7 +14,7 @@ import copyAssets from './copyAssets'; import unlinkAssets from './unlinkAssets'; export function getIOSLinkConfig() { - return { isInstalled, register, unregister, copyAssets, unlinkAssets }; + return {isInstalled, register, unregister, copyAssets, unlinkAssets}; } export default getIOSLinkConfig; diff --git a/packages/cli/src/commands/link/ios/mapHeaderSearchPaths.js b/packages/cli/src/commands/link/ios/mapHeaderSearchPaths.js index fbe95bfc8..eda6341e8 100644 --- a/packages/cli/src/commands/link/ios/mapHeaderSearchPaths.js +++ b/packages/cli/src/commands/link/ios/mapHeaderSearchPaths.js @@ -30,7 +30,7 @@ export default function headerSearchPathIter(project, func) { Object.keys(config) .filter(ref => ref.indexOf('_comment') === -1) .forEach(ref => { - const { buildSettings } = config[ref]; + const {buildSettings} = config[ref]; const shouldVisitBuildSettings = (Array.isArray(buildSettings.OTHER_LDFLAGS) ? buildSettings.OTHER_LDFLAGS diff --git a/packages/cli/src/commands/link/ios/registerNativeModule.js b/packages/cli/src/commands/link/ios/registerNativeModule.js index b735b24a0..d8d9e7551 100644 --- a/packages/cli/src/commands/link/ios/registerNativeModule.js +++ b/packages/cli/src/commands/link/ios/registerNativeModule.js @@ -10,7 +10,7 @@ import xcode from 'xcode'; import fs from 'fs'; import path from 'path'; -import { isEmpty } from 'lodash'; +import {isEmpty} from 'lodash'; import addToHeaderSearchPaths from './addToHeaderSearchPaths'; import getHeadersInFolder from './getHeadersInFolder'; @@ -30,7 +30,7 @@ import addSharedLibraries from './addSharedLibraries'; */ export default function registerNativeModuleIOS( dependencyConfig, - projectConfig + projectConfig, ) { const project = xcode.project(projectConfig.pbxprojPath).parseSync(); const dependencyProject = xcode @@ -39,11 +39,11 @@ export default function registerNativeModuleIOS( const libraries = createGroupWithMessage( project, - projectConfig.libraryFolder + projectConfig.libraryFolder, ); const file = addFileToProject( project, - path.relative(projectConfig.sourceDir, dependencyConfig.projectPath) + path.relative(projectConfig.sourceDir, dependencyConfig.projectPath), ); const targets = getTargets(project); @@ -79,7 +79,7 @@ export default function registerNativeModuleIOS( if (!isEmpty(headers)) { addToHeaderSearchPaths( project, - getHeaderSearchPath(projectConfig.sourceDir, headers) + getHeaderSearchPath(projectConfig.sourceDir, headers), ); } diff --git a/packages/cli/src/commands/link/ios/removeFromHeaderSearchPaths.js b/packages/cli/src/commands/link/ios/removeFromHeaderSearchPaths.js index 83f329026..ee5333fb5 100644 --- a/packages/cli/src/commands/link/ios/removeFromHeaderSearchPaths.js +++ b/packages/cli/src/commands/link/ios/removeFromHeaderSearchPaths.js @@ -14,6 +14,6 @@ import mapHeaderSearchPaths from './mapHeaderSearchPaths'; */ export default function addToHeaderSearchPaths(project, path) { mapHeaderSearchPaths(project, searchPaths => - searchPaths.filter(searchPath => searchPath !== path) + searchPaths.filter(searchPath => searchPath !== path), ); } diff --git a/packages/cli/src/commands/link/ios/removeFromProjectReferences.js b/packages/cli/src/commands/link/ios/removeFromProjectReferences.js index 1398bd845..6382c844c 100644 --- a/packages/cli/src/commands/link/ios/removeFromProjectReferences.js +++ b/packages/cli/src/commands/link/ios/removeFromProjectReferences.js @@ -18,10 +18,10 @@ * Otherwise returns null */ export default function removeFromProjectReferences(project, file) { - const { firstProject } = project.getFirstProject(); + const {firstProject} = project.getFirstProject(); const projectRef = firstProject.projectReferences.find( - item => item.ProjectRef === file.uuid + item => item.ProjectRef === file.uuid, ); if (!projectRef) { @@ -30,7 +30,7 @@ export default function removeFromProjectReferences(project, file) { firstProject.projectReferences.splice( firstProject.projectReferences.indexOf(projectRef), - 1 + 1, ); return projectRef; diff --git a/packages/cli/src/commands/link/ios/removeProjectFromLibraries.js b/packages/cli/src/commands/link/ios/removeProjectFromLibraries.js index 195c14f01..80f8068e4 100644 --- a/packages/cli/src/commands/link/ios/removeProjectFromLibraries.js +++ b/packages/cli/src/commands/link/ios/removeProjectFromLibraries.js @@ -13,8 +13,7 @@ * It's mainly due to limitations of `xcode` library. */ export default function removeProjectFromLibraries(libraries, file) { - // eslint-disable-next-line no-param-reassign libraries.children = libraries.children.filter( - library => library.comment !== file.basename + library => library.comment !== file.basename, ); } diff --git a/packages/cli/src/commands/link/ios/removeSharedLibraries.js b/packages/cli/src/commands/link/ios/removeSharedLibraries.js index 7b5d02381..35882b08b 100644 --- a/packages/cli/src/commands/link/ios/removeSharedLibraries.js +++ b/packages/cli/src/commands/link/ios/removeSharedLibraries.js @@ -15,6 +15,6 @@ export default function removeSharedLibraries(project, libraries) { const target = project.getFirstTarget().uuid; for (const name of libraries) { - project.removeFramework(name, { target }); + project.removeFramework(name, {target}); } } diff --git a/packages/cli/src/commands/link/ios/unlinkAssets.js b/packages/cli/src/commands/link/ios/unlinkAssets.js index 1c6036905..4843dbd28 100644 --- a/packages/cli/src/commands/link/ios/unlinkAssets.js +++ b/packages/cli/src/commands/link/ios/unlinkAssets.js @@ -9,7 +9,7 @@ import fs from 'fs-extra'; import path from 'path'; import xcode from 'xcode'; -import { difference } from 'lodash'; +import {difference} from 'lodash'; import log from '../../../tools/logger'; import groupFilesByType from '../groupFilesByType'; @@ -27,14 +27,14 @@ export default function unlinkAssetsIOS(files, projectConfig) { if (!plist) { log.error( - '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', ); return; } if (!project.pbxGroupByName('Resources')) { log.error( - '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.', ); return; } @@ -44,8 +44,8 @@ export default function unlinkAssetsIOS(files, projectConfig) { .map(asset => project.removeResourceFile( path.relative(projectConfig.sourceDir, asset), - { target: project.getFirstTarget().uuid } - ) + {target: project.getFirstTarget().uuid}, + ), ) .map(file => file.basename); diff --git a/packages/cli/src/commands/link/ios/unregisterNativeModule.js b/packages/cli/src/commands/link/ios/unregisterNativeModule.js index 8eebe5929..6dbc11644 100644 --- a/packages/cli/src/commands/link/ios/unregisterNativeModule.js +++ b/packages/cli/src/commands/link/ios/unregisterNativeModule.js @@ -10,7 +10,7 @@ import xcode from 'xcode'; import path from 'path'; import fs from 'fs'; -import { difference, isEmpty } from 'lodash'; +import {difference, isEmpty} from 'lodash'; import getGroup from './getGroup'; import getTargets from './getTargets'; @@ -30,7 +30,7 @@ import removeSharedLibraries from './removeSharedLibraries'; export default function unregisterNativeModule( dependencyConfig, projectConfig, - iOSDependencies + iOSDependencies, ) { const project = xcode.project(projectConfig.pbxprojPath).parseSync(); const dependencyProject = xcode @@ -41,7 +41,7 @@ export default function unregisterNativeModule( const file = removeProjectFromProject( project, - path.relative(projectConfig.sourceDir, dependencyConfig.projectPath) + path.relative(projectConfig.sourceDir, dependencyConfig.projectPath), ); removeProjectFromLibraries(libraries, file); @@ -56,8 +56,8 @@ export default function unregisterNativeModule( dependencyConfig.sharedLibraries, iOSDependencies.reduce( (libs, dependency) => libs.concat(dependency.sharedLibraries), - projectConfig.sharedLibraries - ) + projectConfig.sharedLibraries, + ), ); removeSharedLibraries(project, sharedLibraries); @@ -66,7 +66,7 @@ export default function unregisterNativeModule( if (!isEmpty(headers)) { removeFromHeaderSearchPaths( project, - getHeaderSearchPath(projectConfig.sourceDir, headers) + getHeaderSearchPath(projectConfig.sourceDir, headers), ); } diff --git a/packages/cli/src/commands/link/ios/writePlist.js b/packages/cli/src/commands/link/ios/writePlist.js index eb5d54c5d..38aaf6467 100644 --- a/packages/cli/src/commands/link/ios/writePlist.js +++ b/packages/cli/src/commands/link/ios/writePlist.js @@ -28,6 +28,6 @@ export default function writePlist(project, sourceDir, plist) { // Ref: https://github.com/facebook/react-native/issues/11668 return fs.writeFileSync( plistPath, - `${plistParser.build(plist, { indent: '\t', offset: -1 })}\n` + `${plistParser.build(plist, {indent: '\t', offset: -1})}\n`, ); } diff --git a/packages/cli/src/commands/link/link.js b/packages/cli/src/commands/link/link.js index 6be0b5484..13d601077 100644 --- a/packages/cli/src/commands/link/link.js +++ b/packages/cli/src/commands/link/link.js @@ -7,8 +7,8 @@ * @flow */ -import { pick } from 'lodash'; -import type { ContextT } from '../../tools/types.flow'; +import {pick} from 'lodash'; +import type {ContextT} from '../../tools/types.flow'; import promiseWaterfall from './promiseWaterfall'; import logger from '../../tools/logger'; @@ -43,13 +43,13 @@ function link([rawPackageName]: Array, ctx: ContextT, opts: FlagsType) { project = getProjectConfig(ctx, platforms); } catch (err) { logger.error( - 'No package found. Are you sure this is a React Native project?' + 'No package found. Are you sure this is a React Native project?', ); return Promise.reject(err); } const hasProjectConfig = Object.keys(platforms).reduce( (acc, key) => acc || key in project, - false + false, ); if (!hasProjectConfig && findReactNativeScripts()) { throw new Error( @@ -57,7 +57,7 @@ function link([rawPackageName]: Array, ctx: ContextT, opts: FlagsType) { 'If you need to include a library that relies on custom native code, ' + 'you might have to eject first. ' + 'See https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md ' + - 'for more information.' + 'for more information.', ); } @@ -80,7 +80,7 @@ function link([rawPackageName]: Array, ctx: ContextT, opts: FlagsType) { return promiseWaterfall(tasks).catch(err => { logger.error( `Something went wrong while linking. Error: ${err.message} \n` + - 'Please file an issue here: https://github.com/react-native-community/react-native-cli/issues' + 'Please file an issue here: https://github.com/react-native-community/react-native-cli/issues', ); throw err; }); diff --git a/packages/cli/src/commands/link/linkAll.js b/packages/cli/src/commands/link/linkAll.js index 4a14d13fd..333185dac 100644 --- a/packages/cli/src/commands/link/linkAll.js +++ b/packages/cli/src/commands/link/linkAll.js @@ -1,6 +1,6 @@ // @flow -import { uniqBy, flatten } from 'lodash'; +import {uniqBy, flatten} from 'lodash'; import path from 'path'; import type { ContextT, @@ -23,25 +23,25 @@ const dedupeAssets = (assets: Array): Array => function linkAll( context: ContextT, platforms: PlatformsT, - project: ProjectConfigT + project: ProjectConfigT, ) { logger.warn( 'Running `react-native link` without package name is deprecated and will be removed ' + 'in next release. If you use this command to link your project assets, ' + - 'please let us know about your use case here: https://goo.gl/RKTeoc' + 'please let us know about your use case here: https://goo.gl/RKTeoc', ); const projectAssets = getAssets(context.root); const dependencies = getProjectDependencies(context.root); const depenendenciesConfig = dependencies.map(dependnecy => - getDependencyConfig(context, platforms, dependnecy) + getDependencyConfig(context, platforms, dependnecy), ); const assets = dedupeAssets( depenendenciesConfig.reduce( (acc, dependency) => acc.concat(dependency.assets), - projectAssets - ) + projectAssets, + ), ); const tasks = flatten( @@ -50,13 +50,13 @@ function linkAll( () => linkDependency(platforms, project, config), () => promisify(config.commands.postlink || commandStub), () => linkAssets(platforms, project, assets), - ]) + ]), ); return promiseWaterfall(tasks).catch(err => { logger.error( `Something went wrong while linking. Error: ${err.message} \n` + - 'Please file an issue here: https://github.com/react-native-community/react-native-cli/issues' + 'Please file an issue here: https://github.com/react-native-community/react-native-cli/issues', ); throw err; }); diff --git a/packages/cli/src/commands/link/linkAssets.js b/packages/cli/src/commands/link/linkAssets.js index 6b36c3796..7060ef4ca 100644 --- a/packages/cli/src/commands/link/linkAssets.js +++ b/packages/cli/src/commands/link/linkAssets.js @@ -1,14 +1,14 @@ // @flow -import { isEmpty } from 'lodash'; -import type { PlatformsT, ProjectConfigT } from '../../tools/types.flow'; +import {isEmpty} from 'lodash'; +import type {PlatformsT, ProjectConfigT} from '../../tools/types.flow'; import logger from '../../tools/logger'; const linkAssets = ( platforms: PlatformsT, project: ProjectConfigT, - assets: Array + assets: Array, ) => { if (isEmpty(assets)) { return; diff --git a/packages/cli/src/commands/link/linkDependency.js b/packages/cli/src/commands/link/linkDependency.js index 60efb7ac9..e669aae29 100644 --- a/packages/cli/src/commands/link/linkDependency.js +++ b/packages/cli/src/commands/link/linkDependency.js @@ -7,12 +7,12 @@ import type { } from '../../tools/types.flow'; import logger from '../../tools/logger'; import pollParams from './pollParams'; -import { getPlatformName } from '../../tools/getPlatforms'; +import {getPlatformName} from '../../tools/getPlatforms'; const linkDependency = async ( platforms: PlatformsT, project: ProjectConfigT, - dependency: DependenciesConfig + dependency: DependenciesConfig, ) => { const params = await pollParams(dependency.params); @@ -33,20 +33,20 @@ const linkDependency = async ( const isInstalled = linkConfig.isInstalled( project[platform], dependency.name, - dependency.config[platform] + dependency.config[platform], ); if (isInstalled) { logger.info( `${getPlatformName(platform)} module "${ dependency.name - }" is already linked` + }" is already linked`, ); return; } logger.info( - `Linking "${dependency.name}" ${getPlatformName(platform)} dependency` + `Linking "${dependency.name}" ${getPlatformName(platform)} dependency`, ); linkConfig.register( @@ -54,13 +54,13 @@ const linkDependency = async ( dependency.config[platform] || {}, params, // $FlowFixMe: We check if project[platform] exists on line 42 - project[platform] + project[platform], ); logger.info( `${getPlatformName(platform)} module "${ dependency.name - }" has been successfully linked` + }" has been successfully linked`, ); }); }; diff --git a/packages/cli/src/commands/link/pods/addPodEntry.js b/packages/cli/src/commands/link/pods/addPodEntry.js index 45b33f275..25ce4875e 100644 --- a/packages/cli/src/commands/link/pods/addPodEntry.js +++ b/packages/cli/src/commands/link/pods/addPodEntry.js @@ -11,7 +11,7 @@ export default function addPodEntry( podLines, linesToAddEntry, podName, - nodePath + nodePath, ) { const newEntry = `pod '${podName}', :path => '../node_modules/${nodePath}'\n`; @@ -20,11 +20,11 @@ export default function addPodEntry( } if (Array.isArray(linesToAddEntry)) { - linesToAddEntry.map(({ line, indentation }, idx) => - podLines.splice(line + idx, 0, getLineToAdd(newEntry, indentation)) + linesToAddEntry.map(({line, indentation}, idx) => + podLines.splice(line + idx, 0, getLineToAdd(newEntry, indentation)), ); } else { - const { line, indentation } = linesToAddEntry; + const {line, indentation} = linesToAddEntry; podLines.splice(line, 0, getLineToAdd(newEntry, indentation)); } } diff --git a/packages/cli/src/commands/link/pods/findMarkedLinesInPodfile.js b/packages/cli/src/commands/link/pods/findMarkedLinesInPodfile.js index c162a59a7..3087937b7 100644 --- a/packages/cli/src/commands/link/pods/findMarkedLinesInPodfile.js +++ b/packages/cli/src/commands/link/pods/findMarkedLinesInPodfile.js @@ -13,7 +13,7 @@ export default function findMarkedLinesInPodfile(podLines) { const result = []; for (let i = 0, len = podLines.length; i < len; i++) { if (podLines[i].includes(MARKER_TEXT)) { - result.push({ line: i + 1, indentation: podLines[i].indexOf('#') }); + result.push({line: i + 1, indentation: podLines[i].indexOf('#')}); } } return result; diff --git a/packages/cli/src/commands/link/pods/isInstalled.js b/packages/cli/src/commands/link/pods/isInstalled.js index 312cc4eee..e68059616 100644 --- a/packages/cli/src/commands/link/pods/isInstalled.js +++ b/packages/cli/src/commands/link/pods/isInstalled.js @@ -16,7 +16,7 @@ export default function isInstalled(iOSProject, dependencyConfig) { // match line with pod declaration: pod 'dependencyPodName' (other possible parameters of pod are ignored) const dependencyRegExp = new RegExp( `pod\\s+('|")${dependencyConfig.podspec}('|")`, - 'g' + 'g', ); const podLines = readPodfile(iOSProject.podfile); for (let i = 0, len = podLines.length; i < len; i++) { diff --git a/packages/cli/src/commands/link/pods/registerNativeModule.js b/packages/cli/src/commands/link/pods/registerNativeModule.js index 5e3ffb976..5d8abca42 100644 --- a/packages/cli/src/commands/link/pods/registerNativeModule.js +++ b/packages/cli/src/commands/link/pods/registerNativeModule.js @@ -17,7 +17,7 @@ import savePodFile from './savePodFile'; export default function registerNativeModulePods( name, dependencyConfig, - iOSProject + iOSProject, ) { const podLines = readPodfile(iOSProject.podfile); const linesToAddEntry = getLinesToAddEntry(podLines, iOSProject); @@ -25,7 +25,7 @@ export default function registerNativeModulePods( savePodFile(iOSProject.podfile, podLines); } -function getLinesToAddEntry(podLines, { projectName }) { +function getLinesToAddEntry(podLines, {projectName}) { const linesToAddPodWithMarker = findMarkedLinesInPodfile(podLines); if (linesToAddPodWithMarker.length > 0) { return linesToAddPodWithMarker; diff --git a/packages/cli/src/commands/link/pods/removePodEntry.js b/packages/cli/src/commands/link/pods/removePodEntry.js index 8a0fd0041..1de92fe9b 100644 --- a/packages/cli/src/commands/link/pods/removePodEntry.js +++ b/packages/cli/src/commands/link/pods/removePodEntry.js @@ -11,7 +11,7 @@ export default function removePodEntry(podfileContent, podName) { // this regex should catch line(s) with full pod definition, like: pod 'podname', :path => '../node_modules/podname', :subspecs => ['Sub2', 'Sub1'] const podRegex = new RegExp( `\\n( |\\t)*pod\\s+("|')${podName}("|')(,\\s*(:[a-z]+\\s*=>)?\\s*(("|').*?("|')|\\[[\\s\\S]*?\\]))*\\n`, - 'g' + 'g', ); return podfileContent.replace(podRegex, '\n'); } diff --git a/packages/cli/src/commands/link/promiseWaterfall.js b/packages/cli/src/commands/link/promiseWaterfall.js index 78f471b37..bc6f2c5a8 100644 --- a/packages/cli/src/commands/link/promiseWaterfall.js +++ b/packages/cli/src/commands/link/promiseWaterfall.js @@ -18,6 +18,6 @@ export default function promiseWaterfall(tasks) { return tasks.reduce( (prevTaskPromise, task) => prevTaskPromise.then(task), - Promise.resolve() + Promise.resolve(), ); } diff --git a/packages/cli/src/commands/link/promisify.js b/packages/cli/src/commands/link/promisify.js index 62b234d2b..e4c2a97a2 100644 --- a/packages/cli/src/commands/link/promisify.js +++ b/packages/cli/src/commands/link/promisify.js @@ -9,5 +9,5 @@ export default func => new Promise((resolve, reject) => - func((err, res) => (err ? reject(err) : resolve(res))) + func((err, res) => (err ? reject(err) : resolve(res))), ); diff --git a/packages/cli/src/commands/link/unlink.js b/packages/cli/src/commands/link/unlink.js index 219121141..72f44e8c5 100644 --- a/packages/cli/src/commands/link/unlink.js +++ b/packages/cli/src/commands/link/unlink.js @@ -7,8 +7,8 @@ * @flow */ -import { flatten, isEmpty, difference } from 'lodash'; -import type { ContextT } from '../../tools/types.flow'; +import {flatten, isEmpty, difference} from 'lodash'; +import type {ContextT} from '../../tools/types.flow'; import logger from '../../tools/logger'; import getProjectConfig from './getProjectConfig'; import getDependencyConfig from './getDependencyConfig'; @@ -16,14 +16,14 @@ import getProjectDependencies from './getProjectDependencies'; import promiseWaterfall from './promiseWaterfall'; import commandStub from './commandStub'; import promisify from './promisify'; -import getPlatforms, { getPlatformName } from '../../tools/getPlatforms'; +import getPlatforms, {getPlatformName} from '../../tools/getPlatforms'; const unlinkDependency = ( platforms, project, dependency, packageName, - otherDependencies + otherDependencies, ) => { Object.keys(platforms || {}).forEach(platform => { if (!project[platform] || !dependency.config[platform]) { @@ -42,18 +42,18 @@ const unlinkDependency = ( const isInstalled = linkConfig.isInstalled( project[platform], packageName, - dependency.config[platform] + dependency.config[platform], ); if (!isInstalled) { logger.info( - `${getPlatformName(platform)} module "${packageName}" is not installed` + `${getPlatformName(platform)} module "${packageName}" is not installed`, ); return; } logger.info( - `Unlinking "${packageName}" ${getPlatformName(platform)} dependency` + `Unlinking "${packageName}" ${getPlatformName(platform)} dependency`, ); linkConfig.unregister( @@ -62,13 +62,13 @@ const unlinkDependency = ( dependency.config[platform], // $FlowFixMe: We check for existence on line 38 project[platform], - otherDependencies + otherDependencies, ); logger.info( `${getPlatformName(platform)} module "${ dependency.name - }" has been successfully unlinked` + }" has been successfully unlinked`, ); }); }; @@ -88,13 +88,13 @@ function unlink(args: Array, ctx: ContextT) { platforms = getPlatforms(ctx.root); } catch (err) { logger.error( - "No package.json found. Are you sure it's a React Native project?" + "No package.json found. Are you sure it's a React Native project?", ); return Promise.reject(err); } const allDependencies = getProjectDependencies(ctx.root).map(dependency => - getDependencyConfig(ctx, platforms, dependency) + getDependencyConfig(ctx, platforms, dependency), ); let otherDependencies; let dependency; @@ -107,7 +107,7 @@ function unlink(args: Array, ctx: ContextT) { } otherDependencies = [...allDependencies]; - dependency = otherDependencies.splice(idx, 1)[0]; // eslint-disable-line prefer-destructuring + dependency = otherDependencies.splice(idx, 1)[0]; } catch (err) { return Promise.reject(err); } @@ -122,7 +122,7 @@ function unlink(args: Array, ctx: ContextT) { project, dependency, packageName, - otherDependencies + otherDependencies, ), () => promisify(dependency.commands.postunlink || commandStub), ]; @@ -133,7 +133,7 @@ function unlink(args: Array, ctx: ContextT) { // link const assets = difference( dependency.assets, - flatten(allDependencies, d => d.assets) + flatten(allDependencies, d => d.assets), ); if (isEmpty(assets)) { @@ -155,12 +155,12 @@ function unlink(args: Array, ctx: ContextT) { }); logger.info( - `${packageName} assets has been successfully unlinked from your project` + `${packageName} assets has been successfully unlinked from your project`, ); }) .catch(err => { logger.error( - `It seems something went wrong while unlinking. Error:\n${err.message}` + `It seems something went wrong while unlinking. Error:\n${err.message}`, ); throw err; }); diff --git a/packages/cli/src/commands/logAndroid/logAndroid.js b/packages/cli/src/commands/logAndroid/logAndroid.js index e2d722b63..6eb2cf651 100644 --- a/packages/cli/src/commands/logAndroid/logAndroid.js +++ b/packages/cli/src/commands/logAndroid/logAndroid.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import { spawnSync } from 'child_process'; +import {spawnSync} from 'child_process'; import logger from '../../tools/logger'; /** @@ -20,7 +20,7 @@ async function logAndroid() { logger.info(`Starting the logger (${adbPath} ${adbArgs.join(' ')})...`); - const log = spawnSync(adbPath, adbArgs, { stdio: 'inherit' }); + const log = spawnSync(adbPath, adbArgs, {stdio: 'inherit'}); if (log.error !== null) { throw log.error; diff --git a/packages/cli/src/commands/logIOS/logIOS.js b/packages/cli/src/commands/logIOS/logIOS.js index fb10721c0..e4c46b5a5 100644 --- a/packages/cli/src/commands/logIOS/logIOS.js +++ b/packages/cli/src/commands/logIOS/logIOS.js @@ -7,7 +7,7 @@ * @format */ -import { execFileSync, spawnSync } from 'child_process'; +import {execFileSync, spawnSync} from 'child_process'; import os from 'os'; import path from 'path'; import logger from '../../tools/logger'; @@ -30,10 +30,10 @@ async function logIOS() { const rawDevices = execFileSync( 'xcrun', ['simctl', 'list', 'devices', '--json'], - { encoding: 'utf8' } + {encoding: 'utf8'}, ); - const { devices } = JSON.parse(rawDevices); + const {devices} = JSON.parse(rawDevices); const device = findAvailableDevice(devices); if (device === undefined) { @@ -51,7 +51,7 @@ function tailDeviceLogs(udid) { 'Logs', 'CoreSimulator', udid, - 'asl' + 'asl', ); const log = spawnSync('syslog', ['-w', '-F', 'std', '-d', logDir], { diff --git a/packages/cli/src/commands/runAndroid/__tests__/runOnAllDevices.test.js b/packages/cli/src/commands/runAndroid/__tests__/runOnAllDevices.test.js index b09559d68..840e5cb54 100644 --- a/packages/cli/src/commands/runAndroid/__tests__/runOnAllDevices.test.js +++ b/packages/cli/src/commands/runAndroid/__tests__/runOnAllDevices.test.js @@ -14,7 +14,7 @@ jest.mock('child_process', () => ({ })); jest.mock('../getAdbPath'); -const { execFileSync } = require('child_process'); +const {execFileSync} = require('child_process'); describe('--appFolder', () => { beforeEach(() => { @@ -56,7 +56,7 @@ describe('--appFolder', () => { }); expect(execFileSync.mock.calls[2][1]).toContain( - 'anotherApp:installStaging' + 'anotherApp:installStaging', ); }); diff --git a/packages/cli/src/commands/runAndroid/adb.js b/packages/cli/src/commands/runAndroid/adb.js index b93d8f98f..d526829bc 100644 --- a/packages/cli/src/commands/runAndroid/adb.js +++ b/packages/cli/src/commands/runAndroid/adb.js @@ -8,7 +8,7 @@ * @flow */ -import { execSync, execFileSync } from 'child_process'; +import {execSync, execFileSync} from 'child_process'; /** * Parses the output of the 'adb devices' command @@ -52,14 +52,14 @@ function getAvailableCPUs(adbPath: string, device: string): Array { let cpus = execFileSync( adbPath, - baseArgs.concat(['ro.product.cpu.abilist']) + baseArgs.concat(['ro.product.cpu.abilist']), ).toString(); // pre-Lollipop if (!cpus || cpus.trim().length === 0) { cpus = execFileSync( adbPath, - baseArgs.concat(['ro.product.cpu.abi']) + baseArgs.concat(['ro.product.cpu.abi']), ).toString(); } diff --git a/packages/cli/src/commands/runAndroid/runAndroid.js b/packages/cli/src/commands/runAndroid/runAndroid.js index a075afe06..d3d2b3033 100644 --- a/packages/cli/src/commands/runAndroid/runAndroid.js +++ b/packages/cli/src/commands/runAndroid/runAndroid.js @@ -7,15 +7,13 @@ * @flow */ -/* eslint-disable consistent-return */ - import path from 'path'; -import { spawnSync, spawn, execFileSync } from 'child_process'; +import {spawnSync, spawn, execFileSync} from 'child_process'; import fs from 'fs'; import isString from 'lodash/isString'; import isPackagerRunning from '../../tools/isPackagerRunning'; -import type { ContextT } from '../../tools/types.flow'; +import type {ContextT} from '../../tools/types.flow'; import adb from './adb'; import runOnAllDevices from './runOnAllDevices'; @@ -32,11 +30,10 @@ function checkAndroid(root) { /** * Starts the app on a connected Android emulator or device. */ -// eslint-disable-next-line flowtype/no-weak-types function runAndroid(argv: Array, ctx: ContextT, args: Object) { if (!checkAndroid(args.root)) { logger.error( - 'Android project not found. Are you sure this is a React Native project?' + 'Android project not found. Are you sure this is a React Native project?', ); return; } @@ -76,7 +73,7 @@ function buildAndRun(args) { const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew'; // "app" is usually the default value for Android apps with only 1 app - const { appFolder } = args; + const {appFolder} = args; const packageName = fs .readFileSync(`${appFolder}/src/main/AndroidManifest.xml`, 'utf8') // $FlowFixMe @@ -85,7 +82,7 @@ function buildAndRun(args) { const packageNameWithSuffix = getPackageNameWithSuffix( args.appId, args.appIdSuffix, - packageName + packageName, ); const adbPath = getAdbPath(); @@ -96,7 +93,7 @@ function buildAndRun(args) { cmd, packageNameWithSuffix, packageName, - adbPath + adbPath, ); } logger.error('Argument missing for parameter --deviceId'); @@ -106,7 +103,7 @@ function buildAndRun(args) { cmd, packageNameWithSuffix, packageName, - adbPath + adbPath, ); } } @@ -116,7 +113,7 @@ function runOnSpecificDevice( gradlew, packageNameWithSuffix, packageName, - adbPath + adbPath, ) { const devices = adb.getDevices(adbPath); if (devices && devices.length > 0) { @@ -127,14 +124,14 @@ function runOnSpecificDevice( args.deviceId, packageNameWithSuffix, packageName, - adbPath + adbPath, ); } else { logger.error( `Could not find device with the id: "${ args.deviceId }". Choose one of the following:`, - ...devices + ...devices, ); } } else { @@ -158,7 +155,7 @@ function buildApk(gradlew) { function tryInstallAppOnDevice(args, adbPath, device) { try { // "app" is usually the default value for Android apps with only 1 app - const { appFolder } = args; + const {appFolder} = args; const variant = args.variant.toLowerCase(); const buildDirectory = `${appFolder}/build/outputs/apk/${variant}`; const apkFile = getInstallApkName( @@ -166,13 +163,13 @@ function tryInstallAppOnDevice(args, adbPath, device) { adbPath, variant, device, - buildDirectory + buildDirectory, ); const pathToApk = `${buildDirectory}/${apkFile}`; const adbArgs = ['-s', device, 'install', pathToApk]; logger.info( - `Installing the app on the device (cd android && adb -s ${device} install ${pathToApk}` + `Installing the app on the device (cd android && adb -s ${device} install ${pathToApk}`, ); execFileSync(adbPath, adbArgs, { stdio: [process.stdin, process.stdout, process.stderr], @@ -181,7 +178,7 @@ function tryInstallAppOnDevice(args, adbPath, device) { logger.error( `${ e.message - }\nCould not install the app on the device, read the error above for details.` + }\nCould not install the app on the device, read the error above for details.`, ); } } @@ -191,7 +188,7 @@ function getInstallApkName( adbPath, variant, device, - buildDirectory + buildDirectory, ) { const availableCPUs = adb.getAvailableCPUs(adbPath, device); @@ -217,7 +214,7 @@ function installAndLaunchOnDevice( selectedDevice, packageNameWithSuffix, packageName, - adbPath + adbPath, ) { tryRunAdbReverse(args.port, selectedDevice); tryInstallAppOnDevice(args, adbPath, selectedDevice); @@ -226,14 +223,14 @@ function installAndLaunchOnDevice( packageNameWithSuffix, packageName, adbPath, - args.mainActivity + args.mainActivity, ); } function startServerInNewWindow( port, terminal = process.env.REACT_TERMINAL, - reactNativePath + reactNativePath, ) { /** * Set up OS-specific filenames and commands @@ -252,7 +249,7 @@ function startServerInNewWindow( */ const launchPackagerScript = path.join( reactNativePath, - `scripts/${scriptFile}` + `scripts/${scriptFile}`, ); /** @@ -261,8 +258,7 @@ function startServerInNewWindow( */ const scriptsDir = path.dirname(launchPackagerScript); const packagerEnvFile = path.join(scriptsDir, packagerEnvFilename); - // eslint-disable-next-line flowtype/no-weak-types - const procConfig: Object = { cwd: scriptsDir }; + const procConfig: Object = {cwd: scriptsDir}; /** * Ensure we overwrite file by passing the `w` flag @@ -277,7 +273,7 @@ function startServerInNewWindow( return spawnSync( 'open', ['-a', terminal, launchPackagerScript], - procConfig + procConfig, ); } return spawnSync('open', [launchPackagerScript], procConfig); @@ -297,7 +293,7 @@ function startServerInNewWindow( return spawn('cmd.exe', ['/C', launchPackagerScript], procConfig); } logger.error( - `Cannot start the packager. Unknown platform ${process.platform}` + `Cannot start the packager. Unknown platform ${process.platform}`, ); } diff --git a/packages/cli/src/commands/runAndroid/runOnAllDevices.js b/packages/cli/src/commands/runAndroid/runOnAllDevices.js index 48956701c..043d89f32 100644 --- a/packages/cli/src/commands/runAndroid/runOnAllDevices.js +++ b/packages/cli/src/commands/runAndroid/runOnAllDevices.js @@ -7,9 +7,8 @@ * @flow */ -/* eslint-disable consistent-return */ -import { spawnSync, execFileSync } from 'child_process'; +import {spawnSync, execFileSync} from 'child_process'; import logger from '../../tools/logger'; import adb from './adb'; import tryRunAdbReverse from './tryRunAdbReverse'; @@ -20,12 +19,11 @@ function getCommand(appFolder, command) { } function runOnAllDevices( - // eslint-disable-next-line flowtype/no-weak-types args: Object, cmd: string, packageNameWithSuffix: string, packageName: string, - adbPath: string + adbPath: string, ) { try { const gradleArgs = []; @@ -36,16 +34,16 @@ function runOnAllDevices( gradleArgs.push( `${getCommand( args.appFolder, - 'install' - )}${args.variant[0].toUpperCase()}${args.variant.slice(1)}` + 'install', + )}${args.variant[0].toUpperCase()}${args.variant.slice(1)}`, ); } else if (args.flavor) { logger.warn('--flavor has been deprecated. Use --variant instead'); gradleArgs.push( `${getCommand( args.appFolder, - 'install' - )}${args.flavor[0].toUpperCase()}${args.flavor.slice(1)}` + 'install', + )}${args.flavor[0].toUpperCase()}${args.flavor.slice(1)}`, ); } else { gradleArgs.push(getCommand(args.appFolder, 'installDebug')); @@ -53,8 +51,8 @@ function runOnAllDevices( logger.info( `Building and installing the app on the device (cd android && ${cmd} ${gradleArgs.join( - ' ' - )})...` + ' ', + )})...`, ); execFileSync(cmd, gradleArgs, { @@ -65,7 +63,7 @@ function runOnAllDevices( 'Could not install the app on the device, read the error above for details.\n' + 'Make sure you have an Android emulator running or a device connected and have\n' + 'set up your Android development environment:\n' + - 'https://facebook.github.io/react-native/docs/getting-started.html' + 'https://facebook.github.io/react-native/docs/getting-started.html', ); // stderr is automatically piped from the gradle process, so the user // should see the error already, there is no need to do @@ -81,7 +79,7 @@ function runOnAllDevices( packageNameWithSuffix, packageName, adbPath, - args.mainActivity + args.mainActivity, ); }); } else { @@ -96,9 +94,9 @@ function runOnAllDevices( `${packageNameWithSuffix}/${packageName}.MainActivity`, ]; logger.info( - `Starting the app (${adbPath} ${fallbackAdbArgs.join(' ')}...` + `Starting the app (${adbPath} ${fallbackAdbArgs.join(' ')}...`, ); - spawnSync(adbPath, fallbackAdbArgs, { stdio: 'inherit' }); + spawnSync(adbPath, fallbackAdbArgs, {stdio: 'inherit'}); } catch (e) { logger.error('adb invocation failed. Do you have adb in your PATH?'); // stderr is automatically piped from the gradle process, so the user diff --git a/packages/cli/src/commands/runAndroid/tryLaunchAppOnDevice.js b/packages/cli/src/commands/runAndroid/tryLaunchAppOnDevice.js index b8916530f..ee793b751 100644 --- a/packages/cli/src/commands/runAndroid/tryLaunchAppOnDevice.js +++ b/packages/cli/src/commands/runAndroid/tryLaunchAppOnDevice.js @@ -7,7 +7,7 @@ * @flow */ -import { spawnSync } from 'child_process'; +import {spawnSync} from 'child_process'; import logger from '../../tools/logger'; function tryLaunchAppOnDevice( @@ -15,7 +15,7 @@ function tryLaunchAppOnDevice( packageNameWithSuffix: string, packageName: string, adbPath: string, - mainActivity: string + mainActivity: string, ) { try { const adbArgs = [ @@ -28,9 +28,9 @@ function tryLaunchAppOnDevice( `${packageNameWithSuffix}/${packageName}.${mainActivity}`, ]; logger.info( - `Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...` + `Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`, ); - spawnSync(adbPath, adbArgs, { stdio: 'inherit' }); + spawnSync(adbPath, adbArgs, {stdio: 'inherit'}); } catch (e) { logger.error('adb invocation failed. Do you have adb in your PATH?'); } diff --git a/packages/cli/src/commands/runAndroid/tryRunAdbReverse.js b/packages/cli/src/commands/runAndroid/tryRunAdbReverse.js index 952e7e885..8c6198848 100644 --- a/packages/cli/src/commands/runAndroid/tryRunAdbReverse.js +++ b/packages/cli/src/commands/runAndroid/tryRunAdbReverse.js @@ -7,7 +7,7 @@ * @flow */ -import { execFileSync } from 'child_process'; +import {execFileSync} from 'child_process'; import logger from '../../tools/logger'; import getAdbPath from './getAdbPath'; diff --git a/packages/cli/src/commands/runIOS/__tests__/findMatchingSimulator-test.js b/packages/cli/src/commands/runIOS/__tests__/findMatchingSimulator-test.js index e3657a184..95d0551a1 100644 --- a/packages/cli/src/commands/runIOS/__tests__/findMatchingSimulator-test.js +++ b/packages/cli/src/commands/runIOS/__tests__/findMatchingSimulator-test.js @@ -53,8 +53,8 @@ describe('findMatchingSimulator', () => { ], }, }, - 'iPhone 6' - ) + 'iPhone 6', + ), ).toEqual({ udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C', name: 'iPhone 6', @@ -105,8 +105,8 @@ describe('findMatchingSimulator', () => { ], }, }, - 'iPhone 6' - ) + 'iPhone 6', + ), ).toEqual({ udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C', name: 'iPhone 6', @@ -154,14 +154,14 @@ describe('findMatchingSimulator', () => { ], }, }, - 'iPhone 6' - ) + 'iPhone 6', + ), ).toEqual(null); }); it('should return null if an odd input', () => { expect(findMatchingSimulator('random string input', 'iPhone 6')).toEqual( - null + null, ); }); @@ -204,8 +204,8 @@ describe('findMatchingSimulator', () => { ], }, }, - null - ) + null, + ), ).toEqual({ udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB', name: 'iPhone 5', @@ -279,8 +279,8 @@ describe('findMatchingSimulator', () => { ], }, }, - null - ) + null, + ), ).toEqual({ udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB', name: 'iPhone 5', @@ -328,8 +328,8 @@ describe('findMatchingSimulator', () => { ], }, }, - null - ) + null, + ), ).toEqual({ udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508', name: 'iPhone 6s', @@ -377,8 +377,8 @@ describe('findMatchingSimulator', () => { ], }, }, - 'iPhone 6' - ) + 'iPhone 6', + ), ).toEqual({ udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C', name: 'iPhone 6', @@ -452,8 +452,8 @@ describe('findMatchingSimulator', () => { ], }, }, - null - ) + null, + ), ).toEqual({ udid: '3A409DC5-5188-42A6-8598-3AA6F34607A5', name: 'iPhone 7', @@ -527,8 +527,8 @@ describe('findMatchingSimulator', () => { ], }, }, - 'iPhone 6s' - ) + 'iPhone 6s', + ), ).toEqual({ udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508', name: 'iPhone 6s', @@ -602,8 +602,8 @@ describe('findMatchingSimulator', () => { ], }, }, - 'iPhone 6s (10.0)' - ) + 'iPhone 6s (10.0)', + ), ).toEqual({ udid: 'CBBB8FB8-77AB-49A9-8297-4CCFE3189C22', name: 'iPhone 6s', @@ -671,8 +671,8 @@ describe('findMatchingSimulator', () => { ], }, }, - 'iPhone 6s (10.0)' - ) + 'iPhone 6s (10.0)', + ), ).toEqual(null); }); @@ -703,8 +703,8 @@ describe('findMatchingSimulator', () => { ], }, }, - 'Apple TV' - ) + 'Apple TV', + ), ).toEqual({ udid: '816C30EA-38EA-41AC-BFDA-96FB632D522E', name: 'Apple TV', diff --git a/packages/cli/src/commands/runIOS/__tests__/findXcodeProject-test.js b/packages/cli/src/commands/runIOS/__tests__/findXcodeProject-test.js index 365d48747..a3d79a0df 100644 --- a/packages/cli/src/commands/runIOS/__tests__/findXcodeProject-test.js +++ b/packages/cli/src/commands/runIOS/__tests__/findXcodeProject-test.js @@ -23,7 +23,7 @@ describe('findXcodeProject', () => { 'PodFile', 'Podfile.lock', 'Pods', - ]) + ]), ).toEqual({ name: 'AwesomeApp.xcodeproj', isWorkspace: false, @@ -41,7 +41,7 @@ describe('findXcodeProject', () => { 'PodFile', 'Podfile.lock', 'Pods', - ]) + ]), ).toEqual({ name: 'AwesomeApp.xcworkspace', isWorkspace: true, @@ -57,7 +57,7 @@ describe('findXcodeProject', () => { 'PodFile', 'Podfile.lock', 'Pods', - ]) + ]), ).toEqual(null); }); }); diff --git a/packages/cli/src/commands/runIOS/__tests__/parseIOSDevicesList-test.js b/packages/cli/src/commands/runIOS/__tests__/parseIOSDevicesList-test.js index e92b6a527..b5ebb2372 100644 --- a/packages/cli/src/commands/runIOS/__tests__/parseIOSDevicesList-test.js +++ b/packages/cli/src/commands/runIOS/__tests__/parseIOSDevicesList-test.js @@ -27,7 +27,7 @@ describe('parseIOSDevicesList', () => { 'Blank', 'System Usage', 'Zombies', - ].join('\n') + ].join('\n'), ); expect(devices).toEqual([ @@ -41,7 +41,7 @@ describe('parseIOSDevicesList', () => { it('ignores garbage', () => { expect(parseIOSDevicesList('Something went terribly wrong (-42)')).toEqual( - [] + [], ); }); }); diff --git a/packages/cli/src/commands/runIOS/findMatchingSimulator.js b/packages/cli/src/commands/runIOS/findMatchingSimulator.js index 09f2d9a6b..0cbdf6466 100644 --- a/packages/cli/src/commands/runIOS/findMatchingSimulator.js +++ b/packages/cli/src/commands/runIOS/findMatchingSimulator.js @@ -7,8 +7,6 @@ * @format */ -/* eslint-disable */ - /** * Takes in a parsed simulator list and a desired name, and returns an object with the matching simulator. The desired * name can optionally include the iOS version in between parenthesis after the device name. Ex: "iPhone 6 (9.2)" in @@ -43,9 +41,12 @@ function findMatchingSimulator(simulators, simulatorString) { const device = devices[versionDescriptor]; let version = versionDescriptor; - if ((/^com\.apple\.CoreSimulator\.SimRuntime\./g).test(version)) { + if (/^com\.apple\.CoreSimulator\.SimRuntime\./g.test(version)) { // Transform "com.apple.CoreSimulator.SimRuntime.iOS-12-2" into "iOS 12.2" - version = version.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g, '$1 $2.$3'); + version = version.replace( + /^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g, + '$1 $2.$3', + ); } // Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc) diff --git a/packages/cli/src/commands/runIOS/parseIOSDevicesList.js b/packages/cli/src/commands/runIOS/parseIOSDevicesList.js index 4bb61bff8..2cacf661a 100644 --- a/packages/cli/src/commands/runIOS/parseIOSDevicesList.js +++ b/packages/cli/src/commands/runIOS/parseIOSDevicesList.js @@ -26,7 +26,7 @@ function parseIOSDevicesList(text: string): Array { const name = device[1]; const version = device[2]; const udid = device[3]; - devices.push({ udid, name, version }); + devices.push({udid, name, version}); } }); diff --git a/packages/cli/src/commands/runIOS/runIOS.js b/packages/cli/src/commands/runIOS/runIOS.js index e2061a452..8e23d7da4 100644 --- a/packages/cli/src/commands/runIOS/runIOS.js +++ b/packages/cli/src/commands/runIOS/runIOS.js @@ -8,15 +8,14 @@ * @format */ -// eslint-disable-next-line import child_process from 'child_process'; import fs from 'fs'; import path from 'path'; -import type { ContextT } from '../../tools/types.flow'; +import type {ContextT} from '../../tools/types.flow'; import findXcodeProject from './findXcodeProject'; import parseIOSDevicesList from './parseIOSDevicesList'; import findMatchingSimulator from './findMatchingSimulator'; -import { ProcessError } from '../../tools/errors'; +import {ProcessError} from '../../tools/errors'; import logger from '../../tools/logger'; type FlagsT = { @@ -34,7 +33,7 @@ type FlagsT = { function runIOS(_: Array, ctx: ContextT, args: FlagsT) { if (!fs.existsSync(args.projectPath)) { throw new Error( - 'iOS project folder not found. Are you sure this is a React Native project?' + 'iOS project folder not found. Are you sure this is a React Native project?', ); } @@ -43,27 +42,27 @@ function runIOS(_: Array, ctx: ContextT, args: FlagsT) { const xcodeProject = findXcodeProject(fs.readdirSync('.')); if (!xcodeProject) { throw new Error( - `Could not find Xcode project files in "${args.projectPath}" folder` + `Could not find Xcode project files in "${args.projectPath}" folder`, ); } const inferredSchemeName = path.basename( xcodeProject.name, - path.extname(xcodeProject.name) + path.extname(xcodeProject.name), ); const scheme = args.scheme || inferredSchemeName; logger.info( `Found Xcode ${xcodeProject.isWorkspace ? 'workspace' : 'project'} ${ xcodeProject.name - }` + }`, ); const devices = parseIOSDevicesList( // $FlowExpectedError https://github.com/facebook/flow/issues/5675 child_process.execFileSync('xcrun', ['instruments', '-s'], { encoding: 'utf8', - }) + }), ); if (args.device) { @@ -76,7 +75,7 @@ function runIOS(_: Array, ctx: ContextT, args: FlagsT) { args.configuration, args.packager, args.verbose, - args.port + args.port, ); } if (devices && devices.length > 0) { @@ -95,10 +94,10 @@ Choose one of the following:${printFoundDevices(devices)}`); } function runOnDeviceByUdid( - args: FlagsT & { udid: string }, + args: FlagsT & {udid: string}, scheme, xcodeProject, - devices + devices, ) { const selectedDevice = matchingDeviceByUdid(devices, args.udid); @@ -110,7 +109,7 @@ function runOnDeviceByUdid( args.configuration, args.packager, args.verbose, - args.port + args.port, ); return; } @@ -132,8 +131,8 @@ async function runOnSimulator(xcodeProject, args, scheme) { child_process.execFileSync( 'xcrun', ['simctl', 'list', '--json', 'devices'], - { encoding: 'utf8' } - ) + {encoding: 'utf8'}, + ), ); } catch (e) { throw new Error('Could not parse the simulator list output'); @@ -156,7 +155,7 @@ async function runOnSimulator(xcodeProject, args, scheme) { * this flag has no effect. */ const activeDeveloperDir = child_process - .execFileSync('xcode-select', ['-p'], { encoding: 'utf8' }) + .execFileSync('xcode-select', ['-p'], {encoding: 'utf8'}) // $FlowExpectedError https://github.com/facebook/flow/issues/5675 .trim(); @@ -178,7 +177,7 @@ async function runOnSimulator(xcodeProject, args, scheme) { args.configuration, args.packager, args.verbose, - args.port + args.port, ); const appPath = getBuildPath(args.configuration, appName, false, scheme); @@ -190,14 +189,14 @@ async function runOnSimulator(xcodeProject, args, scheme) { ['simctl', 'install', selectedSimulator.udid, appPath], { stdio: 'inherit', - } + }, ); const bundleID = child_process .execFileSync( '/usr/libexec/PlistBuddy', ['-c', 'Print:CFBundleIdentifier', path.join(appPath, 'Info.plist')], - { encoding: 'utf8' } + {encoding: 'utf8'}, ) // $FlowExpectedError https://github.com/facebook/flow/issues/5675 .trim(); @@ -209,7 +208,7 @@ async function runOnSimulator(xcodeProject, args, scheme) { ['simctl', 'launch', selectedSimulator.udid, bundleID], { stdio: 'inherit', - } + }, ); } @@ -220,7 +219,7 @@ async function runOnDevice( configuration, launchPackager, verbose, - port + port, ) { const appName = await buildProject( xcodeProject, @@ -229,7 +228,7 @@ async function runOnDevice( configuration, launchPackager, verbose, - port + port, ); const iosDeployInstallArgs = [ @@ -245,12 +244,12 @@ async function runOnDevice( const iosDeployOutput = child_process.spawnSync( 'ios-deploy', iosDeployInstallArgs, - { encoding: 'utf8' } + {encoding: 'utf8'}, ); if (iosDeployOutput.error) { logger.error( - `** INSTALLATION FAILED **\nMake sure you have ios-deploy installed globally.\n(e.g "npm install -g ios-deploy")` + '** INSTALLATION FAILED **\nMake sure you have ios-deploy installed globally.\n(e.g "npm install -g ios-deploy")', ); } else { logger.info('** INSTALLATION SUCCEEDED **'); @@ -264,7 +263,7 @@ function buildProject( configuration, launchPackager = false, verbose, - port + port, ) { return new Promise((resolve, reject) => { const xcodebuildArgs = [ @@ -291,7 +290,7 @@ function buildProject( const buildProcess = child_process.spawn( 'xcodebuild', xcodebuildArgs, - getProcessOptions(launchPackager, port) + getProcessOptions(launchPackager, port), ); let buildOutput = ''; let errorOutput = ''; @@ -314,14 +313,14 @@ function buildProject( reject( new ProcessError( [ - `Failed to build iOS project.`, + 'Failed to build iOS project.', `We ran "xcodebuild" command but it exited with error code ${code}.`, `To debug build logs further, consider building your app with Xcode.app, by opening ${ xcodeProject.name }`, ].join(' '), - errorOutput - ) + errorOutput, + ), ); return; } @@ -361,7 +360,7 @@ function getBuildPath(configuration, appName, isDevice, scheme) { function getProductName(buildOutput) { const productNameMatch = /export FULL_PRODUCT_NAME="?(.+).app"?$/m.exec( - buildOutput + buildOutput, ); return productNameMatch ? productNameMatch[1] : null; } @@ -382,7 +381,7 @@ function matchingDevice(devices, deviceName) { logger.info( `Using first available device ${ devices[0].name - } due to lack of name supplied.` + } due to lack of name supplied.`, ); return devices[0]; } @@ -421,12 +420,12 @@ function printFoundDevices(devices) { function getProcessOptions(launchPackager, port) { if (launchPackager) { return { - env: { ...process.env, RCT_METRO_PORT: port }, + env: {...process.env, RCT_METRO_PORT: port}, }; } return { - env: { ...process.env, RCT_NO_LAUNCH_PACKAGER: true }, + env: {...process.env, RCT_NO_LAUNCH_PACKAGER: true}, }; } diff --git a/packages/cli/src/commands/server/copyToClipBoard.js b/packages/cli/src/commands/server/copyToClipBoard.js index 0017b5c46..4cfc82fbc 100644 --- a/packages/cli/src/commands/server/copyToClipBoard.js +++ b/packages/cli/src/commands/server/copyToClipBoard.js @@ -7,7 +7,7 @@ * @format */ -import { spawn } from 'child_process'; +import {spawn} from 'child_process'; import path from 'path'; import fs from 'fs'; diff --git a/packages/cli/src/commands/server/debugger-ui/DeltaPatcher.js b/packages/cli/src/commands/server/debugger-ui/DeltaPatcher.js index 7793792f4..ed950295f 100644 --- a/packages/cli/src/commands/server/debugger-ui/DeltaPatcher.js +++ b/packages/cli/src/commands/server/debugger-ui/DeltaPatcher.js @@ -55,7 +55,7 @@ // Make sure that the first received bundle is a base. if (!this._initialized && !bundle.base) { throw new Error( - 'DeltaPatcher should receive a base Bundle when being initialized' + 'DeltaPatcher should receive a base Bundle when being initialized', ); } @@ -120,7 +120,7 @@ return [].concat( [this._lastBundle.pre], Array.from(this._lastBundle.modules.values()), - [this._lastBundle.post] + [this._lastBundle.post], ); } } diff --git a/packages/cli/src/commands/server/debugger-ui/debuggerWorker.js b/packages/cli/src/commands/server/debugger-ui/debuggerWorker.js index 4873b4193..070d753b7 100644 --- a/packages/cli/src/commands/server/debugger-ui/debuggerWorker.js +++ b/packages/cli/src/commands/server/debugger-ui/debuggerWorker.js @@ -25,7 +25,7 @@ onmessage = (function() { console.warn( 'Remote debugger is in a background tab which may cause apps to ' + 'perform slowly. Fix this by foregrounding the tab (or opening it in ' + - 'a separate window).' + 'a separate window).', ); }; })(); @@ -56,7 +56,7 @@ onmessage = (function() { var object = message.data; var sendReply = function(result, error) { - postMessage({ replyID: object.id, result: result, error: error }); + postMessage({replyID: object.id, result: result, error: error}); }; var handler = messageHandlers[object.method]; @@ -71,7 +71,7 @@ onmessage = (function() { if (typeof __fbBatchedBridge === 'object') { returnValue = __fbBatchedBridge[object.method].apply( null, - object.arguments + object.arguments, ); } else { error = 'Failed to call function, __fbBatchedBridge is undefined'; diff --git a/packages/cli/src/commands/server/jsPackagerClient.js b/packages/cli/src/commands/server/jsPackagerClient.js index 9387a49c4..3f051df4b 100644 --- a/packages/cli/src/commands/server/jsPackagerClient.js +++ b/packages/cli/src/commands/server/jsPackagerClient.js @@ -48,7 +48,7 @@ class JsPackagerClient { () => new Promise((resolve, reject) => { const messageId = getMessageId(); - this.msgCallbacks.set(messageId, { resolve, reject }); + this.msgCallbacks.set(messageId, {resolve, reject}); this.ws.send( JSON.stringify({ version: PROTOCOL_VERSION, @@ -62,9 +62,9 @@ class JsPackagerClient { this.msgCallbacks.delete(messageId); reject(error); } - } + }, ); - }) + }), ); } @@ -85,9 +85,9 @@ class JsPackagerClient { } else { resolve(); } - } + }, ); - }) + }), ); } @@ -102,9 +102,9 @@ class JsPackagerClient { reject( new Error( `Results received from server are of wrong format:\n${JSON.stringify( - response - )}` - ) + response, + )}`, + ), ); } else { resolve(response); diff --git a/packages/cli/src/commands/server/launchChrome.js b/packages/cli/src/commands/server/launchChrome.js index 5dbf1feec..758dbbd73 100644 --- a/packages/cli/src/commands/server/launchChrome.js +++ b/packages/cli/src/commands/server/launchChrome.js @@ -9,14 +9,14 @@ */ import opn from 'opn'; -import { execSync } from 'child_process'; +import {execSync} from 'child_process'; import logger from '../../tools/logger'; function commandExistsUnixSync(commandName) { try { const stdout = execSync( `command -v ${commandName} 2>/dev/null` + - ` && { echo >&1 '${commandName} found'; exit 0; }` + ` && { echo >&1 '${commandName} found'; exit 0; }`, ); return !!stdout; } catch (error) { @@ -45,7 +45,7 @@ function getChromeAppName(): string { } function launchChrome(url: string) { - opn(url, { app: [getChromeAppName()] }, err => { + opn(url, {app: [getChromeAppName()]}, err => { if (err) { logger.error('Google Chrome exited with error:', err); } diff --git a/packages/cli/src/commands/server/launchEditor.js b/packages/cli/src/commands/server/launchEditor.js index 7dc85fe02..aa0867b94 100644 --- a/packages/cli/src/commands/server/launchEditor.js +++ b/packages/cli/src/commands/server/launchEditor.js @@ -10,7 +10,7 @@ import chalk from 'chalk'; import fs from 'fs'; import path from 'path'; -import { execSync, spawn } from 'child_process'; +import {execSync, spawn} from 'child_process'; import shellQuote from 'shell-quote'; import logger from '../../tools/logger'; @@ -80,7 +80,7 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { case 'code': return addWorkspaceToArgumentsIfExists( ['-g', `${fileName}:${lineNumber}`], - workspace + workspace, ); // For all others, drop the lineNumber until we have // a mapping above, since providing the lineNumber incorrectly @@ -136,7 +136,7 @@ function printInstructions(title) { ' export REACT_EDITOR=atom to your ~/.bashrc or ~/.zshrc depending on ', ' which shell you use.', '', - ].join('\n') + ].join('\n'), ); } @@ -167,7 +167,7 @@ function launchEditor(fileName, lineNumber, projectRoots) { return; } - let [editor, ...args] = guessEditor(); // eslint-disable-line prefer-const + let [editor, ...args] = guessEditor(); if (!editor) { printInstructions('PRO TIP'); return; @@ -176,7 +176,7 @@ function launchEditor(fileName, lineNumber, projectRoots) { const workspace = findRootForFile(projectRoots, fileName); if (lineNumber) { args = args.concat( - getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) + getArgumentsForLineNumber(editor, fileName, lineNumber, workspace), ); } else { args.push(fileName); @@ -195,13 +195,13 @@ function launchEditor(fileName, lineNumber, projectRoots) { 'When running on Windows, file names are checked against a whitelist ' + 'to protect against remote code execution attacks. File names may ' + 'consist only of alphanumeric characters (all languages), periods, ' + - 'dashes, slashes, and underscores.' + 'dashes, slashes, and underscores.', ); return; } logger.info( - `Opening ${chalk.underline(fileName)} with ${chalk.bold(editor)}` + `Opening ${chalk.underline(fileName)} with ${chalk.bold(editor)}`, ); if (_childProcess && isTerminalEditor(editor)) { @@ -218,7 +218,7 @@ function launchEditor(fileName, lineNumber, projectRoots) { stdio: 'inherit', }); } else { - _childProcess = spawn(editor, args, { stdio: 'inherit' }); + _childProcess = spawn(editor, args, {stdio: 'inherit'}); } _childProcess.on('exit', errorCode => { _childProcess = null; diff --git a/packages/cli/src/commands/server/messageSocket.js b/packages/cli/src/commands/server/messageSocket.js index def0193eb..2108cd6e5 100644 --- a/packages/cli/src/commands/server/messageSocket.js +++ b/packages/cli/src/commands/server/messageSocket.js @@ -6,7 +6,7 @@ */ import url from 'url'; -import { Server as WebSocketServer } from 'ws'; +import {Server as WebSocketServer} from 'ws'; import notifier from 'node-notifier'; import logger from '../../tools/logger'; @@ -23,7 +23,7 @@ function parseMessage(data, binary) { return message; } logger.error( - `Received message had wrong protocol version: ${message.version}` + `Received message had wrong protocol version: ${message.version}`, ); } catch (e) { logger.error(`Failed to parse the message as JSON:\n${data}`); @@ -66,7 +66,7 @@ function attachToServer(server, path) { const clientWs = clients.get(clientId); if (clientWs === undefined) { throw new Error( - `could not find id "${clientId}" while forwarding request` + `could not find id "${clientId}" while forwarding request`, ); } return clientWs; @@ -94,7 +94,7 @@ function attachToServer(server, path) { } catch (e) { logger.error( `Failed to send broadcast to client: '${otherId}' ` + - `due to:\n ${e.toString()}` + `due to:\n ${e.toString()}`, ); } } @@ -117,7 +117,7 @@ function attachToServer(server, path) { if (message.id === undefined) { logger.error( `Handling message from ${clientId} failed with:\n${error}\n` + - `message:\n${JSON.stringify(errorMessage)}` + `message:\n${JSON.stringify(errorMessage)}`, ); } else { try { @@ -126,13 +126,13 @@ function attachToServer(server, path) { version: PROTOCOL_VERSION, error, id: message.id, - }) + }), ); } catch (e) { logger.error( `Failed to reply to ${clientId} with error:\n${error}` + `\nmessage:\n${JSON.stringify(errorMessage)}` + - `\ndue to error: ${e.toString()}` + `\ndue to error: ${e.toString()}`, ); } } @@ -161,7 +161,7 @@ function attachToServer(server, path) { version: PROTOCOL_VERSION, result, id: message.id, - }) + }), ); } @@ -174,8 +174,8 @@ function attachToServer(server, path) { id: message.id === undefined ? undefined - : { requestId: message.id, clientId }, - }) + : {requestId: message.id, clientId}, + }), ); } @@ -186,18 +186,17 @@ function attachToServer(server, path) { result: message.result, error: message.error, id: message.id.requestId, - }) + }), ); } clients.set(clientId, clientWs); const onCloseHandler = () => { - clientWs.onmessage = null; // eslint-disable-line no-param-reassign + clientWs.onmessage = null; clients.delete(clientId); }; - clientWs.onclose = onCloseHandler; // eslint-disable-line no-param-reassign - clientWs.onerror = onCloseHandler; // eslint-disable-line no-param-reassign - // eslint-disable-next-line no-param-reassign + clientWs.onclose = onCloseHandler; + clientWs.onerror = onCloseHandler; clientWs.onmessage = event => { const message = parseMessage(event.data, event.binary); if (message === undefined) { @@ -227,9 +226,9 @@ function attachToServer(server, path) { return { broadcast: (method, params) => { - handleSendBroadcast(null, { method, params }); + handleSendBroadcast(null, {method, params}); }, }; } -export default { attachToServer, parseMessage }; +export default {attachToServer, parseMessage}; diff --git a/packages/cli/src/commands/server/middleware/MiddlewareManager.js b/packages/cli/src/commands/server/middleware/MiddlewareManager.js index 696a04d08..ca3025685 100644 --- a/packages/cli/src/commands/server/middleware/MiddlewareManager.js +++ b/packages/cli/src/commands/server/middleware/MiddlewareManager.js @@ -13,7 +13,7 @@ import connect from 'connect'; import errorhandler from 'errorhandler'; import path from 'path'; import serveStatic from 'serve-static'; -import { Server as WebSocketServer } from 'ws'; +import {Server as WebSocketServer} from 'ws'; import indexPageMiddleware from './indexPage'; import copyToClipBoardMiddleware from './copyToClipBoardMiddleware'; @@ -68,7 +68,7 @@ export default class MiddlewareManager { attachDevToolsSocket(socket: WebSocketProxy) { this.app.use( - getDevToolsMiddleware(this.options, () => socket.isChromeConnected()) + getDevToolsMiddleware(this.options, () => socket.isChromeConnected()), ); } } diff --git a/packages/cli/src/commands/server/middleware/getDevToolsMiddleware.js b/packages/cli/src/commands/server/middleware/getDevToolsMiddleware.js index 4b2b293e2..6a714c941 100644 --- a/packages/cli/src/commands/server/middleware/getDevToolsMiddleware.js +++ b/packages/cli/src/commands/server/middleware/getDevToolsMiddleware.js @@ -15,11 +15,11 @@ function launchChromeDevTools(port, args = '') { launchChrome(debuggerURL); } -function launchDevTools({ port, watchFolders }, isChromeConnected) { +function launchDevTools({port, watchFolders}, isChromeConnected) { // Explicit config always wins const customDebugger = process.env.REACT_DEBUGGER; if (customDebugger) { - customDebugger({ watchFolders, customDebugger }); + customDebugger({watchFolders, customDebugger}); } else if (!isChromeConnected()) { // Dev tools are not yet open; we need to open a session launchChromeDevTools(port); @@ -32,7 +32,7 @@ export default function getDevToolsMiddleware(options, isChromeConnected) { // TODO: remove `logger.info` and dev tools binary logger.info( 'We removed support for Safari dev-tools. ' + - 'If you still need this, please let us know.' + 'If you still need this, please let us know.', ); } else if (req.url === '/launch-chrome-devtools') { // TODO: Remove this case in the future @@ -40,7 +40,7 @@ export default function getDevToolsMiddleware(options, isChromeConnected) { 'The method /launch-chrome-devtools is deprecated. You are ' + ' probably using an application created with an older CLI with the ' + ' packager of a newer CLI. Please upgrade your application: ' + - 'https://facebook.github.io/react-native/docs/upgrading.html' + 'https://facebook.github.io/react-native/docs/upgrading.html', ); launchDevTools(options, isChromeConnected); res.end('OK'); diff --git a/packages/cli/src/commands/server/middleware/openStackFrameInEditorMiddleware.js b/packages/cli/src/commands/server/middleware/openStackFrameInEditorMiddleware.js index 8162bb458..676ddd49a 100644 --- a/packages/cli/src/commands/server/middleware/openStackFrameInEditorMiddleware.js +++ b/packages/cli/src/commands/server/middleware/openStackFrameInEditorMiddleware.js @@ -9,7 +9,7 @@ import launchEditor from '../launchEditor'; -export default function getOpenStackFrameInEditorMiddleware({ watchFolders }) { +export default function getOpenStackFrameInEditorMiddleware({watchFolders}) { return (req, res, next) => { if (req.url === '/open-stack-frame') { const frame = JSON.parse(req.rawBody); diff --git a/packages/cli/src/commands/server/middleware/systraceProfileMiddleware.js b/packages/cli/src/commands/server/middleware/systraceProfileMiddleware.js index 5948ab205..7993995d1 100644 --- a/packages/cli/src/commands/server/middleware/systraceProfileMiddleware.js +++ b/packages/cli/src/commands/server/middleware/systraceProfileMiddleware.js @@ -21,9 +21,9 @@ export default function systraceProfileMiddleware(req, res, next) { fs.writeFileSync(dumpName, req.rawBody); const response = `Your profile was saved at:\n${dumpName}\n\n` + - `On Google Chrome navigate to chrome://tracing and then click on "load" ` + - `to load and visualise your profile.\n\n` + - `This message is also printed to your console by the packager so you can copy it :)`; + 'On Google Chrome navigate to chrome://tracing and then click on "load" ' + + 'to load and visualise your profile.\n\n' + + 'This message is also printed to your console by the packager so you can copy it :)'; logger.info(response); res.end(response); } diff --git a/packages/cli/src/commands/server/runServer.js b/packages/cli/src/commands/server/runServer.js index f1436ed4a..08ae78990 100644 --- a/packages/cli/src/commands/server/runServer.js +++ b/packages/cli/src/commands/server/runServer.js @@ -9,11 +9,11 @@ import Metro from 'metro'; -import { Terminal } from 'metro-core'; +import {Terminal} from 'metro-core'; import morgan from 'morgan'; import path from 'path'; -import type { ContextT } from '../../tools/types.flow'; +import type {ContextT} from '../../tools/types.flow'; import messageSocket from './messageSocket'; import webSocketProxy from './webSocketProxy'; import MiddlewareManager from './middleware/MiddlewareManager'; @@ -64,7 +64,7 @@ async function runServer(argv: Array, ctx: ContextT, args: Args) { middlewareManager.getConnectInstance().use(morgan('combined')); metroConfig.watchFolders.forEach( - middlewareManager.serveStatic.bind(middlewareManager) + middlewareManager.serveStatic.bind(middlewareManager), ); metroConfig.server.enhanceMiddleware = middleware => @@ -80,7 +80,7 @@ async function runServer(argv: Array, ctx: ContextT, args: Args) { const wsProxy = webSocketProxy.attachToServer( serverInstance, - '/debugger-proxy' + '/debugger-proxy', ); const ms = messageSocket.attachToServer(serverInstance, '/message'); middlewareManager.attachDevToolsSocket(wsProxy); diff --git a/packages/cli/src/commands/server/webSocketProxy.js b/packages/cli/src/commands/server/webSocketProxy.js index 4d904022c..0f109de08 100644 --- a/packages/cli/src/commands/server/webSocketProxy.js +++ b/packages/cli/src/commands/server/webSocketProxy.js @@ -42,11 +42,11 @@ function attachToServer(server, path) { const clientSocketCloseHandler = () => { clientSocket = null; - send(debuggerSocket, JSON.stringify({ method: '$disconnected' })); + send(debuggerSocket, JSON.stringify({method: '$disconnected'})); }; wss.on('connection', connection => { - const { url } = connection.upgradeReq; + const {url} = connection.upgradeReq; if (url.indexOf('role=debugger') > -1) { if (debuggerSocket) { @@ -56,7 +56,7 @@ function attachToServer(server, path) { debuggerSocket = connection; debuggerSocket.onerror = debuggerSocketCloseHandler; debuggerSocket.onclose = debuggerSocketCloseHandler; - debuggerSocket.onmessage = ({ data }) => send(clientSocket, data); + debuggerSocket.onmessage = ({data}) => send(clientSocket, data); } else if (url.indexOf('role=client') > -1) { if (clientSocket) { clientSocket.onerror = null; @@ -67,7 +67,7 @@ function attachToServer(server, path) { clientSocket = connection; clientSocket.onerror = clientSocketCloseHandler; clientSocket.onclose = clientSocketCloseHandler; - clientSocket.onmessage = ({ data }) => send(debuggerSocket, data); + clientSocket.onmessage = ({data}) => send(debuggerSocket, data); } else { connection.close(1011, 'Missing role param'); } diff --git a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js index 5a987a6cb..438a6f60d 100644 --- a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js +++ b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js @@ -4,7 +4,7 @@ import path from 'path'; import fs from 'fs'; import snapshotDiff from 'snapshot-diff'; import upgrade from '../upgrade'; -import { fetch } from '../helpers'; +import {fetch} from '../helpers'; import logger from '../../../tools/logger'; jest.mock('https'); @@ -18,26 +18,26 @@ jest.mock('execa', () => { stdout: '{"react": "16.6.3"}', }); } - return Promise.resolve({ stdout: '' }); + return Promise.resolve({stdout: ''}); }); return module; }); jest.mock( '/project/root/node_modules/react-native/package.json', - () => ({ name: 'react-native', version: '0.57.8' }), - { virtual: true } + () => ({name: 'react-native', version: '0.57.8'}), + {virtual: true}, ); jest.mock( '/project/root/package.json', - () => ({ name: 'TestApp', dependencies: { 'react-native': '^0.57.8' } }), - { virtual: true } + () => ({name: 'TestApp', dependencies: {'react-native': '^0.57.8'}}), + {virtual: true}, ); jest.mock('../../../tools/PackageManager', () => jest.fn(() => ({ install: args => { mockPushLog('$ yarn add', ...args); }, - })) + })), ); jest.mock('../helpers', () => ({ ...jest.requireActual('../helpers'), @@ -88,21 +88,21 @@ test('uses latest version of react-native when none passed', async () => { test('errors when invalid version passed', async () => { await upgrade.func(['next'], ctx, opts); expect(logger.error).toBeCalledWith( - 'Provided version "next" is not allowed. Please pass a valid semver version' + 'Provided version "next" is not allowed. Please pass a valid semver version', ); }); test('errors when older version passed', async () => { await upgrade.func([olderVersion], ctx, opts); expect(logger.error).toBeCalledWith( - `Trying to upgrade from newer version "${currentVersion}" to older "${olderVersion}"` + `Trying to upgrade from newer version "${currentVersion}" to older "${olderVersion}"`, ); }); test('warns when dependency upgrade version is in semver range', async () => { await upgrade.func([currentVersion], ctx, opts); expect(logger.warn).toBeCalledWith( - `Specified version "${currentVersion}" is already installed in node_modules and it satisfies "^0.57.8" semver range. No need to upgrade` + `Specified version "${currentVersion}" is already installed in node_modules and it satisfies "^0.57.8" semver range. No need to upgrade`, ); }); @@ -146,14 +146,12 @@ $ execa git status $ execa git remote remove tmp-rn-diff-purge success Upgraded React Native to v0.58.4 🎉. Now you can review and commit the changes" `); - expect( snapshotDiff(samplePatch, fs.writeFileSync.mock.calls[0][1], { contextLines: 1, - }) + }), ).toMatchSnapshot('RnDiffApp is replaced with app name (TestApp)'); }); - test('cleans up if patching fails,', async () => { (fetch: any).mockImplementation(() => Promise.resolve(samplePatch)); (execa: any).mockImplementation((command, args) => { @@ -164,23 +162,20 @@ test('cleans up if patching fails,', async () => { }); } if (command === 'git' && args[0] === 'apply') { - // eslint-disable-next-line prefer-promise-reject-errors return Promise.reject({ code: 1, stderr: 'error: .flowconfig: does not exist in index\n', }); } - return Promise.resolve({ stdout: '' }); + return Promise.resolve({stdout: ''}); }); - try { await upgrade.func([newVersion], ctx, opts); } catch (error) { expect(error.message).toBe( - 'Upgrade failed. Please see the messages above for details' + 'Upgrade failed. Please see the messages above for details', ); } - expect(flushOutput()).toMatchInlineSnapshot(` "info Fetching diff between v0.57.8 and v0.58.4... [fs] write tmp-upgrade-rn.patch diff --git a/packages/cli/src/commands/upgrade/helpers.js b/packages/cli/src/commands/upgrade/helpers.js index e40353588..5c9ad2fc2 100644 --- a/packages/cli/src/commands/upgrade/helpers.js +++ b/packages/cli/src/commands/upgrade/helpers.js @@ -6,7 +6,7 @@ export const fetch = (url: string) => const request = https.get(url, response => { if (response.statusCode < 200 || response.statusCode > 299) { reject( - new Error(`Failed to load page, status code: ${response.statusCode}`) + new Error(`Failed to load page, status code: ${response.statusCode}`), ); } const body = []; diff --git a/packages/cli/src/commands/upgrade/legacyUpgrade.js b/packages/cli/src/commands/upgrade/legacyUpgrade.js index 64d991234..57d82da3e 100644 --- a/packages/cli/src/commands/upgrade/legacyUpgrade.js +++ b/packages/cli/src/commands/upgrade/legacyUpgrade.js @@ -11,7 +11,7 @@ import fs from 'fs'; import path from 'path'; import semver from 'semver'; -import type { ContextT } from '../../tools/types.flow'; +import type {ContextT} from '../../tools/types.flow'; import logger from '../../tools/logger'; import copyProjectTemplateAndReplace from '../../tools/generator/copyProjectTemplateAndReplace'; @@ -23,7 +23,7 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { const projectDir = ctx.root; const packageJSON = JSON.parse( - fs.readFileSync(path.resolve(projectDir, 'package.json'), 'utf8') + fs.readFileSync(path.resolve(projectDir, 'package.json'), 'utf8'), ); warn( @@ -33,14 +33,14 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { '- Go back to the old version of React Native\n' + '- Run "npm install -g react-native-git-upgrade"\n' + '- Run "react-native-git-upgrade"\n' + - 'See https://facebook.github.io/react-native/docs/upgrading.html' + 'See https://facebook.github.io/react-native/docs/upgrading.html', ); const projectName = packageJSON.name; if (!projectName) { warn( 'Your project needs to have a name, declared in package.json, ' + - 'such as "name": "AwesomeApp". Please add a project name. Aborting.' + 'such as "name": "AwesomeApp". Please add a project name. Aborting.', ); return; } @@ -49,7 +49,7 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { if (!version) { warn( 'Your "package.json" file doesn\'t seem to declare "react-native" as ' + - 'a dependency. Nothing to upgrade. Aborting.' + 'a dependency. Nothing to upgrade. Aborting.', ); return; } @@ -58,7 +58,7 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { warn( 'Some major releases introduce breaking changes.\n' + 'Please use a caret version number in your "package.json" file \n' + - 'to avoid breakage. Use e.g. react-native: ^0.38.0. Aborting.' + 'to avoid breakage. Use e.g. react-native: ^0.38.0. Aborting.', ); return; } @@ -66,15 +66,15 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { const installed = JSON.parse( fs.readFileSync( path.resolve(projectDir, 'node_modules/react-native/package.json'), - 'utf8' - ) + 'utf8', + ), ); if (!semver.satisfies(installed.version, version)) { warn( 'react-native version in "package.json" doesn\'t match ' + 'the installed version in "node_modules".\n' + - 'Try running "npm install" to fix this. Aborting.' + 'Try running "npm install" to fix this. Aborting.', ); return; } @@ -84,17 +84,17 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { if (!semver.valid(v)) { warn( "A valid version number for 'react-native' is not specified in your " + - "'package.json' file. Aborting." + "'package.json' file. Aborting.", ); return; } logger.info( `Upgrading project to react-native v${installed.version}\n` + - `Check out the release notes and breaking changes: ` + + 'Check out the release notes and breaking changes: ' + `https://github.com/facebook/react-native/releases/tag/v${semver.major( - v - )}.${semver.minor(v)}.0` + v, + )}.${semver.minor(v)}.0`, ); // >= v0.21.0, we require react to be a peer dependency @@ -103,7 +103,7 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { 'Your "package.json" file doesn\'t seem to have "react" as a dependency.\n' + '"react" was changed from a dependency to a peer dependency in react-native v0.21.0.\n' + 'Therefore, it\'s necessary to include "react" in your project\'s dependencies.\n' + - 'Please run "npm install --save react", then re-run "react-native upgrade".\n' + 'Please run "npm install --save react", then re-run "react-native upgrade".\n', ); return; } @@ -115,14 +115,14 @@ function validateAndUpgrade(argv: Array, ctx: ContextT) { 'to do it automatically.\n' + 'Just run:\n' + '"npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev", ' + - 'then run "rnpm upgrade".' + 'then run "rnpm upgrade".', ); } upgradeProjectFiles(projectDir, projectName); logger.info( - `Successfully upgraded this project to react-native v${installed.version}` + `Successfully upgraded this project to react-native v${installed.version}`, ); } @@ -135,7 +135,7 @@ function upgradeProjectFiles(projectDir, projectName) { path.dirname(require.resolve('react-native/template')), projectDir, projectName, - { upgrade: true } + {upgrade: true}, ); } diff --git a/packages/cli/src/commands/upgrade/upgrade.js b/packages/cli/src/commands/upgrade/upgrade.js index 00db8441d..14512eb12 100644 --- a/packages/cli/src/commands/upgrade/upgrade.js +++ b/packages/cli/src/commands/upgrade/upgrade.js @@ -1,14 +1,13 @@ // @flow -/* eslint-disable consistent-return */ import path from 'path'; import fs from 'fs'; import chalk from 'chalk'; import semver from 'semver'; import execa from 'execa'; -import type { ContextT } from '../../tools/types.flow'; +import type {ContextT} from '../../tools/types.flow'; import logger from '../../tools/logger'; import PackageManager from '../../tools/PackageManager'; -import { fetch } from './helpers'; +import {fetch} from './helpers'; import legacyUpgrade from './legacyUpgrade'; type FlagsT = { @@ -19,14 +18,14 @@ const rnDiffPurgeUrl = 'https://github.com/pvinis/rn-diff-purge'; const getLatestRNVersion = async (): Promise => { logger.info('No version passed. Fetching latest...'); - const { stdout } = await execa('npm', ['info', 'react-native', 'version']); + const {stdout} = await execa('npm', ['info', 'react-native', 'version']); return stdout; }; const getRNPeerDeps = async ( - version: string -): Promise<{ [key: string]: string }> => { - const { stdout } = await execa('npm', [ + version: string, +): Promise<{[key: string]: string}> => { + const {stdout} = await execa('npm', [ 'info', `react-native@${version}`, 'peerDependencies', @@ -40,20 +39,20 @@ const getPatch = async (currentVersion, newVersion, projectDir) => { let patch; const rnDiffAppName = 'RnDiffApp'; - const { name } = require(path.join(projectDir, 'package.json')); + const {name} = require(path.join(projectDir, 'package.json')); logger.info(`Fetching diff between v${currentVersion} and v${newVersion}...`); try { patch = await fetch( - `${rnDiffPurgeUrl}/compare/version/${currentVersion}...version/${newVersion}.diff` + `${rnDiffPurgeUrl}/compare/version/${currentVersion}...version/${newVersion}.diff`, ); } catch (error) { logger.error( - `Failed to fetch diff for react-native@${newVersion}. Maybe it's not released yet?` + `Failed to fetch diff for react-native@${newVersion}. Maybe it's not released yet?`, ); logger.info( - `For available releases to diff see: https://github.com/pvinis/rn-diff-purge#version-changes` + 'For available releases to diff see: https://github.com/pvinis/rn-diff-purge#version-changes', ); return null; } @@ -73,30 +72,30 @@ const getVersionToUpgradeTo = async (argv, currentVersion, projectDir) => { logger.error( `Provided version "${ argv[0] - }" is not allowed. Please pass a valid semver version` + }" is not allowed. Please pass a valid semver version`, ); return null; } if (currentVersion > newVersion) { logger.error( - `Trying to upgrade from newer version "${currentVersion}" to older "${newVersion}"` + `Trying to upgrade from newer version "${currentVersion}" to older "${newVersion}"`, ); return null; } if (currentVersion === newVersion) { const { - dependencies: { 'react-native': version }, + dependencies: {'react-native': version}, } = require(path.join(projectDir, 'package.json')); if (semver.satisfies(newVersion, version)) { logger.warn( - `Specified version "${newVersion}" is already installed in node_modules and it satisfies "${version}" semver range. No need to upgrade` + `Specified version "${newVersion}" is already installed in node_modules and it satisfies "${version}" semver range. No need to upgrade`, ); return null; } logger.error( - `Dependency mismatch. Specified version "${newVersion}" is already installed in node_modules and it doesn't satisfy "${version}" semver range of your "react-native" dependency. Please re-install your dependencies` + `Dependency mismatch. Specified version "${newVersion}" is already installed in node_modules and it doesn't satisfy "${version}" semver range of your "react-native" dependency. Please re-install your dependencies`, ); return null; } @@ -107,19 +106,19 @@ const getVersionToUpgradeTo = async (argv, currentVersion, projectDir) => { const installDeps = async (newVersion, projectDir, patchSuccess) => { if (!patchSuccess) { logger.warn( - 'Continuing after failure. Most of the files are upgraded but you will need to deal with some conflicts manually' + 'Continuing after failure. Most of the files are upgraded but you will need to deal with some conflicts manually', ); } logger.info( - `Installing react-native@${newVersion} and its peer dependencies...` + `Installing react-native@${newVersion} and its peer dependencies...`, ); const peerDeps = await getRNPeerDeps(newVersion); - const pm = new PackageManager({ projectDir }); + const pm = new PackageManager({projectDir}); const deps = [ `react-native@${newVersion}`, ...Object.keys(peerDeps).map(module => `${module}@${peerDeps[module]}`), ]; - await pm.install(deps, { silent: true }); + await pm.install(deps, {silent: true}); await execa('git', ['add', 'package.json']); try { await execa('git', ['add', 'yarn.lock']); @@ -136,7 +135,7 @@ const installDeps = async (newVersion, projectDir, patchSuccess) => { const applyPatch = async ( currentVersion: string, newVersion: string, - tmpPatchFile: string + tmpPatchFile: string, ) => { let filesToExclude = ['package.json']; try { @@ -150,7 +149,7 @@ const applyPatch = async ( '-p2', '--3way', ]); - logger.info(`Applying diff...`); + logger.info('Applying diff...'); } catch (error) { filesToExclude = [ ...filesToExclude, @@ -171,10 +170,10 @@ const applyPatch = async ( } logger.error('Automatically applying diff failed'); logger.info( - `Here's the diff we tried to apply: ${rnDiffPurgeUrl}/compare/version/${currentVersion}...version/${newVersion}` + `Here's the diff we tried to apply: ${rnDiffPurgeUrl}/compare/version/${currentVersion}...version/${newVersion}`, ); logger.info( - `You may find release notes helpful: https://github.com/facebook/react-native/releases/tag/v${newVersion}` + `You may find release notes helpful: https://github.com/facebook/react-native/releases/tag/v${newVersion}`, ); return false; } @@ -188,19 +187,19 @@ async function upgrade(argv: Array, ctx: ContextT, args: FlagsT) { if (args.legacy) { return legacyUpgrade.func(argv, ctx); } - const rnDiffGitAddress = `https://github.com/pvinis/rn-diff-purge.git`; + const rnDiffGitAddress = 'https://github.com/pvinis/rn-diff-purge.git'; const tmpRemote = 'tmp-rn-diff-purge'; const tmpPatchFile = 'tmp-upgrade-rn.patch'; const projectDir = ctx.root; - const { version: currentVersion } = require(path.join( + const {version: currentVersion} = require(path.join( projectDir, - 'node_modules/react-native/package.json' + 'node_modules/react-native/package.json', )); const newVersion = await getVersionToUpgradeTo( argv, currentVersion, - projectDir + projectDir, ); if (!newVersion) { @@ -217,11 +216,10 @@ async function upgrade(argv: Array, ctx: ContextT, args: FlagsT) { logger.info('Diff has no changes to apply, proceeding further'); await installDeps(newVersion, projectDir); logger.success( - `Upgraded React Native to v${newVersion} 🎉. Now you can review and commit the changes` + `Upgraded React Native to v${newVersion} 🎉. Now you can review and commit the changes`, ); return; } - let patchSuccess; try { @@ -242,25 +240,22 @@ async function upgrade(argv: Array, ctx: ContextT, args: FlagsT) { } await installDeps(newVersion, projectDir, patchSuccess); logger.info('Running "git status" to check what changed...'); - await execa('git', ['status'], { stdio: 'inherit' }); + await execa('git', ['status'], {stdio: 'inherit'}); await execa('git', ['remote', 'remove', tmpRemote]); if (!patchSuccess) { logger.warn( - 'Please run "git diff" to review the conflicts and resolve them' + 'Please run "git diff" to review the conflicts and resolve them', ); - // eslint-disable-next-line no-unsafe-finally throw new Error( - 'Upgrade failed. Please see the messages above for details' + 'Upgrade failed. Please see the messages above for details', ); } } - logger.success( - `Upgraded React Native to v${newVersion} 🎉. Now you can review and commit the changes` + `Upgraded React Native to v${newVersion} 🎉. Now you can review and commit the changes`, ); } - const upgradeCommand = { name: 'upgrade [version]', description: @@ -275,5 +270,4 @@ const upgradeCommand = { }, ], }; - export default upgradeCommand; diff --git a/packages/cli/src/tools/PackageManager.js b/packages/cli/src/tools/PackageManager.js index a586dd3c9..bcc8de4a4 100644 --- a/packages/cli/src/tools/PackageManager.js +++ b/packages/cli/src/tools/PackageManager.js @@ -1,5 +1,5 @@ // @flow -import { execSync } from 'child_process'; +import {execSync} from 'child_process'; import yarn from './yarn'; type PackageManagerOptions = { @@ -14,7 +14,7 @@ export default class PackageManager { this.options = options; } - executeCommand(command: string, options?: { silent: boolean }) { + executeCommand(command: string, options?: {silent: boolean}) { return execSync(command, { stdio: options && options.silent ? 'pipe' : 'inherit', }); @@ -28,12 +28,12 @@ export default class PackageManager { ); } - install(packageNames: Array, options?: { silent: boolean }) { + install(packageNames: Array, options?: {silent: boolean}) { return this.shouldCallYarn() ? this.executeCommand(`yarn add ${packageNames.join(' ')}`, options) : this.executeCommand( `npm install ${packageNames.join(' ')} --save --save-exact`, - options + options, ); } @@ -41,7 +41,7 @@ export default class PackageManager { return this.shouldCallYarn() ? this.executeCommand(`yarn add -D ${packageNames.join(' ')}`) : this.executeCommand( - `npm install ${packageNames.join(' ')} --save-dev --save-exact` + `npm install ${packageNames.join(' ')} --save-dev --save-exact`, ); } diff --git a/packages/cli/src/tools/__fixtures__/android.js b/packages/cli/src/tools/__fixtures__/android.js index d6097b0bf..d5f603069 100644 --- a/packages/cli/src/tools/__fixtures__/android.js +++ b/packages/cli/src/tools/__fixtures__/android.js @@ -11,10 +11,10 @@ const fs = jest.requireActual('fs'); const path = jest.requireActual('path'); const manifest = fs.readFileSync( - path.join(__dirname, './files/AndroidManifest.xml') + path.join(__dirname, './files/AndroidManifest.xml'), ); const mainJavaClass = fs.readFileSync( - path.join(__dirname, './files/Main.java') + path.join(__dirname, './files/Main.java'), ); function generateValidFileStructure(classFileName) { @@ -27,7 +27,7 @@ function generateValidFileStructure(classFileName) { example: { 'Main.java': mainJavaClass, [classFileName]: fs.readFileSync( - path.join(__dirname, `./files/${classFileName}`) + path.join(__dirname, `./files/${classFileName}`), ), }, }, @@ -50,7 +50,7 @@ exports.userConfigManifest = { example: { 'Main.java': mainJavaClass, 'ReactPackage.java': fs.readFileSync( - path.join(__dirname, './files/ReactPackage.java') + path.join(__dirname, './files/ReactPackage.java'), ), }, }, @@ -58,7 +58,7 @@ exports.userConfigManifest = { }, debug: { 'AndroidManifest.xml': fs.readFileSync( - path.join(__dirname, './files/AndroidManifest-debug.xml') + path.join(__dirname, './files/AndroidManifest-debug.xml'), ), }, }, diff --git a/packages/cli/src/tools/__fixtures__/ios.js b/packages/cli/src/tools/__fixtures__/ios.js index 9e4ac610f..876a6cfd1 100644 --- a/packages/cli/src/tools/__fixtures__/ios.js +++ b/packages/cli/src/tools/__fixtures__/ios.js @@ -14,7 +14,7 @@ const fs = jest.requireActual('fs'); exports.valid = { 'demoProject.xcodeproj': { 'project.pbxproj': fs.readFileSync( - path.join(__dirname, './files/project.pbxproj') + path.join(__dirname, './files/project.pbxproj'), ), }, 'TestPod.podspec': 'empty', @@ -23,7 +23,7 @@ exports.valid = { exports.validTestName = { 'MyTestProject.xcodeproj': { 'project.pbxproj': fs.readFileSync( - path.join(__dirname, './files/project.pbxproj') + path.join(__dirname, './files/project.pbxproj'), ), }, }; diff --git a/packages/cli/src/tools/__fixtures__/projects.js b/packages/cli/src/tools/__fixtures__/projects.js index 321d50cb0..67034aeae 100644 --- a/packages/cli/src/tools/__fixtures__/projects.js +++ b/packages/cli/src/tools/__fixtures__/projects.js @@ -34,6 +34,6 @@ const withPods = { ios: ios.pod, }; -export default { flat, nested, withExamples, withPods }; +export default {flat, nested, withExamples, withPods}; // export { flat, nested, withExamples, withPods }; diff --git a/packages/cli/src/tools/__tests__/PackageManager-test.js b/packages/cli/src/tools/__tests__/PackageManager-test.js index 522bd9b6d..97bb96318 100644 --- a/packages/cli/src/tools/__tests__/PackageManager-test.js +++ b/packages/cli/src/tools/__tests__/PackageManager-test.js @@ -5,7 +5,7 @@ import yarn from '../yarn'; const PROJECT_DIR = '/project/directory'; const PACKAGES = ['react', 'react-native']; -const EXEC_OPTS = { stdio: 'inherit' }; +const EXEC_OPTS = {stdio: 'inherit'}; beforeEach(() => { jest.spyOn(ChildProcess, 'execSync').mockImplementation(() => {}); @@ -20,35 +20,35 @@ describe('yarn', () => { }); it('should install', () => { - const packageManager = new PackageManager({ projectDir: PROJECT_DIR }); + const packageManager = new PackageManager({projectDir: PROJECT_DIR}); packageManager.install(PACKAGES); expect(ChildProcess.execSync).toHaveBeenCalledWith( 'yarn add react react-native', - EXEC_OPTS + EXEC_OPTS, ); }); it('should installDev', () => { - const packageManager = new PackageManager({ projectDir: PROJECT_DIR }); + const packageManager = new PackageManager({projectDir: PROJECT_DIR}); packageManager.installDev(PACKAGES); expect(ChildProcess.execSync).toHaveBeenCalledWith( 'yarn add -D react react-native', - EXEC_OPTS + EXEC_OPTS, ); }); it('should uninstall', () => { - const packageManager = new PackageManager({ projectDir: PROJECT_DIR }); + const packageManager = new PackageManager({projectDir: PROJECT_DIR}); packageManager.uninstall(PACKAGES); expect(ChildProcess.execSync).toHaveBeenCalledWith( - `yarn remove react react-native`, - EXEC_OPTS + 'yarn remove react react-native', + EXEC_OPTS, ); }); }); @@ -64,7 +64,7 @@ describe('npm', () => { expect(ChildProcess.execSync).toHaveBeenCalledWith( 'npm install react react-native --save --save-exact', - EXEC_OPTS + EXEC_OPTS, ); }); @@ -78,7 +78,7 @@ describe('npm', () => { expect(ChildProcess.execSync).toHaveBeenCalledWith( 'npm install react react-native --save-dev --save-exact', - EXEC_OPTS + EXEC_OPTS, ); }); @@ -91,32 +91,32 @@ describe('npm', () => { packageManager.uninstall(PACKAGES); expect(ChildProcess.execSync).toHaveBeenCalledWith( - `npm uninstall react react-native --save`, - EXEC_OPTS + 'npm uninstall react react-native --save', + EXEC_OPTS, ); }); }); it('should use npm if yarn is not available', () => { jest.spyOn(yarn, 'getYarnVersionIfAvailable').mockImplementation(() => false); - const packageManager = new PackageManager({ projectDir: PROJECT_DIR }); + const packageManager = new PackageManager({projectDir: PROJECT_DIR}); packageManager.install(PACKAGES); expect(ChildProcess.execSync).toHaveBeenCalledWith( - `npm install react react-native --save --save-exact`, - EXEC_OPTS + 'npm install react react-native --save --save-exact', + EXEC_OPTS, ); }); it('should use npm if global cli is not using yarn', () => { jest.spyOn(yarn, 'isGlobalCliUsingYarn').mockImplementation(() => false); - const packageManager = new PackageManager({ projectDir: PROJECT_DIR }); + const packageManager = new PackageManager({projectDir: PROJECT_DIR}); packageManager.install(PACKAGES); expect(ChildProcess.execSync).toHaveBeenCalledWith( - `npm install react react-native --save --save-exact`, - EXEC_OPTS + 'npm install react react-native --save --save-exact', + EXEC_OPTS, ); }); diff --git a/packages/cli/src/tools/__tests__/android/findPackageClassName-test.js b/packages/cli/src/tools/__tests__/android/findPackageClassName-test.js index a2ddc80ac..9c9cd8b80 100644 --- a/packages/cli/src/tools/__tests__/android/findPackageClassName-test.js +++ b/packages/cli/src/tools/__tests__/android/findPackageClassName-test.js @@ -30,7 +30,7 @@ const fs = require('fs'); android: mocks.validKotlin, }, }, - platform + platform, ); }); @@ -40,13 +40,13 @@ const fs = require('fs'); it('returns the name of the java class implementing ReactPackage', () => { expect(findPackageClassName(`${root}flatJava`)).toBe( - 'SomeExampleJavaPackage' + 'SomeExampleJavaPackage', ); }); it('returns the name of the kotlin class implementing ReactPackage', () => { expect(findPackageClassName(`${root}flatKotlin`)).toBe( - 'SomeExampleKotlinPackage' + 'SomeExampleKotlinPackage', ); }); diff --git a/packages/cli/src/tools/__tests__/findAssets-test.js b/packages/cli/src/tools/__tests__/findAssets-test.js index 240b8a07e..a912a846f 100644 --- a/packages/cli/src/tools/__tests__/findAssets-test.js +++ b/packages/cli/src/tools/__tests__/findAssets-test.js @@ -15,11 +15,11 @@ jest.mock('fs'); const fs = require('fs'); -const { findAssets } = require('../getAssets'); +const {findAssets} = require('../getAssets'); describe('findAssets', () => { beforeEach(() => { - fs.__setMockFilesystem({ testDir: dependencies.withAssets }); + fs.__setMockFilesystem({testDir: dependencies.withAssets}); }); it('returns an array of all files in given folders', () => { diff --git a/packages/cli/src/tools/__tests__/findPlugins-test.js b/packages/cli/src/tools/__tests__/findPlugins-test.js index 464165d1b..c1cee2079 100644 --- a/packages/cli/src/tools/__tests__/findPlugins-test.js +++ b/packages/cli/src/tools/__tests__/findPlugins-test.js @@ -24,9 +24,9 @@ describe('findPlugins', () => { jest.doMock( pjsonPath, () => ({ - dependencies: { 'rnpm-plugin-test': '*' }, + dependencies: {'rnpm-plugin-test': '*'}, }), - { virtual: true } + {virtual: true}, ); expect(findPlugins(ROOT)).toHaveProperty('commands'); @@ -37,7 +37,7 @@ describe('findPlugins', () => { }); it('returns an empty array if there are no plugins in this folder', () => { - jest.doMock(pjsonPath, () => ({}), { virtual: true }); + jest.doMock(pjsonPath, () => ({}), {virtual: true}); expect(findPlugins(ROOT)).toHaveProperty('commands'); expect(findPlugins(ROOT)).toHaveProperty('platforms'); expect(findPlugins(ROOT).commands).toHaveLength(0); @@ -55,10 +55,10 @@ describe('findPlugins', () => { jest.doMock( pjsonPath, () => ({ - dependencies: { 'rnpm-plugin-test': '*' }, - devDependencies: { 'rnpm-plugin-test-2': '*' }, + dependencies: {'rnpm-plugin-test': '*'}, + devDependencies: {'rnpm-plugin-test-2': '*'}, }), - { virtual: true } + {virtual: true}, ); expect(findPlugins(ROOT)).toHaveProperty('commands'); expect(findPlugins(ROOT)).toHaveProperty('platforms'); @@ -70,10 +70,10 @@ describe('findPlugins', () => { jest.doMock( pjsonPath, () => ({ - dependencies: { 'rnpm-plugin-test': '*' }, - devDependencies: { 'rnpm-plugin-test': '*' }, + dependencies: {'rnpm-plugin-test': '*'}, + devDependencies: {'rnpm-plugin-test': '*'}, }), - { virtual: true } + {virtual: true}, ); expect(findPlugins(ROOT).commands).toHaveLength(1); }); @@ -89,7 +89,7 @@ describe('findPlugins', () => { '@react-native-org/test': '*', }, }), - { virtual: true } + {virtual: true}, ); expect(findPlugins(ROOT)).toHaveProperty('commands'); diff --git a/packages/cli/src/tools/__tests__/ios/findProject-test.js b/packages/cli/src/tools/__tests__/ios/findProject-test.js index 3f7cd0347..0b490a053 100644 --- a/packages/cli/src/tools/__tests__/ios/findProject-test.js +++ b/packages/cli/src/tools/__tests__/ios/findProject-test.js @@ -24,22 +24,22 @@ describe('ios::findProject', () => { }); it('returns null if there are no projects', () => { - fs.__setMockFilesystem({ testDir: projects }); + fs.__setMockFilesystem({testDir: projects}); expect(findProject('/')).toBeNull(); }); it('returns ios project regardless of its name', () => { - fs.__setMockFilesystem({ ios: ios.validTestName }); + fs.__setMockFilesystem({ios: ios.validTestName}); expect(findProject('/')).not.toBeNull(); }); it('ignores node_modules', () => { - fs.__setMockFilesystem({ node_modules: projects.flat }); + fs.__setMockFilesystem({node_modules: projects.flat}); expect(findProject('/')).toBeNull(); }); it('ignores Pods', () => { - fs.__setMockFilesystem({ Pods: projects.flat }); + fs.__setMockFilesystem({Pods: projects.flat}); expect(findProject('/')).toBeNull(); }); diff --git a/packages/cli/src/tools/__tests__/ios/getProjectConfig-test.js b/packages/cli/src/tools/__tests__/ios/getProjectConfig-test.js index b5cf7c5e9..cd51f654c 100644 --- a/packages/cli/src/tools/__tests__/ios/getProjectConfig-test.js +++ b/packages/cli/src/tools/__tests__/ios/getProjectConfig-test.js @@ -21,7 +21,7 @@ describe('ios::getProjectConfig', () => { const userConfig = {}; beforeEach(() => { - fs.__setMockFilesystem({ testDir: projects }); + fs.__setMockFilesystem({testDir: projects}); }); it('returns an object with ios project configuration', () => { diff --git a/packages/cli/src/tools/__tests__/makeCommand-test.js b/packages/cli/src/tools/__tests__/makeCommand-test.js index 38a076a30..6eee9758e 100644 --- a/packages/cli/src/tools/__tests__/makeCommand-test.js +++ b/packages/cli/src/tools/__tests__/makeCommand-test.js @@ -16,7 +16,7 @@ jest.setMock('child_process', { }), }); -const { makeCommand } = require('../getHooks'); +const {makeCommand} = require('../getHooks'); describe('makeCommand', () => { const command = makeCommand('echo'); diff --git a/packages/cli/src/tools/android/findPackageClassName.js b/packages/cli/src/tools/android/findPackageClassName.js index 76ca9cf6c..eaac9631d 100644 --- a/packages/cli/src/tools/android/findPackageClassName.js +++ b/packages/cli/src/tools/android/findPackageClassName.js @@ -18,7 +18,7 @@ import path from 'path'; * @param {String} folder Folder to find java/kt files */ export default function getPackageClassName(folder) { - const files = glob.sync('**/+(*.java|*.kt)', { cwd: folder }); + const files = glob.sync('**/+(*.java|*.kt)', {cwd: folder}); const packages = files .map(filePath => fs.readFileSync(path.join(folder, filePath), 'utf8')) diff --git a/packages/cli/src/tools/android/index.js b/packages/cli/src/tools/android/index.js index 631c8b80a..4fa788a18 100644 --- a/packages/cli/src/tools/android/index.js +++ b/packages/cli/src/tools/android/index.js @@ -53,28 +53,28 @@ export function projectConfig(folder, userConfig = {}) { const mainFilePath = path.join( sourceDir, userConfig.mainFilePath || - `src/main/java/${packageFolder}/MainApplication.java` + `src/main/java/${packageFolder}/MainApplication.java`, ); const stringsPath = path.join( sourceDir, - userConfig.stringsPath || 'src/main/res/values/strings.xml' + userConfig.stringsPath || 'src/main/res/values/strings.xml', ); const settingsGradlePath = path.join( folder, 'android', - userConfig.settingsGradlePath || 'settings.gradle' + userConfig.settingsGradlePath || 'settings.gradle', ); const assetsPath = path.join( sourceDir, - userConfig.assetsPath || 'src/main/assets' + userConfig.assetsPath || 'src/main/assets', ); const buildGradlePath = path.join( sourceDir, - userConfig.buildGradlePath || 'build.gradle' + userConfig.buildGradlePath || 'build.gradle', ); return { @@ -128,5 +128,5 @@ export function dependencyConfig(folder, userConfig = {}) { const packageInstance = userConfig.packageInstance || `new ${packageClassName}()`; - return { sourceDir, folder, manifest, packageImportPath, packageInstance }; + return {sourceDir, folder, manifest, packageImportPath, packageInstance}; } diff --git a/packages/cli/src/tools/assertRequiredOptions.js b/packages/cli/src/tools/assertRequiredOptions.js index 509c37178..c4de673c0 100644 --- a/packages/cli/src/tools/assertRequiredOptions.js +++ b/packages/cli/src/tools/assertRequiredOptions.js @@ -7,8 +7,8 @@ * @format */ -import { Option } from 'commander'; -import { camelCase } from 'lodash'; +import {Option} from 'commander'; +import {camelCase} from 'lodash'; // Commander.js has a 2 years old open issue to support <...> syntax // for options. Until that gets merged, we run the checks manually diff --git a/packages/cli/src/tools/copyAndReplace.js b/packages/cli/src/tools/copyAndReplace.js index 1d6d96438..986088e43 100644 --- a/packages/cli/src/tools/copyAndReplace.js +++ b/packages/cli/src/tools/copyAndReplace.js @@ -29,7 +29,7 @@ function copyAndReplace( srcPath, destPath, replacements, - contentChangedCallback + contentChangedCallback, ) { if (fs.lstatSync(srcPath).isDirectory()) { if (!fs.existsSync(destPath)) { diff --git a/packages/cli/src/tools/findPlugins.js b/packages/cli/src/tools/findPlugins.js index caa78179a..3ae92775c 100644 --- a/packages/cli/src/tools/findPlugins.js +++ b/packages/cli/src/tools/findPlugins.js @@ -8,7 +8,7 @@ */ import path from 'path'; -import { union, uniq, flatten } from 'lodash'; +import {union, uniq, flatten} from 'lodash'; const RNPM_PLUGIN_PATTERNS = [/^rnpm-plugin-/, /^@(.*)\/rnpm-plugin-/]; @@ -68,14 +68,12 @@ const findHasteConfigInPackageAndConcat = (pjson, haste) => { const pkgHaste = pjson.rnpm.haste; if (pkgHaste.platforms) { - // eslint-disable-next-line no-param-reassign haste.platforms = haste.platforms.concat(pkgHaste.platforms); } if (pkgHaste.providesModuleNodeModules) { - // eslint-disable-next-line no-param-reassign haste.providesModuleNodeModules = haste.providesModuleNodeModules.concat( - pkgHaste.providesModuleNodeModules + pkgHaste.providesModuleNodeModules, ); } }; @@ -89,11 +87,11 @@ const findPluginsInFolder = folder => { const deps = union( Object.keys(pjson.dependencies || {}), - Object.keys(pjson.devDependencies || {}) + Object.keys(pjson.devDependencies || {}), ); return deps.reduce((acc, pkg) => { - let { commands, platforms } = acc; + let {commands, platforms} = acc; if (isRNPMPlugin(pkg)) { commands = commands.concat(pkg); } @@ -105,7 +103,7 @@ const findPluginsInFolder = folder => { findHasteConfigInPackageAndConcat(pkgJson, acc.haste); } } - return { commands, platforms, haste: acc.haste }; + return {commands, platforms, haste: acc.haste}; }, getEmptyPluginConfig()); }; @@ -121,7 +119,7 @@ export default function findPlugins(folder: string) { haste: { platforms: uniq(flatten(plugin.haste.platforms)), providesModuleNodeModules: uniq( - flatten(plugin.haste.providesModuleNodeModules) + flatten(plugin.haste.providesModuleNodeModules), ), }, }; diff --git a/packages/cli/src/tools/findReactNativeScripts.js b/packages/cli/src/tools/findReactNativeScripts.js index 9918081b7..876b9dcae 100644 --- a/packages/cli/src/tools/findReactNativeScripts.js +++ b/packages/cli/src/tools/findReactNativeScripts.js @@ -15,7 +15,7 @@ function findReactNativeScripts(): ?string { const executablePath = path.resolve( 'node_modules', '.bin', - 'react-native-scripts' + 'react-native-scripts', ); if (fs.existsSync(executablePath)) { return executablePath; diff --git a/packages/cli/src/tools/findSymlinkedModules.js b/packages/cli/src/tools/findSymlinkedModules.js index 068ded2db..90a0f5933 100644 --- a/packages/cli/src/tools/findSymlinkedModules.js +++ b/packages/cli/src/tools/findSymlinkedModules.js @@ -32,7 +32,7 @@ import fs from 'fs'; */ export default function findSymlinkedModules( projectRoot: string, - ignoredRoots?: Array = [] + ignoredRoots?: Array = [], ) { const nodeModuleRoot = path.join(projectRoot, 'node_modules'); const resolvedSymlinks = findModuleSymlinks(nodeModuleRoot, [ @@ -44,7 +44,7 @@ export default function findSymlinkedModules( function findModuleSymlinks( modulesPath: string, - ignoredPaths: Array = [] + ignoredPaths: Array = [], ): Array { if (!fs.existsSync(modulesPath)) { return []; @@ -58,7 +58,7 @@ function findModuleSymlinks( if (folderName.startsWith('@')) { const scopedModuleFolders = fs.readdirSync(folderPath); maybeSymlinkPaths.push( - ...scopedModuleFolders.map(name => path.join(folderPath, name)) + ...scopedModuleFolders.map(name => path.join(folderPath, name)), ); } else { maybeSymlinkPaths.push(folderPath); @@ -76,9 +76,9 @@ function findModuleSymlinks( findModuleSymlinks(path.join(symlinkPath, 'node_modules'), [ ...ignoredPaths, ...symlinks, - ]) + ]), ), - [] + [], ); return [...new Set([...symlinks, ...nestedSymlinks])]; @@ -89,7 +89,7 @@ function resolveSymlinkPaths(maybeSymlinkPaths, ignoredPaths) { if (fs.lstatSync(maybeSymlinkPath).isSymbolicLink()) { const resolved = path.resolve( path.dirname(maybeSymlinkPath), - fs.readlinkSync(maybeSymlinkPath) + fs.readlinkSync(maybeSymlinkPath), ); if (ignoredPaths.indexOf(resolved) === -1 && fs.existsSync(resolved)) { links.push(resolved); diff --git a/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.js b/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.js index 5a0362a6e..dd8ca4b98 100644 --- a/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.js +++ b/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.js @@ -34,7 +34,7 @@ function copyProjectTemplateAndReplace( srcPath, destPath, newProjectName, - options = {} + options = {}, ) { if (!srcPath) { throw new Error('Need a path to copy from'); @@ -67,7 +67,7 @@ function copyProjectTemplateAndReplace( } const relativeFilePath = translateFilePath( - path.relative(srcPath, absoluteSrcFilePath) + path.relative(srcPath, absoluteSrcFilePath), ) .replace(/HelloWorld/g, newProjectName) .replace(/helloworld/g, newProjectName.toLowerCase()); @@ -94,7 +94,7 @@ function copyProjectTemplateAndReplace( upgradeFileContentChangedCallback( absoluteSrcFilePath, relativeFilePath, - contentChanged + contentChanged, ); } copyAndReplace( @@ -105,7 +105,7 @@ function copyProjectTemplateAndReplace( HelloWorld: newProjectName, helloworld: newProjectName.toLowerCase(), }, - contentChangedCallback + contentChangedCallback, ); }); } @@ -135,7 +135,7 @@ function translateFilePath(filePath) { function upgradeFileContentChangedCallback( absoluteSrcFilePath, relativeDestPath, - contentChanged + contentChanged, ) { if (contentChanged === 'new') { logger.info(`${chalk.bold('new')} ${relativeDestPath}`); @@ -145,11 +145,11 @@ function upgradeFileContentChangedCallback( logger.info( `${chalk.bold(relativeDestPath)} ` + `has changed in the new version.\nDo you want to keep your ${relativeDestPath} or replace it with the ` + - `latest version?\nIf you ever made any changes ` + - `to this file, you'll probably want to keep it.\n` + + 'latest version?\nIf you ever made any changes ' + + "to this file, you'll probably want to keep it.\n" + `You can see the new version here: ${absoluteSrcFilePath}\n` + `Do you want to replace ${relativeDestPath}? ` + - `Answer y to replace, n to keep your version: ` + 'Answer y to replace, n to keep your version: ', ); const answer = prompt(); if (answer === 'y') { @@ -163,7 +163,7 @@ function upgradeFileContentChangedCallback( return 'keep'; } throw new Error( - `Unknown file changed state: ${relativeDestPath}, ${contentChanged}` + `Unknown file changed state: ${relativeDestPath}, ${contentChanged}`, ); } diff --git a/packages/cli/src/tools/generator/printRunInstructions.js b/packages/cli/src/tools/generator/printRunInstructions.js index fa0ab52c5..f09f7adcf 100644 --- a/packages/cli/src/tools/generator/printRunInstructions.js +++ b/packages/cli/src/tools/generator/printRunInstructions.js @@ -17,11 +17,11 @@ function printRunInstructions(projectDir: string, projectName: string) { const xcodeProjectPath = `${path.resolve( projectDir, 'ios', - projectName + projectName, )}.xcodeproj`; const relativeXcodeProjectPath = path.relative( process.cwd(), - xcodeProjectPath + xcodeProjectPath, ); logger.log(` diff --git a/packages/cli/src/tools/generator/promptSync.js b/packages/cli/src/tools/generator/promptSync.js index ce17409af..8c73a5a2c 100644 --- a/packages/cli/src/tools/generator/promptSync.js +++ b/packages/cli/src/tools/generator/promptSync.js @@ -10,8 +10,6 @@ // Simplified version of: // https://github.com/0x00A/prompt-sync/blob/master/index.js -/* eslint-disable */ - import fs from 'fs'; const term = 13; // carriage return @@ -112,7 +110,7 @@ function create() { if (masked) { process.stdout.write( - `\u001b[2K\u001b[0G${ask}${Array(str.length + 1).join(echo)}` + `\u001b[2K\u001b[0G${ask}${Array(str.length + 1).join(echo)}`, ); } else { process.stdout.write('\u001b[s'); @@ -122,7 +120,7 @@ function create() { process.stdout.write(`\u001b[2K\u001b[0G${ask}${str}`); } else { process.stdout.write( - `\u001b[2K\u001b[0G${str}\u001b[${str.length - insert}D` + `\u001b[2K\u001b[0G${str}\u001b[${str.length - insert}D`, ); } process.stdout.write('\u001b[u'); diff --git a/packages/cli/src/tools/generator/templates.js b/packages/cli/src/tools/generator/templates.js index 66150c6b4..85d426e82 100644 --- a/packages/cli/src/tools/generator/templates.js +++ b/packages/cli/src/tools/generator/templates.js @@ -8,7 +8,7 @@ * @flow */ -import { execSync } from 'child_process'; +import {execSync} from 'child_process'; import fs from 'fs'; import path from 'path'; import copyProjectTemplateAndReplace from './copyProjectTemplateAndReplace'; @@ -26,7 +26,7 @@ function createProjectFromTemplate( destPath: string, newProjectName: string, template: string, - destinationRoot: string + destinationRoot: string, ) { const templatePath = path.dirname(require.resolve('react-native/template')); copyProjectTemplateAndReplace(templatePath, destPath, newProjectName); @@ -56,7 +56,7 @@ function createFromRemoteTemplate( template: string, destPath: string, newProjectName: string, - destinationRoot: string + destinationRoot: string, ) { let installPackage; let templateName; @@ -72,7 +72,7 @@ function createFromRemoteTemplate( // Check if the template exists logger.info(`Fetching template ${installPackage}...`); - const packageManager = new PackageManager({ projectDir: destinationRoot }); + const packageManager = new PackageManager({projectDir: destinationRoot}); try { packageManager.install([installPackage]); const templatePath = path.resolve('node_modules', templateName); @@ -98,7 +98,7 @@ function createFromRemoteTemplate( // if this the clean up fails. logger.warn( `Failed to clean up template temp files in node_modules/${templateName}. ` + - 'This is not a critical error, you can work on your app.' + 'This is not a critical error, you can work on your app.', ); } } @@ -119,17 +119,17 @@ function installTemplateDependencies(templatePath, destinationRoot) { dependencies = require(dependenciesJsonPath); } catch (err) { throw new Error( - `Could not parse the template's dependencies.json: ${err.message}` + `Could not parse the template's dependencies.json: ${err.message}`, ); } const dependenciesToInstall = Object.keys(dependencies).map( - depName => `${depName}@${dependencies[depName]}` + depName => `${depName}@${dependencies[depName]}`, ); - new PackageManager({ projectDir: destinationRoot }).install( - dependenciesToInstall + new PackageManager({projectDir: destinationRoot}).install( + dependenciesToInstall, ); logger.info("Linking native dependencies into the project's build files..."); - execSync('react-native link', { stdio: 'inherit' }); + execSync('react-native link', {stdio: 'inherit'}); } function installTemplateDevDependencies(templatePath, destinationRoot) { @@ -137,7 +137,7 @@ function installTemplateDevDependencies(templatePath, destinationRoot) { // that are required by this template const devDependenciesJsonPath = path.resolve( templatePath, - 'devDependencies.json' + 'devDependencies.json', ); logger.info('Adding develop dependencies for the project...'); if (!fs.existsSync(devDependenciesJsonPath)) { @@ -150,16 +150,16 @@ function installTemplateDevDependencies(templatePath, destinationRoot) { dependencies = require(devDependenciesJsonPath); } catch (err) { throw new Error( - `Could not parse the template's devDependencies.json: ${err.message}` + `Could not parse the template's devDependencies.json: ${err.message}`, ); } const dependenciesToInstall = Object.keys(dependencies).map( - depName => `${depName}@${dependencies[depName]}` + depName => `${depName}@${dependencies[depName]}`, ); - new PackageManager({ projectDir: destinationRoot }).installDev( - dependenciesToInstall + new PackageManager({projectDir: destinationRoot}).installDev( + dependenciesToInstall, ); } -export { createProjectFromTemplate }; +export {createProjectFromTemplate}; diff --git a/packages/cli/src/tools/getAssets.js b/packages/cli/src/tools/getAssets.js index 26c751dcd..d0927ea61 100644 --- a/packages/cli/src/tools/getAssets.js +++ b/packages/cli/src/tools/getAssets.js @@ -7,7 +7,7 @@ import path from 'path'; import getPackageConfiguration from './getPackageConfiguration'; const findAssetsInFolder = folder => - glob.sync(path.join(folder, '**'), { nodir: true }); + glob.sync(path.join(folder, '**'), {nodir: true}); /** * Given an array of assets folders, e.g. ['Fonts', 'Images'], @@ -21,7 +21,7 @@ export function findAssets(folder: string, assets?: string[]) { .reduce( (acc, assetPath) => (acc.concat(findAssetsInFolder(assetPath)): Array), - [] + [], ); } diff --git a/packages/cli/src/tools/getHooks.js b/packages/cli/src/tools/getHooks.js index ec8da8a4a..aac342808 100644 --- a/packages/cli/src/tools/getHooks.js +++ b/packages/cli/src/tools/getHooks.js @@ -2,15 +2,14 @@ * @flow */ -import { spawn } from 'child_process'; +import {spawn} from 'child_process'; import getPackageConfiguration from './getPackageConfiguration'; export function makeCommand(command: string) { - // eslint-disable-next-line flowtype/no-weak-types return (cb: Function) => { if (!cb) { throw new Error( - `You missed a callback function for the ${command} command` + `You missed a callback function for the ${command} command`, ); } diff --git a/packages/cli/src/tools/getLegacyConfig.js b/packages/cli/src/tools/getLegacyConfig.js index c359d8fc5..2b5386f8e 100644 --- a/packages/cli/src/tools/getLegacyConfig.js +++ b/packages/cli/src/tools/getLegacyConfig.js @@ -22,7 +22,7 @@ const generateDeprecationMessage = api => export default (root: string) => ({ getPlatformConfig: util.deprecate( () => getPlatforms(root), - generateDeprecationMessage('getPlatformConfig()') + generateDeprecationMessage('getPlatformConfig()'), ), getProjectConfig: util.deprecate(() => { const platforms = getPlatforms(root); diff --git a/packages/cli/src/tools/getPackageConfiguration.js b/packages/cli/src/tools/getPackageConfiguration.js index e430b565c..b1ce140e5 100644 --- a/packages/cli/src/tools/getPackageConfiguration.js +++ b/packages/cli/src/tools/getPackageConfiguration.js @@ -2,13 +2,13 @@ * @flow */ import path from 'path'; -import type { PackageConfigurationT } from './types.flow'; +import type {PackageConfigurationT} from './types.flow'; /** * Returns configuration of the CLI from `package.json`. */ export default function getPackageConfiguration( - folder: string + folder: string, ): PackageConfigurationT { return require(path.join(folder, './package.json')).rnpm || {}; } diff --git a/packages/cli/src/tools/getPlatforms.js b/packages/cli/src/tools/getPlatforms.js index 84fd95554..2aefde45d 100644 --- a/packages/cli/src/tools/getPlatforms.js +++ b/packages/cli/src/tools/getPlatforms.js @@ -3,7 +3,7 @@ */ import path from 'path'; -import type { PlatformsT } from './types.flow'; +import type {PlatformsT} from './types.flow'; import findPlugins from './findPlugins'; @@ -35,9 +35,9 @@ export default function getPlatforms(root: string): PlatformsT { (acc, pathToPlatform) => Object.assign( acc, - require(path.join(root, 'node_modules', pathToPlatform)) + require(path.join(root, 'node_modules', pathToPlatform)), ), - {} + {}, ); return { diff --git a/packages/cli/src/tools/ios/findPodspecName.js b/packages/cli/src/tools/ios/findPodspecName.js index 67126cea1..08b8ec83c 100644 --- a/packages/cli/src/tools/ios/findPodspecName.js +++ b/packages/cli/src/tools/ios/findPodspecName.js @@ -11,19 +11,19 @@ import glob from 'glob'; import path from 'path'; export default function findPodspecName(folder) { - const podspecs = glob.sync('*.podspec', { cwd: folder }); + const podspecs = glob.sync('*.podspec', {cwd: folder}); let podspecFile = null; if (podspecs.length === 0) { return null; } if (podspecs.length === 1) { - podspecFile = podspecs[0]; // eslint-disable-line prefer-destructuring + podspecFile = podspecs[0]; } else { const folderParts = folder.split(path.sep); const currentFolder = folderParts[folderParts.length - 1]; const toSelect = podspecs.indexOf(`${currentFolder}.podspec`); if (toSelect === -1) { - podspecFile = podspecs[0]; // eslint-disable-line prefer-destructuring + podspecFile = podspecs[0]; } else { podspecFile = podspecs[toSelect]; } diff --git a/packages/cli/src/tools/ios/findProject.js b/packages/cli/src/tools/ios/findProject.js index 62715579c..3b1862f88 100644 --- a/packages/cli/src/tools/ios/findProject.js +++ b/packages/cli/src/tools/ios/findProject.js @@ -46,7 +46,7 @@ export default function findProject(folder) { }) .filter( project => - path.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project) + path.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project), ) .sort(project => (path.dirname(project) === IOS_BASE ? -1 : 1)); diff --git a/packages/cli/src/tools/isPackagerRunning.js b/packages/cli/src/tools/isPackagerRunning.js index c08ca4142..97f92550d 100644 --- a/packages/cli/src/tools/isPackagerRunning.js +++ b/packages/cli/src/tools/isPackagerRunning.js @@ -23,10 +23,11 @@ function isPackagerRunning(packagerPort = process.env.RCT_METRO_PORT || 8081) { res => res .text() - .then(body => - body === 'packager-status:running' ? 'running' : 'unrecognized' + .then( + body => + body === 'packager-status:running' ? 'running' : 'unrecognized', ), - () => 'not_running' + () => 'not_running', ); } diff --git a/packages/cli/src/tools/loadMetroConfig.js b/packages/cli/src/tools/loadMetroConfig.js index 2d79bb173..127083ff1 100644 --- a/packages/cli/src/tools/loadMetroConfig.js +++ b/packages/cli/src/tools/loadMetroConfig.js @@ -3,16 +3,16 @@ * @flow */ import path from 'path'; -import { createBlacklist } from 'metro'; -import { loadConfig } from 'metro-config'; -import type { ContextT } from './types.flow'; +import {createBlacklist} from 'metro'; +import {loadConfig} from 'metro-config'; +import type {ContextT} from './types.flow'; import findPlugins from './findPlugins'; import findSymlinkedModules from './findSymlinkedModules'; const resolveSymlinksForRoots = roots => roots.reduce( (arr, rootPath) => arr.concat(findSymlinkedModules(rootPath, roots)), - [...roots] + [...roots], ); const getWatchFolders = () => { @@ -48,7 +48,7 @@ export const getDefaultConfig = (ctx: ContextT) => { serializer: { getModulesRunBeforeMainModule: () => [ require.resolve( - path.join(ctx.reactNativePath, 'Libraries/tools/InitializeCore') + path.join(ctx.reactNativePath, 'Libraries/tools/InitializeCore'), ), ], getPolyfills: () => @@ -59,11 +59,11 @@ export const getDefaultConfig = (ctx: ContextT) => { }, transformer: { babelTransformerPath: require.resolve( - 'metro-react-native-babel-transformer' + 'metro-react-native-babel-transformer', ), assetRegistryPath: path.join( ctx.reactNativePath, - 'Libraries/Image/AssetRegistry' + 'Libraries/Image/AssetRegistry', ), }, watchFolders: getWatchFolders(), @@ -76,7 +76,7 @@ export type ConfigOptionsT = {| resetCache?: boolean, watchFolders?: string[], sourceExts?: string[], - reporter?: any, // eslint-disable-line flowtype/no-weak-types + reporter?: any, config?: string, |}; @@ -85,10 +85,10 @@ export type ConfigOptionsT = {| * * This allows the CLI to always overwrite the file settings. */ -export default async function load( +export default (async function load( ctx: ContextT, // $FlowFixMe - troubles with empty object being inexact - options?: ConfigOptionsT = {} + options?: ConfigOptionsT = {}, ) { const defaultConfig = getDefaultConfig(ctx); @@ -97,8 +97,8 @@ export default async function load( cwd: ctx.root, ...options, }, - defaultConfig + defaultConfig, ); return config; -} +}); diff --git a/packages/cli/src/tools/types.flow.js b/packages/cli/src/tools/types.flow.js index 408241333..495c26190 100644 --- a/packages/cli/src/tools/types.flow.js +++ b/packages/cli/src/tools/types.flow.js @@ -2,8 +2,6 @@ * @flow */ -/* eslint-disable flowtype/no-weak-types */ - export type ContextT = { root: string, reactNativePath: string, @@ -64,7 +62,7 @@ export type PlatformConfigT = { string, DependencyConfigT, ProjectConfigT, - Array + Array, ) => void, copyAssets: (string[], ProjectConfigT) => void, unlinkAssets: (string[], ProjectConfigT) => void, @@ -112,7 +110,7 @@ export type DependenciesConfig = { name: string, path: string, assets: string[], - commands: { [name: string]: string }, + commands: {[name: string]: string}, params: InquirerPromptT[], }; @@ -123,12 +121,12 @@ export type PlatformsT = { ios: PlatformConfigT< ProjectConfigIOST, DependencyConfigIOST, - IOSConfigParamsT + IOSConfigParamsT, >, android: PlatformConfigT< ProjectConfigAndroidT, DependencyConfigAndroidT, - AndroidConfigParamsT + AndroidConfigParamsT, >, [name: string]: PlatformConfigT, }; @@ -140,7 +138,7 @@ export type InquirerPromptT = any; */ export type PackageConfigurationT = { assets?: string[], - commands?: { [name: string]: string }, + commands?: {[name: string]: string}, params?: InquirerPromptT[], android: AndroidConfigParamsT, ios: IOSConfigParamsT, diff --git a/packages/cli/src/tools/yarn.js b/packages/cli/src/tools/yarn.js index bb7372bf7..38317daca 100644 --- a/packages/cli/src/tools/yarn.js +++ b/packages/cli/src/tools/yarn.js @@ -7,7 +7,7 @@ * @format */ -import { execSync } from 'child_process'; +import {execSync} from 'child_process'; import fs from 'fs'; import path from 'path'; import semver from 'semver'; diff --git a/packages/global-cli/index.js b/packages/global-cli/index.js index 1c8da2dad..d24657bbd 100755 --- a/packages/global-cli/index.js +++ b/packages/global-cli/index.js @@ -68,7 +68,7 @@ const getRNPkgJsonPath = function() { process.cwd(), 'node_modules', 'react-native', - 'package.json' + 'package.json', ); }; @@ -114,7 +114,10 @@ const commands = options._; if (cli) { cli.run(); } else { - if (options._.length === 0 && (options.h || options.help) || commands.length === 0) { + if ( + (options._.length === 0 && (options.h || options.help)) || + commands.length === 0 + ) { console.log( [ '', @@ -131,7 +134,7 @@ if (cli) { ' -v, --version use a specific version of React Native', ' --template use an app template. Use --template to see available templates.', '', - ].join('\n') + ].join('\n'), ); process.exit(0); } @@ -149,7 +152,7 @@ if (cli) { console.error( 'Command `%s` unrecognized. ' + 'Make sure that you have run `npm install` and that you are inside a react-native project.', - commands[0] + commands[0], ); process.exit(1); break; @@ -161,7 +164,7 @@ function validateProjectName(name) { console.error( '"%s" is not a valid name for a project. Please use a valid identifier ' + 'name (alphanumeric).', - name + name, ); process.exit(1); } @@ -170,7 +173,7 @@ function validateProjectName(name) { console.error( '"%s" is not a valid name for a project. Please do not use the ' + 'reserved word "React".', - name + name, ); process.exit(1); } @@ -220,7 +223,7 @@ function createProject(name, options) { console.log( 'This will walk you through creating a new React Native project in', - root + root, ); if (!fs.existsSync(root)) { @@ -239,7 +242,7 @@ function createProject(name, options) { }; fs.writeFileSync( path.join(root, 'package.json'), - JSON.stringify(packageJson) + JSON.stringify(packageJson), ); process.chdir(root); @@ -278,18 +281,18 @@ function run(root, projectName, options) { console.log(`Installing ${getInstallPackage(rnPackage)}...`); if (!forceNpmClient) { console.log( - 'Consider installing yarn to make this faster: https://yarnpkg.com' + 'Consider installing yarn to make this faster: https://yarnpkg.com', ); } installCommand = `npm install --save --save-exact ${getInstallPackage( - rnPackage + rnPackage, )}`; if (options.verbose) { installCommand += ' --verbose'; } } try { - execSync(installCommand, { stdio: 'inherit' }); + execSync(installCommand, {stdio: 'inherit'}); } catch (err) { console.error(err); console.error(`Command \`${installCommand}\` failed.`); @@ -307,11 +310,11 @@ function checkNodeVersion() { } if (!semver.satisfies(process.version, packageJson.engines.node)) { console.error( - 'You are currently running Node %s but React Native requires %s. ' + - 'Please use a supported version of Node.\n' + - 'See https://facebook.github.io/react-native/docs/getting-started.html', + 'You are currently running Node %s but React Native requires %s. ' + + 'Please use a supported version of Node.\n' + + 'See https://facebook.github.io/react-native/docs/getting-started.html', process.version, - packageJson.engines.node + packageJson.engines.node, ); } } @@ -322,7 +325,7 @@ function printVersionsAndExit(reactNativePackageJsonPath) { console.log(`react-native: ${require(reactNativePackageJsonPath).version}`); } catch (e) { console.log( - 'react-native: n/a - not inside a React Native project directory' + 'react-native: n/a - not inside a React Native project directory', ); } process.exit(); diff --git a/scripts/build.js b/scripts/build.js index 689ba6d6a..cceda31af 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -25,9 +25,8 @@ const mkdirp = require('mkdirp'); const babel = require('@babel/core'); const chalk = require('chalk'); const micromatch = require('micromatch'); -const prettier = require('prettier'); const stringLength = require('string-length'); -const { PACKAGES_DIR, getPackages } = require('./helpers'); +const {PACKAGES_DIR, getPackages} = require('./helpers'); const OK = chalk.reset.inverse.bold.green(' DONE '); const SRC_DIR = 'src'; @@ -37,10 +36,6 @@ const IGNORE_PATTERN = '**/__{tests,mocks,fixtures}__/**'; const transformOptions = require('../babel.config.js'); -const prettierConfig = prettier.resolveConfig.sync(__filename); -prettierConfig.trailingComma = 'none'; -prettierConfig.parser = 'babel'; - const adjustToTerminalWidth = str => { const columns = process.stdout.columns || 80; const WIDTH = columns - stringLength(OK) + 1; @@ -87,7 +82,7 @@ function buildFile(file, silent) { silent || process.stdout.write( `${chalk.dim(' \u2022 ') + - path.relative(PACKAGES_DIR, file)} (ignore)\n` + path.relative(PACKAGES_DIR, file)} (ignore)\n`, ); return; } @@ -101,21 +96,20 @@ function buildFile(file, silent) { `${chalk.red(' \u2022 ') + path.relative(PACKAGES_DIR, file) + chalk.red(' \u21D2 ') + - path.relative(PACKAGES_DIR, destPath)} (copy)\n` + path.relative(PACKAGES_DIR, destPath)} (copy)\n`, ); } else { const options = Object.assign({}, transformOptions); const transformed = babel.transformFileSync(file, options).code; - const prettyCode = prettier.format(transformed, prettierConfig); - fs.writeFileSync(destPath, prettyCode); + fs.writeFileSync(destPath, transformed); silent || process.stdout.write( `${chalk.green(' \u2022 ') + path.relative(PACKAGES_DIR, file) + chalk.green(' \u21D2 ') + - path.relative(PACKAGES_DIR, destPath)}\n` + path.relative(PACKAGES_DIR, destPath)}\n`, ); } } diff --git a/scripts/watch.js b/scripts/watch.js index 4da6e2fd8..20f711590 100644 --- a/scripts/watch.js +++ b/scripts/watch.js @@ -10,10 +10,10 @@ */ const fs = require('fs'); -const { execSync } = require('child_process'); +const {execSync} = require('child_process'); const path = require('path'); const chalk = require('chalk'); -const { getPackages } = require('./helpers'); +const {getPackages} = require('./helpers'); const BUILD_CMD = `node ${path.resolve(__dirname, './build.js')}`; @@ -33,7 +33,7 @@ getPackages().forEach(p => { const srcDir = path.resolve(p, 'src'); try { fs.accessSync(srcDir, fs.F_OK); - fs.watch(path.resolve(p, 'src'), { recursive: true }, (event, filename) => { + fs.watch(path.resolve(p, 'src'), {recursive: true}, (event, filename) => { const filePath = path.resolve(srcDir, filename); if ((event === 'change' || event === 'rename') && exists(filePath)) { @@ -47,8 +47,8 @@ getPackages().forEach(p => { `${chalk.red(' \u2022 ') + path.relative( path.resolve(srcDir, '..', '..'), - buildFile - )} (deleted)\n` + buildFile, + )} (deleted)\n`, ); } catch (e) { // omit @@ -65,7 +65,7 @@ setInterval(() => { if (files.length) { filesToBuild = new Map(); try { - execSync(`${BUILD_CMD} ${files.join(' ')}`, { stdio: [0, 1, 2] }); + execSync(`${BUILD_CMD} ${files.join(' ')}`, {stdio: [0, 1, 2]}); } catch (e) { // omit } diff --git a/yarn.lock b/yarn.lock index 3e1667e42..004d46d55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -989,22 +989,6 @@ lodash "^4.17.10" to-fast-properties "^2.0.0" -"@callstack/eslint-config@^3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@callstack/eslint-config/-/eslint-config-3.0.2.tgz#e40fcf73749aa8fb0b83bf243a2d6fdbc416fbd2" - integrity sha512-Frzn1E/egdqppp/2OLi76SMa6Z3yv4oRDjXDdYPCPtEJDyjzUh2lfTpURqziKbACUexTXMxAA+XMN0BSJ9RgUw== - dependencies: - babel-eslint "^10.0.1" - eslint-config-airbnb "^17.1.0" - eslint-config-prettier "^3.0.1" - eslint-plugin-flowtype "^3.0.0" - eslint-plugin-import "^2.14.0" - eslint-plugin-jest "^21.21.0" - eslint-plugin-jsx-a11y "^6.1.1" - eslint-plugin-prettier "^3.0.0" - eslint-plugin-react "^7.5.1" - prettier "^1.14.2" - "@lerna/add@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.10.6.tgz#6f2c6b26eb905c40fef4180f3ffa34ad9dbb860b" @@ -1610,6 +1594,21 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== +"@react-native-community/eslint-config@^0.0.2": + version "0.0.2" + resolved "https://registry.yarnpkg.com/@react-native-community/eslint-config/-/eslint-config-0.0.2.tgz#042224762e00ef06b45693a14be78ebda5fb7def" + integrity sha512-oKtMR046Ptfjvzd67MPm7Q8a5H8MeMsKB7E5bKgcMoybdZBmrsqo3Fn49FCKwc6yHd4KUkTyQihE4Fgk9jaanA== + dependencies: + babel-eslint "9.0.0" + eslint-plugin-eslint-comments "^3.0.1" + eslint-plugin-flowtype "2.43.0" + eslint-plugin-jest "21.8.0" + eslint-plugin-prettier "2.6.0" + eslint-plugin-react "7.8.2" + eslint-plugin-react-hooks "^1.0.1" + eslint-plugin-react-native "3.5.0" + prettier "1.13.6" + JSONStream@^1.0.4, JSONStream@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -1754,14 +1753,6 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -aria-query@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-3.0.0.tgz#65b3fcc1ca1155a8c9ae64d6eee297f15d5133cc" - integrity sha1-ZbP8wcoRVajJrmTW7uKX8V1RM8w= - dependencies: - ast-types-flow "0.0.7" - commander "^2.11.0" - arr-diff@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" @@ -1859,11 +1850,6 @@ assign-symbols@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" -ast-types-flow@0.0.7, ast-types-flow@^0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad" - integrity sha1-9wtzXGvKGlycItmCw+Oef+ujva0= - astral-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" @@ -1898,17 +1884,10 @@ aws4@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" -axobject-query@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.0.2.tgz#ea187abe5b9002b377f925d8bf7d1c561adf38f9" - integrity sha512-MCeek8ZH7hKyO1rWUbKNQBbl4l2eY0ntk7OGi+q0RlafrCnfPxC06WZA+uebCfmYp4mNU9jRBP1AhGyf8+W3ww== - dependencies: - ast-types-flow "0.0.7" - -babel-eslint@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed" - integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ== +babel-eslint@9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-9.0.0.tgz#7d9445f81ed9f60aff38115f838970df9f2b6220" + integrity sha512-itv1MwE3TMbY0QtNfeL7wzak1mV47Uy+n6HtSOO4Xd7rvmO+tsGQSgyOEEgo6Y2vHZKZphaoelNeSVj4vkLA1g== dependencies: "@babel/code-frame" "^7.0.0" "@babel/parser" "^7.0.0" @@ -2402,7 +2381,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@^2.11.0, commander@^2.9.0: +commander@^2.9.0: version "2.19.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" @@ -2483,11 +2462,6 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" -contains-path@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" - integrity sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo= - conventional-changelog-angular@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-5.0.2.tgz#39d945635e03b6d0c9d4078b1df74e06163dc66a" @@ -2663,11 +2637,6 @@ cyclist@~0.2.2: resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" integrity sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA= -damerau-levenshtein@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.4.tgz#03191c432cb6eea168bb77f3a55ffdccb8978514" - integrity sha1-AxkcQyy27qFou3fzpV/9zLiXhRQ= - dargs@^4.0.1: version "4.1.0" resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17" @@ -2694,7 +2663,7 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: +debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -2875,17 +2844,10 @@ dir-glob@2.0.0: arrify "^1.0.1" path-type "^3.0.0" -doctrine@1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" - integrity sha1-N53Ocw9hZvds76TmcHoVmwLFpvo= - dependencies: - esutils "^2.0.2" - isarray "^1.0.0" - -doctrine@^2.1.0: +doctrine@^2.0.2, doctrine@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + integrity sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw== dependencies: esutils "^2.0.2" @@ -2944,11 +2906,6 @@ electron-to-chromium@^1.3.103: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.103.tgz#a695777efdbc419cad6cbb0e58458251302cd52f" integrity sha512-tObPqGmY9X8MUM8i3MEimYmbnLLf05/QV5gPlkR8MQ3Uj8G8B2govE1U4cQcBYtv3ymck9Y8cIOu4waoiykMZQ== -emoji-regex@^6.5.1: - version "6.5.1" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.5.1.tgz#9baea929b155565c11ea41c6626eaa65cef992c2" - integrity sha512-PAHp6TxrCy7MGMFidro8uikr+zlJJKJ/Q6mm2ExZ7HwkyR9lSVFfE3kt36qcwa24BQL7y0G9axycGjK1A/0uNQ== - encodeurl@~1.0.1, encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" @@ -2987,7 +2944,7 @@ errorhandler@^1.5.0: accepts "~1.3.3" escape-html "~1.0.3" -es-abstract@^1.5.1, es-abstract@^1.6.1, es-abstract@^1.7.0: +es-abstract@^1.5.1, es-abstract@^1.7.0: version "1.12.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165" dependencies: @@ -3036,118 +2993,60 @@ escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" -eslint-config-airbnb-base@^13.1.0: - version "13.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.1.0.tgz#b5a1b480b80dfad16433d6c4ad84e6605052c05c" - integrity sha512-XWwQtf3U3zIoKO1BbHh6aUhJZQweOwSt4c2JrPDg9FP3Ltv3+YfEv7jIDB8275tVnO/qOHbfuYg3kzw6Je7uWw== - dependencies: - eslint-restricted-globals "^0.1.1" - object.assign "^4.1.0" - object.entries "^1.0.4" - -eslint-config-airbnb@^17.1.0: - version "17.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-17.1.0.tgz#3964ed4bc198240315ff52030bf8636f42bc4732" - integrity sha512-R9jw28hFfEQnpPau01NO5K/JWMGLi6aymiF6RsnMURjTk+MqZKllCqGK/0tOvHkPi/NWSSOU2Ced/GX++YxLnw== - dependencies: - eslint-config-airbnb-base "^13.1.0" - object.assign "^4.1.0" - object.entries "^1.0.4" - -eslint-config-prettier@^3.0.1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-3.3.0.tgz#41afc8d3b852e757f06274ed6c44ca16f939a57d" - integrity sha512-Bc3bh5bAcKNvs3HOpSi6EfGA2IIp7EzWcg2tS4vP7stnXu/J1opihHDM7jI9JCIckyIDTgZLSWn7J3HY0j2JfA== - dependencies: - get-stdin "^6.0.0" - -eslint-import-resolver-node@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" - integrity sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q== +eslint-plugin-eslint-comments@^3.0.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.1.1.tgz#32ff0afba8a48e17073817e6d03fbc5622f735b7" + integrity sha512-GZDKhOFqJLKlaABX+kdoLskcTINMrVOWxGca54KcFb1QCPd0CLmqgAMRxkkUfGSmN+5NJUMGh7NGccIMcWPSfQ== dependencies: - debug "^2.6.9" - resolve "^1.5.0" + escape-string-regexp "^1.0.5" + ignore "^5.0.5" -eslint-module-utils@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz#b270362cd88b1a48ad308976ce7fa54e98411746" - integrity sha1-snA2LNiLGkitMIl2zn+lTphBF0Y= +eslint-plugin-flowtype@2.43.0: + version "2.43.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.43.0.tgz#47cdac5f01cda53f1c3e8477f0c83fee66a1606e" + integrity sha512-gFlHd3b6L28Mm8nbNoK6YtWgJ6STngf8GY3RA5DfeUYU3mRYJcHZ4c70bsBoERnCZy+nGHyus+aJ4jkimSnu5g== dependencies: - debug "^2.6.8" - pkg-dir "^1.0.0" + lodash "^4.15.0" -eslint-plugin-flowtype@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-3.2.0.tgz#824364ed5940a404b91326fdb5a313a2a74760df" - integrity sha512-baJmzngM6UKbEkJ5OY3aGw2zjXBt5L2QKZvTsOlXX7yHKIjNRrlJx2ods8Rng6EdqPR9rVNIQNYHpTs0qfn2qA== - dependencies: - lodash "^4.17.10" +eslint-plugin-jest@21.8.0: + version "21.8.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-21.8.0.tgz#4f3155e2898c1efb0ce548f3e084e07db5e21c07" + integrity sha512-u8+tOrVHHAv9SetdzCghLaBrHyaBLx+6surC+A+VfLy7CfXixTvQnJmD/Ym8mDE6e7wPDZWWgsqb3FGAWh7NTw== -eslint-plugin-import@^2.14.0: - version "2.14.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.14.0.tgz#6b17626d2e3e6ad52cfce8807a845d15e22111a8" - integrity sha512-FpuRtniD/AY6sXByma2Wr0TXvXJ4nA/2/04VPlfpmUDPOpOY264x+ILiwnrk/k4RINgDAyFZByxqPUbSQ5YE7g== +eslint-plugin-prettier@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.0.tgz#33e4e228bdb06142d03c560ce04ec23f6c767dd7" + integrity sha512-floiaI4F7hRkTrFe8V2ItOK97QYrX75DjmdzmVITZoAP6Cn06oEDPQRsO6MlHEP/u2SxI3xQ52Kpjw6j5WGfeQ== dependencies: - contains-path "^0.1.0" - debug "^2.6.8" - doctrine "1.5.0" - eslint-import-resolver-node "^0.3.1" - eslint-module-utils "^2.2.0" - has "^1.0.1" - lodash "^4.17.4" - minimatch "^3.0.3" - read-pkg-up "^2.0.0" - resolve "^1.6.0" + fast-diff "^1.1.1" + jest-docblock "^21.0.0" -eslint-plugin-jest@^21.21.0: - version "21.27.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-21.27.2.tgz#2a795b7c3b5e707df48a953d651042bd01d7b0a8" - integrity sha512-0E4OIgBJVlAmf1KfYFtZ3gYxgUzC5Eb3Jzmrc9ikI1OY+/cM8Kh72Ti7KfpeHNeD3HJNf9SmEfmvQLIz44Hrhw== - -eslint-plugin-jsx-a11y@^6.1.1: - version "6.1.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.1.2.tgz#69bca4890b36dcf0fe16dd2129d2d88b98f33f88" - integrity sha512-7gSSmwb3A+fQwtw0arguwMdOdzmKUgnUcbSNlo+GjKLAQFuC2EZxWqG9XHRI8VscBJD5a8raz3RuxQNFW+XJbw== - dependencies: - aria-query "^3.0.0" - array-includes "^3.0.3" - ast-types-flow "^0.0.7" - axobject-query "^2.0.1" - damerau-levenshtein "^1.0.4" - emoji-regex "^6.5.1" - has "^1.0.3" - jsx-ast-utils "^2.0.1" +eslint-plugin-react-hooks@^1.0.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.4.0.tgz#ad86001e05519368e55a888b1b31004b8e2ae8f6" + integrity sha512-fMGlzztW/5hSQT0UBnlPwulao0uF8Kyp0Uv6PA81lzmcDz2LBtthkWQaE8Wz2F2kEe7mSRDgK8ABEFK1ipeDxw== -eslint-plugin-prettier@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.0.tgz#f6b823e065f8c36529918cdb766d7a0e975ec30c" - integrity sha512-4g11opzhqq/8+AMmo5Vc2Gn7z9alZ4JqrbZ+D4i8KlSyxeQhZHlmIrY8U9Akf514MoEhogPa87Jgkq87aZ2Ohw== - dependencies: - prettier-linter-helpers "^1.0.0" +eslint-plugin-react-native-globals@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-native-globals/-/eslint-plugin-react-native-globals-0.1.2.tgz#ee1348bc2ceb912303ce6bdbd22e2f045ea86ea2" + integrity sha512-9aEPf1JEpiTjcFAmmyw8eiIXmcNZOqaZyHO77wgm0/dWfT/oxC1SrIq8ET38pMxHYrcB6Uew+TzUVsBeczF88g== -eslint-plugin-prettier@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.1.tgz#19d521e3981f69dd6d14f64aec8c6a6ac6eb0b0d" - integrity sha512-/PMttrarPAY78PLvV3xfWibMOdMDl57hmlQ2XqFeA37wd+CJ7WSxV7txqjVPHi/AAFKd2lX0ZqfsOc/i5yFCSQ== +eslint-plugin-react-native@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-3.5.0.tgz#78a5d6aadb11f85d1b114488d1fddfa2bf4fc1fb" + integrity sha512-L0qwiBQbG3MVMQk4XVCyyX+9nqJjr9YUmqpJ98Gb+uAmD+xlxT33rDL9ZBQgzMzBxDcUW6WiPcll8j9uXpyLyQ== dependencies: - prettier-linter-helpers "^1.0.0" + eslint-plugin-react-native-globals "^0.1.1" -eslint-plugin-react@^7.5.1: - version "7.11.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.11.1.tgz#c01a7af6f17519457d6116aa94fc6d2ccad5443c" - integrity sha512-cVVyMadRyW7qsIUh3FHp3u6QHNhOgVrLQYdQEB1bPWBsgbNCHdFAeNMquBMCcZJu59eNthX053L70l7gRt4SCw== +eslint-plugin-react@7.8.2: + version "7.8.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.8.2.tgz#e95c9c47fece55d2303d1a67c9d01b930b88a51d" + integrity sha512-H3ne8ob4Bn6NXSN9N9twsn7t8dyHT5bF/ibQepxIHi6JiPIdC2gXlfYvZYucbdrWio4FxBq7Z4mSauQP+qmMkQ== dependencies: - array-includes "^3.0.3" - doctrine "^2.1.0" - has "^1.0.3" + doctrine "^2.0.2" + has "^1.0.1" jsx-ast-utils "^2.0.1" - prop-types "^15.6.2" - -eslint-restricted-globals@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz#35f0d5cbc64c2e3ed62e93b4b1a7af05ba7ed4d7" - integrity sha1-NfDVy8ZMLj7WLpO0saevBbp+1Nc= + prop-types "^15.6.0" eslint-scope@3.7.1: version "3.7.1" @@ -3414,7 +3313,7 @@ fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" -fast-diff@^1.1.2: +fast-diff@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== @@ -3671,7 +3570,7 @@ fstream@^1.0.0, fstream@^1.0.2: mkdirp ">=0.5 0" rimraf "2" -function-bind@^1.1.0, function-bind@^1.1.1: +function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -3736,11 +3635,6 @@ get-stdin@^4.0.1: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= -get-stdin@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" - integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== - get-stream@^3.0.0: version "3.0.0" resolved "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -3941,7 +3835,7 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -has@^1.0.1, has@^1.0.3: +has@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" dependencies: @@ -4032,6 +3926,11 @@ ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" +ignore@^5.0.5: + version "5.0.5" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.0.5.tgz#c663c548d6ce186fb33616a8ccb5d46e56bdbbf9" + integrity sha512-kOC8IUb8HSDMVcYrDVezCxpJkzSQWTAzf3olpKM6o9rM5zpojx23O0Fl8Wr4+qJ6ZbPEHqf1fdwev/DS7v7pmA== + image-size@^0.6.0: version "0.6.3" resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.3.tgz#e7e5c65bb534bd7cdcedd6cb5166272a85f75fb2" @@ -4431,7 +4330,7 @@ is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" -isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: +isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -4632,6 +4531,11 @@ jest-diff@^24.0.0: jest-get-type "^24.0.0" pretty-format "^24.0.0" +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + integrity sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw== + jest-docblock@^24.0.0: version "24.0.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-24.0.0.tgz#54d77a188743e37f62181a91a01eb9222289f94e" @@ -5303,11 +5207,11 @@ lodash.throttle@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" -lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: +lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.5, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" -loose-envify@^1.0.0, loose-envify@^1.3.1: +loose-envify@^1.0.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" dependencies: @@ -6159,7 +6063,7 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" -object-keys@^1.0.11, object-keys@^1.0.12: +object-keys@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2" @@ -6169,26 +6073,6 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" -object.assign@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" - -object.entries@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.0.4.tgz#1bf9a4dd2288f5b33f3a993d257661f05d161a5f" - integrity sha1-G/mk3SKI9bM/Opk9JXZh8F0WGl8= - dependencies: - define-properties "^1.1.2" - es-abstract "^1.6.1" - function-bind "^1.1.0" - has "^1.0.1" - object.getownpropertydescriptors@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" @@ -6478,7 +6362,7 @@ path-key@^2.0.0, path-key@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" -path-parse@^1.0.5, path-parse@^1.0.6: +path-parse@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" @@ -6532,13 +6416,6 @@ pirates@^4.0.0: dependencies: node-modules-regexp "^1.0.0" -pkg-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" - integrity sha1-ektQio1bstYp1EcFb/TpyTFM89Q= - dependencies: - find-up "^1.0.0" - pkg-dir@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" @@ -6587,22 +6464,10 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier-linter-helpers@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" - integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== - dependencies: - fast-diff "^1.1.2" - -prettier@^1.14.2: - version "1.15.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.3.tgz#1feaac5bdd181237b54dbe65d874e02a1472786a" - integrity sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg== - -prettier@^1.16.0: - version "1.16.0" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.0.tgz#104dd25f5ee3d0c9d0a6ce4bb40ced8481d51219" - integrity sha512-MCBCYeAuZfejUPdEpkleLWvpRBwLii/Sp5jQs0eb8Ul/drGIDjkL6tAU24tk6yCGf0KPV5rhPPPlczfBmN2pWQ== +prettier@1.13.6: + version "1.13.6" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.6.tgz#00ae0b777ad92f81a9e7a1df2f0470b6dab0cb44" + integrity sha512-p5eqCNiohWZN++7aJXUVj0JgLqHCPLf9GLIcLBHGNWs4Y9FJOPs6+KNO2WT0udJIQJTbeZFrJkjzjcb8fkAYYQ== pretty-format@24.0.0-alpha.6: version "24.0.0-alpha.6" @@ -6680,13 +6545,14 @@ promzard@^0.3.0: dependencies: read "1" -prop-types@^15.6.2: - version "15.6.2" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102" - integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ== +prop-types@^15.6.0: + version "15.7.2" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" + integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== dependencies: - loose-envify "^1.3.1" + loose-envify "^1.4.0" object-assign "^4.1.1" + react-is "^16.8.1" proto-list@~1.2.1: version "1.2.4" @@ -6779,6 +6645,11 @@ react-deep-force-update@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.2.tgz#3d2ae45c2c9040cbb1772be52f8ea1ade6ca2ee1" +react-is@^16.8.1: + version "16.8.3" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.3.tgz#4ad8b029c2a718fc0cfc746c8d4e1b7221e5387d" + integrity sha512-Y4rC1ZJmsxxkkPuMLwvKvlL1Zfpbcu+Bf4ZigkHup3v9EfdYhAlWAaVyA19olXq2o2mGn0w+dFKvk3pVVlYcIA== + react-proxy@^1.1.7: version "1.1.8" resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-1.1.8.tgz#9dbfd9d927528c3aa9f444e4558c37830ab8c26a" @@ -7090,13 +6961,6 @@ resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: dependencies: path-parse "^1.0.5" -resolve@^1.6.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.9.0.tgz#a14c6fdfa8f92a7df1d996cb7105fa744658ea06" - integrity sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ== - dependencies: - path-parse "^1.0.6" - restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"