Skip to content

Commit

Permalink
fix: eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
GoPro16 committed Oct 11, 2019
1 parent 7066a79 commit bc4d8e9
Show file tree
Hide file tree
Showing 27 changed files with 407 additions and 371 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"regenerator-runtime": "^0.13.2",
"sass-loader": "^8.0.0",
"ts-jest": "^24.0.0",
"typescript": "^3.3.1"
"typescript": "^3.6.4"
},
"license": "MIT",
"lint-staged": {
Expand Down
98 changes: 49 additions & 49 deletions packages/favorites/FavoritesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,55 @@ const AV_INTERNAL_GLOBALS = {

export const FavoritesContext = createContext();

const validatedFavorites = input => {
const validFavorites = reduce(
input,
(result, favorite) => {
if (
!isUndefined(favorite.id) &&
!isUndefined(favorite.pos) &&
isNumber(favorite.pos)
) {
result.push(favorite);
}
return result;
},
[]
);
sortBy(validFavorites, 'pos').forEach((favorite, index) => {
favorite.pos = index;
});

return validFavorites;
};

const submitFavorites = async newfavorites => {
const favorites = validatedFavorites(newfavorites);

return avSettingsApi.setApplication(NAV_APP_ID, {
favorites,
});
};

const sendUpdate = faves => {
avMessages.send({
favorites: faves,
event: AV_INTERNAL_GLOBALS.FAVORITES_UPDATE,
});
};

const openMaxModal = () => {
const atMaxLog = {
category: 'favorites',
label: 'max-favorites-modal',
event: 'modal-open',
};

avLogMessagesApi.info(atMaxLog);

avMessages.send(AV_INTERNAL_GLOBALS.MAX_FAVORITES);
};

const Favorites = ({ children }) => {
const [favorites, setFavorites] = useState([]);

Expand Down Expand Up @@ -50,43 +99,6 @@ const Favorites = ({ children }) => {
return () => avMessages.unsubscribe(AV_INTERNAL_GLOBALS.FAVORITES_UPDATE);
}, []);

const validatedFavorites = input => {
const validFavorites = reduce(
input,
(result, favorite) => {
if (
!isUndefined(favorite.id) &&
!isUndefined(favorite.pos) &&
isNumber(favorite.pos)
) {
result.push(favorite);
}
return result;
},
[]
);
sortBy(validFavorites, 'pos').forEach((favorite, index) => {
favorite.pos = index;
});

return validFavorites;
};

const submitFavorites = async newfavorites => {
const favorites = validatedFavorites(newfavorites);

return avSettingsApi.setApplication(NAV_APP_ID, {
favorites,
});
};

const sendUpdate = faves => {
avMessages.send({
favorites: faves,
event: AV_INTERNAL_GLOBALS.FAVORITES_UPDATE,
});
};

const deleteFavorite = async id => {
const result = await submitFavorites(
clone(favorites).filter(favorite => favorite.id !== id)
Expand All @@ -98,18 +110,6 @@ const Favorites = ({ children }) => {
sendUpdate(newFavorites);
};

const openMaxModal = () => {
const atMaxLog = {
category: 'favorites',
label: 'max-favorites-modal',
event: 'modal-open',
};

avLogMessagesApi.info(atMaxLog);

avMessages.send(AV_INTERNAL_GLOBALS.MAX_FAVORITES);
};

const addFavorite = async id => {
if (favorites.length >= MAX_FAVORITES) {
openMaxModal();
Expand Down
2 changes: 1 addition & 1 deletion packages/favorites/__test__/FavoriteHeart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@testing-library/react';
import { avSettingsApi } from '@availity/api-axios';
import avMessages from '@availity/message-core';
import maxFavorites from './maxFavorites';
import maxFavorites from './maxFavorites.json';
import Favorites, { FavoriteHeart } from '..';

jest.mock('@availity/api-axios');
Expand Down
50 changes: 27 additions & 23 deletions packages/feature/Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,13 @@ import 'react-block-ui/style.css';
import isFeatureEnabled from './isFeatureEnabled';

class Feature extends Component {
static propTypes = {
features: PropTypes.oneOfType([
PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.string),
PropTypes.string,
])
),
PropTypes.string,
]).isRequired,
loader: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
whenDisabled: PropTypes.node,
children: PropTypes.node,
negate: PropTypes.bool,
};
constructor(props) {
super(props);

static defaultProps = {
whenDisabled: null,
children: null,
};

state = {
loading: false,
};
this.state = {
loading: false,
};
}

async checkFeatures() {
const { loading } = this.state;
Expand Down Expand Up @@ -84,4 +67,25 @@ class Feature extends Component {
}
}

Feature.propTypes = {
features: PropTypes.oneOfType([
PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.string),
PropTypes.string,
])
),
PropTypes.string,
]).isRequired,
loader: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
whenDisabled: PropTypes.node,
children: PropTypes.node,
negate: PropTypes.bool,
};

