Skip to content

Commit

Permalink
refactor: resolved eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalQamar95 committed Apr 6, 2023
1 parent fb765eb commit 72caaae
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/components/icons/InsertLink.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function InsertLink() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/Issue.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function Issue() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/People.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function People() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/PushPin.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function PushPin() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/Question.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function Question() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/QuestionAnswer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function QuestionAnswer() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/QuestionAnswerOutline.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function QuestionAnswerOutline() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/StarFilled.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function StarFilled() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/StarOutline.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function StarOutline() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/ThumbUpFilled.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function ThumbUpFilled() {
return (
<svg
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/ThumbUpOutline.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line react/function-component-definition
export default function ThumbUpOutline() {
return (
<svg
Expand Down
13 changes: 8 additions & 5 deletions src/discussions/common/HoverCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { postShape } from '../posts/post/proptypes';
import ActionsDropdown from './ActionsDropdown';
import { DiscussionContext } from './context';

function HoverCard({
const HoverCard = ({
intl,
commentOrPost,
actionHandlers,
Expand All @@ -27,7 +27,7 @@ function HoverCard({
onFollow,
isClosedPost,
endorseIcons,
}) {
}) => {
const { enableInContextSidebar } = useContext(DiscussionContext);
const userCanAddThreadInBlackoutDate = useUserCanAddThreadInBlackoutDate();
return (
Expand All @@ -40,8 +40,10 @@ function HoverCard({
<div className="d-flex">
<Button
variant="tertiary"
className={classNames('px-2.5 py-2 border-0 font-style text-gray-700 font-size-12',
{ 'w-100': enableInContextSidebar })}
className={classNames(
'px-2.5 py-2 border-0 font-style text-gray-700 font-size-12',
{ 'w-100': enableInContextSidebar },
)}
onClick={() => handleResponseCommentButton()}
disabled={isClosedPost}
style={{ lineHeight: '20px' }}
Expand Down Expand Up @@ -107,7 +109,7 @@ function HoverCard({
</div>
</div>
);
}
};

HoverCard.propTypes = {
intl: intlShape.isRequired,
Expand All @@ -118,6 +120,7 @@ HoverCard.propTypes = {
onFollow: PropTypes.func,
addResponseCommentButtonMessage: PropTypes.string.isRequired,
isClosedPost: PropTypes.bool.isRequired,
// eslint-disable-next-line react/forbid-prop-types
endorseIcons: PropTypes.objectOf(PropTypes.any),
};

Expand Down
4 changes: 2 additions & 2 deletions src/discussions/discussions-home/DiscussionContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Routes } from '../../data/constants';
import { PostCommentsView } from '../post-comments';
import { PostEditor } from '../posts';

function DiscussionContent() {
const DiscussionContent = () => {
const postEditorVisible = useSelector((state) => state.threads.postEditorVisible);

return (
Expand All @@ -32,6 +32,6 @@ function DiscussionContent() {
</div>
</div>
);
}
};

export default injectIntl(DiscussionContent);
7 changes: 5 additions & 2 deletions src/discussions/discussions-home/DiscussionsHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import DiscussionSidebar from './DiscussionSidebar';
import useFeedbackWrapper from './FeedbackWrapper';
import InformationBanner from './InformationBanner';

export default function DiscussionsHome() {
const DiscussionsHome = () => {
const location = useLocation();
const postActionBarRef = useRef(null);
const postEditorVisible = useSelector(selectPostEditorVisible);
Expand Down Expand Up @@ -67,6 +67,7 @@ export default function DiscussionsHome() {
}, [path]);

return (
// eslint-disable-next-line react/jsx-no-constructed-context-values
<DiscussionContext.Provider value={{
page,
courseId,
Expand Down Expand Up @@ -130,4 +131,6 @@ export default function DiscussionsHome() {
{!enableInContextSidebar && <Footer />}
</DiscussionContext.Provider>
);
}
};

export default DiscussionsHome;
13 changes: 9 additions & 4 deletions src/discussions/learners/LearnersView.test.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable default-param-last */
import React from 'react';

import {
Expand Down Expand Up @@ -200,7 +201,8 @@ describe('LearnersView', () => {
username:
['learner-1', 'learner-2'],
},
])('should have a search bar with a clear button and \'$output\' results found text.',
])(
'should have a search bar with a clear button and \'$output\' results found text.',
async ({
searchText, output, learnersCount, username,
}) => {
Expand All @@ -226,7 +228,8 @@ describe('LearnersView', () => {
expect(clearButton).toBeInTheDocument();
expect(leaners).toHaveLength(learnersCount);
});
});
},
);

test('When click on the clear button it should move to a list of all learners.', async () => {
await setUpLearnerMockResponse();
Expand Down Expand Up @@ -256,7 +259,8 @@ describe('LearnersView', () => {
expect(learners).toHaveLength(3);
});

it('should display reported and previously reported message by passing activeFlags or inactiveFlags',
it(
'should display reported and previously reported message by passing activeFlags or inactiveFlags',
async () => {
await setUpLearnerMockResponse(2, 2, 1, ['learner-1', 'learner-2'], '', 1, 1);
await assignPrivilages(true);
Expand All @@ -273,7 +277,8 @@ describe('LearnersView', () => {
expect(reportedIcon).toBeInTheDocument();
expect(reported).toBeInTheDocument();
expect(previouslyReported).toBeInTheDocument();
});
},
);

it('should display load more button and display more learners by clicking on button.', async () => {
await setUpLearnerMockResponse();
Expand Down
2 changes: 1 addition & 1 deletion src/discussions/topics/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function countFilteredTopics(topicsSelector, provider) {
? item.name.toLowerCase().includes(query)
: true
));
count += nonCoursewareTopicsList?.length;
count += nonCoursewareTopicsList?.length ?? 0;
// Counting legacy topics
if (provider === DiscussionProvider.LEGACY) {
const categories = topicsSelector?.categoryIds;
Expand Down

0 comments on commit 72caaae

Please sign in to comment.