From ea22ee6bf67aba86fcfb775a73830bca6a3ff633 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 16 Nov 2022 18:47:42 -0800 Subject: [PATCH] Fixup template devDependencies (#35372) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixes missing/incorrect devDependencies in a newly built app. The previous set did not pull in prettier, causing linting to fail. There was a peerDependency warning on yarn install. We also saw a separate lint warning at runtime specific to TS 4.9 being pulled in now, so we constrain in that version a bit. Prettier and preset-env versions match the constraints and lockfiles of other RN packages. ## Changelog [General] [Fixed] - Fixup template devDependencies Pull Request resolved: https://github.com/facebook/react-native/pull/35372 Test Plan: Created a new app targeting 0.71 via `react-native init`. 1. `yarn install --force` no longer shows warnings 2. `prettier` is installed, `yarn lint` no longer fails, and shows no warnings or errors 3. ~Tentatively a test step to add tests against linting in new app, but last time doing that in CircleCI led to timeouts with no output that I didn't have time to debug, so maybe that's fixed now? �‍♀️.~ (edit: still hangs) Reviewed By: NickGerleman Differential Revision: D41363021 Pulled By: lunaleaps fbshipit-source-id: d6163b01e8934d75a231fa0fd849d7bde7b3500c --- scripts/run-ci-e2e-tests.js | 11 +++++++++++ template/package.json | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index cdff750f319..9a928be712e 100644 --- a/scripts/run-ci-e2e-tests.js +++ b/scripts/run-ci-e2e-tests.js @@ -91,6 +91,7 @@ try { mv('_bundle', '.bundle'); mv('_eslintrc.js', '.eslintrc.js'); + mv('_prettierrc.js', '.prettierrc.js'); mv('_watchmanconfig', '.watchmanconfig'); describe('Install React Native package'); @@ -282,6 +283,16 @@ try { exitCode = 1; throw Error(exitCode); } + + // TODO: ESLint infinitely hangs when running in the environment created by + // this script, but not projects generated by `react-native init`. + /* + describe('Test: ESLint/Prettier linting and formatting'); + if (exec('yarn lint').code) { + echo('linting errors were found'); + exitCode = 1; + throw Error(exitCode); + }*/ } exitCode = 0; } finally { diff --git a/template/package.json b/template/package.json index f464239a1df..564730979ea 100644 --- a/template/package.json +++ b/template/package.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@babel/core": "^7.12.9", + "@babel/preset-env": "^7.14.0", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^3.0.0", "@tsconfig/react-native": "^2.0.2", @@ -27,8 +28,9 @@ "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.73.3", + "prettier": "^2.4.1", "react-test-renderer": "18.2.0", - "typescript": "^4.8.3" + "typescript": "4.8.4" }, "jest": { "preset": "react-native"