You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/eslint-plugin/README.md
+21-9Lines changed: 21 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,19 @@ Update your `.vscode/settings.json` by adding the directories of apps using the
41
41
}
42
42
```
43
43
44
+
### ⚠️ React version
45
+
46
+
With the introduction of React 18, it's no longer necessary to import React in your JSX files. The ESLint plugin is configured for React version 18 and above, so you won't encounter any errors. However, TypeScript will generate an error if it isn't configured correctly. To resolve this, simply add `"jsx": "react-native"` to your `tsconfig.json` file.
47
+
48
+
If your project is using a version of React that's below 18, iyou should upgrade to a newer version of React. If upgrading isn't an option, here's the situation: importing React in your JSX files remains mandatory, but ESLint won't flag any errors, even though it should. This is due to the plugin configuration; the recommended configuration extends the plugin react/jsx-runtime, which disables the following rules:
49
+
50
+
-`'react/jsx-uses-react': "error"`
51
+
-`'react/react-in-jsx-scope': "error"`
52
+
53
+
These rules are crucial as they trigger an error when React is not in scope. Therefore, you'll need to include them in the rules section of your .eslintrc.js file to ensure an error is flagged whenever someone omits the import for React.
54
+
55
+
Remember, the recommended solution is to upgrade to a newer version of React. This advice should only be disregarded in exceptional circumstances where upgrading React is not feasible.
56
+
44
57
## Shareable configurations
45
58
46
59
This plugin exports multiple configurations that can be used in your `.eslintrc` config file:
@@ -74,15 +87,14 @@ This plugin exports some custom rules that you can optionally use in your projec
74
87
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
75
88
💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
|[accessibility-props-require-accessible](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/accessibility-props-require-accessible.md)| Requires accessible prop when accessibility props are defined | ♿ | 🔧 ||
81
-
|[do-not-use-role-on-image](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/do-not-use-role-on-image.md)| Disallow role prop on Image component | ♿ | 🔧 ||
|[require-named-effect](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/require-named-effect.md)| Enforces the use of named functions inside a useEffect ||||
|[requires-accessibility-role-when-accessible](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/requires-accessibility-role-when-accessible.md)| Enforces accessibilityRole or role when component is accessible | ♿ || 💡 |
|[accessibility-props-require-accessible](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/accessibility-props-require-accessible.md)| Requires accessible prop when accessibility props are defined | ♿ | 🔧 ||
93
+
|[do-not-use-role-on-image](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/do-not-use-role-on-image.md)| Disallow role prop on Image component | ♿ | 🔧 ||
|[require-named-effect](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/require-named-effect.md)| Enforces the use of named functions inside a useEffect ||||
|[requires-accessibility-role-when-accessible](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/requires-accessibility-role-when-accessible.md)| Enforces accessibilityRole or role when component is accessible | ♿ || 💡 |
0 commit comments