diff --git a/local-cli/__mocks__/beeper.js b/local-cli/__mocks__/beeper.js index 93d96304b0..79410a08cb 100644 --- a/local-cli/__mocks__/beeper.js +++ b/local-cli/__mocks__/beeper.js @@ -1,5 +1,14 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + 'use strict'; + // beeper@1.1.0 has a return statement outside of a function // and therefore doesn't parse. Let's mock it so that we can // run the tests. - module.exports = function () {}; diff --git a/local-cli/__tests__/generators-test.js b/local-cli/__tests__/generators-test.js index f36fa70212..c08925403f 100644 --- a/local-cli/__tests__/generators-test.js +++ b/local-cli/__tests__/generators-test.js @@ -13,6 +13,7 @@ jest.autoMockOff(); var path = require('path'); var fs = require('fs'); +// eslint-disable-next-line improperly-disabled-jasmine-tests xdescribe('React Yeoman Generators', function() { describe('react:react', function() { var assert; @@ -44,7 +45,7 @@ xdescribe('React Yeoman Generators', function() { jest.runAllTicks(); jest.runOnlyPendingTimers(); return generated; - }, "generation", 750); + }, 'generation', 750); }); it('creates files', function() { @@ -87,7 +88,7 @@ xdescribe('React Yeoman Generators', function() { var stat = fs.statSync('android'); expect(stat.isDirectory()).toBe(true); - }) + }); }); describe('react:android', function () { @@ -123,7 +124,7 @@ xdescribe('React Yeoman Generators', function() { jest.runAllTicks(); jest.runOnlyPendingTimers(); return generated; - }, "generation", 750); + }, 'generation', 750); }); it('creates files', function () { @@ -203,7 +204,7 @@ xdescribe('React Yeoman Generators', function() { jest.runAllTicks(); jest.runOnlyPendingTimers(); return generated; - }, "generation", 750); + }, 'generation', 750); }); it('creates files', function() { diff --git a/local-cli/android/android.js b/local-cli/android/android.js index 0620626c22..173da600c4 100644 --- a/local-cli/android/android.js +++ b/local-cli/android/android.js @@ -8,8 +8,8 @@ */ 'use strict'; -var generate = require('../generate/generate'); var fs = require('fs'); +var generate = require('../generate/generate'); function android(argv, config, args) { return generate([ @@ -29,9 +29,9 @@ module.exports = { try { return JSON.parse( fs.readFileSync('package.json', 'utf8') - ).name + ).name; } catch (e) { - return 'unknown-app-name' + return 'unknown-app-name'; } }, }], diff --git a/local-cli/bundle/buildBundle.js b/local-cli/bundle/buildBundle.js index 327a9564e0..047ec2ac50 100644 --- a/local-cli/bundle/buildBundle.js +++ b/local-cli/bundle/buildBundle.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; const log = require('../util/log').out('bundle'); const Promise = require('promise'); diff --git a/local-cli/bundle/bundle.js b/local-cli/bundle/bundle.js index 5077a9947d..f5d8d008c4 100644 --- a/local-cli/bundle/bundle.js +++ b/local-cli/bundle/bundle.js @@ -6,10 +6,11 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; const buildBundle = require('./buildBundle'); -const outputBundle = require('./output/bundle'); const bundleCommandLineArgs = require('./bundleCommandLineArgs'); +const outputBundle = require('./output/bundle'); /** * Builds the bundle starting to look for dependencies at the given entry path. diff --git a/local-cli/bundle/getAssetDestPathAndroid.js b/local-cli/bundle/getAssetDestPathAndroid.js index f462ba5e81..b4e49f8b59 100644 --- a/local-cli/bundle/getAssetDestPathAndroid.js +++ b/local-cli/bundle/getAssetDestPathAndroid.js @@ -8,8 +8,8 @@ */ 'use strict'; -const path = require('path'); const assetPathUtils = require('./assetPathUtils'); +const path = require('path'); function getAssetDestPathAndroid(asset, scale) { const androidFolder = assetPathUtils.getAndroidDrawableFolderName(asset, scale); diff --git a/local-cli/bundle/output/bundle.js b/local-cli/bundle/output/bundle.js index 34d1fa71a1..9fbf4d8924 100644 --- a/local-cli/bundle/output/bundle.js +++ b/local-cli/bundle/output/bundle.js @@ -9,6 +9,7 @@ 'use strict'; const Promise = require('promise'); + const meta = require('./meta'); const writeFile = require('./writeFile'); diff --git a/local-cli/bundle/output/unbundle/as-assets.js b/local-cli/bundle/output/unbundle/as-assets.js index 0698d2a373..41bd5565da 100644 --- a/local-cli/bundle/output/unbundle/as-assets.js +++ b/local-cli/bundle/output/unbundle/as-assets.js @@ -8,14 +8,15 @@ */ 'use strict'; -const mkdirp = require('mkdirp'); -const path = require('path'); +const MAGIC_UNBUNDLE_NUMBER = require('./magic-number'); const Promise = require('promise'); const buildSourceMapWithMetaData = require('./build-unbundle-sourcemap-with-metadata'); +const mkdirp = require('mkdirp'); +const path = require('path'); const writeFile = require('../writeFile'); const writeSourceMap = require('./write-sourcemap'); -const MAGIC_UNBUNDLE_NUMBER = require('./magic-number'); + const {joinModules} = require('./util'); const MAGIC_UNBUNDLE_FILENAME = 'UNBUNDLE'; // must not start with a dot, as that won't go into the apk diff --git a/local-cli/bundle/output/unbundle/as-indexed-file.js b/local-cli/bundle/output/unbundle/as-indexed-file.js index 969f0fbd01..ea9d2e54fe 100644 --- a/local-cli/bundle/output/unbundle/as-indexed-file.js +++ b/local-cli/bundle/output/unbundle/as-indexed-file.js @@ -8,13 +8,14 @@ */ 'use strict'; +const MAGIC_UNBUNDLE_FILE_HEADER = require('./magic-number'); +const Promise = require('promise'); + const buildSourceMapWithMetaData = require('./build-unbundle-sourcemap-with-metadata'); const fs = require('fs'); -const Promise = require('promise'); const writeSourceMap = require('./write-sourcemap'); -const {joinModules} = require('./util'); -const MAGIC_UNBUNDLE_FILE_HEADER = require('./magic-number'); +const {joinModules} = require('./util'); const SIZEOF_UINT32 = 4; /** diff --git a/local-cli/bundle/output/unbundle/index.js b/local-cli/bundle/output/unbundle/index.js index d3411ca7aa..942464b847 100644 --- a/local-cli/bundle/output/unbundle/index.js +++ b/local-cli/bundle/output/unbundle/index.js @@ -8,8 +8,8 @@ */ 'use strict'; -const asIndexedFile = require('./as-indexed-file'); const asAssets = require('./as-assets'); +const asIndexedFile = require('./as-indexed-file'); function buildBundle(packagerClient, requestOptions) { return packagerClient.buildBundle({ diff --git a/local-cli/bundle/output/unbundle/write-sourcemap.js b/local-cli/bundle/output/unbundle/write-sourcemap.js index d74a702608..f64b1cd2cd 100644 --- a/local-cli/bundle/output/unbundle/write-sourcemap.js +++ b/local-cli/bundle/output/unbundle/write-sourcemap.js @@ -9,6 +9,7 @@ 'use strict'; const Promise = require('promise'); + const writeFile = require('../writeFile'); function writeSourcemap(fileName, contents, log) { diff --git a/local-cli/bundle/output/writeFile.js b/local-cli/bundle/output/writeFile.js index bb30d941fa..5f7d7db0d4 100644 --- a/local-cli/bundle/output/writeFile.js +++ b/local-cli/bundle/output/writeFile.js @@ -8,9 +8,10 @@ */ 'use strict'; -const fs = require('fs'); const Promise = require('promise'); +const fs = require('fs'); + function writeFile(file, data, encoding) { return new Promise((resolve, reject) => { fs.writeFile( diff --git a/local-cli/bundle/signedsource.js b/local-cli/bundle/signedsource.js index db09dfffc6..2876a53be8 100644 --- a/local-cli/bundle/signedsource.js +++ b/local-cli/bundle/signedsource.js @@ -11,7 +11,7 @@ var TOKEN = '<>', OLDTOKEN = '<>', TOKENS = [TOKEN, OLDTOKEN], - PATTERN = new RegExp('@'+'generated (?:SignedSource<<([a-f0-9]{32})>>)'); + PATTERN = new RegExp('@' + 'generated (?:SignedSource<<([a-f0-9]{32})>>)'); exports.SIGN_OK = {message:'ok'}; exports.SIGN_UNSIGNED = new Error('unsigned'); @@ -19,13 +19,14 @@ exports.SIGN_INVALID = new Error('invalid'); // Thrown by sign(). Primarily for unit tests. exports.TokenNotFoundError = new Error( - 'Code signing placeholder not found (expected to find \''+TOKEN+'\')'); + 'Code signing placeholder not found (expected to find \'' + TOKEN + '\')'); var md5_hash_hex; // MD5 hash function for Node.js. To port this to other platforms, provide an // alternate code path for defining the md5_hash_hex function. var crypto = require('crypto'); +// eslint-disable-next-line no-shadow md5_hash_hex = function md5_hash_hex(data, input_encoding) { var md5sum = crypto.createHash('md5'); md5sum.update(data, input_encoding); @@ -37,7 +38,7 @@ md5_hash_hex = function md5_hash_hex(data, input_encoding) { // // @return str to be embedded in to-be-signed file function signing_token() { - return '@'+'generated '+TOKEN; + return '@' + 'generated ' + TOKEN; } exports.signing_token = signing_token; @@ -59,13 +60,14 @@ exports.is_signed = is_signed; function sign(file_data) { var first_time = file_data.indexOf(TOKEN) !== -1; if (!first_time) { - if (is_signed(file_data)) + if (is_signed(file_data)) { file_data = file_data.replace(PATTERN, signing_token()); - else + } else { throw exports.TokenNotFoundError; + } } var signature = md5_hash_hex(file_data, 'utf8'); - var signed_data = file_data.replace(TOKEN, 'SignedSource<<'+signature+'>>'); + var signed_data = file_data.replace(TOKEN, 'SignedSource<<' + signature + '>>'); return { first_time: first_time, signed_data: signed_data }; } exports.sign = sign; @@ -78,18 +80,20 @@ exports.sign = sign; // it contains an invalid signature. function verify_signature(file_data) { var match = PATTERN.exec(file_data); - if (!match) + if (!match) { return exports.SIGN_UNSIGNED; + } // Replace the signature with the TOKEN, then hash and see if it matches // the value in the file. For backwards compatibility, also try with // OLDTOKEN if that doesn't match. var k, token, with_token, actual_md5, expected_md5 = match[1]; for (k in TOKENS) { token = TOKENS[k]; - with_token = file_data.replace(PATTERN, '@'+'generated '+token); + with_token = file_data.replace(PATTERN, '@' + 'generated ' + token); actual_md5 = md5_hash_hex(with_token, 'utf8'); - if (expected_md5 === actual_md5) + if (expected_md5 === actual_md5) { return exports.SIGN_OK; + } } return exports.SIGN_INVALID; } diff --git a/local-cli/bundle/unbundle.js b/local-cli/bundle/unbundle.js index b8715501d6..6d6045355e 100644 --- a/local-cli/bundle/unbundle.js +++ b/local-cli/bundle/unbundle.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; const bundleWithOutput = require('./bundle').withOutput; const bundleCommandLineArgs = require('./bundleCommandLineArgs'); diff --git a/local-cli/core/config/android/findAndroidAppFolder.js b/local-cli/core/config/android/findAndroidAppFolder.js index 2f1ddb355f..3a76f4d189 100644 --- a/local-cli/core/config/android/findAndroidAppFolder.js +++ b/local-cli/core/config/android/findAndroidAppFolder.js @@ -1,3 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const fs = require('fs'); const path = require('path'); diff --git a/local-cli/core/config/android/findManifest.js b/local-cli/core/config/android/findManifest.js index 3827b4276e..bbe71696d0 100644 --- a/local-cli/core/config/android/findManifest.js +++ b/local-cli/core/config/android/findManifest.js @@ -1,3 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const glob = require('glob'); const path = require('path'); diff --git a/local-cli/core/config/android/findPackageClassName.js b/local-cli/core/config/android/findPackageClassName.js index 30a33b1337..3552e1c447 100644 --- a/local-cli/core/config/android/findPackageClassName.js +++ b/local-cli/core/config/android/findPackageClassName.js @@ -1,6 +1,16 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const fs = require('fs'); -const path = require('path'); const glob = require('glob'); +const path = require('path'); /** * Gets package's class name (class that implements ReactPackage) diff --git a/local-cli/core/config/android/index.js b/local-cli/core/config/android/index.js index 295b3b7d31..086fd86a6d 100644 --- a/local-cli/core/config/android/index.js +++ b/local-cli/core/config/android/index.js @@ -1,10 +1,18 @@ -const path = require('path'); -const fs = require('fs'); -const glob = require('glob'); +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const findAndroidAppFolder = require('./findAndroidAppFolder'); const findManifest = require('./findManifest'); -const readManifest = require('./readManifest'); const findPackageClassName = require('./findPackageClassName'); +const path = require('path'); +const readManifest = require('./readManifest'); const getPackageName = (manifest) => manifest.attr.package; diff --git a/local-cli/core/config/android/readManifest.js b/local-cli/core/config/android/readManifest.js index 056447695c..8a39c7d27a 100644 --- a/local-cli/core/config/android/readManifest.js +++ b/local-cli/core/config/android/readManifest.js @@ -1,3 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const fs = require('fs'); const xml = require('xmldoc'); diff --git a/local-cli/core/config/findAssets.js b/local-cli/core/config/findAssets.js index 0cd2f0dd3b..ddfa9beea3 100644 --- a/local-cli/core/config/findAssets.js +++ b/local-cli/core/config/findAssets.js @@ -1,3 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const glob = require('glob'); const path = require('path'); @@ -13,8 +23,8 @@ const findAssetsInFolder = (folder) => module.exports = function findAssets(folder, assets) { return (assets || []) .map(assetsFolder => path.join(folder, assetsFolder)) - .reduce((assets, assetsFolder) => - assets.concat(findAssetsInFolder(assetsFolder)), + .reduce((_assets, assetsFolder) => + _assets.concat(findAssetsInFolder(assetsFolder)), [] ); }; diff --git a/local-cli/core/config/index.js b/local-cli/core/config/index.js index 3c52ab9984..a013d17ee3 100644 --- a/local-cli/core/config/index.js +++ b/local-cli/core/config/index.js @@ -1,8 +1,17 @@ -const path = require('path'); +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; const android = require('./android'); -const ios = require('./ios'); const findAssets = require('./findAssets'); +const ios = require('./ios'); +const path = require('path'); const wrapCommands = require('./wrapCommands'); const getRNPMConfig = (folder) => diff --git a/local-cli/core/config/ios/findProject.js b/local-cli/core/config/ios/findProject.js index 1acc982169..71170337e5 100644 --- a/local-cli/core/config/ios/findProject.js +++ b/local-cli/core/config/ios/findProject.js @@ -1,3 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const glob = require('glob'); const path = require('path'); @@ -39,7 +49,7 @@ module.exports = function findProject(folder) { return path.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project); }) .sort((projectA, projectB) => { - return path.dirname(projectA) === IOS_BASE? -1 : 1; + return path.dirname(projectA) === IOS_BASE ? -1 : 1; }); if (projects.length === 0) { diff --git a/local-cli/core/config/ios/index.js b/local-cli/core/config/ios/index.js index 5e1f2c0917..2cb18f62c2 100644 --- a/local-cli/core/config/ios/index.js +++ b/local-cli/core/config/ios/index.js @@ -1,5 +1,15 @@ -const path = require('path'); +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const findProject = require('./findProject'); +const path = require('path'); /** * For libraries specified without an extension, add '.tbd' for those that diff --git a/local-cli/core/config/wrapCommands.js b/local-cli/core/config/wrapCommands.js index 7be7f1cf36..a0f0fbc75b 100644 --- a/local-cli/core/config/wrapCommands.js +++ b/local-cli/core/config/wrapCommands.js @@ -1,9 +1,19 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const makeCommand = require('../makeCommand'); module.exports = function wrapCommands(commands) { const mappedCommands = {}; - Object.keys(commands || []).forEach((k) => - mappedCommands[k] = makeCommand(commands[k]) - ); + Object.keys(commands || []).forEach((k) => { + mappedCommands[k] = makeCommand(commands[k]); + }); return mappedCommands; }; diff --git a/local-cli/core/findPlugins.js b/local-cli/core/findPlugins.js index c07c143a1d..f9dc1bc263 100644 --- a/local-cli/core/findPlugins.js +++ b/local-cli/core/findPlugins.js @@ -1,3 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const path = require('path'); const union = require('lodash').union; const uniq = require('lodash').uniq; diff --git a/local-cli/core/getCommands.js b/local-cli/core/getCommands.js index 7cd50dec1c..5a1988f50d 100644 --- a/local-cli/core/getCommands.js +++ b/local-cli/core/getCommands.js @@ -1,5 +1,15 @@ -const path = require('path'); +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const findPlugins = require('./findPlugins'); +const path = require('path'); const flatten = require('lodash').flatten; const attachPackage = (command, pkg) => Array.isArray(command) diff --git a/local-cli/core/makeCommand.js b/local-cli/core/makeCommand.js index 5175f0e687..901b2f864f 100644 --- a/local-cli/core/makeCommand.js +++ b/local-cli/core/makeCommand.js @@ -1,3 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + const spawn = require('child_process').spawn; module.exports = function makeCommand(command) { diff --git a/local-cli/generate-android.js b/local-cli/generate-android.js index 081f625fe7..c3a43d2b97 100644 --- a/local-cli/generate-android.js +++ b/local-cli/generate-android.js @@ -8,7 +8,6 @@ */ 'use strict'; -var fs = require('fs'); var path = require('path'); var yeoman = require('yeoman-environment'); diff --git a/local-cli/generator-utils.js b/local-cli/generator-utils.js index 1f591b66d2..26debe31dc 100644 --- a/local-cli/generator-utils.js +++ b/local-cli/generator-utils.js @@ -8,8 +8,8 @@ */ 'use strict'; -var path = require('path'); var fs = require('fs'); +var path = require('path'); function copyAndReplace(src, dest, replacements) { if (fs.lstatSync(src).isDirectory()) { diff --git a/local-cli/server/server.js b/local-cli/server/server.js index fe0ee73aec..24fd5d128a 100644 --- a/local-cli/server/server.js +++ b/local-cli/server/server.js @@ -9,10 +9,10 @@ 'use strict'; const chalk = require('chalk'); +const findSymlinksPaths = require('./findSymlinksPaths'); const formatBanner = require('./formatBanner'); const path = require('path'); const runServer = require('./runServer'); -const findSymlinksPaths = require('./findSymlinksPaths'); const NODE_MODULES = path.resolve(__dirname, '..', '..', '..'); /**