Граф коммитов

13 Коммитов

Автор SHA1 Сообщение Дата
MaeIg 38fcafe623 Extract the function createParserErrorCapturer into a single function in the parsers/utils.js file (#34934)
Summary:
This PR aims to reduce code duplication by extracting `createParserErrorCapturer` function from the flow and typescript folders into a shared parsers/utils.js file. It is a task of https://github.com/facebook/react-native/issues/34872:
> Extract the function createParserErrorCapturer ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/utils.js#L122-L143) [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/utils.js#L114-L135)) into a single function in the parsers/utils.js file and replace its invocation with this new function.

## 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
-->
[Internal] [Changed] - Extract the function createParserErrorCapturer into a single function in the parsers/utils.js file

Pull Request resolved: https://github.com/facebook/react-native/pull/34934

Test Plan:
yarn flow:
<img width="628" alt="image" src="https://user-images.githubusercontent.com/40902940/194948886-d6763e39-ea07-4004-86cc-5287c4783012.png">

yarn lint:
<img width="509" alt="image" src="https://user-images.githubusercontent.com/40902940/194948916-3e54afa5-7e0b-4a61-ac18-8ec306d8c6d4.png">

yarn jest react-native-codegen:
<img width="386" alt="image" src="https://user-images.githubusercontent.com/40902940/194948966-d1e5b12e-02ab-4d53-a4bf-6abaf4d70fbe.png">

Reviewed By: cipolleschi

Differential Revision: D40256048

Pulled By: cipolleschi

fbshipit-source-id: 098519a17d6e3128d236c639b246a706f9dbf66d
2022-10-11 05:24:25 -07:00
Rujin Cao 41c6c69aaa '@emails' -> '@oncall' (*.js)
Differential Revision: D39684030

fbshipit-source-id: 69f281e9e630334ca405a92f75b659795d9ad3e1
2022-09-21 20:47:05 -07:00
Christoph Purrer b444f0e44e react-native-code-gen Add Enum Type support for C++ TurboModules
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
2022-08-30 00:48:06 -07:00
Christoph Purrer 776046b89b Update flow-parser for react-native-codegen and eslint-plugin-spec
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
2022-08-18 11:32:01 -07:00
Dmitry Rykun ee9c1a5260 Add postpack hook that undoes prepack
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
2022-07-29 03:56:23 -07:00
Dmitry Rykun e44150409e Bump dependencies version number
Summary:
[Changelog][General] - Bump packages version number:
react-native/eslint-plugin-specs: ^0.71.0,
react-native-gradle-plugin: ^0.71.0,
react-native-codegen: ^0.71.0

Reviewed By: cortinico

Differential Revision: D38204441

fbshipit-source-id: 7188aae2decb307852e55a1b6b1180f3f068a75c
2022-07-27 08:19:11 -07:00
Lorenzo Sciandra 8441c4a6f7 fix npm lifecycle hook (#34273)
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
2022-07-26 06:47:51 -07:00
Nicola Corti ea8d8e2f49 Bump @react-native/eslint-plugin-specs to 0.0.4
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
2022-06-23 01:23:52 -07:00
Yann Pringault 97291bfa31 fix(eslint-config): switch to new babel parser (#34020)
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
2022-06-21 21:04:42 -07:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Luna Wei c034b7e7e1 Bump dependency on eslint-plugin-specs to minimum 0.0.2
Summary: Changelog: [Internal] - Update our release package.json to reference the react-native/eslint-plugin-specs module and a version > 0.0.2

Reviewed By: sota000

Differential Revision: D32973565

fbshipit-source-id: 49bfdb94f5dfdd9617e5849010241e4dda9dc9db
2021-12-09 15:57:20 -08:00
Luna Wei 2d06e6a4c9 eslint-plugin-specs prepublish step
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
2021-12-08 20:28:17 -08:00
Luna Wei bfc6392e1a Rename eslint-plugin-codegen to eslint-plugin-specs (#32698)
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
2021-12-02 20:47:12 -08:00