Skip to content

Commit

Permalink
chore(eslint-plugin-vtex): right docs url for eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
gtkatakura committed Apr 29, 2024
1 parent 5c58793 commit cee7fd5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/eslint-plugin-vtex/CHANGELOG.md
Expand Up @@ -11,6 +11,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`
- Right docs path to eslint rules

## [2.2.1] - 2022-05-30
### Added
Expand Down
51 changes: 51 additions & 0 deletions packages/eslint-plugin-vtex/docs/rules/consistent-props-type.md
@@ -0,0 +1,51 @@
# Enforce the consistent way to define the props type (`vtex/consistent-props-type`)

Examples of **incorrect** code for this rule:

- Invalid props type name. Must be: DividerProps

```tsx
type Props = {}

const Divider = (props: Props) => {
return <hr {...props} />
}
```

- Invalid inline props type. DividerProps must define all the props.

```tsx
type DividerProps = {}

const Divider = (props: DividerProps & { inline: true }) => {
return <hr {...props} />
}
```

- Invalid generics props type name. Must be: Props

```tsx
type DividerProps = {}

const Divider = <T extends DividerProps>(props: T) => {
return <hr />
}
```

Examples of **correct** code for this rule:

```tsx
type DividerProps = {}

const Divider = (props: DividerProps) => {
return <hr {...props} />
}
```

```tsx
type DividerProps = {}

const Divider = <Props extends DividerProps>(props: Props) => {
return <hr />
}
```
2 changes: 1 addition & 1 deletion packages/eslint-plugin-vtex/src/createRule.ts
Expand Up @@ -2,5 +2,5 @@ import { ESLintUtils } from '@typescript-eslint/utils'

export const createRule = ESLintUtils.RuleCreator(
(name) =>
`https://github.com/vtex/typescript/tree/main/packages/eslint-plugin-vtex/docs/${name}.md`
`https://github.com/vtex/typescript/tree/main/packages/eslint-plugin-vtex/docs/rules/${name}.md`
)

0 comments on commit cee7fd5

Please sign in to comment.