Skip to content

Commit

Permalink
Merge pull request #115 from vtex/feat/rule-consistent-props-type
Browse files Browse the repository at this point in the history
feat(eslint-plugin): support to ts on the codebase + new consistent-props-type rule
  • Loading branch information
gtkatakura committed Apr 29, 2024
2 parents bec549e + 2f2f3c3 commit c6b28d1
Show file tree
Hide file tree
Showing 27 changed files with 2,784 additions and 299 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/ci.yml
@@ -1,6 +1,12 @@
name: CI

on: [push, pull_request]
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
Lint:
Expand All @@ -9,10 +15,13 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '14'
node-version: '18'
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run build
run: yarn build

- name: Run lint
run: yarn lint

Expand All @@ -27,12 +36,10 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '14'
node-version: '18'

- name: Install dependencies
run: |
yarn install --frozen-lockfile
yarn --cwd fixtures/app install --no-lockfile
run: yarn install --frozen-lockfile

- name: Verdaccio login
run: |
Expand Down Expand Up @@ -63,6 +70,13 @@ jobs:
--no-push \
--yes
- uses: actions/setup-node@v1
with:
node-version: '14'

- name: Install dependencies
run: yarn --cwd fixtures/app install --no-lockfile

- name: Install packages and run test
if: steps.changed-packages.outputs.PACKAGES
run: |
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-vtex-react/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-vtex-react",
"version": "9.0.3",
"version": "9.0.8-alpha.0",
"description": "VTEX's eslint config for React",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -36,7 +36,7 @@
"directory": "packages/eslint-config-vtex-react"
},
"dependencies": {
"eslint-config-vtex": "^15.0.2",
"eslint-config-vtex": "^15.0.7-alpha.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-vtex/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-vtex",
"version": "15.0.2",
"version": "15.0.7-alpha.0",
"description": "VTEX's eslint config",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vtex": "^2.2.1"
"eslint-plugin-vtex": "^2.2.6-alpha.0"
},
"peerDependencies": {
"eslint": "^8",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-vtex/.gitignore
@@ -0,0 +1,2 @@
# package build
dist
2 changes: 2 additions & 0 deletions packages/eslint-plugin-vtex/CHANGELOG.md
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- `vtex/consistent-props-type` rule

## [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 />
}
```
11 changes: 0 additions & 11 deletions packages/eslint-plugin-vtex/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions packages/eslint-plugin-vtex/lib/includes/getDocUrl.js

This file was deleted.

84 changes: 0 additions & 84 deletions packages/eslint-plugin-vtex/lib/rules/prefer-early-return.js

This file was deleted.

This file was deleted.

0 comments on commit c6b28d1

Please sign in to comment.