Skip to content

Commit

Permalink
feat(eslint-plugin-vtex): support ObjectPattern for consistent-props-…
Browse files Browse the repository at this point in the history
…types
  • Loading branch information
gtkatakura committed Apr 29, 2024
1 parent d3bf294 commit a34a5d3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/eslint-plugin-vtex/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Changes entrypoint to dist/index.js
- Support to ObjectPattern on the component props for `vtex/consistent-props-type`

## [2.2.1] - 2022-05-30
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,48 @@ ruleTester.run('consistent-props-type', consistentPropsType, {
],
},

{
code: `
function Divider({ inline }: { inline: boolean }) {
return <hr />
}
`,
errors: [
{
messageId: 'invalidInlinePropsType',
data: { expectedPropsTypeName: 'DividerProps' },
},
],
},

{
code: `
function Divider({ inline, ...props }: { inline: boolean }) {
return <hr />
}
`,
errors: [
{
messageId: 'invalidInlinePropsType',
data: { expectedPropsTypeName: 'DividerProps' },
},
],
},

{
code: `
function Divider({ ...props }: { inline: boolean }) {
return <hr />
}
`,
errors: [
{
messageId: 'invalidInlinePropsType',
data: { expectedPropsTypeName: 'DividerProps' },
},
],
},

{
code: `
const Divider = (props: { inline: boolean } & { intersection: true }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const consistentPropsType = createRule({

create(context) {
return {
':function > Identifier > TSTypeAnnotation'(
':function > :matches(Identifier, ObjectPattern) > TSTypeAnnotation'(
node: TSESTree.TSTypeAnnotation
) {
if (isInsideAnotherFunction(context)) return
Expand Down

0 comments on commit a34a5d3

Please sign in to comment.