Skip to content

Commit

Permalink
Merge pull request #2120 from jomasti/issue-2119
Browse files Browse the repository at this point in the history
[Fix] `jsx-indent`: Prevent crash on valueless props
  • Loading branch information
ljharb committed Jan 4, 2019
2 parents 230c7e0 + 9d3955a commit 096161a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent.js
Expand Up @@ -253,7 +253,7 @@ module.exports = {
}

function handleAttribute(node) {
if (!checkAttributes || node.value.type !== 'JSXExpressionContainer') {
if (!checkAttributes || (!node.value || node.value.type !== 'JSXExpressionContainer')) {
return;
}
const nameIndent = getNodeIndent(node.name);
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/jsx-indent.js
Expand Up @@ -820,6 +820,18 @@ const Component = () => (
);
`,
options: ['tab', {checkAttributes: false}]
}, {
code: `
function Foo() {
return (
<input
type="radio"
defaultChecked
/>
);
}
`,
options: [2, {checkAttributes: true}]
}],

invalid: [{
Expand Down

0 comments on commit 096161a

Please sign in to comment.