Skip to content

Commit 4d3f6dc

Browse files
committed
chore: improve typescript app config too
1 parent 6024adc commit 4d3f6dc

File tree

3 files changed

+82
-29
lines changed

3 files changed

+82
-29
lines changed

examples/TypeScriptMessaging/eslint.config.mjs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
import eslintPluginReact from 'eslint-plugin-react';
22
import eslintPluginReactNative from 'eslint-plugin-react-native';
3+
import eslintPluginReactNativeOfficial from '@react-native/eslint-plugin';
34
import eslintPluginComments from 'eslint-plugin-eslint-comments';
45
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
56
import eslintPluginJest from 'eslint-plugin-jest';
67

78
import eslintReactNativeConfig from '@react-native/eslint-config';
89

9-
import typescriptParser from '@typescript-eslint/parser';
10+
import tsEslint from 'typescript-eslint';
1011

12+
/**
13+
* @react-native/eslint-config is for some reason still using the old notation
14+
* for globals. We parse them manually here to make sure they're compatible with
15+
* the new config. All globals which were previously set to true are now readonly.
16+
*/
1117
const globals = Object.keys(eslintReactNativeConfig.globals).reduce((acc, key) => {
1218
if (eslintReactNativeConfig.globals[key]) {
1319
acc[key] = 'readonly';
1420
}
1521
return acc;
1622
}, {});
1723

18-
export default [
24+
export default tsEslint.config(
25+
tsEslint.configs.recommended,
1926
{
2027
ignores: ['node_modules/', 'dist/', '**/*.config.js'],
2128
},
@@ -24,13 +31,24 @@ export default [
2431
languageOptions: {
2532
ecmaVersion: 'latest',
2633
sourceType: 'module',
27-
parser: typescriptParser,
34+
parser: tsEslint.parser,
35+
parserOptions: {
36+
ecmaFeatures: {
37+
jsx: true,
38+
},
39+
},
2840
globals: {
2941
...globals,
3042
console: 'readonly',
3143
},
3244
},
45+
settings: {
46+
react: {
47+
version: 'detect',
48+
},
49+
},
3350
plugins: {
51+
'@react-native': eslintPluginReactNativeOfficial,
3452
react: eslintPluginReact,
3553
'react-native': eslintPluginReactNative,
3654
'eslint-comments': eslintPluginComments,
@@ -43,4 +61,4 @@ export default [
4361
'react-native/no-inline-styles': 'off',
4462
},
4563
},
46-
];
64+
);

examples/TypeScriptMessaging/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"ios": "react-native run-ios",
88
"start": "react-native start",
99
"test": "jest",
10-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
10+
"lint": "eslint .",
1111
"clean": "watchman watch-del-all && yarn cache clean && rm -rf ios/build && pod cache clean --all && rm -rf android/build && cd android && ./gradlew clean && cd -",
1212
"clean-all": "yarn clean && rm -rf node_modules && rm -rf ios/Pods && rm -rf vendor && bundle install && yarn install && cd ios && bundle exec pod install && cd -"
1313
},
@@ -43,13 +43,13 @@
4343
"@react-native-community/cli-platform-ios": "15.1.3",
4444
"@react-native/babel-preset": "0.77.1",
4545
"@react-native/eslint-config": "^0.77.1",
46+
"@react-native/eslint-plugin": "^0.77.1",
4647
"@react-native/metro-config": "0.77.1",
4748
"@react-native/typescript-config": "0.77.1",
4849
"@rnx-kit/metro-config": "^2.0.1",
4950
"@types/jest": "^29.5.13",
5051
"@types/react": "^18.2.6",
5152
"@types/react-test-renderer": "^18.0.0",
52-
"@typescript-eslint/parser": "^8.24.1",
5353
"eslint": "^9.20.1",
5454
"eslint-plugin-eslint-comments": "^3.2.0",
5555
"eslint-plugin-jest": "^28.11.0",
@@ -59,6 +59,7 @@
5959
"jest": "^29.7.0",
6060
"prettier": "^3.5.1",
6161
"react-test-renderer": "18.3.1",
62-
"typescript": "5.7.3"
62+
"typescript": "5.7.3",
63+
"typescript-eslint": "^8.24.1"
6364
}
6465
}

