Skip to content

Commit 877df2c

Browse files
authored
Merge pull request #91 from vtex-apps/chore/pr-actions
Chore/pr actions
2 parents 11a7a57 + 3653747 commit 877df2c

10 files changed

+1543
-979
lines changed

.eslintrc.json

-9
This file was deleted.

.github/workflows/pull-request.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: PR actions
2+
'on':
3+
pull_request:
4+
branches:
5+
- master
6+
jobs:
7+
danger-ci:
8+
name: Danger CI
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@master
12+
- uses: actions/setup-node@master
13+
with:
14+
node-version: 12.x
15+
env:
16+
RUNNER_TEMP: /tmp
17+
- name: Danger CI
18+
uses: vtex/danger@master
19+
env:
20+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
21+
REQUIRE_CHANGELOG_VERSION: false
22+
io-app-test:
23+
name: IO app test
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@master
27+
- uses: actions/setup-node@master
28+
with:
29+
node-version: 12.x
30+
env:
31+
RUNNER_TEMP: /tmp
32+
- name: Get yarn cache directory path
33+
id: yarn-cache-dir-path
34+
run: 'echo "::set-output name=dir::$(yarn cache dir)"'
35+
- uses: actions/cache@v1
36+
id: yarn-cache
37+
with:
38+
path: '${{ steps.yarn-cache-dir-path.outputs.dir }}'
39+
key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}"
40+
restore-keys: |
41+
${{ runner.os }}-yarn-
42+
- name: Run test on every builder directory
43+
uses: vtex/action-io-app-test@master
44+
lint:
45+
name: Lint
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@master
49+
- uses: actions/setup-node@master
50+
with:
51+
node-version: 12.x
52+
env:
53+
RUNNER_TEMP: /tmp
54+
- name: Get yarn cache directory path
55+
id: yarn-cache-dir-path
56+
run: 'echo "::set-output name=dir::$(yarn cache dir)"'
57+
- uses: actions/cache@v1
58+
id: yarn-cache
59+
with:
60+
path: '${{ steps.yarn-cache-dir-path.outputs.dir }}'
61+
key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}"
62+
restore-keys: |
63+
${{ runner.os }}-yarn-
64+
- name: yarn install
65+
run: yarn install --frozen-lockfile
66+
- name: Lint project
67+
uses: vtex/action-lint@master

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Security
10+
- Bump multiple package versions.
911

1012
## [2.0.4] - 2020-04-28
1113
### Fixed

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"license": "UNLICENSED",
55
"scripts": {
6-
"lint": "cd ./react && yarn lint",
6+
"lint": "eslint --ext ts,tsx .",
77
"format": "prettier --write \"**/*.{ts,js,json}\"",
88
"test": "cd ./react && yarn test",
99
"lint:locales": "intl-equalizer",
@@ -21,6 +21,9 @@
2121
"eslint --fix",
2222
"prettier --write"
2323
],
24+
"*.{json,graphql,gql}": [
25+
"prettier --write"
26+
],
2427
"*.json": [
2528
"prettier --write"
2629
]
@@ -31,7 +34,7 @@
3134
"@vtex/prettier-config": "^0.1.3",
3235
"eslint": "^6.8.0",
3336
"eslint-config-vtex": "^12.2.1",
34-
"eslint-config-vtex-react": "^5.1.0",
37+
"eslint-config-vtex-react": "^6.1.0",
3538
"husky": "^4.2.0",
3639
"lint-staged": "^10.0.2",
3740
"prettier": "^1.19.1",

react/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "vtex-react",
2+
"extends": "vtex-react/io",
33
"env": {
44
"browser": true,
55
"es6": true,

react/Search.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { FC, Fragment } from 'react'
2-
import { prop } from 'ramda'
32
import { useQuery } from 'react-apollo'
43

54
import RightArrow from './components/icons/RightArrow'
@@ -12,31 +11,35 @@ interface Props {
1211
}
1312
}
1413

