Skip to content

Additional eslint rules #11804

Merged
sampaiodiego merged 9 commits intodevelopfrom
more-eslint-rules
Aug 17, 2018
Merged

Additional eslint rules #11804
sampaiodiego merged 9 commits intodevelopfrom
more-eslint-rules

Conversation

@sampaiodiego
Copy link
Copy Markdown
Member

@sampaiodiego sampaiodiego commented Aug 16, 2018

Add the remaining lint fixes that weren't able to fix automatically, so this ones needs more carful and reviewing.

I have also added a specific job for linting livechat widget, since its under a hidden folder (.app) it was being ignored by the regular lint command.

For easy reviewing, here is a list of rules being applied:

Closes #10565

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11804 August 16, 2018 18:15 Inactive
"debug": "meteor run --inspect",
"debug-brk": "meteor run --inspect-brk",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've removed the fix job because it can be done like this: meteor npm run core-lint -- --fix or meteor npm run livechat-lint -- --fix

ggazzo
ggazzo previously approved these changes Aug 16, 2018
template.preparing.set(false);
});
};
return file;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This return is unnecessary, you can change the map to a forEach

, userData);
: obj[currKey] = obj[currKey] || {}
, userData)
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks strange, the userData would be the second parameter of the reduce right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes.. fixing

currentTracker = Tracker.autorun(function(c) {
const user = Meteor.user();
if ((user && user.username == null) || user == null && RocketChat.settings.get('Accounts_AllowAnonymousRead') === false) {
if ((user == null || user.username == null) && RocketChat.settings.get('Accounts_AllowAnonymousRead') === false) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure about this change, It will allow users without username on servers with anonymous read true to open a room instead of show the screen to select usernames right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok.. the logic change was unintended.. fixing

@sampaiodiego sampaiodiego temporarily deployed to rocket-chat-pr-11804 August 16, 2018 19:15 Inactive
unreadsFrom = subscription.ls;
}
userMentions = subscription.userMentions;
({ userMentions } = subscription);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?


if (access || joined) {
msgs = room.msgs;
({ msgs } = room);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?

unreadsFrom = dm.ls;
}
userMentions = dm.userMentions;
({ userMentions } = dm);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?


if (access || joined) {
msgs = room.msgs;
({ msgs } = room);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?

return value;
} else if (typeof data === 'object') {
value = hljs.highlight('json', JSON.stringify(data, null, 2)).value;
({ value } = hljs.highlight('json', JSON.stringify(data, null, 2)));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?

if (e.target.files == null || files.length === 0) {
if (e.dataTransfer.files != null) {
files = e.dataTransfer.files;
({ files } = e.dataTransfer);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?

if (files == null || files.length === 0) {
if (e.dataTransfer != null && e.dataTransfer.files != null) {
files = e.dataTransfer.files;
({ files } = e.dataTransfer);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?

const loginResult = await AccountsServer.loginWithUser({ id });

tokens = loginResult.tokens;
({ tokens } = loginResult);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?

const loginResult = await AccountsServer.loginWithUser({ id: user.id });

tokens = loginResult.tokens;
({ tokens } = loginResult);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?


if (access || joined) {
msgs = room.msgs;
({ msgs } = room);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert?

@sampaiodiego sampaiodiego temporarily deployed to rocket-chat-pr-11804 August 16, 2018 20:26 Inactive
@sampaiodiego sampaiodiego temporarily deployed to rocket-chat-pr-11804 August 16, 2018 20:29 Inactive
@geekgonecrazy
Copy link
Copy Markdown
Contributor

Out of curiosity.. the destructuring...

Why: ({ msgs } = room); ?

Isn't it normally just: { msgs } = room; ?

I know reverted. But just curious :)

@sampaiodiego sampaiodiego merged commit dcdcbfb into develop Aug 17, 2018
@sampaiodiego sampaiodiego deleted the more-eslint-rules branch August 17, 2018 00:35
@sampaiodiego
Copy link
Copy Markdown
Member Author

wow.. same moment I merged 😂

so @geekgonecrazy for destructuring without declaration, the parenthesis are required: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assignment_without_declaration

@sampaiodiego
Copy link
Copy Markdown
Member Author

sampaiodiego commented Aug 17, 2018

so, correct:

const { msgs } = room;
// or
let msgs;
({ msgs } = room);

@geekgonecrazy
Copy link
Copy Markdown
Contributor

Ah! I think the cases I've done have been consts.

Thanks! :)

@sampaiodiego sampaiodiego mentioned this pull request Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants