Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47333
Motivated by https://github.com/facebook/hermes/issues/1549. This was originally changed in https://github.com/facebook/react-native/pull/46696, as our internal Flow support had diverged from `babel/eslint-parser` (https://github.com/facebook/react-native/issues/46601).
We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript or Flow in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses `babel/plugin-syntax-flow` via `babel/eslint-parser` (**this change**).
I'd love to simplify this 😅.
Switching to `hermes-eslint` for the RN monorepo codebase (D63541483) is unchanged.
Changelog: [Internal]
Reviewed By: robhogan, cipolleschi
Differential Revision: D65272156
fbshipit-source-id: 3a2bbe3fcf8ed6057f6d994a0be4985e6bf46fa9
Summary:
Similar to D63541483, modernises our Flow syntax support for our published ESLint config to use `hermes-eslint` (`hermes-parser`).
Changelog: [Internal]
Reviewed By: hoxyq
Differential Revision: D63541856
fbshipit-source-id: 06cc5725faf5934fda07713ec1dac54ff9c32ddf
Summary:
This change bumps the React Native version in main to 0.77
bypass-github-export-checks
## Changelog:
[General][Changed] - Bump main to 0.77-main
## Facebook:
generated by running `js1 publish react-native 0.77.0-main`
Reviewed By: cortinico
Differential Revision: D62575939
fbshipit-source-id: 6d239fca2eed6cfe51f8c37f78d8dc8730c18b8c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46295
X-link: https://github.com/facebook/metro/pull/1343
Updated all **babel** packages in all `package.json` across the repo and ran `npx yarn-deduplicate yarn.lock --scopes babel`. Afterwards, fixed the following issues appearing as a result of that (squashed the following initially separate diffs to make this packages update work atomically):
### (D61336392) updated jest snapshot tests failing
### (D61336393) updated babel types and corrected typings accordingly
The latest babel 7 introduces the following features we need to adjust our types to:
* `JSXNamespacedName` is removed from valid `CallExpression` args ([PR](https://github.com/babel/babel/pull/16421))
* `JSXNamespacedName` is used for namespaced XML properties in things like `<div namespace:name="value">`, but `fn(namespace:name)` doesn't make any sense.
* Dynamic imports are enabled behind a new flag `createImportExpressions` ([PR](https://github.com/babel/babel/pull/15682)), introducing calls such as `import(foo, options)`. These complicate the expected values passed to `import` to be more than just strings.
* Since these are behind a flag that is not expected to be enabled, we can throw an error for now and whoever uses it can add a support to it if needed later.
### Added a new metro ENV ignore
`BROWSERSLIST_ROOT_PATH` is set to `""` explicitly in `xplat/js/BUCK`
and then ignored in
`js/tools/metro-buck-transform-worker/src/EnvVarAllowList.js`
Reviewed By: robhogan
Differential Revision: D61543660
fbshipit-source-id: abbcab72642cf6dc03eed5142eb78dbcc7f63a86
Summary:
In a future release of React Native, string refs will no longer be supported. This increases the severity of the `no-string-refs` lint rule to convey this.
Changelog:
[General][Changed] - `no-string-refs` is now a lint error
Reviewed By: kassens
Differential Revision: D56826663
fbshipit-source-id: 603f5b205bb9fd8a5dcb8ee917f6a2ba1ac47e6e
Summary:
The React Native ESLint preset currently endorses the Prettier integration that is [explicitly recommended against by Pretier itself](https://prettier.io/docs/en/integrating-with-linters). Notice the difference between these two packages:
- `eslint-config-prettier` is the config that turns off all formatting rules. It's **recommended by Prettier** to be used together with Prettier. You'd still use Prettier itself to actually do the formatting.
- `eslint-plugin-prettier` is a legacy plugin developed a long time ago and that predates most modern Prettier integrations. It runs Prettier as if it were an ESLint rule, applies formatting on `--fix`, and **is not recommended**.
Unfortunately, RN uses the latter one (and always has).
This PR removes `eslint-plugin-prettier` and instead enables `eslint-config-prettier`, as recommended by Prettier.
As a consequence, you'll no longer see squiggly lines in your editor for stuff that isn't actually errors:
<img width="558" alt="Screenshot 2024-04-01 at 20 00 50" src="https://github.com/facebook/react-native/assets/810438/91ae2cec-a9ef-4205-a9ce-6ab858785ed2">
As another consequence, **you'll have to set up your own Prettier step in your pipeline**.
For example, if your precommit hook only contained `eslint --fix`, you'll now also need to run `prettier --write` there as well. Similarly, if you want Prettier to fail CI, you'd need to find where you call `eslint` and also do `prettier --check` there.
Here's an example for how to do it: https://github.com/bluesky-social/social-app/pull/3373
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[GENERAL] [BREAKING] - RN ESLint config no longer runs Prettier during ESLint
Pull Request resolved: https://github.com/facebook/react-native/pull/43756
Test Plan:
Tested locally, verified formatting changes no longer get flagged as violations by the RN config.
<img width="470" alt="Screenshot 2024-04-01 at 20 33 55" src="https://github.com/facebook/react-native/assets/810438/515db971-18bc-4625-bb6d-b9d072692923">
Reviewed By: motiz88
Differential Revision: D55643699
Pulled By: yungsters
fbshipit-source-id: 97df774275922086f0356ac857d6425713184e39
Summary:
Minor fix to package.json which newer version of npm warn about when publishing, after running `npm pkg fix -ws` on the workspace.
{F1470070110}
## Changelog: [Internal] npm pkg fix -ws
Pull Request resolved: https://github.com/facebook/react-native/pull/43519
Test Plan: eyescloseddog
Reviewed By: cortinico
Differential Revision: D55012872
Pulled By: blakef
fbshipit-source-id: ff3c63a3eefaf56d369219a3d4b32d44d6d842c9
Summary:
This PR updates `typescript-eslint/eslint-plugin` and `typescript-eslint/parser` to `v7` and `eslint-plugin-jest` to `v27`, removing any dependencies on `typescript-eslint` `v6`, allowing projects using `react-native/eslint-config` to safely update to `typescript-eslint` `v7` without having to worry about duplicate major versions installed
## Changelog:
- [General] [Changed]: Updated `eslint-plugin-jest` to `v27`
- [General] [Changed]: Updated `typescript-eslint` monorepo to `v7`
Pull Request resolved: https://github.com/facebook/react-native/pull/43406
Test Plan: `yarn run lint` executed locally successfully
Reviewed By: robhogan
Differential Revision: D54749676
Pulled By: tdn120
fbshipit-source-id: f6fae92fc95333e28b36a3d2bd8470c8869d38bc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42300
Changelog: [Internal]
The version of the `keyword-spacing` lint rule we have installed is apparently buggy. Either way it's unnecessary since we use Prettier.
Reviewed By: christophpurrer
Differential Revision: D52799550
fbshipit-source-id: 2e199938d45c554039b2117163fd403f236bf752
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42086
Changelog: [General][Changed] - Update monorepo dependency versions to remove ^
This change will remove the caret for now as we already perform an "align" step everytime we bump a monorepo library. This prevents monorepo library updates to affect existing releases.
The "align" step updates all monorepo libraries to use the updated bumped version: https://fburl.com/code/xfistiph
Reviewed By: huntie
Differential Revision: D52440454
fbshipit-source-id: ff071032f04bc554903dde153c594991163dfe2f
Summary:
When upgrading ESLint to latest, the RN plugin fails to run because of a deprecated API:
```
Error: Parsing error: DeprecationError: 'originalKeywordKind' has been deprecated since v5.0.0 and can no longer be used. Use 'identifierToKeywordKind(identifier)' instead.
```
## Changelog:
- [GENERAL] [FIXED] Updated ESLint version to fix `originalKeywordKind` deprecation error
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: https://github.com/facebook/react-native/pull/39654
Test Plan: Run CI and Lint
Reviewed By: NickGerleman
Differential Revision: D49634978
Pulled By: robhogan
fbshipit-source-id: f65f0d56053acf1c877fe0f368a7f4e13c8c57d1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39012
Upgrades many of our projects to `v8-compile-cache@^2.4.0`, which includes [zertosh/v8-compile-cache#45](https://github.com/zertosh/v8-compile-cache/pull/45). This fixes a very opaque segmentation fault when `v8-compile-cache` is used on Apple Silicon with mixed architecture modes.
This also upgrades our projects to `eslint@^2.3.1`, which no longer has the dependency on an outdated version of `v8-compile-cache`.
Changelog:
[Internal]
Reviewed By: zertosh, NickGerleman
Differential Revision: D48336030
fbshipit-source-id: afa73d1f00bff826a8b76fa09949b9d35a97905b
Summary:
X-link: https://github.com/facebook/metro/pull/987
While working on https://github.com/facebook/react-native/pull/35786 I noticed some inconsistencies in the versioning for Babel and Flow across the monorepo. So in this PR I wanted to address that so that for 0.72 we'll have the codebase in a more consistent shape.
Happy to split in multiple PRs if needed.
## Changelog
[GENERAL] [CHANGED] - Bump Babel packages to ^7.20.0 (or closest latest release), bump flow parser to 0.206.0 in a few places that were left out from latest bump
Pull Request resolved: https://github.com/facebook/react-native/pull/35787
Test Plan: CI is green.
Reviewed By: cipolleschi
Differential Revision: D42384881
Pulled By: hoxyq
fbshipit-source-id: 21fd43391d12722cf707c3cdbbb36f49c036359d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37347
This fixes the file-structure of `eslint-config-react-native-communtiy`, and `eslint-plugin-react-native-communtiy` to match the name they were renamed to as part of 0.72.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D45721173
fbshipit-source-id: 7ad784dbf56fb4cd05d7dba608e6d5064392e43d
Summary:
Renamed `eslint-config-react-native` to `eslint-config-react-native-community`, due to the fact, that initial name is already taken on `npm`. Additionally, I added very simple `README.md` file, to prepare the package to be published.
[General] [Changed] - Changed `eslint-config-react-native` name to `eslint-config-react-native-community`
Pull Request resolved: https://github.com/facebook/react-native/pull/23718
Differential Revision: D14298553
Pulled By: cpojer
fbshipit-source-id: bad5a42502ccdebf5f95d8217187be23bbf8f26c
Summary:
Basing on discussion from this issue - https://github.com/react-native-community/discussions-and-proposals/issues/65 we moved ESLint/Prettier config to its own package inside packages directory.
At this moment we had to left all `eslint` dependencies in root `package.json` since `eslint-config-react-native` is not published yet.
[General] [Changed] - Move eslint/prettier config to packages/eslint-config-react-native
Pull Request resolved: https://github.com/facebook/react-native/pull/23688
Differential Revision: D14277068
Pulled By: cpojer
fbshipit-source-id: ef2d0b33210418318cc8324f15fedd84df0ef64d