Skip to content

Commit

Permalink
Upgrade react/jsx-no-comment-textnodes lint to an error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
motiz88 authored and facebook-github-bot committed Dec 17, 2020
1 parent 4537131 commit 8c8172f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-config-react-native-community/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ module.exports = {

'react/display-name': 0,
'react/jsx-boolean-value': 0,
'react/jsx-no-comment-textnodes': 1,
'react/jsx-no-comment-textnodes': 2,
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-undef': 2,
'react/jsx-sort-props': 0,
Expand Down

0 comments on commit 8c8172f

Please sign in to comment.