Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [`no-unused-state`]: avoid a crash ([#3258][] @WillyLiaoWH @ljharb)
* [`jsx-no-useless-fragment`]: use proper apostrophe in error message ([#3266][] @develohpanda)
* `propTypes`: handle imported types/interface in forwardRef generic ([#3280][] @vedadeepta)
* [`button-has-type`]: fix exception for `<button type>` ([#3255][] @meowtec)

### Changed
* [readme] remove global usage and eslint version from readme ([#3254][] @aladdin-add)
Expand Down Expand Up @@ -48,6 +49,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
[#3260]: https://github.jsx-eslintckcr/eslint-plugin-react/pull/3260
[#3259]: https://githubjsx-eslintickcr/eslint-plugin-react/pull/3259
[#3258]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3258
[#3255]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3255
[#3254]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3254
[#3251]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3251
[#3249]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3249
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/button-has-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module.exports = {
return;
}

if (typeProp.value.type === 'JSXExpressionContainer') {
if (typeProp.value && typeProp.value.type === 'JSXExpressionContainer') {
checkExpression(node, typeProp.value.expression);
return;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/button-has-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ ruleTester.run('button-has-type', rule, {
},
],
},
{
code: '<button type/>',
errors: [
{
messageId: 'invalidValue',
data: { value: true },
},
],
},
{
code: '<button type={condition ? "reset" : "button"}/>',
options: [{ reset: false }],
Expand Down