react-native-macos/packages/eslint-config-react-native-...
Tom Spencer ae67c5ac45 Disable ESLint `no-undef` for TypeScript files (#32655)
Summary:
The `typescript-eslint` project [recommends that `no-undef` is disabled for TypeScript files](6c3816b383/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:

<img width="506" alt="Screenshot 2021-11-24 at 12 38 22" src="https://user-images.githubusercontent.com/820863/143239961-eb8ed709-60f9-490a-bda3-fc581673d56c.png">

- 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`:

<img width="419" alt="Screenshot 2021-11-24 at 12 40 04" src="https://user-images.githubusercontent.com/820863/143240213-06428b24-09c8-4f95-8e77-7f4fd160eed1.png">

## 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] - 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
2021-12-02 14:43:36 -08:00
..
README.md docs: mention prettier in eslint-config README (#28930) 2020-05-20 03:32:46 -07:00
index.js Disable ESLint `no-undef` for TypeScript files (#32655) 2021-12-02 14:43:36 -08:00
package.json RN: Upgrade ESLint Packages (#32560) 2021-11-09 13:16:42 -08:00
yarn.lock RN: Upgrade ESLint Packages (#32560) 2021-11-09 13:16:42 -08:00

README.md

eslint-config-react-native-community

Version

Installation

yarn add --dev eslint prettier @react-native-community/eslint-config

Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like

Usage

Add to your eslint config (.eslintrc, or eslintConfig field in package.json):

{
    "extends": "@react-native-community"
}