Summary:
Fixes lots of ESLint warnings. Many of them where in PR #20877 by janicduplessis which requested to split the linting fixes from configuration and package changes.
I solved only the issues that I was most certain about but I would love to get hands on all of them with a little bit of input.
Pull Request resolved: https://github.com/facebook/react-native/pull/22062
Differential Revision: D12889447
Pulled By: TheSavior
fbshipit-source-id: 35f7a08104a5b859c860afdde4af2b32c0685c50
Summary:
Changed gradle repo list to have consistent priority. mavenLocal is top priority because it requires manual setup, also won't conflict with other repos.
Pull Request resolved: https://github.com/facebook/react-native/pull/22041
Differential Revision: D12871549
Pulled By: hramos
fbshipit-source-id: c86730fde956dca77174c6454fdcb005a5eec8a9
Summary: Adds copyright headers to all files that are missing them.
Reviewed By: hramos
Differential Revision: D12837494
fbshipit-source-id: 6330a18919676dec9ff2c03b7c9329ed9127d930
Summary:
Makes the delta bundle data structures more consistent.
The changes are as follows:
* There are now two types of JSON bundles that can be downloaded from the delta endpoint. Base bundles (`Bundle` type), and Delta bundles (`DeltaBundle` type).
* The `reset` boolean is renamed to `base`.
* `pre` and `post` properties are now strings.
* Only `Bundle` can define `pre` and `post` properties.
* The `delta` property is renamed to `modules`.
* Deleted modules are now listed inside of the `deleted` property, which is only defined by `DeltaBundle`.
Reviewed By: mjesun
Differential Revision: D10446831
fbshipit-source-id: 40e229a2811d48950f0bad8dd341ece189089e9b
Summary:
A while back Jest introduced `jest.requireActual` and `jest.requireMock` which are aliases to `require.requireActual` and `require.requireMock`. We believe that users should use official Jest API and are planning to deprecate the latter.
Pull Request resolved: https://github.com/facebook/react-native/pull/21849
Differential Revision: D10448849
Pulled By: TheSavior
fbshipit-source-id: 34fffde97f48c26098c74ee222a56d99071703a6
Summary: The only thing extra that we need to do is to include `JavaScriptCore.framework` inside the HelloWorld.xcodeproj file.
Reviewed By: hramos
Differential Revision: D9893035
fbshipit-source-id: 2a29d1fd645eafa2e09109ad14d09f812dfa2601
Summary:
Fixes#19069
The --simulator option for the run-ios command now can take an optional
iOS version between parenthesis to further match the desired simulator.
This is useful if you have installed simulators for different iOS
versions and you want to run the app in an especific one. Example:
react-native run-ios --simulator "iPhone 6s (9.3)"
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.
Updated tests for the findMatchingSimulator function to include test cases specifying iOS version, and tested on the command line in my app to make sure it has the expected behavior.
[CLI] [ENHANCEMENT] [{/runIOS/findMatchingSimulator.js}] - run-ios command with the --simulator option now allows specifying the iOS version to run an specific simulator if you have multiple versions of the simulator installed. Example: `react-native run-ios --simulator "iPhone 6s (9.3)"`.
Pull Request resolved: https://github.com/facebook/react-native/pull/19079
Differential Revision: D10432487
Pulled By: hramos
fbshipit-source-id: efa50d798b79d83bfe357ee17967a56c7c003bee
Summary:
This diff removes the `sinon` dependency from `metro` and `react-native-github`. It was only used in a handful of tests and having to learn and remember another mocking API just for these cases was not worth it IMO.
While doing the migration, most of the things that `sinon` provides can be done with `jest` in a very similar (and user friendly) way.
I've found, though, two small things that are more user friendly with `sinon`. I'm documenting them here because it may be worth adding them to jest:
With `sinon`:
```
stub.throws(new Error('foo'));
```
With `jest`:
```
mock.mockImplementation(() => {
throw new Error('foo');
});
```
Taking into account that `jest` has a `mockRejectedValue` method for mocks (to return a rejected promise) I don't see any reason why it does not have a `mockThrowError` method.
With `sinon`:
```
expect(mock1.calledBefore(mock2)).toBeTruthy();
```
With `jest`:
```
expect(mock1.mock.invocationCallOrder[0]).toBeLessThan(
mock2.mock.invocationCallOrder[0],
);
```
There's a community matcher that adds this matcher in `jest-extended`: https://github.com/jest-community/jest-extended#tohavebeencalledbefore, but we're not using `jest-extended` in `xplat/js`.
Reviewed By: jeanlauliac
Differential Revision: D10238331
fbshipit-source-id: 5441125b69596ad85bf8f56d203cfd20759bc358
Summary:
With the new xcode command line tools (10.1 beta2), running `xcrun simctl list --json devices` seems to gives us a slightly different format than what we were expecting. More specifically, the `availability` key is changed to `isAvailable` and returns `'YES'` if the simulator is available:
Before:
```js
devices: {
'iOS 9.2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
name: 'iPhone 4s',
udid: 'B9B5E161-416B-43C4-A78F-729CB96CC8C6',
},
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
name: 'iPhone 5',
udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB',
},
...
]
}
```
After:
```js
devices: {
'iOS 12.1': [
{
state: 'Shutdown',
isAvailable: 'YES',
name: 'iPhone 6s',
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
{
state: 'Shutdown',
isAvailable: 'YES',
name: 'iPhone 6',
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
},
...
]
}
```
Without this fix, `npm run ios` is not able to launch the simulator correctly and returns the following error:
```
Could not find iPhone 6 simulator
Error: Could not find iPhone 6 simulator
at resolve (/Users/antonyc/Projects/AwesomeProject/node_modules/react-native/local-cli/runIOS/runIOS.js:148:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/antonyc/Projects/AwesomeProject/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/antonyc/Projects/AwesomeProject/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/antonyc/Projects/AwesomeProject/node_modules/react-native/local-cli/cliEntry.js:117:22)
```
Pull Request resolved: https://github.com/facebook/react-native/pull/21557
Differential Revision: D10248115
Pulled By: TheSavior
fbshipit-source-id: 37197bbf828e4a6e254270d46411a6716a91afe3
Summary:
Update several files to use the proper copyright header:
```
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
```
In the case of Xcode project files, I used the shortform version, `Copyright (c) Facebook, Inc. and its affiliates.`
Reviewed By: axe-fb
Differential Revision: D10114529
fbshipit-source-id: a1f2d5a46d04797c1cf281ea9ab80d3a2caa6fb4
Summary:
There were approximately 350 unused suppressions in xplat/js when checking with .flowconfig.android
The flow team is partially responsible for this, since our release process hasn't changed since we added the flowconfig. In the diff beneath this one, I added the functionality necessary for us to not add any more unused suppressions. To test it, I made this diff. The steps were:
1. Start iOS server
2. Start android server
3. remove unused ios suppressions
4. remove unused android suppressions
5. add ios suppressions with site=react_native_ios_fb
6. add android suppressions with site=react_native_android_fb
7. remove unused ios suppressions. The ones that are unused are ones where an android comment was inserted as well, since the ios comment no longer is next to the error
8. add suppressions using ios flowconfig with site=react_native_fb
9. remove unused android suppressions. The unused ones are ones that were moved up when the cross-platform suppressions were inserted.
I'm going to make this into a script to make sure we don't contribute anymore unused suppressions from our side.
The controller you requested could not be found. nolint
Reviewed By: TheSavior
Differential Revision: D10053893
fbshipit-source-id: 7bee212062f8b2153c6ba906a30cf40df2224019
Summary: This makes the Metro config type readonly, only a couple of things inside Metro needed to be tweaked :)
Reviewed By: mjesun
Differential Revision: D10028083
fbshipit-source-id: 15f5d957a8ee7384d6156c973639d86240fd251f
Summary:
This PR is the result of running `yarn prettify` on the codebase - which caught a few files that were not prettified. This will make instructing people to run prettify a bit less complicated, since unrelated files will not show up in diffs.
Pull Request resolved: https://github.com/facebook/react-native/pull/21327
Differential Revision: D10046057
Pulled By: TheSavior
fbshipit-source-id: 2c771a3c758c72816c707e32ee2f4587e466f277
Summary:
@public
Otherwise tests using `path` but not `fs` have an empty mock, as it happens on https://github.com/facebook/metro/issues/235#issuecomment-423722747
Reviewed By: mjesun
Differential Revision: D10008513
fbshipit-source-id: 673e2ca79c8105a68818985dc08fe7ccd5d13881
Summary:
Upgrade React Native to Android SDK 27 again, following the reversal in D9886607 (68c7999c25).
The SDK 27 is actually available internally in an alternate location that is suitable for use cases like React Native's. For future reference, SDK 28 is also available for use in this location.
Reviewed By: axe-fb
Differential Revision: D9929066
fbshipit-source-id: 9413f891d5587293a30544351340e9407a2dce55
Summary:
fix ci path problem on Windows
pass all current ci.
none
[GENERAL] [INTERNAL] [CI] - fix ci path problem on Windows
Pull Request resolved: https://github.com/facebook/react-native/pull/21203
Differential Revision: D9943608
Pulled By: hramos
fbshipit-source-id: 66e3e196a6c0015e0472851abeee32de9fef140c
Summary:
this is just a suggestion, but as the iPhone 6 is discontinued by Apple
and the new iPhone line will match the X version, it could be good to update the default simulator.
it could also be the iPhone 8, feel free to suggest other changes!
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
Pull Request resolved: https://github.com/facebook/react-native/pull/21148
Differential Revision: D9928120
Pulled By: hramos
fbshipit-source-id: 005faa3a8e00b67f98a778c92ecc01b064e14199
Summary:
Due to Kureev's cleanup in c4a66a89a2 some arguments are no longer properly passed to metro, but just the default values. This broke the `--projectRoot` and `--watchFolders` arguments used by storybook to change the bundle entrypoint.
This PR simply fixes the regression by assigning these values from argv instead of reading config defaults.
Related: the undocumented `REACT_NATIVE_APP_ROOT` env var is broken, not sure for how long, but I can fix it as a part of this PR or make a new one.
Pull Request resolved: https://github.com/facebook/react-native/pull/21165
Differential Revision: D9929642
Pulled By: hramos
fbshipit-source-id: 00485a0429bd4301de03e5cb455e928878c4ba8f
Summary:
@public
The React Native CLI is not passing the default `maxWorkers` param to Metro, making it run in a single thread and making the development process really slow.
This fixes https://github.com/facebook/metro/issues/253
Reviewed By: mjesun
Differential Revision: D9915500
fbshipit-source-id: d15030af582e99fe20535c07e751cfe12e444f2f
Summary:
Go back to using compileSdkVersion 26 and targetSdkVersion 26, temporarily. We can re-add this once Android SDK 27 becomes available in Facebook's internal repository.
The Android SDK Build Tools 27.0.3 **are** available, so we can continue using those.
Reviewed By: axe-fb
Differential Revision: D9886607
fbshipit-source-id: 6c1c9c1e1309c3a0483cc4c0bd8dcb4a5f29fc7e
Summary:
This is an updated (rebased) version of the very old #16579.
I added a [template](https://github.com/facebook/react-native/tree/master/local-cli/templates/HelloNavigation) for react-navigation directly into the React Native repo a long time ago. The feature `react-native init --template foo` supports both:
- Remote templates (`react-native-template-foo` in npm as well as HTTP URLs)
- Local templates that ship with react-native itself
In retrospect, adding the local template wasn't a good idea. Templates should live outside of the React Native repo and be versioned independently. This way templates can be fixed independently of React Native releases, and people can use new templates without having to upgrade React Native.
Pull Request resolved: https://github.com/facebook/react-native/pull/21155
Differential Revision: D9885719
Pulled By: hramos
fbshipit-source-id: d2982f374d3c451c09e348ce5fcdca9d0be5a474
Summary:
@public
These tests are using a mock memory FS to start with, so there is no reason at all they should depend on the host OS or filesystem details. This changeset fixes that so that we fully mock the `fs` and `path` modules dependending on the mock platform (not the host platform). I also added an example of how we can test both platforms (regardless of the host platform) in `findPackageClassName`. Follow up changeset will be to do the same for all the other affected tests.
Related to https://github.com/facebook/react-native/issues/20260.
Reviewed By: mjesun
Differential Revision: D9771024
fbshipit-source-id: b368b43e8e54292d33b6183eec9a9ea69f2e6e76
Summary:
This PR gives RNPM the ability to look for plugins in `scoped` modules.
The regexes for finding RNPM plugins will match these hypothetical examples:
* `rnpm-plugin-foo`
* `org/rnpm-plugin-foo`
The regexes for finding React Native plugins will match these hypothetical examples:
* `react-native-foo`
* `org/react-native-foo`
* `The controller you requested could not be found./module` (will be useful in the slimmening)
* `The controller you requested could not be found./module`
RNPM plugins will be able to benefit from this immediately, but React Native plugins will run into this Metro issue currently:
https://github.com/facebook/metro/issues/241
Pull Request resolved: https://github.com/facebook/react-native/pull/21082
Differential Revision: D9809094
Pulled By: hramos
fbshipit-source-id: 4b0694ad4119b37dd5664af52c48e48ebe4d7404
Summary: This change drops the year from the copyright headers and the LICENSE file.
Reviewed By: yungsters
Differential Revision: D9727774
fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
Summary: buildifier was updated and now we sort loads!
Reviewed By: zertosh
Differential Revision: D9771824
fbshipit-source-id: 0001aa5f656d4aa40b3498d5bfd792a3d14e56e1
Summary: This pull request removes the hard-coded version of the `metro-react-native-babel-preset` as defined in the `init` command. That way, the version always matches React Native version specified in its `package.json`, making it match Metro version.
Differential Revision: D9759540
Pulled By: hramos
fbshipit-source-id: 90835442e2db1900851cbfb8c3c625229184d851
Summary:
Motivation:
--------------
PR #20767 bumped the version of the Android Gradle Plugin to v3 which uses the newer Gradle dependency configurations `implementation` and `api` which make `compile` obsolete.
While the PR updated the template Gradle configuration, it did not cover the `link` command which will still link native modules using `compile` resulting in a warning message beeing displayed during an app build.
Since `compile` will be eventually removed by Gradle, this commit updates the `link` command to attach native modules using `implementation`.
Pull Request resolved: https://github.com/facebook/react-native/pull/20853
Differential Revision: D9733888
Pulled By: hramos
fbshipit-source-id: 22853480d7ba7be65e3387effda2fd6c72b6906a
Summary:
This also relink the require() onto `RamBundle.js` from Metro so we can remove `unbundle.js` from there completely.
Pull Request resolved: https://github.com/facebook/react-native/pull/21013
Reviewed By: hramos
Differential Revision: D9721443
Pulled By: jeanlauliac
fbshipit-source-id: 3e42ebde4cb2c735ef0934ba3b1e20f1054440df
Summary:
The default react-native template has ic_launcher_round icons on the resources but has not been used.
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
Pull Request resolved: https://github.com/facebook/react-native/pull/20968
Differential Revision: D9661731
Pulled By: hramos
fbshipit-source-id: ad8f2f952df2c32aea2a8d3e69c445ed27387aa6
Summary:
Use a whitelist to validate user-provided file names. This doesn't cover the entire range of valid filenames but should cover almost all of them in practice. Allows letters, numbers, periods, dashes, and underscores. Opting to use a whitelist instead of a blacklist because getting this wrong leaves us vulnerable to a RCE attack.
This is the same patch I submitted to create-react-app: https://github.com/facebook/create-react-app/pull/4866
See s163726 for more details
Reviewed By: LukasReschke
Differential Revision: D9504148
fbshipit-source-id: e3c7587f1b7f93bec90a58a38d5f6d58f1f59275
Summary:
This pull request adds the ability for a platform developer to provide a `"haste"` key under the `"rnpm"` key in their `package.json` which allows the packager to pick up that platform's javascript files. The intent is to remove the need to have custom platforms hardcoded in. This is inspired by the `"jest": { "haste": {} }` key used by jest.
For example, React Native Dom would have an entry like:
```json
{
"rnpm": {
"haste": {
"providesModuleNodeModules": [
"react-native-dom"
],
"platforms": [
"dom"
]
}
}
}
```
Support for more keys (path blacklists perhaps?) could be added in the future.
This succeeds #20662, as per a discussion I had with matthargett.
I've got an open discussion over here as well: https://github.com/react-native-community/discussions-and-proposals/issues/21
Pull Request resolved: https://github.com/facebook/react-native/pull/20825
Differential Revision: D9596429
Pulled By: hramos
fbshipit-source-id: a02f0da0bea8870bdc45d55e23da8ccbc36249f2
Summary: This diff fixes a couple of edge cases that caused Metro to keep the process running when there were some specific errors (specially around the `dependencies` command and the transformer path).
Reviewed By: jrwats
Differential Revision: D9551834
fbshipit-source-id: 959cefcec9e2687dff89c94a871ae74c50d2dd77