examples/TypeScriptMessaging/yarn.lock

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@
17931793
eslint-plugin-react-hooks "^4.6.0"
17941794
eslint-plugin-react-native "^4.0.0"
17951795

1796-
"@react-native/[email protected]":
1796+
"@react-native/[email protected]", "@react-native/eslint-plugin@^0.77.1":
17971797
version "0.77.1"
17981798
resolved "https://registry.yarnpkg.com/@react-native/eslint-plugin/-/eslint-plugin-0.77.1.tgz#34e13d7bab2af1a0d68fc609547ba205df51331d"
17991799
integrity sha512-K1nuM/aLWYpUq8y/KJ34UCazYE4gdY1mxkwXhRSadDVpogK4Z/0xbSGYZQDHfvmOyQMZkM6mplQLztGrxD/CvA==
@@ -2132,6 +2132,21 @@
21322132
dependencies:
21332133
"@types/yargs-parser" "*"
21342134

2135+
"@typescript-eslint/[email protected]":
2136+
version "8.24.1"
2137+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.24.1.tgz#d104c2a6212304c649105b18af2c110b4a1dd4ae"
2138+
integrity sha512-ll1StnKtBigWIGqvYDVuDmXJHVH4zLVot1yQ4fJtLpL7qacwkxJc1T0bptqw+miBQ/QfUbhl1TcQ4accW5KUyA==
2139+
dependencies:
2140+
"@eslint-community/regexpp" "^4.10.0"
2141+
"@typescript-eslint/scope-manager" "8.24.1"
2142+
"@typescript-eslint/type-utils" "8.24.1"
2143+
"@typescript-eslint/utils" "8.24.1"
2144+
"@typescript-eslint/visitor-keys" "8.24.1"
2145+
graphemer "^1.4.0"
2146+
ignore "^5.3.1"
2147+
natural-compare "^1.4.0"
2148+
ts-api-utils "^2.0.1"
2149+
21352150
"@typescript-eslint/eslint-plugin@^7.1.1":
21362151
version "7.18.0"
21372152
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz#b16d3cf3ee76bf572fdf511e79c248bdec619ea3"
@@ -2147,6 +2162,17 @@
21472162
natural-compare "^1.4.0"
21482163
ts-api-utils "^1.3.0"
21492164

2165+
"@typescript-eslint/[email protected]":
2166+
version "8.24.1"
2167+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.24.1.tgz#67965c2d2ddd7eadb2f094c395695db8334ef9a2"
2168+
integrity sha512-Tqoa05bu+t5s8CTZFaGpCH2ub3QeT9YDkXbPd3uQ4SfsLoh1/vv2GEYAioPoxCWJJNsenXlC88tRjwoHNts1oQ==
2169+
dependencies:
2170+
"@typescript-eslint/scope-manager" "8.24.1"
2171+
"@typescript-eslint/types" "8.24.1"
2172+
"@typescript-eslint/typescript-estree" "8.24.1"
2173+
"@typescript-eslint/visitor-keys" "8.24.1"
2174+
debug "^4.3.4"
2175+
21502176
"@typescript-eslint/parser@^7.1.1":
21512177
version "7.18.0"
21522178
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.18.0.tgz#83928d0f1b7f4afa974098c64b5ce6f9051f96a0"
@@ -2158,17 +2184,6 @@
21582184
"@typescript-eslint/visitor-keys" "7.18.0"
21592185
debug "^4.3.4"
21602186

2161-
"@typescript-eslint/parser@^8.24.1":
2162-
version "8.24.1"
2163-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.24.1.tgz#67965c2d2ddd7eadb2f094c395695db8334ef9a2"
2164-
integrity sha512-Tqoa05bu+t5s8CTZFaGpCH2ub3QeT9YDkXbPd3uQ4SfsLoh1/vv2GEYAioPoxCWJJNsenXlC88tRjwoHNts1oQ==
2165-
dependencies:
2166-
"@typescript-eslint/scope-manager" "8.24.1"
2167-
"@typescript-eslint/types" "8.24.1"
2168-
"@typescript-eslint/typescript-estree" "8.24.1"
2169-
"@typescript-eslint/visitor-keys" "8.24.1"
2170-
debug "^4.3.4"
2171-
21722187
"@typescript-eslint/[email protected]":
21732188
version "5.62.0"
21742189
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz#d9457ccc6a0b8d6b37d0eb252a23022478c5460c"
@@ -2203,6 +2218,16 @@
22032218
debug "^4.3.4"
22042219
ts-api-utils "^1.3.0"
22052220

