Skip to content

Commit

Permalink
[Test] jsx-key: add a failing test case for optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLee-LX authored and ljharb committed Mar 29, 2020
1 parent da7a045 commit 12686c4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/lib/rules/jsx-key.js
Expand Up @@ -50,7 +50,7 @@ ruleTester.run('jsx-key', rule, {
{code: 'foo(() => <></>);', parser: parsers.BABEL_ESLINT},
{code: '<></>;', parser: parsers.BABEL_ESLINT}
],
invalid: [{
invalid: [].concat({
code: '[<App />];',
errors: [{message: 'Missing "key" prop for element in array'}]
}, {
Expand All @@ -69,6 +69,14 @@ ruleTester.run('jsx-key', rule, {
code: '[1, 2 ,3].map(x => { return <App /> });',
errors: [{message: 'Missing "key" prop for element in iterator'}]
}, {
code: '[1, 2, 3]?.map(x => <BabelEslintApp />)',
parser: parsers.BABEL_ESLINT,
errors: [{message: 'Missing "key" prop for element in iterator'}]
}, parsers.TS({
code: '[1, 2, 3]?.map(x => <TypescriptEslintApp />)',
parser: parsers['@TYPESCRIPT_ESLINT'],
errors: [{message: 'Missing "key" prop for element in iterator'}]
}), {
code: '[1, 2, 3].map(x => <>{x}</>);',
parser: parsers.BABEL_ESLINT,
options: [{checkFragmentShorthand: true}],
Expand All @@ -80,5 +88,5 @@ ruleTester.run('jsx-key', rule, {
options: [{checkFragmentShorthand: true}],
settings,
errors: [{message: 'Missing "key" prop for element in array. Shorthand fragment syntax does not support providing keys. Use Act.Frag instead'}]
}]
})
});

0 comments on commit 12686c4

Please sign in to comment.