@@ -10,6 +10,7 @@ function noop() {}
10
10
11
11
function isInteger ( value ) {
12
12
return (
13
+ // eslint-disable-next-line no-restricted-globals
13
14
typeof value === 'number' && isFinite ( value ) && Math . floor ( value ) === value
14
15
) ;
15
16
}
@@ -19,10 +20,7 @@ function defaultItemRender(page, type, element) {
19
20
}
20
21
21
22
function calculatePage ( p , state , props ) {
22
- let pageSize = p ;
23
- if ( typeof pageSize === 'undefined' ) {
24
- pageSize = state . pageSize ;
25
- }
23
+ const pageSize = typeof p === 'undefined' ? state . pageSize : p ;
26
24
return Math . floor ( ( props . total - 1 ) / pageSize ) + 1 ;
27
25
}
28
26
@@ -54,18 +52,21 @@ class Pagination extends React.Component {
54
52
const hasOnChange = props . onChange !== noop ;
55
53
const hasCurrent = 'current' in props ;
56
54
if ( hasCurrent && ! hasOnChange ) {
55
+ // eslint-disable-next-line no-console
57
56
console . warn (
58
57
'Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.' ,
59
- ) ; // eslint-disable-line
58
+ ) ;
60
59
}
61
60
62
61
let current = props . defaultCurrent ;
63
62
if ( 'current' in props ) {
63
+ // eslint-disable-next-line prefer-destructuring
64
64
current = props . current ;
65
65
}
66
66
67
67
let pageSize = props . defaultPageSize ;
68
68
if ( 'pageSize' in props ) {
69
+ // eslint-disable-next-line prefer-destructuring
69
70
pageSize = props . pageSize ;
70
71
}
71
72
@@ -134,6 +135,7 @@ class Pagination extends React.Component {
134
135
*/
135
136
getItemIcon = icon => {
136
137
const { prefixCls } = this . props ;
138
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
137
139
let iconNode = icon || < a className = { `${ prefixCls } -item-link` } /> ;
138
140
if ( typeof icon === 'function' ) {
139
141
iconNode = React . createElement ( icon , { ...this . props } ) ;
@@ -148,6 +150,7 @@ class Pagination extends React.Component {
148
150
let value ;
149
151
if ( inputValue === '' ) {
150
152
value = inputValue ;
153
+ // eslint-disable-next-line no-restricted-globals
151
154
} else if ( isNaN ( Number ( inputValue ) ) ) {
152
155
value = currentInputValue ;
153
156
} else if ( inputValue >= allPages ) {
@@ -202,6 +205,7 @@ class Pagination extends React.Component {
202
205
// fix the issue:
203
206
// Once 'total' is 0, 'current' in 'onShowSizeChange' is 0, which is not correct.
204
207
if ( newCurrent === 0 ) {
208
+ // eslint-disable-next-line prefer-destructuring
205
209
current = this . state . current ;
206
210
}
207
211
@@ -355,6 +359,7 @@ class Pagination extends React.Component {
355
359
key . substr ( 0 , 5 ) === 'aria-' ||
356
360
key === 'role'
357
361
) {
362
+ // eslint-disable-next-line no-param-reassign
358
363
prev [ key ] = props [ key ] ;
359
364
}
360
365
return prev ;
@@ -463,7 +468,7 @@ class Pagination extends React.Component {
463
468
/> ,
464
469
) ;
465
470
}
466
- for ( let i = 1 ; i <= allPages ; i ++ ) {
471
+ for ( let i = 1 ; i <= allPages ; i += 1 ) {
467
472
const active = this . state . current === i ;
468
473
pagerList . push (
469
474
< Pager { ...pagerProps } key = { i } page = { i } active = { active } /> ,
@@ -553,7 +558,7 @@ class Pagination extends React.Component {
553
558
left = allPages - pageBufferSize * 2 ;
554
559
}
555
560
556
- for ( let i = left ; i <= right ; i ++ ) {
561
+ for ( let i = left ; i <= right ; i += 1 ) {
557
562
const active = current === i ;
558
563
pagerList . push (
559
564
< Pager
0 commit comments