2221+
"@typescript-eslint/[email protected]":
2222+
version "8.24.1"
2223+
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.24.1.tgz#99113e1df63d1571309d87eef68967344c78dd65"
2224+
integrity sha512-/Do9fmNgCsQ+K4rCz0STI7lYB4phTtEXqqCAs3gZW0pnK7lWNkvWd5iW545GSmApm4AzmQXmSqXPO565B4WVrw==
2225+
dependencies:
2226+
"@typescript-eslint/typescript-estree" "8.24.1"
2227+
"@typescript-eslint/utils" "8.24.1"
2228+
debug "^4.3.4"
2229+
ts-api-utils "^2.0.1"
2230+
22062231
"@typescript-eslint/[email protected]":
22072232
version "5.62.0"
22082233
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f"
@@ -2269,6 +2294,16 @@
22692294
"@typescript-eslint/types" "7.18.0"
22702295
"@typescript-eslint/typescript-estree" "7.18.0"
22712296

2297+
"@typescript-eslint/[email protected]", "@typescript-eslint/utils@^6.0.0 || ^7.0.0 || ^8.0.0":
2298+
version "8.24.1"
2299+
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.24.1.tgz#08d14eac33cfb3456feeee5a275b8ad3349e52ed"
2300+
integrity sha512-OOcg3PMMQx9EXspId5iktsI3eMaXVwlhC8BvNnX6B5w9a4dVgpkQZuU8Hy67TolKcl+iFWq0XX+jbDGN4xWxjQ==
2301+
dependencies:
2302+
"@eslint-community/eslint-utils" "^4.4.0"
2303+
"@typescript-eslint/scope-manager" "8.24.1"
2304+
"@typescript-eslint/types" "8.24.1"
2305+
"@typescript-eslint/typescript-estree" "8.24.1"
2306+
22722307
"@typescript-eslint/utils@^5.10.0":
22732308
version "5.62.0"
22742309
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86"
@@ -2283,16 +2318,6 @@
22832318
eslint-scope "^5.1.1"
22842319
semver "^7.3.7"
22852320

2286-
"@typescript-eslint/utils@^6.0.0 || ^7.0.0 || ^8.0.0":
2287-
version "8.24.1"
2288-
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.24.1.tgz#08d14eac33cfb3456feeee5a275b8ad3349e52ed"
2289-
integrity sha512-OOcg3PMMQx9EXspId5iktsI3eMaXVwlhC8BvNnX6B5w9a4dVgpkQZuU8Hy67TolKcl+iFWq0XX+jbDGN4xWxjQ==
2290-
dependencies:
2291-
"@eslint-community/eslint-utils" "^4.4.0"
2292-
"@typescript-eslint/scope-manager" "8.24.1"
2293-
"@typescript-eslint/types" "8.24.1"
2294-
"@typescript-eslint/typescript-estree" "8.24.1"
2295-
22962321
"@typescript-eslint/[email protected]":
22972322
version "5.62.0"
22982323
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz#2174011917ce582875954ffe2f6912d5931e353e"
@@ -7301,6 +7326,15 @@ typed-array-length@^1.0.7:
73017326
possible-typed-array-names "^1.0.0"
73027327
reflect.getprototypeof "^1.0.6"
73037328

7329+
typescript-eslint@^8.24.1:
7330+
version "8.24.1"
7331+
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.24.1.tgz#ce85d791392608a2a9f80c4b2530a214d16a2a47"
7332+
integrity sha512-cw3rEdzDqBs70TIcb0Gdzbt6h11BSs2pS0yaq7hDWDBtCCSei1pPSUXE9qUdQ/Wm9NgFg8mKtMt1b8fTHIl1jA==
7333+
dependencies:
7334+
"@typescript-eslint/eslint-plugin" "8.24.1"
7335+
"@typescript-eslint/parser" "8.24.1"
7336+
"@typescript-eslint/utils" "8.24.1"
7337+
73047338
73057339
version "5.7.3"
73067340
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e"

0 commit comments

Comments
 (0)