From ae67c5ac45a8044fc1db66aee8eae6e881d660e4 Mon Sep 17 00:00:00 2001 From: Tom Spencer Date: Thu, 2 Dec 2021 14:42:03 -0800 Subject: [PATCH] Disable ESLint `no-undef` for TypeScript files (#32655) Summary: The `typescript-eslint` project [recommends that `no-undef` is disabled for TypeScript files](https://github.com/typescript-eslint/typescript-eslint/blob/6c3816b3831e6e683c1a7842196b34248803d69b/docs/linting/TROUBLESHOOTING.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors), since TypeScript itself will perform this check. Disabling this config property has two benefits: - Undefined variables and types will only be reported once, by the TypeScript compiler. Currently they are reported twice: once by TypeScript, and once by ESLint: Screenshot 2021-11-24 at 12 38 22 - Types that are declared globally by React Native will no longer be erroneously reported as undefined - this is currently the case for some types, e.g. `Blob`: Screenshot 2021-11-24 at 12 40 04 ## Changelog [General] [Fixed] - ESLint no-undef rule clashing with TypeScript compiler for TS files Pull Request resolved: https://github.com/facebook/react-native/pull/32655 Test Plan: - Before: ESLint reporting on undefined variables in TypeScript files - After: ESLint no longer reporting on undefined variables in TypeScript files Reviewed By: GijsWeterings Differential Revision: D32647147 Pulled By: yungsters fbshipit-source-id: 070c734ac7a075b556492726c8fecf4fdab65898 --- packages/eslint-config-react-native-community/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-react-native-community/index.js b/packages/eslint-config-react-native-community/index.js index b9b7ee2273491d..e57ae48b77c660 100644 --- a/packages/eslint-config-react-native-community/index.js +++ b/packages/eslint-config-react-native-community/index.js @@ -58,6 +58,7 @@ module.exports = { 'no-unused-vars': 'off', 'no-shadow': 'off', '@typescript-eslint/no-shadow': 1, + 'no-undef': 'off', }, }, {