Skip to content

Commit 0a20666

Browse files
author
Anees Iqbal
committed
🆕 Allow ?? operator
1 parent 8c682ad commit 0a20666

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/rules/jsx-embed-condition.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ module.exports = {
2727
return {
2828
JSXExpressionContainer(node) {
2929
if (
30-
node.parent == null || node.parent.type !== 'JSXElement'
31-
|| node.expression == null || node.expression.type !== 'LogicalExpression'
30+
node.parent == null
31+
|| node.parent.type !== 'JSXElement'
32+
|| node.expression == null
33+
|| node.expression.type !== 'LogicalExpression'
34+
|| node.operator === '??'
3235
) {
3336
return;
3437
}

tests/lib/rules/jsx-embed-condition.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ ruleTester.run('jsx-embed-condition', rule, {
4040
code: '<App>{x ? <div>{y ? <y /> : <z />}</div> : null}</App>'
4141
}, {
4242
code: '<App x={x && y}>{x ? <div>{y ? <y /> : <z />}</div> : null}</App>'
43-
}],
43+
}
44+
// {
45+
// code: '<App test>{x ?? <div />}</App>'
46+
// }
47+
// TODO: ^ Using above gives a Parsing error in ESLint.
48+
// Is the parser out of date
49+
],
4450

4551
invalid: [{
4652
code: '<div>{x && <div />}</div>',

0 commit comments

Comments
 (0)