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
Boolean. When set to `true`, this option ignores all attributes except for `children` during validation, preventing false positives in scenarios where these attributes are used safely or validated internally. Default is `false`.
Even with `ignoreAttributes: true`, `children` expressions are still checked. In the example above, `{value && <MyInnerChildComponent />}` will still be flagged.
185
+
186
+
Nested JSX children within attributes are also still checked:
187
+
188
+
```jsx
189
+
constComponent= ({ enabled }) => {
190
+
return (
191
+
<Foo bar={
192
+
<Something>{enabled &&<MuchWow />}</Something>
193
+
} />
194
+
)
195
+
}
196
+
```
197
+
198
+
Here, even though `<Something>…</Something>` is inside an attribute of `<Foo>`, the `{enabled && <MuchWow />}` expression is children of `<Something>`, so it is still flagged.
199
+
200
+
Examples of **correct** code for this rule, with the above configuration:
201
+
202
+
```jsx
203
+
constComponent= ({ enabled, checked }) => {
204
+
return<CheckBox checked={enabled && checked} />
205
+
}
206
+
```
207
+
208
+
With `ignoreAttributes: true`, logical expressions in non-children attributes like `checked` are not flagged.
209
+
156
210
### `validStrategies`
157
211
158
212
An array containing `"coerce"`, `"ternary"`, or both (default: `["ternary", "coerce"]`) - Decide which strategies are considered valid to prevent leaked renders (at least 1 is required). The "coerce" option will transform the conditional of the JSX expression to a boolean. The "ternary" option transforms the binary expression into a ternary expression returning `null` for falsy values. The first option from the array will be the strategy used when autofixing, so the order of the values matters.
0 commit comments