diff --git a/app/javascript/chat/__tests__/__snapshots__/article.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/article.test.jsx.snap
index a615af0d7..93f14bd56 100644
--- a/app/javascript/chat/__tests__/__snapshots__/article.test.jsx.snap
+++ b/app/javascript/chat/__tests__/__snapshots__/article.test.jsx.snap
@@ -79,6 +79,7 @@ exports[` should load article 1`] = `
class="heart-reaction-button "
data-category="like"
onClick={[Function]}
+ type="button"
>
should load article 1`] = `
class="unicorn-reaction-button "
data-category="unicorn"
onClick={[Function]}
+ type="button"
>
should load article 1`] = `
class="readinglist-reaction-button "
data-category="readinglist"
onClick={[Function]}
+ type="button"
>
should load chat 1`] = `
SEND
diff --git a/app/javascript/chat/__tests__/__snapshots__/compose.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/compose.test.jsx.snap
index c258418fa..1cb93ca6f 100644
--- a/app/javascript/chat/__tests__/__snapshots__/compose.test.jsx.snap
+++ b/app/javascript/chat/__tests__/__snapshots__/compose.test.jsx.snap
@@ -14,6 +14,7 @@ exports[` behavior with message should render and test snapshot 1`] =
SEND
diff --git a/app/javascript/chat/__tests__/__snapshots__/githubRepo.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/githubRepo.test.jsx.snap
index d3eb50c34..7077f3307 100644
--- a/app/javascript/chat/__tests__/__snapshots__/githubRepo.test.jsx.snap
+++ b/app/javascript/chat/__tests__/__snapshots__/githubRepo.test.jsx.snap
@@ -16,7 +16,13 @@ preact-render-spy (1 nodes)
data-path="Camera"
onClick={[Function value]}
>
- 📁 Camera
+
+ 📁
+
+ Camera
@@ -26,7 +32,13 @@ preact-render-spy (1 nodes)
data-path="Environment"
onClick={[Function value]}
>
- 📁 Environment
+
+ 📁
+
+ Environment
@@ -36,7 +48,13 @@ preact-render-spy (1 nodes)
data-path="Interactables"
onClick={[Function value]}
>
- 📁 Interactables
+
+ 📁
+
+ Interactables
diff --git a/app/javascript/chat/__tests__/__snapshots__/message.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/message.test.jsx.snap
index 60219a67d..d92a9e227 100644
--- a/app/javascript/chat/__tests__/__snapshots__/message.test.jsx.snap
+++ b/app/javascript/chat/__tests__/__snapshots__/message.test.jsx.snap
@@ -10,18 +10,21 @@ exports[`
should render and test snapshot 1`] = `
×
-
Channel Invitations 🤗
+
+ Channel Invitations
+
+ 🤗
+
+
name
some description
', () => {
const pendingusers = context.find('.channeldetails__pendingusers');
for (let i = 0; i < pendingusers.length; i += 1) {
expect(pendingusers.at(i).text()).toEqual(
- `@${moddetails.pending_users_select_fields[i].username} - ${
- moddetails.pending_users_select_fields[i].name
- }`,
+ `@${moddetails.pending_users_select_fields[i].username} - ${moddetails.pending_users_select_fields[i].name}`,
);
expect(
pendingusers
@@ -199,11 +197,13 @@ describe(' ', () => {
let inviteAttrAns;
const included = (list, el) => {
const keys = Object.keys(list);
- for (const key of keys) {
+ for (let i = 0; i < keys.length; i += 1) {
+ const key = keys[i];
if (list[key].id === el.id) {
return true;
}
}
+ return false;
};
for (let i = 0; i < searchedusersdivs.length; i += 1) {
if (
@@ -224,9 +224,7 @@ describe(' ', () => {
.childAt(0)
.text(),
).toEqual(
- `@${searchedusers.searchedUsers[i].user.username} - ${
- searchedusers.searchedUsers[i].title
- }`,
+ `@${searchedusers.searchedUsers[i].user.username} - ${searchedusers.searchedUsers[i].title}`,
);
if (
diff --git a/app/javascript/chat/__tests__/chat.test.jsx b/app/javascript/chat/__tests__/chat.test.jsx
index 16383bed9..020ef786e 100644
--- a/app/javascript/chat/__tests__/chat.test.jsx
+++ b/app/javascript/chat/__tests__/chat.test.jsx
@@ -16,7 +16,7 @@ global.window = doc.defaultView;
global.window.algoliasearch = algoliasearch;
// mock observer and user ID
-window.IntersectionObserver = jest.fn(function() {
+window.IntersectionObserver = jest.fn(function intersectionObserverMock() {
this.observe = jest.fn();
});
global.window.currentUser = { id: 'some_id' };
diff --git a/app/javascript/chat/article.jsx b/app/javascript/chat/article.jsx
index e8c7b4156..14b156ae5 100644
--- a/app/javascript/chat/article.jsx
+++ b/app/javascript/chat/article.jsx
@@ -1,20 +1,30 @@
import { h, Component } from 'preact';
+import PropTypes from 'prop-types';
+// eslint-disable-next-line import/no-unresolved
import heartImage from 'images/emoji/emoji-one-heart.png';
+// eslint-disable-next-line import/no-unresolved
import unicornImage from 'images/emoji/emoji-one-unicorn.png';
+// eslint-disable-next-line import/no-unresolved
import bookmarkImage from 'images/emoji/emoji-one-bookmark.png';
export default class Article extends Component {
+ static propTypes = {
+ resource: PropTypes.shape({
+ id: PropTypes.string,
+ }).isRequired,
+ };
+
constructor(props) {
super(props);
this.state = {
- reactionCounts: [],
userReactions: [],
optimisticUserReaction: null,
};
}
componentDidMount() {
- fetch(`/reactions?article_id=${this.props.resource.id}`, {
+ const { resource } = this.props;
+ fetch(`/reactions?article_id=${resource.id}`, {
Accept: 'application/json',
'Content-Type': 'application/json',
credentials: 'same-origin',
@@ -29,11 +39,12 @@ export default class Article extends Component {
};
displayReactionsFailure = response => {
+ // eslint-disable-next-line no-console
console.log(response);
};
handleNewReactionResponse = response => {
- let oldUserReactions = this.state.userReactions;
+ let { userReactions: oldUserReactions } = this.state;
const foundReactions = oldUserReactions.filter(obj => {
return obj.category === response.category;
});
@@ -41,7 +52,7 @@ export default class Article extends Component {
oldUserReactions.push({ category: response.category });
} else {
oldUserReactions = oldUserReactions.filter(obj => {
- return obj.category != response.category;
+ return obj.category !== response.category;
});
}
this.setState({
@@ -51,14 +62,15 @@ export default class Article extends Component {
};
handleNewReactionFailure = response => {
+ // eslint-disable-next-line no-console
console.log(response);
};
handleReactionClick = e => {
e.preventDefault();
const { target } = e;
+ const { resource: article } = this.props;
this.setState({ optimisticUserReaction: target.dataset.category });
- const article = this.props.resource;
fetch('/reactions', {
method: 'POST',
headers: {
@@ -93,6 +105,7 @@ export default class Article extends Component {
return (
- {article.user.name}
+
+ {article.user.name}
+ {' '}
+
{' '}
- | {article.readable_publish_date}
+ |
+ {' '}
+ {article.readable_publish_date}
+ {/* eslint-disable-next-line react/no-danger */}
diff --git a/app/javascript/chat/channelDetails.jsx b/app/javascript/chat/channelDetails.jsx
index 380daffd3..c15876cff 100644
--- a/app/javascript/chat/channelDetails.jsx
+++ b/app/javascript/chat/channelDetails.jsx
@@ -94,7 +94,8 @@ class ChannelDetails extends Component {
userInList = (list, user) => {
const keys = Object.keys(list);
- for (const key of keys) {
+ for (let i = 0; i < keys.length; i += 1) {
+ const key = keys[i];
if (user.id === list[key].id) {
return true;
}
@@ -144,16 +145,25 @@ class ChannelDetails extends Component {
if (this.userInList(channel.channel_users, user)) {
invite = (
- is already in {channel.channel_name}
+ is already in
+ {' '}
+ {channel.channel_name}
);
}
return (
);
@@ -167,7 +177,12 @@ class ChannelDetails extends Component {
rel="noopener noreferrer"
data-content={`users/${user.id}`}
>
- @{user.username} - {user.name}
+ @
+ {user.username}
+ {' '}
+-
+ {' '}
+ {user.name}
));
@@ -188,7 +203,8 @@ class ChannelDetails extends Component {