jsx-key
NOTE: this rule is included the following rule sets:
recommendedreactjsxEnable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"] // ...or "react", "jsx"
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended # or ... deno lint --rules-tags=react # or ... deno lint --rules-tags=jsx
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["jsx-key"],
"exclude": ["jsx-key"]
}
}
}Ensure the key attribute is present when passing iterables into JSX. It allows
frameworks to optimize checking the order of elements.
Invalid:
const foo = [<div>foo</div>];
const foo = [<>foo</>];
[1, 2, 3].map(() => <div />);
Array.from([1, 2, 3], () => <div />);
Valid:
const foo = [<div key="a">foo</div>];
const foo = [<Fragment key="b">foo</Fragment>];
[1, 2, 3].map((x) => <div key={x} />);
Array.from([1, 2, 3], (x) => <div key={x} />);