Skip to content

Commit

Permalink
fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Feb 27, 2020
1 parent a18df2a commit b1ac0b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module.exports = {
'react/no-array-index-key': 0,
'react/sort-comp': 0,
'@typescript-eslint/no-explicit-any': 0,
'jsx-a11y/no-noninteractive-tabindex': 0,
},
};
1 change: 1 addition & 0 deletions src/Options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Options extends React.Component {

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

Expand Down
19 changes: 12 additions & 7 deletions src/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function noop() {}

function isInteger(value) {
return (
// eslint-disable-next-line no-restricted-globals
typeof value === 'number' && isFinite(value) && Math.floor(value) === value
);
}
Expand All @@ -19,10 +20,7 @@ function defaultItemRender(page, type, element) {
}

function calculatePage(p, state, props) {
let pageSize = p;
if (typeof pageSize === 'undefined') {
pageSize = state.pageSize;
}
const pageSize = typeof p === 'undefined' ? state.pageSize : p;
return Math.floor((props.total - 1) / pageSize) + 1;
}

Expand Down Expand Up @@ -54,18 +52,21 @@ class Pagination extends React.Component {
const hasOnChange = props.onChange !== noop;
const hasCurrent = 'current' in props;
if (hasCurrent && !hasOnChange) {
// eslint-disable-next-line no-console
console.warn(
'Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.',
); // eslint-disable-line
);
}

let current = props.defaultCurrent;
if ('current' in props) {
// eslint-disable-next-line prefer-destructuring
current = props.current;
}

let pageSize = props.defaultPageSize;
if ('pageSize' in props) {
// eslint-disable-next-line prefer-destructuring
pageSize = props.pageSize;
}

Expand Down Expand Up @@ -134,6 +135,7 @@ class Pagination extends React.Component {
*/
getItemIcon = icon => {
const { prefixCls } = this.props;
// eslint-disable-next-line jsx-a11y/anchor-has-content
let iconNode = icon || <a className={`${prefixCls}-item-link`} />;
if (typeof icon === 'function') {
iconNode = React.createElement(icon, { ...this.props });
Expand All @@ -148,6 +150,7 @@ class Pagination extends React.Component {
let value;
if (inputValue === '') {
value = inputValue;
// eslint-disable-next-line no-restricted-globals
} else if (isNaN(Number(inputValue))) {
value = currentInputValue;
} else if (inputValue >= allPages) {
Expand Down Expand Up @@ -202,6 +205,7 @@ class Pagination extends React.Component {
// fix the issue:
// Once 'total' is 0, 'current' in 'onShowSizeChange' is 0, which is not correct.
if (newCurrent === 0) {
// eslint-disable-next-line prefer-destructuring
current = this.state.current;
}

Expand Down Expand Up @@ -355,6 +359,7 @@ class Pagination extends React.Component {
key.substr(0, 5) === 'aria-' ||
key === 'role'
) {
// eslint-disable-next-line no-param-reassign
prev[key] = props[key];
}
return prev;
Expand Down Expand Up @@ -463,7 +468,7 @@ class Pagination extends React.Component {
/>,
);
}
for (let i = 1; i <= allPages; i++) {
for (let i = 1; i <= allPages; i += 1) {
const active = this.state.current === i;
pagerList.push(
<Pager {...pagerProps} key={i} page={i} active={active} />,
Expand Down Expand Up @@ -553,7 +558,7 @@ class Pagination extends React.Component {
left = allPages - pageBufferSize * 2;
}

for (let i = left; i <= right; i++) {
for (let i = left; i <= right; i += 1) {
const active = current === i;
pagerList.push(
<Pager
Expand Down

1 comment on commit b1ac0b0

@vercel
Copy link

@vercel vercel bot commented on b1ac0b0 Feb 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are pushing commits at a very fast pace (across the whole organization).
Due to that, we cannot deploy the commit b1ac0b0.

You can try again later or upgrade your plan.

Please sign in to comment.