Skip to content

Commit ce26dc2

Browse files
ismayHendrikThePendric
ismay
andauthored
ci: replace semantic commit checks with new workflow (#1188)
* ci: replace semantic commit checks with new workflow * style: fix prettier errors * ci: fix lint script * ci: fix lint script * style: ignore import extension errors * style: ignore prop-type errors * style: remove unused eslint disable * chore: fix husky after rebase * chore: address eslint violation after rebase Co-authored-by: Hendrik de Graaf <[email protected]>
1 parent edb2d8d commit ce26dc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+922
-429
lines changed

.eslintrc.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ const { config } = require('@dhis2/cli-style')
22

33
module.exports = {
44
extends: [config.eslintReact],
5-
plugins: ['react-hooks'],
65
rules: {
7-
'react-hooks/rules-of-hooks': 'error',
86
'react-hooks/exhaustive-deps': 'error',
7+
'import/extensions': 'off',
98
},
109
}

.github/semantic.yml

-4
This file was deleted.
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'dhis2: verify (commits)'
2+
3+
on:
4+
pull_request:
5+
types: ['opened', 'edited', 'reopened', 'synchronize']
6+
7+
jobs:
8+
lint-pr-title:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: c-hive/gha-yarn-cache@v1
13+
- run: yarn install --frozen-lockfile
14+
- id: commitlint
15+
run: echo ::set-output name=config_path::$(node -e "process.stdout.write(require('@dhis2/cli-style').config.commitlint)")
16+
- uses: JulienKode/[email protected]
17+
with:
18+
configuration-path: ${{ steps.commitlint.outputs.config_path }}
19+
20+
lint-commits:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
- uses: c-hive/gha-yarn-cache@v1
27+
- run: yarn install --frozen-lockfile
28+
- id: commitlint
29+
run: echo ::set-output name=config_path::$(node -e "process.stdout.write(require('@dhis2/cli-style').config.commitlint)")
30+
- uses: wagoid/commitlint-github-action@v4
31+
with:
32+
configFile: ${{ steps.commitlint.outputs.config_path }}

.hooks/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn d2-style check commit "$1"

.hooks/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn d2-style check --staged

.huskyrc.js

-15
This file was deleted.

docs/advanced/offline.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,8 @@ export function CacheableSectionWrapper({ id }) {
7171
import { useCacheableSections } from '@dhis2/app-runtime'
7272

7373
function DemoComponent() {
74-
const {
75-
startRecording,
76-
remove,
77-
lastUpdated,
78-
isCached,
79-
recordingState,
80-
} = useCacheableSection(id)
74+
const { startRecording, remove, lastUpdated, isCached, recordingState } =
75+
useCacheableSection(id)
8176
}
8277
```
8378

@@ -115,11 +110,11 @@ function StartRecordingButton({ id }) {
115110
startRecording({
116111
onStarted: () => console.log('Recording started'),
117112
onCompleted: () => console.log('Recording completed'),
118-
onError: err => console.error(err),
113+
onError: (err) => console.error(err),
119114
recordingTimeoutDelay: 1000, // the default
120115
})
121116
.then(() => console.log('startRecording signal sent successfully'))
122-
.catch(err =>
117+
.catch((err) =>
123118
console.error(`Error when starting recording: ${err}`)
124119
)
125120
}

docs/hooks/useAlerts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Alerter = () => {
3535
const Alerts = () => {
3636
const alerts = useAlerts()
3737

38-
return alerts.map(alert => (
38+
return alerts.map((alert) => (
3939
<div key={alert.id}>
4040
{alert.message}
4141
<button onClick={alert.remove}>hide</button>

docs/hooks/useDataQuery.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const IndicatorList = () => {
6464
{data && (
6565
<pre>
6666
{data.indicators.indicators
67-
.map(ind => ind.displayName)
67+
.map((ind) => ind.displayName)
6868
.join('\n')}
6969
</pre>
7070
)}
@@ -101,7 +101,7 @@ export const IndicatorList = () => {
101101
const pager = data?.indicators?.pager
102102
const hasNextPage = pager?.nextPage
103103

104-
const handlePageChange = nextPage => {
104+
const handlePageChange = (nextPage) => {
105105
// "page" variable in query is passed via refetch below
106106
refetch({ page: nextPage })
107107
}
@@ -114,7 +114,7 @@ export const IndicatorList = () => {
114114
{data && (
115115
<pre>
116116
{data.indicators.indicators
117-
.map(ind => ind.displayName)
117+
.map((ind) => ind.displayName)
118118
.join('\n')}
119119
</pre>
120120
)}

examples/cra/src/components/Alerts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react'
44
export const Alerts = () => {
55
const alerts = useAlerts()
66

7-
return alerts.map(alert => (
7+
return alerts.map((alert) => (
88
<div key={alert.id}>
99
{alert.message}
1010
<button onClick={alert.remove}>hide</button>

examples/cra/src/components/IndicatorList.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const query = {
1616

1717
export const IndicatorList = () => {
1818
const { loading, error, data, refetch } = useDataQuery(query)
19-
const { show } = useAlert(id => `Created indicator ${id}`)
19+
const { show } = useAlert((id) => `Created indicator ${id}`)
2020
return (
2121
<div>
2222
<h3>Indicators</h3>
@@ -25,7 +25,7 @@ export const IndicatorList = () => {
2525
{data && (
2626
<>
2727
<pre>
28-
{data.indicators.indicators.map(ind => (
28+
{data.indicators.indicators.map((ind) => (
2929
<Indicator
3030
key={ind.id}
3131
indicator={ind}
@@ -46,7 +46,7 @@ export const IndicatorList = () => {
4646
&lt;- Previous
4747
</button>
4848
<AddButton
49-
onCreate={result => {
49+
onCreate={(result) => {
5050
show(result.response.uid)
5151
refetch()
5252
}}

examples/cra/src/components/SwitchableProvider.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react/prop-types */
2+
13
import { Provider, DataProvider } from '@dhis2/app-runtime'
24
import React from 'react'
35

examples/cra/src/serviceWorker.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function register(config) {
5757
function registerValidSW(swUrl, config) {
5858
navigator.serviceWorker
5959
.register(swUrl)
60-
.then(registration => {
60+
.then((registration) => {
6161
registration.onupdatefound = () => {
6262
const installingWorker = registration.installing
6363
if (installingWorker == null) {
@@ -93,15 +93,15 @@ function registerValidSW(swUrl, config) {
9393
}
9494
}
9595
})
96-
.catch(error => {
96+
.catch((error) => {
9797
console.error('Error during service worker registration:', error)
9898
})
9999
}
100100

101101
function checkValidServiceWorker(swUrl, config) {
102102
// Check if the service worker can be found. If it can't reload the page.
103103
fetch(swUrl)
104-
.then(response => {
104+
.then((response) => {
105105
// Ensure service worker exists, and that we really are getting a JS file.
106106
const contentType = response.headers.get('content-type')
107107
if (
@@ -110,7 +110,7 @@ function checkValidServiceWorker(swUrl, config) {
110110
contentType.indexOf('javascript') === -1)
111111
) {
112112
// No service worker found. Probably a different app. Reload the page.
113-
navigator.serviceWorker.ready.then(registration => {
113+
navigator.serviceWorker.ready.then((registration) => {
114114
registration.unregister().then(() => {
115115
window.location.reload()
116116
})
@@ -129,7 +129,7 @@ function checkValidServiceWorker(swUrl, config) {
129129

130130
export function unregister() {
131131
if ('serviceWorker' in navigator) {
132-
navigator.serviceWorker.ready.then(registration => {
132+
navigator.serviceWorker.ready.then((registration) => {
133133
registration.unregister()
134134
})
135135
}

examples/query-playground/src/components/Editor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'brace/theme/monokai'
66
import 'brace/theme/github'
77
import './Editor.css'
88

9-
export const Editor = props => (
9+
export const Editor = (props) => (
1010
<AceEditor
1111
fontSize={14}
1212
mode="json"

examples/query-playground/src/components/QueryEditor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const defaultMutation = {
2222
},
2323
}
2424

25-
const getDefaultQueryByType = type =>
25+
const getDefaultQueryByType = (type) =>
2626
JSON.stringify(type === 'query' ? defaultQuery : defaultMutation, null, 4)
2727

2828
export const QueryEditor = ({
@@ -51,7 +51,7 @@ export const QueryEditor = ({
5151
execute({ query: parsed, type }).then(setResult)
5252
}
5353

54-
const onKeyPress = event => {
54+
const onKeyPress = (event) => {
5555
if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') {
5656
onExecute()
5757
event.stopPropagation()

examples/query-playground/src/components/TabControls.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ const TabControl = ({
3838
onEditDoneClick()
3939
}
4040

41-
const onEditIconClick = event => {
41+
const onEditIconClick = (event) => {
4242
event.stopPropagation()
4343
onEditClick()
4444
}
4545

46-
const onRemoveIconClick = event => {
46+
const onRemoveIconClick = (event) => {
4747
event.stopPropagation()
4848
onRemoveTab()
4949
}
@@ -72,7 +72,7 @@ const TabControl = ({
7272
)}
7373

7474
{edit && (
75-
<div onClick={e => e.stopPropagation()}>
75+
<div onClick={(e) => e.stopPropagation()}>
7676
<Modal>
7777
<form onSubmit={save}>
7878
<ModalTitle>Edit tab name</ModalTitle>

examples/query-playground/src/hooks/useExecuteQuery.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useDataEngine } from '@dhis2/app-runtime'
22
import { useState } from 'react'
33

4-
const stringify = obj => JSON.stringify(obj, undefined, 2)
4+
const stringify = (obj) => JSON.stringify(obj, undefined, 2)
55

66
export const useExecuteQuery = () => {
77
const engine = useDataEngine()

examples/query-playground/src/hooks/useTabs.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ const spliceTabs = (tabs, index, updatedTab) => {
2323
return [...before, ...updated, ...after]
2424
}
2525

26-
const newTab = id => {
26+
const newTab = (id) => {
2727
return { ...tabTemplate, id, name: `Query ${id}` }
2828
}
2929

30-
const initTabState = storageNameSpace => {
30+
const initTabState = (storageNameSpace) => {
3131
if (localStorage.getItem(storageNameSpace)) {
3232
const { version, ...storedState } = JSON.parse(
3333
localStorage.getItem(storageNameSpace)
@@ -42,9 +42,9 @@ const initTabState = storageNameSpace => {
4242
tabs: [newTab(1)],
4343
}
4444
}
45-
const nextAvailableId = tabs => {
45+
const nextAvailableId = (tabs) => {
4646
let candidate = 0
47-
while (tabs.some(tab => tab.id === candidate)) {
47+
while (tabs.some((tab) => tab.id === candidate)) {
4848
++candidate
4949
}
5050
return candidate
@@ -98,13 +98,13 @@ const reducer = (state, action) => {
9898
}
9999
}
100100

101-
const prepareForStorage = state => ({
101+
const prepareForStorage = (state) => ({
102102
version: VERSION,
103103
...state,
104-
tabs: state.tabs.map(tab => ({ ...tab, result: '' })),
104+
tabs: state.tabs.map((tab) => ({ ...tab, result: '' })),
105105
})
106106

107-
const useTabState = storageNameSpace => {
107+
const useTabState = (storageNameSpace) => {
108108
const [state, dispatch] = useReducer(
109109
reducer,
110110
storageNameSpace,
@@ -124,7 +124,7 @@ const useTabState = storageNameSpace => {
124124
})
125125
}
126126

127-
const removeTab = index => {
127+
const removeTab = (index) => {
128128
dispatch({
129129
type: 'remove',
130130
payload: {
@@ -143,7 +143,7 @@ const useTabState = storageNameSpace => {
143143
})
144144
}
145145

146-
const setActiveTab = index => {
146+
const setActiveTab = (index) => {
147147
dispatch({
148148
type: 'setActive',
149149
payload: {
@@ -166,14 +166,13 @@ const useTabState = storageNameSpace => {
166166
export const useTabs = () => {
167167
const { baseUrl } = useConfig()
168168
const storageNameSpace = `playground-${baseUrl}`
169-
const [state, { addTab, removeTab, editTab, setActiveTab }] = useTabState(
170-
storageNameSpace
171-
)
169+
const [state, { addTab, removeTab, editTab, setActiveTab }] =
170+
useTabState(storageNameSpace)
172171

173-
const setName = name => editTab(state.activeTab, { name })
174-
const setQuery = query => editTab(state.activeTab, { query })
175-
const setResult = result => editTab(state.activeTab, { result })
176-
const setType = type => editTab(state.activeTab, { type })
172+
const setName = (name) => editTab(state.activeTab, { name })
173+
const setQuery = (query) => editTab(state.activeTab, { query })
174+
const setResult = (result) => editTab(state.activeTab, { result })
175+
const setType = (type) => editTab(state.activeTab, { type })
177176

178177
return {
179178
activeTab: state.activeTab,

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"devDependencies": {
1313
"@dhis2/cli-app-scripts": "^6.2.0",
14-
"@dhis2/cli-style": "^7.2.2",
14+
"@dhis2/cli-style": "^10.4.1",
1515
"@dhis2/cli-utils-docsite": "^2.0.3",
1616
"@testing-library/jest-dom": "^5.14.1",
1717
"@testing-library/react": "^12.0.0",
@@ -48,11 +48,11 @@
4848
"test:services": "loop \"yarn test\" --cwd ./services --exit-on-error",
4949
"test:runtime": "cd runtime && yarn test",
5050
"test": "yarn test:services && yarn test:runtime",
51-
"format": "d2-style js apply --all --no-stage && d2-style text apply --all --no-stage",
51+
"format": "d2-style apply js --all --no-stage && d2-style apply text --all --no-stage",
5252
"start": "yarn build && cd examples/query-playground && yarn start",
5353
"docs:build": "d2-utils-docsite build ./docs -o ./dist && yarn build:playground",
5454
"docs:serve": "d2-utils-docsite serve ./docs -o ./dist",
55-
"lint": "d2-style js check && d2-style text check"
55+
"lint": "d2-style check js && d2-style check text"
5656
},
5757
"d2": {
5858
"docsite": {

0 commit comments

Comments
 (0)