From 59ee57352738f030b41589a450209e51e44bbb06 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 1 Dec 2022 12:10:46 -0800 Subject: [PATCH] Fix @react-native/eslint-config linting of jsx files Summary: `react-native/eslint-config` enables rules for TypeScript and `.js` files (as Flow), but seems to completely no-op if you have a `.jsx` file. Enabling it in an override leads to syntax errors because the config has not been enlightened on how to parse JSX. This would normally happen if a config extended `plugin:react/recommended`, but we are already cutomizing the React plugin rules. So we instead just directly set `ecmaFeatures: {jsx: true}` as reccomended by https://github.com/jsx-eslint/eslint-plugin-react. Changelog: [General][Breaking] - Fix react-native/eslint-config linting of jsx files Reviewed By: rickhanlonii Differential Revision: D41654962 fbshipit-source-id: 778da0928fadb86caa6a33254379d3d7dd394892 --- packages/eslint-config-react-native-community/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/eslint-config-react-native-community/index.js b/packages/eslint-config-react-native-community/index.js index c7fd706c8b2bdf..00b9bc5512588b 100644 --- a/packages/eslint-config-react-native-community/index.js +++ b/packages/eslint-config-react-native-community/index.js @@ -14,6 +14,9 @@ module.exports = { parserOptions: { sourceType: 'module', + ecmaFeatures: { + jsx: true, + }, }, extends: ['plugin:prettier/recommended'], @@ -46,6 +49,9 @@ module.exports = { 'ft-flow/use-flow-type': 1, }, }, + { + files: ['*.jsx'], + }, { files: ['*.ts', '*.tsx'], parser: '@typescript-eslint/parser',