14+
interface SearchQueryResult {
15+
searchEngine: SearchResult[]
16+
}
17+
1518
interface SearchResult {
1619
title: string
1720
snippet: string
1821
link: string
1922
}
2023

21-
const isNotLastResult = (results: [SearchResult], index: number) =>
24+
const isNotLastResult = (results: SearchResult[], index: number) =>
2225
index !== results.length - 1
2326

2427
const isFirstResult = (index: number) => index === 0
2528

2629
const Search: FC<Props> = ({ query }) => {
2730
const queryString = query.q || ''
2831

29-
const { data, loading } = useQuery(searchEngine, {
32+
const { data, loading } = useQuery<SearchQueryResult>(searchEngine, {
3033
variables: { searchQuery: queryString },
3134
})
3235

33-
const results: [SearchResult] = prop('searchEngine', data) || []
36+
const results = data?.searchEngine ?? []
3437

3538
return (
3639
<Fragment>
3740
{!loading ? (
3841
queryString && (
39-
<div className={`w-100 flex flex-column`}>
42+
<div className="w-100 flex flex-column">
4043
<h1 className="t-heading-3">
4144
{results.length > 0
4245
? `Results for "${queryString}"`

react/components/AppVersionContext.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function useAppVersionDispatch() {
109109
const EnhancedAppVersionProvider: FC = ({ children }) => {
110110
const { route, navigate } = useRuntime()
111111
const app = route?.params?.app || IO_DOCUMENTATION
112-
const appName = app.split('@')[0]
112+
const [appName] = app.split('@')
113113
const appVersionFromUrl = app?.split('@')[1]
114114

115115
const { data, loading, error } = useQuery(publishedQuery, {
@@ -121,14 +121,15 @@ const EnhancedAppVersionProvider: FC = ({ children }) => {
121121
// Just a bit hacky: It always check if the url has a trailing slash, setting it if not.
122122
// It's useful for README's that link to other files
123123
useEffect(() => {
124-
if (!appVersionFromUrl || route.path.endsWith('/')){
124+
if (!appVersionFromUrl || route.path.endsWith('/')) {
125125
return
126126
}
127127
navigate({
128-
to: route.path + '/',
128+
to: `${route.path}/`,
129129
replace: true,
130-
preventRemount: true
130+
preventRemount: true,
131131
})
132+
// eslint-disable-next-line react-hooks/exhaustive-deps
132133
}, [route.path])
133134

134135
// Always set the app's version on the URL (except io-documentation)
@@ -145,8 +146,9 @@ const EnhancedAppVersionProvider: FC = ({ children }) => {
145146
navigate({
146147
page: route.id,
147148
params: { ...currentParams, app: updatedApp },
148-
replace: true
149+
replace: true,
149150
})
151+
// eslint-disable-next-line react-hooks/exhaustive-deps
150152
}, [data])
151153

152154
if (loading) {

react/components/SearchBar.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const SearchBar: FC = () => {
1010

1111
const [inputString, setInputString] = useState(queryString ?? '')
1212

13-
const handleSubmit = (e: any) => {
13+
const handleSubmit = (e: React.FormEvent) => {
1414
e.preventDefault()
1515
if (inputString !== '') {
1616
navigate({
@@ -22,8 +22,8 @@ const SearchBar: FC = () => {
2222
}
2323

2424
return (
25-
<div className={`flex items-center`}>
26-
<form onSubmit={(e: any) => handleSubmit(e)}>
25+
<div className="flex items-center">
26+
<form onSubmit={(e: React.FormEvent) => handleSubmit(e)}>
2727
<InputSearch
2828
placeholder="Search IO Docs..."
2929
value={inputString}
@@ -32,7 +32,7 @@ const SearchBar: FC = () => {
3232
}) => {
3333
setInputString(e.target.value)
3434
}}
35-
onSubmit={(e: any) => handleSubmit(e)}
35+
onSubmit={(e: React.FormEvent) => handleSubmit(e)}
3636
size="small"
3737
/>
3838
</form>

0 commit comments

Comments
 (0)