mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Summary: Upgrades the severity of the [`react/jsx-no-comment-textnodes`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md) lint rule from warning to error. The higher severity is warranted because, in React Native code in particular, rendering an unintended text node is likely to throw an error at runtime (unless it happens to be wrapped in `<Text />`). Furthermore, this lint is highly actionable because there's always a workaround that is less ambiguous: 1. If intending to write a comment (likely), wrap it in curly braces: `<>{ /* this is a comment */ }</>` 2. If intending to write an actual text node beginning with `//` or `/*` (unlikely), wrap it in curly braces and quotes: `<>{'/* this is a text node */'}</>` Changelog: [Internal] Reviewed By: GijsWeterings Differential Revision: D25615642 fbshipit-source-id: d5a59989b04c244111071893efc546083641ac54
eslint-config-react-native-community
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"
}