-
-
Notifications
You must be signed in to change notification settings - Fork 51
[rule] Disallow __html #1739
Copy link
Copy link
Open
Labels
area: react-xRules in eslint-plugin-react-xRules in eslint-plugin-react-xpriority: mediumNormal priorityNormal prioritystatus: triageNeeds initial review / classificationNeeds initial review / classificationtype: new-ruleIntroduce a new ESLint ruleIntroduce a new ESLint rule
Metadata
Metadata
Assignees
Labels
area: react-xRules in eslint-plugin-react-xRules in eslint-plugin-react-xpriority: mediumNormal priorityNormal prioritystatus: triageNeeds initial review / classificationNeeds initial review / classificationtype: new-ruleIntroduce a new ESLint ruleIntroduce a new ESLint rule
Problem Description
There's an existing
no-dangerously-set-innerhtmlrule to prevent the usage ofdangerouslySetInnerHTML.However, the actual issue is construction of the
__htmlobject. The original idea with__htmlis that the server-side (or a client-side HTML sanitization library) would sanitize the content, then return it as a__htmlobject. You'd then use this directly in the React component.Essentially, the
__htmlobject is a JSON-serializable way for the server (or a library) to communicate to the client that the string of HTML is safe to use directly. It's never supposed to be used directly in product code.Alternative Solutions
N/A
Rule Documentation Template
Rule Details
__htmlis an implementation detail used by server-side code (and client-side HTML sanitization libraries) to mark HTML text as safe to directly use in a React component. It should never appear in product code.Invalid
Valid
Evaluation Checklist