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 @@ -7,7 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

### Fixed
* [`jsx-no-leaked-render`]: prevent wrongly adding parens ([#3700][] @developer-bandi)
* [`boolean-prop-naming`]: detect TS interfaces ([#3701][] @developer-bandi)

[#3701]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3701
[#3700]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3700

## [7.34.0] - 2024.03.03
Expand Down
8 changes: 6 additions & 2 deletions lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ module.exports = {
}

function findAllTypeAnnotations(identifier, node) {
if (node.type === 'TSTypeLiteral' || node.type === 'ObjectTypeAnnotation') {
if (node.type === 'TSTypeLiteral' || node.type === 'ObjectTypeAnnotation' || node.type === 'TSInterfaceBody') {
const currentNode = [].concat(
objectTypeAnnotations.get(identifier.name) || [],
node
Expand Down Expand Up @@ -363,6 +363,10 @@ module.exports = {
findAllTypeAnnotations(node.id, node.typeAnnotation);
},

TSInterfaceDeclaration(node) {
findAllTypeAnnotations(node.id, node.body);
},

// eslint-disable-next-line object-shorthand
'Program:exit'() {
if (!rule) {
Expand All @@ -386,7 +390,7 @@ module.exports = {
[].concat(propType).forEach((prop) => {
validatePropNaming(
component.node,
prop.properties || prop.members
prop.properties || prop.members || prop.body
);
});
}
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -1239,5 +1239,20 @@ ruleTester.run('boolean-prop-naming', rule, {
},
],
},
{
code: `
interface TestFNType {
enabled: boolean
}
const HelloNew = (props: TestFNType) => { return <div /> };
`,
options: [{ rule: '^is[A-Z]([A-Za-z0-9]?)+' }],
features: ['ts', 'no-babel'],
errors: [
{
message: 'Prop name (enabled) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)',
},
],
},
]),
});