Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 47bf8c7

Browse files
authored
feat(global): try TS workflow (#1013)
* chore(ts-workflow): basic setup * chore(ts-workflow): testId -> testid to avoid warning * chore(ts-workflow): resolve type warnings * chore(ts-workflow): rename _app * chore(ts-workflow): basic lint & rules setup * chore(ts-workflow): logic & store with ts support && rules adjust * chore(ts-workflow): tsx test * chore(ts-workflow): add tsc check, resolve errors * chore(ts-workflow): add tsc check, resolve errors * fix(ts-workflow): rootStore TS hint * refactor(ts-workflow): generator container store.js -> store.ts * refactor(ts-workflow): cycle import issue doc * refactor(ts-workflow): generator logic.js -> logic.ts * refactor(ts-workflow): generator index.js && styles.js to ts version * chore(ts-workflow): styles/*.js -> ts && resolve error/warning * chore(ts-workflow): more styles/*.js -> ts && resolve error/warning * chore(ts-workflow): more styles/*.js -> ts && resolve error/warning * chore(ts-workflow): resolve type warning * chore(ts-workflow): more js -> ts * ci(actions): use offical elixir action * fix(build): missing style error * chore(ts-workflow): utils js -> ts * fix(ts-workflow): type warnings
1 parent 13dafc3 commit 47bf8c7

File tree

643 files changed

+1084
-686
lines changed

Some content is hidden

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

643 files changed

+1084
-686
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
!.eslintrc.js
2+
.gitignore
3+
*.json
4+
*.lock
5+
*.hbs

.eslintrc.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
// see details:
22
// https://github.com/groupher/eslint-config-web/blob/master/index.js
33
module.exports = {
4-
extends: ['@groupher/eslint-config-web'],
4+
root: true,
5+
parser: '@typescript-eslint/parser',
6+
plugins: ['@typescript-eslint'],
7+
extends: [
8+
'@groupher/eslint-config-web',
9+
'eslint:recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
],
12+
// extends: ['@groupher/eslint-config-web'],
513
settings: {
14+
// see if the import lib exsit or not
15+
'import/parsers': {
16+
'@typescript-eslint/parser': ['.ts', '.tsx'],
17+
},
618
'import/resolver': {
719
'babel-module': {},
820
'eslint-import-resolver-custom-alias': {
@@ -14,20 +26,35 @@ module.exports = {
1426
'@/constant': 'utils/constant',
1527
'@/hooks': 'src/hooks',
1628
'@/hoc': 'src/hoc',
17-
'@/config': 'config',
1829
'@/stores': 'src/stores',
1930
'@/model': 'src/stores/SharedModel',
2031
'@/utils': 'utils',
2132
'@/schemas': 'src/schemas',
2233
'@/Img': 'src/components/Img',
2334
'@/SvgIcons': 'src/components/SvgIcons',
2435
'@/i18n': 'i18n',
36+
'@/types': 'src/types',
2537
},
26-
extensions: ['.js', '.jsx'],
38+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
2739
},
2840
},
2941
},
3042
rules: {
43+
'@typescript-eslint/ban-ts-comment': 0,
44+
'react/jsx-filename-extension': [
45+
2,
46+
{ extensions: ['.js', '.jsx', '.ts', '.tsx'] },
47+
],
3148
'import/no-named-as-default': 0,
49+
'import/extensions': [
50+
'error',
51+
'ignorePackages',
52+
{
53+
js: 'never',
54+
jsx: 'never',
55+
ts: 'never',
56+
tsx: 'never',
57+
},
58+
],
3259
},
3360
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
repository: 'coderplanets/coderplanets_server'
3030
path: 'backend_server'
3131
- name: (Backend) Setup Elixir and OTP
32-
uses: actions/setup-elixir@v1
32+
uses: erlef/setup-elixir@v1
3333
with:
3434
elixir-version: '1.10.3' # Define the elixir version [required]
3535
otp-version: '22.3' # Define the OTP version [required]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ cypress/videos/
1313
.vscode/
1414
.DS_Store
1515
report.*
16+
.eslintcache

next-env.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"clean": "shjs ./utils/scripts/clean.js",
2323
"gen": "plop --plopfile ./utils/scripts/generators/index.js",
2424
"analyze": "cross-env ANALYZE=true next build",
25-
"lint": "./node_modules/.bin/eslint --ext .js --fix src/ utils/",
26-
"lint:staged": "git diff --cached --name-only --diff-filter=ACRM | grep \".js$\" | xargs ./node_modules/.bin/eslint --ext .js",
25+
"lint": "./node_modules/.bin/eslint --ext .js,.ts,.tsx --fix src/ utils/",
26+
"lint:staged": "git diff --cached --name-only --diff-filter=ACRM | xargs ./node_modules/.bin/eslint --cache --ext .js,.ts,.tsx && tsc --noemit",
2727
"test": "cross-env NODE_ENV=test jest --config .jest.config.js",
2828
"test:dev": "cross-env NODE_ENV=test jest --config .jest.config.js",
2929
"test:watch": "npm run test -- --watch",
@@ -140,6 +140,9 @@
140140
"@commitlint/cli": "^8.2.0",
141141
"@commitlint/config-conventional": "^8.2.0",
142142
"@groupher/eslint-config-web": "2.0.9",
143+
"@types/ramda": "^0.27.38",
144+
"@typescript-eslint/eslint-plugin": "^4.17.0",
145+
"@typescript-eslint/parser": "^4.17.0",
143146
"babel-eslint": "^10.0.2",
144147
"babel-jest": "^23.6.0",
145148
"bundlewatch": "^0.2.7",
@@ -160,6 +163,7 @@
160163
"react-test-renderer": "16.10.0",
161164
"shelljs": "0.8.4",
162165
"standard-version": "^8.0.1",
163-
"start-server-and-test": "1.10.1"
166+
"start-server-and-test": "1.10.1",
167+
"typescript": "^4.2.3"
164168
}
165169
}

src/components/AlertBar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Wrapper } from './styles'
1515
const log = buildLog('c:AlertBar:index')
1616

1717
const AlertBar = ({ children }) => {
18-
return <Wrapper testId="alertBar">{children}</Wrapper>
18+
return <Wrapper testid="alertBar">{children}</Wrapper>
1919
}
2020

2121
AlertBar.propTypes = {

src/components/AlertBar/styles/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import styled from 'styled-components'
44
// import { theme } from '@/utils'
55

66
export const Wrapper = styled.div.attrs((props) => ({
7-
'data-test-id': props.testId,
7+
'data-test-id': props.testid,
88
}))`
99
font-size: 14px;
1010
font-variant: tabular-nums;

src/components/Buttons/NotifyButton/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import {
2525
/* eslint-disable-next-line */
2626
const log = buildLog('c:NotifyButton:index')
2727

28-
const NotifyButton = ({ testId, subscribed }) => {
28+
const NotifyButton = ({ testid, subscribed }) => {
2929
return (
30-
<Wrapper testId={testId}>
30+
<Wrapper testid={testid}>
3131
{subscribed ? (
3232
<Main>
3333
<NotifyOnIcon src={`${ICON}/article/notify-on.svg`} />
@@ -68,12 +68,12 @@ const NotifyButton = ({ testId, subscribed }) => {
6868
}
6969

7070
NotifyButton.propTypes = {
71-
testId: T.string,
71+
testid: T.string,
7272
subscribed: T.bool,
7373
}
7474

7575
NotifyButton.defaultProps = {
76-
testId: 'notify-button',
76+
testid: 'notify-button',
7777
subscribed: false,
7878
}
7979

src/components/Buttons/styles/notify_button/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Img from '@/Img'
44
import { css, theme } from '@/utils'
55

66
export const Wrapper = styled.div.attrs((props) => ({
7-
'data-test-id': props.testId,
7+
'data-test-id': props.testid,
88
}))`
99
${css.flexColumn()};
1010
`

0 commit comments

Comments
 (0)