Skip to content

Commit

Permalink
Merge branch 'master' into async-server-action
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgezreik authored Apr 12, 2024
2 parents f3cb35c + 4467db5 commit 9d050e8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [`no-unknown-property`]: support `popover`, `popovertarget`, `popovertargetaction` attributes ([#3707][] @ljharb)
* [`no-unknown-property`]: only match `data-*` attributes containing `-` ([#3713][] @silverwind)
* [`checked-requires-onchange-or-readonly`]: correct options that were behaving opposite ([#3715][] @jaesoekjjang)
* [`boolean-prop-naming`]: avoid a crash with a non-TSTypeReference type ([#3718][] @developer-bandi)

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

[#3729]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3729
[#3718]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3718
[#3715]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3715
[#3713]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3713
[#3707]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3707
Expand Down
6 changes: 5 additions & 1 deletion lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ module.exports = {
} else if (annotation.type === 'TSTypeReference') {
propType = objectTypeAnnotations.get(annotation.typeName.name);
} else if (annotation.type === 'TSIntersectionType') {
propType = flatMap(annotation.types, (type) => objectTypeAnnotations.get(type.typeName.name));
propType = flatMap(annotation.types, (type) => (
type.type === 'TSTypeReference'
? objectTypeAnnotations.get(type.typeName.name)
: type
));
}

if (propType) {
Expand Down
33 changes: 31 additions & 2 deletions tests/lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -1312,10 +1312,10 @@ ruleTester.run('boolean-prop-naming', rule, {
code: `
type Props = {
enabled: boolean
}
};
type BaseProps = {
semi: boolean
}
};
const Hello = (props: Props & BaseProps) => <div />;
`,
Expand All @@ -1338,5 +1338,34 @@ ruleTester.run('boolean-prop-naming', rule, {
},
],
},
{
code: `
type Props = {
enabled: boolean
};
const Hello = (props: Props & {
semi: boolean
}) => <div />;
`,
options: [{ rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+' }],
features: ['ts', 'no-babel', 'no-ts-old'],
errors: [
{
messageId: 'patternMismatch',
data: {
propName: 'enabled',
pattern: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
},
},
{
messageId: 'patternMismatch',
data: {
propName: 'semi',
pattern: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
},
},
],
},
]),
});

0 comments on commit 9d050e8

Please sign in to comment.