From 9eba4e6e48ce323b52fb9660db691c5c7750edad Mon Sep 17 00:00:00 2001 From: Emin Khateeb Date: Fri, 20 Dec 2019 08:36:16 +0100 Subject: [PATCH] completed eslint ts setup and fixed eslint issues (#112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * completed eslint ts setup and fixed eslint issues * minor change in direction 😄 * upgraded type definitions * declared custom global variable * moved global var definition below imports --- README.md | 2 +- template/App.tsx | 5 +++-- template/_eslintrc.js | 2 ++ template/package.json | 7 ++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c16110f..f4ebee6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ ## :arrow_forward: Usage ### Note on the legacy CLI -There seems to be quite some confusion about the legacy CLI. This template only works with the new CLI. Make sure you have uninstalled the legacy `react-native-cli` first (`npm uninstall -g react-native-cli`), for the above command to work. If you wish to not use `npx`, you can also install the new CLI globally (`npm i -g @react-native-community/cli` or `yarn global add @react-native-community/cli`). +There seems to be quite some confusion about the legacy CLI. This template only works with the new CLI. Make sure you have uninstalled the legacy `react-native-cli` first (`npm uninstall -g react-native-cli`), for the below command to work. If you wish to not use `npx`, you can also install the new CLI globally (`npm i -g @react-native-community/cli` or `yarn global add @react-native-community/cli`). Further information can be found here: https://github.com/react-native-community/cli#about diff --git a/template/App.tsx b/template/App.tsx index aae764d..843b783 100644 --- a/template/App.tsx +++ b/template/App.tsx @@ -26,8 +26,9 @@ import { ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; +declare var global: {HermesInternal: null | {}}; + const App = () => { - const usingHermes = typeof HermesInternal === 'object' && HermesInternal !== null; return ( <> @@ -36,7 +37,7 @@ const App = () => { contentInsetAdjustmentBehavior="automatic" style={styles.scrollView}>
- {!usingHermes ? null : ( + {global.HermesInternal == null ? null : ( Engine: Hermes diff --git a/template/_eslintrc.js b/template/_eslintrc.js index 40c6dcd..1896997 100644 --- a/template/_eslintrc.js +++ b/template/_eslintrc.js @@ -1,4 +1,6 @@ module.exports = { root: true, extends: '@react-native-community', + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], }; diff --git a/template/package.json b/template/package.json index 344e159..b8cfac7 100644 --- a/template/package.json +++ b/template/package.json @@ -17,9 +17,10 @@ "@babel/core": "^7.6.2", "@babel/runtime": "^7.6.2", "@react-native-community/eslint-config": "^0.0.5", - "@types/jest": "^24.0.18", - "@types/react-native": "^0.60.22", - "@types/react-test-renderer": "16.9.0", + "@types/jest": "^24.0.24", + "@types/react-native": "^0.60.25", + "@types/react-test-renderer": "16.9.1", + "@typescript-eslint/eslint-plugin": "^2.12.0", "@typescript-eslint/parser": "^2.12.0", "babel-jest": "^24.9.0", "eslint": "^6.5.1",