Skip to content

Commit b1ac0b0

Browse files
committed
fix eslint errors
1 parent a18df2a commit b1ac0b0

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = {
99
'react/no-array-index-key': 0,
1010
'react/sort-comp': 0,
1111
'@typescript-eslint/no-explicit-any': 0,
12+
'jsx-a11y/no-noninteractive-tabindex': 0,
1213
},
1314
};

src/Options.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Options extends React.Component {
1313

1414
getValidValue() {
1515
const { goInputText, current } = this.state;
16+
// eslint-disable-next-line no-restricted-globals
1617
return !goInputText || isNaN(goInputText) ? current : Number(goInputText);
1718
}
1819

src/Pagination.jsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function noop() {}
1010

1111
function isInteger(value) {
1212
return (
13+
// eslint-disable-next-line no-restricted-globals
1314
typeof value === 'number' && isFinite(value) && Math.floor(value) === value
1415
);
1516
}
@@ -19,10 +20,7 @@ function defaultItemRender(page, type, element) {
1920
}
2021

2122
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;
2624
return Math.floor((props.total - 1) / pageSize) + 1;
2725
}
2826

@@ -54,18 +52,21 @@ class Pagination extends React.Component {
5452
const hasOnChange = props.onChange !== noop;
5553
const hasCurrent = 'current' in props;
5654
if (hasCurrent && !hasOnChange) {
55+
// eslint-disable-next-line no-console
5756
console.warn(
5857
'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+
);
6059
}
6160

6261
let current = props.defaultCurrent;
6362
if ('current' in props) {
63+
// eslint-disable-next-line prefer-destructuring
6464
current = props.current;
6565
}
6666

6767
let pageSize = props.defaultPageSize;
6868
if ('pageSize' in props) {
69+
// eslint-disable-next-line prefer-destructuring
6970
pageSize = props.pageSize;
7071
}
7172

@@ -134,6 +135,7 @@ class Pagination extends React.Component {
134135
*/
135136
getItemIcon = icon => {
136137
const { prefixCls } = this.props;
138+
// eslint-disable-next-line jsx-a11y/anchor-has-content
137139
let iconNode = icon || <a className={`${prefixCls}-item-link`} />;
138140
if (typeof icon === 'function') {
139141
iconNode = React.createElement(icon, { ...this.props });
@@ -148,6 +150,7 @@ class Pagination extends React.Component {
148150
let value;
149151
if (inputValue === '') {
150152
value = inputValue;
153+
// eslint-disable-next-line no-restricted-globals
151154
} else if (isNaN(Number(inputValue))) {
152155
value = currentInputValue;
153156
} else if (inputValue >= allPages) {
@@ -202,6 +205,7 @@ class Pagination extends React.Component {
202205
// fix the issue:
203206
// Once 'total' is 0, 'current' in 'onShowSizeChange' is 0, which is not correct.
204207
if (newCurrent === 0) {
208+
// eslint-disable-next-line prefer-destructuring
205209
current = this.state.current;
206210
}
207211

@@ -355,6 +359,7 @@ class Pagination extends React.Component {
355359
key.substr(0, 5) === 'aria-' ||
356360
key === 'role'
357361
) {
362+
// eslint-disable-next-line no-param-reassign
358363
prev[key] = props[key];
359364
}
360365
return prev;
@@ -463,7 +468,7 @@ class Pagination extends React.Component {
463468
/>,
464469
);
465470
}
466-
for (let i = 1; i <= allPages; i++) {
471+
for (let i = 1; i <= allPages; i += 1) {
467472
const active = this.state.current === i;
468473
pagerList.push(
469474
<Pager {...pagerProps} key={i} page={i} active={active} />,
@@ -553,7 +558,7 @@ class Pagination extends React.Component {
553558
left = allPages - pageBufferSize * 2;
554559
}
555560

556-
for (let i = left; i <= right; i++) {
561+
for (let i = left; i <= right; i += 1) {
557562
const active = current === i;
558563
pagerList.push(
559564
<Pager

0 commit comments

Comments
 (0)