eslint: prefer-const, no-loop-func, no-const-assign, no-var

This commit is contained in:
Alex Gleason 2021-08-03 12:10:42 -05:00
parent 249c76ffaa
commit a310197a5a
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
53 changed files with 136 additions and 136 deletions

View file

@ -105,6 +105,10 @@ module.exports = {
semi: 'error', semi: 'error',
strict: 'off', strict: 'off',
'valid-typeof': 'error', 'valid-typeof': 'error',
'prefer-const': 'error',
'no-loop-func': 'error',
'no-const-assign': 'error',
'no-var': 'error',
'react/jsx-boolean-value': 'error', 'react/jsx-boolean-value': 'error',
'react/jsx-closing-bracket-location': ['error', 'line-aligned'], 'react/jsx-closing-bracket-location': ['error', 'line-aligned'],

View file

@ -45,7 +45,7 @@ export function showAlertForError(error) {
} }
let message = statusText; let message = statusText;
let title = `${status}`; const title = `${status}`;
if (data.error) { if (data.error) {
message = data.error; message = data.error;

View file

@ -148,7 +148,7 @@ export function handleComposeSubmit(dispatch, getState, data, status) {
const timeline = getState().getIn(['timelines', timelineId]); const timeline = getState().getIn(['timelines', timelineId]);
if (timeline && timeline.get('items').size > 0 && timeline.getIn(['items', 0]) !== null && timeline.get('online')) { if (timeline && timeline.get('items').size > 0 && timeline.getIn(['items', 0]) !== null && timeline.get('online')) {
let dequeueArgs = {}; const dequeueArgs = {};
if (timelineId === 'community') dequeueArgs.onlyMedia = getSettings(getState()).getIn(['community', 'other', 'onlyMedia']); if (timelineId === 'community') dequeueArgs.onlyMedia = getSettings(getState()).getIn(['community', 'other', 'onlyMedia']);
dispatch(dequeueTimeline(timelineId, null, dequeueArgs)); dispatch(dequeueTimeline(timelineId, null, dequeueArgs));
dispatch(updateTimeline(timelineId, data.id)); dispatch(updateTimeline(timelineId, data.id));
@ -272,6 +272,8 @@ export function uploadCompose(files) {
for (const [i, f] of Array.from(files).entries()) { for (const [i, f] of Array.from(files).entries()) {
if (media.size + i > uploadLimit - 1) break; if (media.size + i > uploadLimit - 1) break;
// FIXME: Don't define function in loop
/* eslint-disable no-loop-func */
resizeImage(f).then(file => { resizeImage(f).then(file => {
const data = new FormData(); const data = new FormData();
data.append('file', file); data.append('file', file);
@ -287,6 +289,7 @@ export function uploadCompose(files) {
.then(({ data }) => dispatch(uploadComposeSuccess(data))); .then(({ data }) => dispatch(uploadComposeSuccess(data)));
}).catch(error => dispatch(uploadComposeFail(error))); }).catch(error => dispatch(uploadComposeFail(error)));
/* eslint-enable no-loop-func */
}; };
}; };
}; };

View file

@ -11,8 +11,8 @@ import { List as ImmutableList } from 'immutable';
const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => { const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => {
let word; let word;
let left = str.slice(0, caretPosition).search(/\S+$/); const left = str.slice(0, caretPosition).search(/\S+$/);
let right = str.slice(caretPosition).search(/\s/); const right = str.slice(caretPosition).search(/\s/);
if (right < 0) { if (right < 0) {
word = str.slice(left); word = str.slice(left);

View file

@ -11,8 +11,8 @@ import classNames from 'classnames';
const textAtCursorMatchesToken = (str, caretPosition) => { const textAtCursorMatchesToken = (str, caretPosition) => {
let word; let word;
let left = str.slice(0, caretPosition).search(/\S+$/); const left = str.slice(0, caretPosition).search(/\S+$/);
let right = str.slice(caretPosition).search(/\s/); const right = str.slice(caretPosition).search(/\s/);
if (right < 0) { if (right < 0) {
word = str.slice(left); word = str.slice(left);

View file

@ -41,7 +41,7 @@ export default class ExtendedVideoPlayer extends React.PureComponent {
render() { render() {
const { src, muted, controls, alt } = this.props; const { src, muted, controls, alt } = this.props;
let conditionalAttributes = {}; const conditionalAttributes = {};
if (isIOS()) { if (isIOS()) {
conditionalAttributes.playsInline = '1'; conditionalAttributes.playsInline = '1';
} }

View file

@ -169,7 +169,7 @@ class Item extends React.PureComponent {
</a> </a>
); );
} else if (attachment.get('type') === 'gifv') { } else if (attachment.get('type') === 'gifv') {
let conditionalAttributes = {}; const conditionalAttributes = {};
if (isIOS()) { if (isIOS()) {
conditionalAttributes.playsInline = '1'; conditionalAttributes.playsInline = '1';
} }
@ -563,9 +563,8 @@ class MediaGallery extends React.PureComponent {
const { media, intl, sensitive } = this.props; const { media, intl, sensitive } = this.props;
const { visible } = this.state; const { visible } = this.state;
const sizeData = this.getSizeData(media.size); const sizeData = this.getSizeData(media.size);
let children, spoilerButton;
children = media.take(ATTACHMENT_LIMIT).map((attachment, i) => ( const children = media.take(ATTACHMENT_LIMIT).map((attachment, i) => (
<Item <Item
key={attachment.get('id')} key={attachment.get('id')}
onClick={this.handleClick} onClick={this.handleClick}
@ -580,6 +579,8 @@ class MediaGallery extends React.PureComponent {
/> />
)); ));
let spoilerButton;
if (visible) { if (visible) {
spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible)} icon='eye-slash' overlay onClick={this.handleOpen} />; spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible)} icon='eye-slash' overlay onClick={this.handleOpen} />;
} else { } else {

View file

@ -19,7 +19,7 @@ import {
const getAccount = makeGetAccount(); const getAccount = makeGetAccount();
const getBadges = (account) => { const getBadges = (account) => {
let badges = []; const badges = [];
if (isAdmin(account)) { if (isAdmin(account)) {
badges.push(<Badge key='admin' slug='admin' title='Admin' />); badges.push(<Badge key='admin' slug='admin' title='Admin' />);

View file

@ -292,13 +292,13 @@ class Status extends ImmutablePureComponent {
render() { render() {
let media = null; let media = null;
let poll = null; const poll = null;
let statusAvatar, prepend, rebloggedByText, reblogContent; let statusAvatar, prepend, rebloggedByText, reblogContent;
const { intl, hidden, featured, otherAccounts, unread, showThread, group } = this.props; const { intl, hidden, featured, otherAccounts, unread, showThread, group } = this.props;
let { status, account, ...other } = this.props; // FIXME: why does this need to reassign status and account??
let { status, account, ...other } = this.props; // eslint-disable-line prefer-const
if (status === null) { if (status === null) {
return null; return null;

View file

@ -284,7 +284,7 @@ class StatusActionBar extends ImmutablePureComponent {
const mutingConversation = status.get('muted'); const mutingConversation = status.get('muted');
const ownAccount = status.getIn(['account', 'id']) === me; const ownAccount = status.getIn(['account', 'id']) === me;
let menu = []; const menu = [];
menu.push({ text: intl.formatMessage(messages.open), action: this.handleOpen }); menu.push({ text: intl.formatMessage(messages.open), action: this.handleOpen });
@ -388,7 +388,7 @@ class StatusActionBar extends ImmutablePureComponent {
'😩': messages.reactionWeary, '😩': messages.reactionWeary,
}[meEmojiReact] || messages.favourite); }[meEmojiReact] || messages.favourite);
let menu = this._makeMenu(publicStatus); const menu = this._makeMenu(publicStatus);
let reblogIcon = 'retweet'; let reblogIcon = 'retweet';
let replyIcon; let replyIcon;
let replyTitle; let replyTitle;

View file

@ -50,8 +50,8 @@ class StatusContent extends React.PureComponent {
const links = node.querySelectorAll('a'); const links = node.querySelectorAll('a');
for (var i = 0; i < links.length; ++i) { for (let i = 0; i < links.length; ++i) {
let link = links[i]; const link = links[i];
if (link.classList.contains('status-link')) { if (link.classList.contains('status-link')) {
continue; continue;
} }
@ -59,7 +59,7 @@ class StatusContent extends React.PureComponent {
link.setAttribute('rel', 'nofollow noopener'); link.setAttribute('rel', 'nofollow noopener');
link.setAttribute('target', '_blank'); link.setAttribute('target', '_blank');
let mention = this.props.status.get('mentions').find(item => link.href === `${item.get('url')}`); const mention = this.props.status.get('mentions').find(item => link.href === `${item.get('url')}`);
if (mention) { if (mention) {
link.addEventListener('click', this.onMentionClick.bind(this, mention), false); link.addEventListener('click', this.onMentionClick.bind(this, mention), false);

View file

@ -69,7 +69,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onReply(status, router) { onReply(status, router) {
dispatch((_, getState) => { dispatch((_, getState) => {
let state = getState(); const state = getState();
if (state.getIn(['compose', 'text']).trim().length !== 0) { if (state.getIn(['compose', 'text']).trim().length !== 0) {
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.replyMessage), message: intl.formatMessage(messages.replyMessage),

View file

@ -138,7 +138,7 @@ class Header extends ImmutablePureComponent {
makeMenu() { makeMenu() {
const { account, intl, me, meAccount, version } = this.props; const { account, intl, me, meAccount, version } = this.props;
let menu = []; const menu = [];
if (!account || !me) { if (!account || !me) {
return []; return [];
@ -245,7 +245,7 @@ class Header extends ImmutablePureComponent {
makeInfo() { makeInfo() {
const { account, me } = this.props; const { account, me } = this.props;
let info = []; const info = [];
if (!account || !me) return info; if (!account || !me) return info;

View file

@ -93,7 +93,7 @@ class MediaItem extends ImmutablePureComponent {
/> />
); );
} else if (['gifv', 'video'].indexOf(attachment.get('type')) !== -1) { } else if (['gifv', 'video'].indexOf(attachment.get('type')) !== -1) {
let conditionalAttributes = {}; const conditionalAttributes = {};
if (isIOS()) { if (isIOS()) {
conditionalAttributes.playsInline = '1'; conditionalAttributes.playsInline = '1';
} }

View file

@ -29,7 +29,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
if (accountFetchError) { if (accountFetchError) {
accountId = null; accountId = null;
} else { } else {
let account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase()); const account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase());
accountId = account ? account.getIn(['id'], null) : -1; accountId = account ? account.getIn(['id'], null) : -1;
accountUsername = account ? account.getIn(['acct'], '') : ''; accountUsername = account ? account.getIn(['acct'], '') : '';
} }

View file

@ -29,7 +29,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
if (accountFetchError) { if (accountFetchError) {
accountId = null; accountId = null;
} else { } else {
let account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase()); const account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase());
accountId = account ? account.getIn(['id'], null) : -1; accountId = account ? account.getIn(['id'], null) : -1;
accountUsername = account ? account.getIn(['acct'], '') : ''; accountUsername = account ? account.getIn(['acct'], '') : '';
accountApId = account ? account.get('url') : ''; accountApId = account ? account.get('url') : '';

View file

@ -67,7 +67,7 @@ class ActionBar extends React.PureComponent {
const { intl, onClickLogOut, meUsername, isStaff } = this.props; const { intl, onClickLogOut, meUsername, isStaff } = this.props;
const size = this.props.size || 16; const size = this.props.size || 16;
let menu = []; const menu = [];
menu.push({ text: intl.formatMessage(messages.profile), to: `/@${meUsername}` }); menu.push({ text: intl.formatMessage(messages.profile), to: `/@${meUsername}` });
menu.push({ text: intl.formatMessage(messages.lists), to: '/lists' }); menu.push({ text: intl.formatMessage(messages.lists), to: '/lists' });

View file

@ -38,7 +38,7 @@ const getFrequentlyUsedEmojis = createSelector([
.toArray(); .toArray();
if (emojis.length < DEFAULTS.length) { if (emojis.length < DEFAULTS.length) {
let uniqueDefaults = DEFAULTS.filter(emoji => !emojis.includes(emoji)); const uniqueDefaults = DEFAULTS.filter(emoji => !emojis.includes(emoji));
emojis = emojis.concat(uniqueDefaults.slice(0, DEFAULTS.length - emojis.length)); emojis = emojis.concat(uniqueDefaults.slice(0, DEFAULTS.length - emojis.length));
} }

View file

@ -16,7 +16,7 @@ const regexSupplant = function(regex, flags) {
regex = regex.source; regex = regex.source;
} }
return new RegExp(regex.replace(/#\{(\w+)\}/g, function(match, name) { return new RegExp(regex.replace(/#\{(\w+)\}/g, function(match, name) {
var newRegex = regexen[name] || ''; let newRegex = regexen[name] || '';
if (typeof newRegex !== 'string') { if (typeof newRegex !== 'string') {
newRegex = newRegex.source; newRegex = newRegex.source;
} }

View file

@ -142,8 +142,8 @@ class EditProfile extends ImmutablePureComponent {
getFormdata = () => { getFormdata = () => {
const data = this.getParams(); const data = this.getParams();
let formData = new FormData(); const formData = new FormData();
for (let key in data) { for (const key in data) {
// Compact the submission. This should probably be done better. // Compact the submission. This should probably be done better.
const shouldAppend = Boolean(data[key] !== undefined || key.startsWith('fields_attributes')); const shouldAppend = Boolean(data[key] !== undefined || key.startsWith('fields_attributes'));
if (shouldAppend) formData.append(key, data[key] || ''); if (shouldAppend) formData.append(key, data[key] || '');

View file

@ -18,6 +18,8 @@ const emojify = (str, customEmojis = {}, autoplay = false) => {
if (i === str.length) { if (i === str.length) {
break; break;
} else if (str[i] === ':') { } else if (str[i] === ':') {
// FIXME: This is insane.
/* eslint-disable no-loop-func */
if (!(() => { if (!(() => {
rend = str.indexOf(':', i + 1) + 1; rend = str.indexOf(':', i + 1) + 1;
if (!rend) return false; // no pair of ':' if (!rend) return false; // no pair of ':'
@ -33,6 +35,7 @@ const emojify = (str, customEmojis = {}, autoplay = false) => {
} }
return false; return false;
})()) rend = ++i; })()) rend = ++i;
/* eslint-enable no-loop-func */
} else if (tag >= 0) { // <, & } else if (tag >= 0) { // <, &
rend = str.indexOf('>;'[tag], i + 1) + 1; rend = str.indexOf('>;'[tag], i + 1) + 1;
if (!rend) { if (!rend) {

View file

@ -87,7 +87,7 @@ Object.keys(emojiIndex.emojis).forEach(key => {
} }
const { native } = emoji; const { native } = emoji;
let { short_names, search, unified } = emojiMartData.emojis[key]; const { short_names, search, unified } = emojiMartData.emojis[key];
if (short_names[0] !== key) { if (short_names[0] !== key) {
throw new Error('The compresser expects the first short_code to be the ' + throw new Error('The compresser expects the first short_code to be the ' +
@ -95,9 +95,11 @@ Object.keys(emojiIndex.emojis).forEach(key => {
'is no longer the case.'); 'is no longer the case.');
} }
short_names = short_names.slice(1); // first short name can be inferred from the key const searchData = [
native,
const searchData = [native, short_names, search]; short_names.slice(1), // first short name can be inferred from the key
search,
];
if (unicodeToUnifiedName(native) !== unified) { if (unicodeToUnifiedName(native) !== unified) {
// unified name can't be derived from unicodeToUnifiedName // unified name can't be derived from unicodeToUnifiedName

View file

@ -8,28 +8,22 @@ const emojis = {};
// decompress // decompress
Object.keys(shortCodesToEmojiData).forEach((shortCode) => { Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
let [ const [
filenameData, // eslint-disable-line no-unused-vars filenameData, // eslint-disable-line no-unused-vars
searchData, searchData,
] = shortCodesToEmojiData[shortCode]; ] = shortCodesToEmojiData[shortCode];
let [ const [
native, native,
short_names, short_names,
search, search,
unified, unified,
] = searchData; ] = searchData;
if (!unified) {
// unified name can be derived from unicodeToUnifiedName
unified = unicodeToUnifiedName(native);
}
short_names = [shortCode].concat(short_names);
emojis[shortCode] = { emojis[shortCode] = {
native, native,
search, search,
short_names, short_names: [shortCode].concat(short_names),
unified, unified: unified || unicodeToUnifiedName(native),
}; };
}); });

View file

@ -4,16 +4,16 @@
import data from './emoji_mart_data_light'; import data from './emoji_mart_data_light';
import { getData, getSanitizedData, uniq, intersect } from './emoji_utils'; import { getData, getSanitizedData, uniq, intersect } from './emoji_utils';
let originalPool = {}; const originalPool = {};
let index = {}; let index = {};
let emojisList = {}; const emojisList = {};
let emoticonsList = {}; const emoticonsList = {};
let customEmojisList = []; let customEmojisList = [];
for (let emoji in data.emojis) { for (const emoji in data.emojis) {
let emojiData = data.emojis[emoji]; const emojiData = data.emojis[emoji];
let { short_names, emoticons } = emojiData; const { short_names, emoticons } = emojiData;
let id = short_names[0]; const id = short_names[0];
if (emoticons) { if (emoticons) {
emoticons.forEach(emoticon => { emoticons.forEach(emoticon => {
@ -31,7 +31,7 @@ for (let emoji in data.emojis) {
function clearCustomEmojis(pool) { function clearCustomEmojis(pool) {
customEmojisList.forEach((emoji) => { customEmojisList.forEach((emoji) => {
let emojiId = emoji.id || emoji.short_names[0]; const emojiId = emoji.id || emoji.short_names[0];
delete pool[emojiId]; delete pool[emojiId];
delete emojisList[emojiId]; delete emojisList[emojiId];
@ -42,7 +42,7 @@ export function addCustomToPool(custom, pool = originalPool) {
if (customEmojisList.length) clearCustomEmojis(pool); if (customEmojisList.length) clearCustomEmojis(pool);
custom.forEach((emoji) => { custom.forEach((emoji) => {
let emojiId = emoji.id || emoji.short_names[0]; const emojiId = emoji.id || emoji.short_names[0];
if (emojiId && !pool[emojiId]) { if (emojiId && !pool[emojiId]) {
pool[emojiId] = getData(emoji); pool[emojiId] = getData(emoji);
@ -85,8 +85,8 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
pool = {}; pool = {};
data.categories.forEach(category => { data.categories.forEach(category => {
let isIncluded = include && include.length ? include.indexOf(category.name.toLowerCase()) > -1 : true; const isIncluded = include && include.length ? include.indexOf(category.name.toLowerCase()) > -1 : true;
let isExcluded = exclude && exclude.length ? exclude.indexOf(category.name.toLowerCase()) > -1 : false; const isExcluded = exclude && exclude.length ? exclude.indexOf(category.name.toLowerCase()) > -1 : false;
if (!isIncluded || isExcluded) { if (!isIncluded || isExcluded) {
return; return;
} }
@ -95,8 +95,8 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
}); });
if (custom.length) { if (custom.length) {
let customIsIncluded = include && include.length ? include.indexOf('custom') > -1 : true; const customIsIncluded = include && include.length ? include.indexOf('custom') > -1 : true;
let customIsExcluded = exclude && exclude.length ? exclude.indexOf('custom') > -1 : false; const customIsExcluded = exclude && exclude.length ? exclude.indexOf('custom') > -1 : false;
if (customIsIncluded && !customIsExcluded) { if (customIsIncluded && !customIsExcluded) {
addCustomToPool(custom, pool); addCustomToPool(custom, pool);
} }
@ -116,13 +116,13 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
aIndex = aIndex[char]; aIndex = aIndex[char];
if (!aIndex.results) { if (!aIndex.results) {
let scores = {}; const scores = {};
aIndex.results = []; aIndex.results = [];
aIndex.pool = {}; aIndex.pool = {};
for (let id in aPool) { for (const id in aPool) {
let emoji = aPool[id], const emoji = aPool[id],
{ search } = emoji, { search } = emoji,
sub = value.substr(0, length), sub = value.substr(0, length),
subIndex = search.indexOf(sub); subIndex = search.indexOf(sub);
@ -139,7 +139,7 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
} }
aIndex.results.sort((a, b) => { aIndex.results.sort((a, b) => {
let aScore = scores[a.id], const aScore = scores[a.id],
bScore = scores[b.id]; bScore = scores[b.id];
return aScore - bScore; return aScore - bScore;

View file

@ -15,19 +15,16 @@ const { unicodeToFilename } = require('./unicode_to_filename');
const unicodeMapping = {}; const unicodeMapping = {};
function processEmojiMapData(emojiMapData, shortCode) { function processEmojiMapData(emojiMapData, shortCode) {
let [ native, filename ] = emojiMapData; const [ native, filename ] = emojiMapData;
if (!filename) {
// filename name can be derived from unicodeToFilename
filename = unicodeToFilename(native);
}
unicodeMapping[native] = { unicodeMapping[native] = {
shortCode: shortCode, shortCode,
filename: filename, filename: filename || unicodeToFilename(native),
}; };
} }
Object.keys(shortCodesToEmojiData).forEach((shortCode) => { Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
let [ filenameData ] = shortCodesToEmojiData[shortCode]; const [ filenameData ] = shortCodesToEmojiData[shortCode];
filenameData.forEach(emojiMapData => processEmojiMapData(emojiMapData, shortCode)); filenameData.forEach(emojiMapData => processEmojiMapData(emojiMapData, shortCode));
}); });
emojisWithoutShortCodes.forEach(emojiMapData => processEmojiMapData(emojiMapData)); emojisWithoutShortCodes.forEach(emojiMapData => processEmojiMapData(emojiMapData));

View file

@ -6,7 +6,7 @@ import data from './emoji_mart_data_light';
const buildSearch = (data) => { const buildSearch = (data) => {
const search = []; const search = [];
let addToSearch = (strings, split) => { const addToSearch = (strings, split) => {
if (!strings) { if (!strings) {
return; return;
} }
@ -33,12 +33,12 @@ const buildSearch = (data) => {
const _String = String; const _String = String;
const stringFromCodePoint = _String.fromCodePoint || function() { const stringFromCodePoint = _String.fromCodePoint || function() {
let MAX_SIZE = 0x4000; const MAX_SIZE = 0x4000;
let codeUnits = []; const codeUnits = [];
let highSurrogate; let highSurrogate;
let lowSurrogate; let lowSurrogate;
let index = -1; let index = -1;
let length = arguments.length; const length = arguments.length;
if (!length) { if (!length) {
return ''; return '';
} }
@ -80,16 +80,16 @@ const SKINS = [
]; ];
function unifiedToNative(unified) { function unifiedToNative(unified) {
let unicodes = unified.split('-'), const unicodes = unified.split('-'),
codePoints = unicodes.map((u) => `0x${u}`); codePoints = unicodes.map((u) => `0x${u}`);
return stringFromCodePoint.apply(null, codePoints); return stringFromCodePoint.apply(null, codePoints);
} }
function sanitize(emoji) { function sanitize(emoji) {
let { name, short_names, skin_tone, skin_variations, emoticons, unified, custom, imageUrl } = emoji, const { name, short_names, skin_tone, skin_variations, emoticons, unified, custom, imageUrl } = emoji;
id = emoji.id || short_names[0], const id = emoji.id || short_names[0];
colons = `:${id}:`; const colons = `:${id}:`;
if (custom) { if (custom) {
return { return {
@ -102,14 +102,10 @@ function sanitize(emoji) {
}; };
} }
if (skin_tone) {
colons += `:skin-tone-${skin_tone}:`;
}
return { return {
id, id,
name, name,
colons, colons: skin_tone ? `${colons}:skin-tone-${skin_tone}:` : colons,
emoticons, emoticons,
unified: unified.toLowerCase(), unified: unified.toLowerCase(),
skin: skin_tone || (skin_variations ? 1 : null), skin: skin_tone || (skin_variations ? 1 : null),
@ -125,7 +121,7 @@ function getData(emoji, skin, set) {
let emojiData = {}; let emojiData = {};
if (typeof emoji === 'string') { if (typeof emoji === 'string') {
let matches = emoji.match(COLONS_REGEX); const matches = emoji.match(COLONS_REGEX);
if (matches) { if (matches) {
emoji = matches[1]; emoji = matches[1];
@ -168,7 +164,7 @@ function getData(emoji, skin, set) {
if (emojiData.skin_variations && skin > 1 && set) { if (emojiData.skin_variations && skin > 1 && set) {
emojiData = JSON.parse(_JSON.stringify(emojiData)); emojiData = JSON.parse(_JSON.stringify(emojiData));
let skinKey = SKINS[skin - 1], const skinKey = SKINS[skin - 1],
variationData = emojiData.skin_variations[skinKey]; variationData = emojiData.skin_variations[skinKey];
if (!variationData.variations && emojiData.variations) { if (!variationData.variations && emojiData.variations) {
@ -178,8 +174,8 @@ function getData(emoji, skin, set) {
if (variationData[`has_img_${set}`]) { if (variationData[`has_img_${set}`]) {
emojiData.skin_tone = skin; emojiData.skin_tone = skin;
for (let k in variationData) { for (const k in variationData) {
let v = variationData[k]; const v = variationData[k];
emojiData[k] = v; emojiData[k] = v;
} }
} }
@ -210,11 +206,11 @@ function intersect(a, b) {
} }
function deepMerge(a, b) { function deepMerge(a, b) {
let o = {}; const o = {};
for (let key in a) { for (const key in a) {
let originalValue = a[key], const originalValue = a[key];
value = originalValue; let value = originalValue;
if (b.hasOwnProperty(key)) { if (b.hasOwnProperty(key)) {
value = b[key]; value = b[key];

View file

@ -96,7 +96,7 @@ class Filters extends ImmutablePureComponent {
const { intl, dispatch } = this.props; const { intl, dispatch } = this.props;
const { phrase, whole_word, expires_at, irreversible } = this.state; const { phrase, whole_word, expires_at, irreversible } = this.state;
const { home_timeline, public_timeline, notifications, conversations } = this.state; const { home_timeline, public_timeline, notifications, conversations } = this.state;
let context = []; const context = [];
if (home_timeline) { if (home_timeline) {
context.push('home'); context.push('home');

View file

@ -28,7 +28,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
if (accountFetchError) { if (accountFetchError) {
accountId = null; accountId = null;
} else { } else {
let account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase()); const account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase());
accountId = account ? account.getIn(['id'], null) : -1; accountId = account ? account.getIn(['id'], null) : -1;
} }

View file

@ -28,7 +28,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
if (accountFetchError) { if (accountFetchError) {
accountId = null; accountId = null;
} else { } else {
let account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase()); const account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase());
accountId = account ? account.getIn(['id'], null) : -1; accountId = account ? account.getIn(['id'], null) : -1;
} }

View file

@ -26,7 +26,7 @@ class HashtagTimeline extends React.PureComponent {
}; };
title = () => { title = () => {
let title = [this.props.params.id]; const title = [this.props.params.id];
if (this.additionalFor('any')) { if (this.additionalFor('any')) {
title.push(' ', <FormattedMessage key='any' id='hashtag.column_header.tag_mode.any' values={{ additional: this.additionalFor('any') }} defaultMessage='or {additional}' />); title.push(' ', <FormattedMessage key='any' id='hashtag.column_header.tag_mode.any' values={{ additional: this.additionalFor('any') }} defaultMessage='or {additional}' />);
@ -54,13 +54,13 @@ class HashtagTimeline extends React.PureComponent {
} }
_subscribe(dispatch, id, tags = {}) { _subscribe(dispatch, id, tags = {}) {
let any = (tags.any || []).map(tag => tag.value); const any = (tags.any || []).map(tag => tag.value);
let all = (tags.all || []).map(tag => tag.value); const all = (tags.all || []).map(tag => tag.value);
let none = (tags.none || []).map(tag => tag.value); const none = (tags.none || []).map(tag => tag.value);
[id, ...any].map(tag => { [id, ...any].map(tag => {
this.disconnects.push(dispatch(connectHashtagStream(id, tag, status => { this.disconnects.push(dispatch(connectHashtagStream(id, tag, status => {
let tags = status.tags.map(tag => tag.name); const tags = status.tags.map(tag => tag.name);
return all.filter(tag => tags.includes(tag)).length === all.length && return all.filter(tag => tags.includes(tag)).length === all.length &&
none.filter(tag => tags.includes(tag)).length === 0; none.filter(tag => tags.includes(tag)).length === 0;

View file

@ -28,7 +28,7 @@ class CSVImporter extends ImmutablePureComponent {
handleSubmit = (event) => { handleSubmit = (event) => {
const { dispatch, action, intl } = this.props; const { dispatch, action, intl } = this.props;
let params = new FormData(); const params = new FormData();
params.append('list', this.state.file); params.append('list', this.state.file);
this.setState({ isLoading: true }); this.setState({ isLoading: true });

View file

@ -22,7 +22,7 @@ export default class ColumnSettings extends React.PureComponent {
onAllSoundsChange = (path, checked) => { onAllSoundsChange = (path, checked) => {
const soundSettings = [['sounds', 'follow'], ['sounds', 'favourite'], ['sounds', 'pleroma:emoji_reaction'], ['sounds', 'mention'], ['sounds', 'reblog'], ['sounds', 'poll'], ['sounds', 'move']]; const soundSettings = [['sounds', 'follow'], ['sounds', 'favourite'], ['sounds', 'pleroma:emoji_reaction'], ['sounds', 'mention'], ['sounds', 'reblog'], ['sounds', 'poll'], ['sounds', 'move']];
for (var i = 0; i < soundSettings.length; i++) { for (let i = 0; i < soundSettings.length; i++) {
this.props.onChange(soundSettings[i], checked); this.props.onChange(soundSettings[i], checked);
} }
} }

View file

@ -19,7 +19,7 @@ export default class MultiSettingToggle extends React.PureComponent {
} }
onChange = ({ target }) => { onChange = ({ target }) => {
for (var i = 0; i < this.props.settingPaths.length; i++) { for (let i = 0; i < this.props.settingPaths.length; i++) {
this.props.onChange(this.props.settingPaths[i], target.checked); this.props.onChange(this.props.settingPaths[i], target.checked);
} }
} }

View file

@ -121,7 +121,7 @@ class IconPickerMenu extends React.PureComponent {
return <div style={{ width: 299 }} />; return <div style={{ width: 299 }} />;
} }
let data = { compressed: true, categories: [], aliases: [], emojis: [] }; const data = { compressed: true, categories: [], aliases: [], emojis: [] };
const title = intl.formatMessage(messages.emoji); const title = intl.formatMessage(messages.emoji);
const { modifierOpen } = this.state; const { modifierOpen } = this.state;
@ -209,7 +209,7 @@ class IconPickerDropdown extends React.PureComponent {
const { intl, onPickEmoji, value } = this.props; const { intl, onPickEmoji, value } = this.props;
const title = intl.formatMessage(messages.emoji); const title = intl.formatMessage(messages.emoji);
const { active, loading, placement } = this.state; const { active, loading, placement } = this.state;
let forkAwesomeIcons = require('../forkawesome.json'); const forkAwesomeIcons = require('../forkawesome.json');
return ( return (
<div className='font-icon-picker-dropdown' onKeyDown={this.handleKeyDown}> <div className='font-icon-picker-dropdown' onKeyDown={this.handleKeyDown}>

View file

@ -454,7 +454,7 @@ class ColorPicker extends React.PureComponent {
render() { render() {
const { style, value, onChange } = this.props; const { style, value, onChange } = this.props;
let margin_left_picker = isMobile(window.innerWidth) ? '20px' : '12px'; const margin_left_picker = isMobile(window.innerWidth) ? '20px' : '12px';
return ( return (
<div id='SketchPickerContainer' ref={this.setRef} style={{ ...style, marginLeft: margin_left_picker, position: 'absolute', zIndex: 1000 }}> <div id='SketchPickerContainer' ref={this.setRef} style={{ ...style, marginLeft: margin_left_picker, position: 'absolute', zIndex: 1000 }}>

View file

@ -294,7 +294,7 @@ class ActionBar extends React.PureComponent {
'😩': messages.reactionWeary, '😩': messages.reactionWeary,
}[meEmojiReact] || messages.favourite); }[meEmojiReact] || messages.favourite);
let menu = []; const menu = [];
if (publicStatus) { if (publicStatus) {
menu.push({ text: intl.formatMessage(messages.copy), action: this.handleCopy }); menu.push({ text: intl.formatMessage(messages.copy), action: this.handleCopy });
@ -360,7 +360,7 @@ class ActionBar extends React.PureComponent {
if (status.get('visibility') === 'direct') reblogIcon = 'envelope'; if (status.get('visibility') === 'direct') reblogIcon = 'envelope';
else if (status.get('visibility') === 'private') reblogIcon = 'lock'; else if (status.get('visibility') === 'private') reblogIcon = 'lock';
let reblog_disabled = (status.get('visibility') === 'direct' || status.get('visibility') === 'private'); const reblog_disabled = (status.get('visibility') === 'direct' || status.get('visibility') === 'private');
return ( return (

View file

@ -179,7 +179,7 @@ export default class Card extends React.PureComponent {
let embed = ''; let embed = '';
const imageUrl = card.get('image') || card.getIn(['pleroma', 'opengraph', 'thumbnail_url']); const imageUrl = card.get('image') || card.getIn(['pleroma', 'opengraph', 'thumbnail_url']);
let thumbnail = <div style={{ backgroundImage: `url(${imageUrl})`, width: horizontal ? width : null, height: horizontal ? height : null }} className='status-card__image-image' />; const thumbnail = <div style={{ backgroundImage: `url(${imageUrl})`, width: horizontal ? width : null, height: horizontal ? height : null }} className='status-card__image-image' />;
if (interactive) { if (interactive) {
if (embedded) { if (embedded) {

View file

@ -95,7 +95,7 @@ export default class DetailedStatus extends ImmutablePureComponent {
} }
let media = ''; let media = '';
let poll = ''; const poll = '';
let statusTypeIcon = ''; let statusTypeIcon = '';
if (this.props.measureHeight) { if (this.props.measureHeight) {

View file

@ -59,7 +59,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onReply(status, router) { onReply(status, router) {
dispatch((_, getState) => { dispatch((_, getState) => {
let state = getState(); const state = getState();
if (state.getIn(['compose', 'text']).trim().length !== 0) { if (state.getIn(['compose', 'text']).trim().length !== 0) {
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.replyMessage), message: intl.formatMessage(messages.replyMessage),

View file

@ -90,7 +90,7 @@ const makeMapStateToProps = () => {
const ids = [statusId]; const ids = [statusId];
while (ids.length > 0) { while (ids.length > 0) {
let id = ids.shift(); const id = ids.shift();
const replies = contextReplies.get(id); const replies = contextReplies.get(id);
if (statusId !== id) { if (statusId !== id) {
@ -199,7 +199,7 @@ class Status extends ImmutablePureComponent {
} }
handleReplyClick = (status) => { handleReplyClick = (status) => {
let { askReplyConfirmation, dispatch, intl } = this.props; const { askReplyConfirmation, dispatch, intl } = this.props;
if (askReplyConfirmation) { if (askReplyConfirmation) {
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.replyMessage), message: intl.formatMessage(messages.replyMessage),

View file

@ -19,7 +19,7 @@ export default class ColumnLoading extends ImmutablePureComponent {
}; };
render() { render() {
let { title, icon } = this.props; const { title, icon } = this.props;
return ( return (
<Column> <Column>
<ColumnHeader icon={icon} title={title} focusable={false} /> <ColumnHeader icon={icon} title={title} focusable={false} />

View file

@ -103,7 +103,7 @@ class ProfileDropdown extends React.PureComponent {
const { intl, account, otherAccounts } = this.props; const { intl, account, otherAccounts } = this.props;
const size = this.props.size || 16; const size = this.props.size || 16;
let menu = []; const menu = [];
menu.push({ text: this.renderAccount(account), to: `/@${account.get('acct')}` }); menu.push({ text: this.renderAccount(account), to: `/@${account.get('acct')}` });

View file

@ -53,7 +53,7 @@ class TabsBar extends React.PureComponent {
getNavLinks() { getNavLinks() {
const { intl: { formatMessage }, logo, account, dashboardCount, notificationCount, chatsCount } = this.props; const { intl: { formatMessage }, logo, account, dashboardCount, notificationCount, chatsCount } = this.props;
let links = []; const links = [];
if (logo) { if (logo) {
links.push( links.push(
<Link key='logo' className='tabs-bar__link--logo' to='/' data-preview-title-id='column.home'> <Link key='logo' className='tabs-bar__link--logo' to='/' data-preview-title-id='column.home'>

View file

@ -208,7 +208,7 @@ class Video extends React.PureComponent {
const x = (e.clientX - rect.left) / this.volWidth; //x position within the element. const x = (e.clientX - rect.left) / this.volWidth; //x position within the element.
if(!isNaN(x)) { if(!isNaN(x)) {
var slideamt = x; let slideamt = x;
if(x > 1) { if(x > 1) {
slideamt = 1; slideamt = 1;
} else if(x < 0) { } else if(x < 0) {

View file

@ -11,7 +11,7 @@ export function isMobile(width) {
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
let userTouching = false; let userTouching = false;
let listenerOptions = supportsPassiveEvents ? { passive: true } : false; const listenerOptions = supportsPassiveEvents ? { passive: true } : false;
function touchListener() { function touchListener() {
userTouching = true; userTouching = true;

View file

@ -12,8 +12,8 @@ const initialState = ImmutableMap({
}); });
const parseItems = items => { const parseItems = items => {
let ids = []; const ids = [];
let map = {}; const map = {};
items.forEach(item => { items.forEach(item => {
ids.push(item.id); ids.push(item.id);

View file

@ -113,7 +113,7 @@ const updateNotificationsQueue = (state, notification, intlMessages, intlLocale)
const alreadyExists = queuedNotifications.has(notification.id) || listedNotifications.has(notification.id); const alreadyExists = queuedNotifications.has(notification.id) || listedNotifications.has(notification.id);
if (alreadyExists) return state; if (alreadyExists) return state;
let newQueuedNotifications = queuedNotifications; const newQueuedNotifications = queuedNotifications;
return state.withMutations(mutable => { return state.withMutations(mutable => {
if (totalQueuedNotificationsCount <= MAX_QUEUED_NOTIFICATIONS) { if (totalQueuedNotificationsCount <= MAX_QUEUED_NOTIFICATIONS) {

View file

@ -126,7 +126,7 @@ export const makeGetStatus = () => {
const getAlertsBase = state => state.get('alerts'); const getAlertsBase = state => state.get('alerts');
export const getAlerts = createSelector([getAlertsBase], (base) => { export const getAlerts = createSelector([getAlertsBase], (base) => {
let arr = []; const arr = [];
base.forEach(item => { base.forEach(item => {
arr.push({ arr.push({

View file

@ -3,7 +3,7 @@ import { List as ImmutableList } from 'immutable';
const guessDomain = account => { const guessDomain = account => {
try { try {
let re = /https?:\/\/(.*?)\//i; const re = /https?:\/\/(.*?)\//i;
return re.exec(account.get('url'))[1]; return re.exec(account.get('url'))[1];
} catch(e) { } catch(e) {
return null; return null;
@ -50,7 +50,7 @@ export const getFollowDifference = (state, accountId, type) => {
}; };
export const isLocal = account => { export const isLocal = account => {
let domain = account.get('acct').split('@')[1]; const domain = account.get('acct').split('@')[1];
return domain === undefined ? true : false; return domain === undefined ? true : false;
}; };

View file

@ -20,8 +20,8 @@ export const getFeatures = createSelector([
}); });
export const parseVersion = version => { export const parseVersion = version => {
let regex = /^([\w\.]*)(?: \(compatible; ([\w]*) (.*)\))?$/; const regex = /^([\w\.]*)(?: \(compatible; ([\w]*) (.*)\))?$/;
let match = regex.exec(version); const match = regex.exec(version);
return { return {
software: match[2] || 'Mastodon', software: match[2] || 'Mastodon',
version: match[3] || match[1], version: match[3] || match[1],

View file

@ -29,12 +29,12 @@ function hexToRgb(hex) {
// Taken from chromatism.js // Taken from chromatism.js
// https://github.com/graypegg/chromatism/blob/master/src/conversions/rgb.js // https://github.com/graypegg/chromatism/blob/master/src/conversions/rgb.js
const rgbToHsl = value => { const rgbToHsl = value => {
var r = value.r / 255; const r = value.r / 255;
var g = value.g / 255; const g = value.g / 255;
var b = value.b / 255; const b = value.b / 255;
var rgbOrdered = [ r, g, b ].sort(); const rgbOrdered = [ r, g, b ].sort();
var l = ((rgbOrdered[0] + rgbOrdered[2]) / 2) * 100; const l = ((rgbOrdered[0] + rgbOrdered[2]) / 2) * 100;
var s, h; let s, h;
if (rgbOrdered[0] === rgbOrdered[2]) { if (rgbOrdered[0] === rgbOrdered[2]) {
s = 0; s = 0;
h = 0; h = 0;

View file

@ -25,7 +25,7 @@ const backendEndpoints = [
]; ];
const makeProxyConfig = () => { const makeProxyConfig = () => {
let proxyConfig = {}; const proxyConfig = {};
proxyConfig['/api/patron'] = { proxyConfig['/api/patron'] = {
target: patronUrl, target: patronUrl,
secure: secureProxy, secure: secureProxy,

View file

@ -105,7 +105,7 @@ manageTranslations({
/* eslint-disable no-console */ /* eslint-disable no-console */
function findVariablesinAST(tree) { function findVariablesinAST(tree) {
let result = new Set(); const result = new Set();
tree.forEach((element) => { tree.forEach((element) => {
switch (element.type) { switch (element.type) {
case parser.TYPE.argument: case parser.TYPE.argument:
@ -114,7 +114,7 @@ function findVariablesinAST(tree) {
break; break;
case parser.TYPE.plural: case parser.TYPE.plural:
result.add(element.value); result.add(element.value);
let subTrees = Object.values(element.options).map((option) => option.value); const subTrees = Object.values(element.options).map((option) => option.value);
subTrees.forEach((subtree) => { subTrees.forEach((subtree) => {
findVariablesinAST(subtree).forEach((variable) => { findVariablesinAST(subtree).forEach((variable) => {
result.add(variable); result.add(variable);
@ -139,7 +139,7 @@ const extractedMessagesFiles = readMessageFiles(translationsDirectory);
const extractedMessages = extractedMessagesFiles.reduce((acc, messageFile) => { const extractedMessages = extractedMessagesFiles.reduce((acc, messageFile) => {
messageFile.descriptors.forEach((descriptor) => { messageFile.descriptors.forEach((descriptor) => {
descriptor.descriptors.forEach((item) => { descriptor.descriptors.forEach((item) => {
let variables = findVariables(item.defaultMessage); const variables = findVariables(item.defaultMessage);
acc.push({ acc.push({
id: item.id, id: item.id,
defaultMessage: item.defaultMessage, defaultMessage: item.defaultMessage,
@ -172,7 +172,7 @@ function pushIfUnique(arr, newItem) {
const problems = translations.reduce((acc, translation) => { const problems = translations.reduce((acc, translation) => {
extractedMessages.forEach((message) => { extractedMessages.forEach((message) => {
try { try {
let translationVariables = findVariables(translation.data[message.id]); const translationVariables = findVariables(translation.data[message.id]);
if ([...difference(translationVariables, message.variables)].length > 0) { if ([...difference(translationVariables, message.variables)].length > 0) {
pushIfUnique(acc, { pushIfUnique(acc, {
language: translation.language, language: translation.language,
@ -206,7 +206,7 @@ if (problems.length > 0) {
console.error('-'.repeat(60)); console.error('-'.repeat(60));
problems.forEach((problem) => { problems.forEach((problem) => {
let color = (problem.severity === 'error') ? '\x1b[31m' : ''; const color = (problem.severity === 'error') ? '\x1b[31m' : '';
console.error(`${color}${problem.language}\t${problem.type}\t${problem.id}\x1b[0m`); console.error(`${color}${problem.language}\t${problem.type}\t${problem.id}\x1b[0m`);
}); });
console.error('\n'); console.error('\n');