Feature.defaultProps = {
whenDisabled: null,
children: null,
};

export default Feature;
8 changes: 4 additions & 4 deletions packages/feedback/src/FeedbackForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const FeedbackForm = ({
Thank you for your feedback.
</ModalHeader>
) : (
<React.Fragment>
<>
<ModalHeader aria-live="assertive" id="feedback-form-header">
{prompt || `Tell us what you think about ${name}`}
</ModalHeader>
Expand Down Expand Up @@ -141,7 +141,7 @@ const FeedbackForm = ({
/>
</FormGroup>
{active ? (
<React.Fragment>
<>
{aboutOptions.length > 0 && (
<SelectField
name="feedbackApp"
Expand Down Expand Up @@ -170,7 +170,7 @@ const FeedbackForm = ({
rows="2"
/>
)}
</React.Fragment>
</>
) : null}
</ModalBody>

Expand All @@ -185,7 +185,7 @@ const FeedbackForm = ({
</Button>
</ModalFooter>
</Form>
</React.Fragment>
</>
);
};

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/tests/useEffectAsync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const Component = ({ asyncFunc }) => {

return <div data-testid="effect-test">{state}</div>;
};
const asyncFunc = () => Promise.resolve('World');

describe('useEffectAsync', () => {
test('should render "Hello" then "World"', async () => {
// Create Async Method
const asyncFunc = () => Promise.resolve('World');
// Render
const { getByTestId } = render(<Component asyncFunc={asyncFunc} />);

Expand Down
4 changes: 2 additions & 2 deletions packages/page-header/PageHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const PageHeader = ({
);

return (
<React.Fragment>
<>
<div className="d-flex align-items-start">
{React.isValidElement(crumbs) ? (
crumbs
Expand Down Expand Up @@ -141,7 +141,7 @@ const PageHeader = ({
/>
)}
</div>
</React.Fragment>
</>
);
};

Expand Down
6 changes: 3 additions & 3 deletions packages/pagination/src/PaginationContent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { Util, Button } from 'reactstrap';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand Down Expand Up @@ -54,10 +54,10 @@ const PaginationContent = ({
if (indexOfItemToReference === key) {
const ComponentWithRef = React.forwardRef((props, innerRef) => {
return (
<Fragment>
<>
<span className="sr-only" ref={innerRef} />
<Component {...props} />
</Fragment>
</>
);
});

Expand Down
84 changes: 40 additions & 44 deletions packages/pagination/src/PaginationControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,53 +97,49 @@ const PaginationControls = ({
return items;
};

return (
<React.Fragment>
{pageCount > 1 || !autoHide ? (
<Pagination data-testid="pagination-controls-con" {...rest}>
{directionLinks ? (
<PaginationItem
disabled={currentPage === 1}
data-testid="pagination-control-previous"
>
<PaginationLink
onClick={() =>
currentPage === 1 ? null : setPage(currentPage - 1)
}
type="button"
previous
>
{leftCaret} Prev
</PaginationLink>
</PaginationItem>
) : (
''
)}
{paginate()}
{directionLinks ? (
<PaginationItem
disabled={currentPage === pageCount}
data-testid="pagination-control-next"
>
<PaginationLink
data-testid="pagination-control-next-link"
onClick={() =>
currentPage === pageCount ? null : setPage(currentPage + 1)
}
type="button"
next
>
Next {rightCaret}
</PaginationLink>
</PaginationItem>
) : (
''
)}
</Pagination>
return pageCount > 1 || !autoHide ? (
<Pagination data-testid="pagination-controls-con" {...rest}>
{directionLinks ? (
<PaginationItem
disabled={currentPage === 1}
data-testid="pagination-control-previous"
>
<PaginationLink
onClick={() =>
currentPage === 1 ? null : setPage(currentPage - 1)
}
type="button"
previous
>
{leftCaret} Prev
</PaginationLink>
</PaginationItem>
) : (
''
)}
</React.Fragment>
{paginate()}
{directionLinks ? (
<PaginationItem
disabled={currentPage === pageCount}
data-testid="pagination-control-next"
>
<PaginationLink
data-testid="pagination-control-next-link"
onClick={() =>
currentPage === pageCount ? null : setPage(currentPage + 1)
}
type="button"
next
>
Next {rightCaret}
</PaginationLink>
</PaginationItem>
) : (
''
)}
</Pagination>
) : (
''
);
};

Expand Down
Loading

0 comments on commit bc4d8e9

Please sign in to comment.