Skip to content

Commit 675408d

Browse files
authored
docs: add react version documentation (#80)
* fix: correct table in readme * doc: add documentation about React version
1 parent 020d6b4 commit 675408d

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

packages/eslint-plugin/.eslint-doc-generatorrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const { prettier: prettierRC } = require("./package.json"); // or wherever your
55
const config = {
66
postprocess: (content, path) =>
77
prettier.format(content, { ...prettierRC, parser: "markdown" }),
8-
urlRuleDoc: path => `
9-
https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/${path}.md`,
8+
urlRuleDoc: (path) =>
9+
`https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/${path}.md`,
1010
};
1111

1212
module.exports = config;

packages/eslint-plugin/README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ Update your `.vscode/settings.json` by adding the directories of apps using the
4141
}
4242
```
4343

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+
4457
## Shareable configurations
4558

4659
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
7487
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
7588
💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
7689

77-
| Name                                        | Description | 💼 | 🔧 | 💡 |
78-
| :------------------------------------------ | :---------- | :-- | :-- | :-- |
79-
80-
| [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 || 🔧 | |
82-
| [image-requires-accessible-prop](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/image-requires-accessible-prop.md) | Require accessible prop on image components || 🔧 | 💡 |
83-
| [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 | | | |
84-
| [requires-accessibility-label](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/requires-accessibility-label.md) | Enforces label when component accessible || | 💡 |
85-
| [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 || | 💡 |
90+
| Name                                        | Description | 💼 | 🔧 | 💡 |
91+
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------- | :-- | :-- | :-- |
92+
| [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 || 🔧 | |
94+
| [image-requires-accessible-prop](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/image-requires-accessible-prop.md) | Require accessible prop on image components || 🔧 | 💡 |
95+
| [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 | | | |
96+
| [requires-accessibility-label](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/requires-accessibility-label.md) | Enforces label when component accessible || | 💡 |
97+
| [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 || | 💡 |
8698

8799
<!-- end auto-generated rules list -->
88100

0 commit comments

Comments
 (0)