Skip to content

Commit

Permalink
Fix @react-native/eslint-config linting of jsx files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Dec 1, 2022
1 parent 07c8854 commit 59ee573
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/eslint-config-react-native-community/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = {

parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},

extends: ['plugin:prettier/recommended'],
Expand Down Expand Up @@ -46,6 +49,9 @@ module.exports = {
'ft-flow/use-flow-type': 1,
},
},
{
files: ['*.jsx'],
},
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
Expand Down

0 comments on commit 59ee573

Please sign in to comment.