Skip to content

Commit 9d050e8

Browse files
authored
Merge branch 'master' into async-server-action
2 parents f3cb35c + 4467db5 commit 9d050e8

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1313
* [`no-unknown-property`]: support `popover`, `popovertarget`, `popovertargetaction` attributes ([#3707][] @ljharb)
1414
* [`no-unknown-property`]: only match `data-*` attributes containing `-` ([#3713][] @silverwind)
1515
* [`checked-requires-onchange-or-readonly`]: correct options that were behaving opposite ([#3715][] @jaesoekjjang)
16+
* [`boolean-prop-naming`]: avoid a crash with a non-TSTypeReference type ([#3718][] @developer-bandi)
1617

1718
### Changed
1819
* [`boolean-prop-naming`]: improve error message (@ljharb)
@@ -22,6 +23,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
2223
- [`async-server-action`]: add rule ([#3729][] @jorgezreik)
2324

2425
[#3729]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3729
26+
[#3718]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3718
2527
[#3715]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3715
2628
[#3713]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3713
2729
[#3707]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3707

lib/rules/boolean-prop-naming.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,11 @@ module.exports = {
387387
} else if (annotation.type === 'TSTypeReference') {
388388
propType = objectTypeAnnotations.get(annotation.typeName.name);
389389
} else if (annotation.type === 'TSIntersectionType') {
390-
propType = flatMap(annotation.types, (type) => objectTypeAnnotations.get(type.typeName.name));
390+
propType = flatMap(annotation.types, (type) => (
391+
type.type === 'TSTypeReference'
392+
? objectTypeAnnotations.get(type.typeName.name)
393+
: type
394+
));
391395
}
392396

393397
if (propType) {

tests/lib/rules/boolean-prop-naming.js

+31-2
Original file line numberDiff line numberDiff line change
@@ -1312,10 +1312,10 @@ ruleTester.run('boolean-prop-naming', rule, {
13121312
code: `
13131313
type Props = {
13141314
enabled: boolean
1315-
}
1315+
};
13161316
type BaseProps = {
13171317
semi: boolean
1318-
}
1318+
};
13191319
13201320
const Hello = (props: Props & BaseProps) => <div />;
13211321
`,
@@ -1338,5 +1338,34 @@ ruleTester.run('boolean-prop-naming', rule, {
13381338
},
13391339
],
13401340
},
1341+
{
1342+
code: `
1343+
type Props = {
1344+
enabled: boolean
1345+
};
1346+
1347+
const Hello = (props: Props & {
1348+
semi: boolean
1349+
}) => <div />;
1350+
`,
1351+
options: [{ rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+' }],
1352+
features: ['ts', 'no-babel', 'no-ts-old'],
1353+
errors: [
1354+
{
1355+
messageId: 'patternMismatch',
1356+
data: {
1357+
propName: 'enabled',
1358+
pattern: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
1359+
},
1360+
},
1361+
{
1362+
messageId: 'patternMismatch',
1363+
data: {
1364+
propName: 'semi',
1365+
pattern: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
1366+
},
1367+
},
1368+
],
1369+
},
13411370
]),
13421371
});

0 commit comments

Comments
 (0)