Skip to content

Commit 6f6f0a0

Browse files
committed
ts,tsx code format
1 parent c9fa8af commit 6f6f0a0

Some content is hidden

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

66 files changed

+307
-306
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module.exports = {
8484
'@typescript-eslint/space-before-function-paren': [2],
8585
'@typescript-eslint/keyword-spacing': [2, ],
8686
'@typescript-eslint/comma-spacing': 2,
87-
'@typescript-eslint/type-annotation-spacing': 2
87+
'@typescript-eslint/type-annotation-spacing': 2,
88+
'@typescript-eslint/ban-types': 0
8889
}
8990
}

src/components/editor/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const toolbarOptions = [
2929
interface IEditor {
3030
disabled?: boolean
3131
value: string
32-
onChange(text: string): Function
32+
onChange(text: string): () => void
3333
}
3434

3535
export default class QuillEditorComponent extends React.Component<IEditor> {
@@ -49,7 +49,7 @@ export default class QuillEditorComponent extends React.Component<IEditor> {
4949

5050
$editor: HTMLDivElement = null
5151

52-
componentDidMount() {
52+
componentDidMount () {
5353
const { onChange } = this.props
5454
const { $editor } = this
5555
this.quillEditor = new Quill($editor, this.quillOptions)
@@ -59,7 +59,7 @@ export default class QuillEditorComponent extends React.Component<IEditor> {
5959
if (_html === '<p><br></p>') {
6060
_html = ''
6161
}
62-
if(this.oldVal !== _html) {
62+
if (this.oldVal !== _html) {
6363
this.oldVal = _html
6464
onChange && onChange(_html)
6565
}
@@ -70,13 +70,13 @@ export default class QuillEditorComponent extends React.Component<IEditor> {
7070
changeEditorText = () => {
7171
const { value } = this.props
7272
// 赋值
73-
if(this.oldVal !== value && value !== undefined && this.quillEditor) {
73+
if (this.oldVal !== value && value !== undefined && this.quillEditor) {
7474
this.quillEditor.root.innerHTML = value
7575
this.oldVal = value
7676
}
7777
}
7878

79-
render(){
79+
render () {
8080
const { disabled } = this.props
8181
this.changeEditorText()
8282

src/components/loading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface ILoadingProps {
77

88
export default class Loading extends React.Component<ILoadingProps> {
99

10-
render() {
10+
render () {
1111
const { size = 'default' } = this.props
1212

1313
return (

src/pages/article/articleCreate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ export default class ArticleCreate extends React.Component<IProps> {
2929
this.props.history.push(`/home/blog-article/${id}`)
3030
}
3131

32-
componentDidMount() {
32+
componentDidMount () {
3333
this.props.articleCreateStore.getInitData()
3434
}
3535

36-
render(){
36+
render () {
3737
const { mainData, typeList, tagList, tagChange, inputChange, save } = this.props.articleCreateStore
3838

3939
return <React.Fragment>

src/pages/article/articleCreateStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class articleCreateStore {
4444
})
4545
}
4646

47-
@action save = (cb: Function) => {
47+
@action save = (cb: (args: any) => void) => {
4848
this.loading = true
4949

5050
$http.post(GRAPHQL_API, {
5151
query: postArticle,
5252
variables: {input: this.mainData}
5353
}).then((res: any) => {
54-
const {article:{id}} = res.data
54+
const {article: {id}} = res.data
5555
cb(id)
5656
runInAction(() => {
5757
this.loading = false

src/pages/article/articleEdit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export default class ArticleEdit extends React.Component<IProps> {
2525
this.props.history.go(-1)
2626
}
2727

28-
componentDidMount() {
28+
componentDidMount () {
2929
const {id}: any = this.props.match.params
3030
this.props.articleEditStore.getDetail(id)
3131
}
3232

33-
render(){
33+
render () {
3434
const { mainData, typeList, tagList, tagChange, inputChange, update } = this.props.articleEditStore
3535

3636
return <React.Fragment>

src/pages/article/articleList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ export default class ArticleList extends React.Component<IProps> {
5252
render: (text: string, record, index) => <Button size="small" type="primary" onClick={() => this.viewDetail(record)}>详情</Button>,
5353
}]
5454

55-
viewDetail(data: IArticle) {
55+
viewDetail (data: IArticle) {
5656
this.props.history.push(`/home/blog-article/${data.id}`)
5757
}
5858

5959
create = () => {
6060
this.props.history.push('/home/blog-articleCreate')
6161
}
6262

63-
componentDidMount() {
63+
componentDidMount () {
6464
this.props.articleListStore.search()
6565
}
6666

67-
render(){
67+
render () {
6868
const { value, loading, list, meta, createdAt, inputChange, search, clear } = this.props.articleListStore
6969

7070
return <React.Fragment>

src/pages/article/articleListStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class articleListStore {
2828

2929

3030
@action inputChange = (value: any, type: string) => {
31-
if(type === 'createdAt') {
31+
if (type === 'createdAt') {
3232
this.createdAt = value
3333
const range = value
3434
this.value[type] = range.map((d: Moment, index: number) => {
@@ -55,7 +55,7 @@ class articleListStore {
5555
@action search = (pagination: any = {}, filters: any, orders: any) => {
5656
this.value['page'] = pagination.current || 1
5757

58-
if(orders && Object.keys(orders).length > 0) {
58+
if (orders && Object.keys(orders).length > 0) {
5959
this.value.order[orders.field] = orders.order === 'ascend' ? 'ASC' : 'DESC'
6060
}
6161

src/pages/articleType/articleTypeCreate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export default class ArticleTypeCreate extends React.Component<IProps> {
1616
this.props.history.push(`/home/blog-type/${id}`)
1717
}
1818

19-
componentDidMount() {
19+
componentDidMount () {
2020
//
2121
}
2222

23-
render(){
23+
render () {
2424
const { mainData, inputChange, save } = this.props.articleTypeCreateStore
2525

2626
return <React.Fragment>

src/pages/articleType/articleTypeCreateStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class articleTypeCreateStore {
1717
query: postArticleType,
1818
variables: this.mainData
1919
}).then((res: any) => {
20-
const {articleType:{id}} = res.data
20+
const {articleType: {id}} = res.data
2121
cb(id)
2222
runInAction(() => {
2323
this.loading = false

src/pages/articleType/articleTypeEdit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export default class ArticleTypeCreate extends React.Component<IProps> {
1212
this.props.history.go(-1)
1313
}
1414

15-
componentDidMount() {
15+
componentDidMount () {
1616
const {id}: any = this.props.match.params
1717
this.props.articleTypeEditStore.getDetail(id)
1818
}
1919

20-
render(){
20+
render () {
2121
const { mainData, inputChange, update } = this.props.articleTypeEditStore
2222

2323
return <React.Fragment>

src/pages/articleType/articleTypeEditStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class articleTypeEditStore {
4646
query: postArticleType,
4747
variables: this.mainData
4848
}).then((res: any) => {
49-
const {editArticleType:{id}} = res.data
49+
const {editArticleType: {id}} = res.data
5050
runInAction(() => {
5151
this.loading = false
5252

src/pages/articleType/articleTypeList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ export default class ArticleTypeList extends React.Component<IProps> {
5050
render: (text: string, record: IArticleType, index: number) => <Button size="small" type="primary" onClick={() => this.viewDetail(record)}>详情</Button>
5151
}]
5252

53-
viewDetail(data: IArticleType) {
53+
viewDetail (data: IArticleType) {
5454
this.props.history.push(`/home/blog-type/${data.id}`)
5555
}
5656

5757
create = () => {
5858
this.props.history.push('/home/blog-typeCreate')
5959
}
6060

61-
componentDidMount() {
61+
componentDidMount () {
6262
this.props.articleTypeListStore.search()
6363
}
6464

65-
render(){
65+
render () {
6666
const { value, loading, list, meta, createdAt, inputChange, search, clear } = this.props.articleTypeListStore
6767

6868
return <React.Fragment>

src/pages/articleType/articleTypeListStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class articleTypeListStore {
2626

2727

2828
@action inputChange = (value: any, type: string) => {
29-
if(type === 'createdAt') {
29+
if (type === 'createdAt') {
3030
this.createdAt = value
3131
const range = value
3232
this.value[type] = range.map((d: Moment, index: number) => {
@@ -51,7 +51,7 @@ class articleTypeListStore {
5151
@action search = (pagination: any = {}, filters: any, orders: any) => {
5252
this.value['page'] = pagination.current || 1
5353

54-
if(orders && Object.keys(orders).length > 0) {
54+
if (orders && Object.keys(orders).length > 0) {
5555
this.value.order[orders.field] = orders.order === 'ascend' ? 'ASC' : 'DESC'
5656
}
5757

src/pages/charts/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22

33
export default class Chart extends React.Component<IProps> {
44

5-
render(){
5+
render () {
66

77
return (
88
<div>

src/pages/comment/commentEdit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export default class CommentEdit extends React.Component<IProps> {
1212
this.props.history.go(-1)
1313
}
1414

15-
componentDidMount() {
15+
componentDidMount () {
1616
const {id}: any = this.props.match.params
1717
this.props.commentEditStore.getDetail(id)
1818
}
1919

20-
render(){
20+
render () {
2121
const { mainData } = this.props.commentEditStore
2222

2323
return <React.Fragment>

src/pages/comment/commentList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ export default class CommentList extends React.Component<IProps> {
4848
render: (text: string, record: IComment, index: number) => <Button size="small" type="primary" onClick={() => this.viewDetail(record)}>详情</Button>
4949
}]
5050

51-
viewDetail(data: IComment) {
51+
viewDetail (data: IComment) {
5252
this.props.history.push(`/home/blog-comment/${data.id}`)
5353
}
5454

55-
componentDidMount() {
55+
componentDidMount () {
5656
this.props.commentListStore.search()
5757
}
5858

59-
render(){
59+
render () {
6060
const { value, loading, list, meta, createdAt, inputChange, search, clear } = this.props.commentListStore
6161

6262
return <React.Fragment>

src/pages/comment/commentListStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class commentListStore {
2626

2727

2828
@action inputChange = (value: any, type: string) => {
29-
if(type === 'createdAt') {
29+
if (type === 'createdAt') {
3030
this.createdAt = value
3131
const range = value
3232
this.value[type] = range.map((d: Moment, index: number) => {
@@ -51,7 +51,7 @@ class commentListStore {
5151
@action search = (pagination: any = {}, filters: any, orders: any) => {
5252
this.value['page'] = pagination.current || 1
5353

54-
if(orders && Object.keys(orders).length > 0) {
54+
if (orders && Object.keys(orders).length > 0) {
5555
this.value.order[orders.field] = orders.order === 'ascend' ? 'ASC' : 'DESC'
5656
}
5757

src/pages/dashboard/dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22

33
export default class Dashboard extends React.Component {
4-
render(){
4+
render () {
55
return <div>
66
<p>Welcome to Dashboard!</p>
77
<div>GraphQL Application. </div>

src/pages/demo/demo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ const styles = {
2929
@observer
3030
export default class Demo extends React.Component<IProps> {
3131

32-
componentDidMount() {
32+
componentDidMount () {
3333
// console.log($http)
3434
// console.log(this.props)
3535
}
3636

37-
render(){
37+
render () {
3838
const {demoStore: {
3939
count, add, desc,
4040
inputApi, methodChange, typeChange, inputParams, testApi,

src/pages/demo/demoHooks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react'
22
import { Button } from 'antd'
33

44

5-
function useState<T>(initialValue: T): [T, (newState: T) => void] {
5+
function useState<T> (initialValue: T): [T, (newState: T) => void] {
66
let state = initialValue
77

8-
function setState(newState: T) {
8+
function setState (newState: T) {
99
state = newState
1010
// render()
1111
}

src/pages/demo/demoMobx.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ export default class DemoMobx extends React.Component<IProps> {
3939
// })
4040
// }
4141

42-
@observable count = 66;
42+
@observable count = 66
4343

4444
@action add = () => { this.count++ }
4545
@action dec = () => { this.count-- }
4646

47-
componentDidMount() {
47+
componentDidMount () {
4848
// console.log($http)
4949
// console.log(this.props)
5050
console.log(this)
5151
}
5252

53-
render(){
53+
render () {
5454
// const {count} = this.state
5555
const {count, add, dec} = this
5656

src/pages/demo/demoRedux.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ class DemoRedux extends React.Component<any> {
3535
store.dispatch({type: 'DECREASE'})
3636
}
3737

38-
shouldComponentUpdate(preState: any, nextProps: any) {
38+
shouldComponentUpdate (preState: any, nextProps: any) {
3939
console.log(preState, nextProps, 'shouldComponentUpdate')
4040
return true
4141
}
4242

43-
componentDidMount() {
43+
componentDidMount () {
4444
console.log(this.props, 'demo --- componentDidMount store.getState().counter')
4545
}
4646

47-
render(){
47+
render () {
4848
// const count = 9
4949
const { counter: {count}, disabled } = this.props
5050
const { ADD, DECREASE } = this.props
51-
console.log( count , 'demo render =-===count', disabled, )
51+
console.log( count, 'demo render =-===count', disabled, )
5252

5353
return <div>
5454
<section style={styles.block}>

src/pages/demo/reducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const countActions = {
2424

2525
// reducer
2626
const countReducer = (state = initCountState, action: IAction) => {
27-
switch(action.type) {
27+
switch (action.type) {
2828
case ADD :
2929
state.count++
3030
console.log('add', state)
@@ -41,7 +41,7 @@ const countReducer = (state = initCountState, action: IAction) => {
4141
// reducer
4242
const infoReducer = (state = initInfoState, action: IAction) => {
4343
let random = + Math.random()
44-
switch(action.type) {
44+
switch (action.type) {
4545
case 'SET_NAME' :
4646
state.name = '这里是Redux' + random
4747
return state

0 commit comments

Comments
 (0)