Summary:
There are cases where we want to pass an enum type into a TurboModule method which is handy to restrict certain arguments to a restricted set of values, e.g. restricting quality to ```enum Quality { SD, HD, }```
Approach:
- We are not generating an ```enum``` type in C++ but rather just cast type safe to the corresponding member type.
- We don't support mixed enum types at this time, e.g. ```export enum StringOption { One = 'one', Two = 2, Three = 'three', };``` will not work. See: https://www.typescriptlang.org/docs/handbook/enums.html#heterogeneous-enums
- We only support untyped (default to String), String, and Number enum properties
This is for C++ only, Java and ObjC are not supported atm.
Changelog:
[General][Added] - react-native-code-gen Add Enum Type support for C++ TurboModules
Reviewed By: RSNara
Differential Revision: D38880963
fbshipit-source-id: f2399b29948306bc555429b6f96c43ea4c39c46e
Summary:
Updating flow-parser to a more recent version which also supports parsing enums
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D38832380
fbshipit-source-id: e3ef477abf85939ce3c9d92844e28dc59d8231c1
Summary: Changelog: [General][Changed] - `eslint-plugin-specs` package has prepack hook that changes `PACKAGE_USAGE` variable of `react-native-modules.js` to `true`. This changed file is can then be published to NPM, but should not be committed to the repo. This diff adds postpack hook that reverts the change, so we do not have to do it manually.
Reviewed By: cipolleschi
Differential Revision: D38244367
fbshipit-source-id: 818dbdea82e7e4b89094b3e27ae2d63b9e736659
Summary:
In `0.70-stable` we started seeing `yarn run lint` fail; turns out, this is happening because the latest release of `react-native/eslint-plugin-specs` 0.0.4 (from ea8d8e2f49) is faulty: the underlying reason is that since 0.0.2 there was this local workaround in place 2d06e6a4c9 (that changes a flag from false to true) but in NPM 8 the lifecycle hook `prepublish` has [been deprecated](https://docs.npmjs.com/cli/v8/using-npm/scripts#life-cycle-scripts) so this pre publishing script to change the flag was not run (you can easily verify by checking the node_module and see `react-native-modules.js` the flag on L17 is set to false).
This PR addresses it by moving to the new lifecycle hook `prepack` (and modifies the other files accordingly).
After this PR is merged, we'll need to cherry pick it into 0.70 and do both a new release from the 0.70 branch and one from the main branch to have new versions of this module with the flag set correctly.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[General] [Fixed] - Fix eslint-plugin-specs prepack npm lifecycle hook now that we use npm 8
Pull Request resolved: https://github.com/facebook/react-native/pull/34273
Test Plan: Go in the `eslint-plugin-specs` folder, run `npm pack`, unzip the generated tar file, go into `package`, verify that L17 of `react-native-modules.js` is correctly changed to `const PACKAGE_USAGE = true;` (instead of false - which is what happen without this fix).
Reviewed By: GijsWeterings
Differential Revision: D38151433
Pulled By: dmitryrykun
fbshipit-source-id: 7c4f13dae70eb731d57cbafa90f7be05c9bb8576
Summary:
As we changed the deps for react-native/eslint-plugin-specs, let's release a new version of it.
Changelog:
[General] [Changed] - Bump react-native/eslint-plugin-specs to 0.0.4
Reviewed By: jacdebug
Differential Revision: D37353474
fbshipit-source-id: dc77c987ee06d72903d246544c63816a64ecd7f6
Summary:
[`babel-eslint`](https://github.com/babel/babel-eslint) is deprecated now. We should use the new Babel parser.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[General] [Fixed] - Use new Babel parser instead of deprecated one
Pull Request resolved: https://github.com/facebook/react-native/pull/34020
Test Plan: Ensure lint is working as expected.
Reviewed By: cortinico
Differential Revision: D37239826
Pulled By: jacdebug
fbshipit-source-id: f5fa5d7f829d6d3ae5cffd855ed6c8542c7d46de
Summary:
#Changelog: [Internal] - This is an attempt to fix public publishing of eslint-plugin-specs. Currently, internal consumption of this package assumes access to `react-native-codegen/src` but for external usage, we leverage the published `react-native-codegen` which transforms files out to the `lib` folder vs. `src`.
For a similar-ish suit, this change is adding a prepublish step that will very basically update the references.
Reviewed By: mdvacca
Differential Revision: D32910080
fbshipit-source-id: f5e508090cbbf5097a848ddef3b721002a6c6277
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32698
Changelog: [Internal] - Renaming the eslint-plugin-codegen to eslint-plugin-specs as a better descriptor for this package. Part of the plan is to publish as a public npm package
Reviewed By: RSNara
Differential Revision: D32777702
fbshipit-source-id: 7776c481871031dba1280d87fb76b777ecc23339