Skip to content

Commit 096161a

Browse files
authored
Merge pull request #2120 from jomasti/issue-2119
[Fix] `jsx-indent`: Prevent crash on valueless props
2 parents 230c7e0 + 9d3955a commit 096161a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/rules/jsx-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ module.exports = {
253253
}
254254

255255
function handleAttribute(node) {
256-
if (!checkAttributes || node.value.type !== 'JSXExpressionContainer') {
256+
if (!checkAttributes || (!node.value || node.value.type !== 'JSXExpressionContainer')) {
257257
return;
258258
}
259259
const nameIndent = getNodeIndent(node.name);

tests/lib/rules/jsx-indent.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,18 @@ const Component = () => (
820820
);
821821
`,
822822
options: ['tab', {checkAttributes: false}]
823+
}, {
824+
code: `
825+
function Foo() {
826+
return (
827+
<input
828+
type="radio"
829+
defaultChecked
830+
/>
831+
);
832+
}
833+
`,
834+
options: [2, {checkAttributes: true}]
823835
}],
824836

825837
invalid: [{

0 commit comments

Comments
 (0)