eslint: prefer-const, no-loop-func, no-const-assign, no-var
This commit is contained in:
parent
249c76ffaa
commit
a310197a5a
53 changed files with 136 additions and 136 deletions
|
@ -105,6 +105,10 @@ module.exports = {
|
|||
semi: 'error',
|
||||
strict: 'off',
|
||||
'valid-typeof': 'error',
|
||||
'prefer-const': 'error',
|
||||
'no-loop-func': 'error',
|
||||
'no-const-assign': 'error',
|
||||
'no-var': 'error',
|
||||
|
||||
'react/jsx-boolean-value': 'error',
|
||||
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
|
||||
|
|
|
@ -45,7 +45,7 @@ export function showAlertForError(error) {
|
|||
}
|
||||
|
||||
let message = statusText;
|
||||
let title = `${status}`;
|
||||
const title = `${status}`;
|
||||
|
||||
if (data.error) {
|
||||
message = data.error;
|
||||
|
|
|
@ -148,7 +148,7 @@ export function handleComposeSubmit(dispatch, getState, data, status) {
|
|||
const timeline = getState().getIn(['timelines', timelineId]);
|
||||
|
||||
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']);
|
||||
dispatch(dequeueTimeline(timelineId, null, dequeueArgs));
|
||||
dispatch(updateTimeline(timelineId, data.id));
|
||||
|
@ -272,6 +272,8 @@ export function uploadCompose(files) {
|
|||
for (const [i, f] of Array.from(files).entries()) {
|
||||
if (media.size + i > uploadLimit - 1) break;
|
||||
|
||||
// FIXME: Don't define function in loop
|
||||
/* eslint-disable no-loop-func */
|
||||
resizeImage(f).then(file => {
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
|
@ -287,6 +289,7 @@ export function uploadCompose(files) {
|
|||
.then(({ data }) => dispatch(uploadComposeSuccess(data)));
|
||||
|
||||
}).catch(error => dispatch(uploadComposeFail(error)));
|
||||
/* eslint-enable no-loop-func */
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -11,8 +11,8 @@ import { List as ImmutableList } from 'immutable';
|
|||
const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => {
|
||||
let word;
|
||||
|
||||
let left = str.slice(0, caretPosition).search(/\S+$/);
|
||||
let right = str.slice(caretPosition).search(/\s/);
|
||||
const left = str.slice(0, caretPosition).search(/\S+$/);
|
||||
const right = str.slice(caretPosition).search(/\s/);
|
||||
|
||||
if (right < 0) {
|
||||
word = str.slice(left);
|
||||
|
|
|
@ -11,8 +11,8 @@ import classNames from 'classnames';
|
|||
const textAtCursorMatchesToken = (str, caretPosition) => {
|
||||
let word;
|
||||
|
||||
let left = str.slice(0, caretPosition).search(/\S+$/);
|
||||
let right = str.slice(caretPosition).search(/\s/);
|
||||
const left = str.slice(0, caretPosition).search(/\S+$/);
|
||||
const right = str.slice(caretPosition).search(/\s/);
|
||||
|
||||
if (right < 0) {
|
||||
word = str.slice(left);
|
||||
|
|
|
@ -41,7 +41,7 @@ export default class ExtendedVideoPlayer extends React.PureComponent {
|
|||
|
||||
render() {
|
||||
const { src, muted, controls, alt } = this.props;
|
||||
let conditionalAttributes = {};
|
||||
const conditionalAttributes = {};
|
||||
if (isIOS()) {
|
||||
conditionalAttributes.playsInline = '1';
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ class Item extends React.PureComponent {
|
|||
</a>
|
||||
);
|
||||
} else if (attachment.get('type') === 'gifv') {
|
||||
let conditionalAttributes = {};
|
||||
const conditionalAttributes = {};
|
||||
if (isIOS()) {
|
||||
conditionalAttributes.playsInline = '1';
|
||||
}
|
||||
|
@ -563,9 +563,8 @@ class MediaGallery extends React.PureComponent {
|
|||
const { media, intl, sensitive } = this.props;
|
||||
const { visible } = this.state;
|
||||
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
|
||||
key={attachment.get('id')}
|
||||
onClick={this.handleClick}
|
||||
|
@ -580,6 +579,8 @@ class MediaGallery extends React.PureComponent {
|
|||
/>
|
||||
));
|
||||
|
||||
let spoilerButton;
|
||||
|
||||
if (visible) {
|
||||
spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible)} icon='eye-slash' overlay onClick={this.handleOpen} />;
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
const getAccount = makeGetAccount();
|
||||
|
||||
const getBadges = (account) => {
|
||||
let badges = [];
|
||||
const badges = [];
|
||||
|
||||
if (isAdmin(account)) {
|
||||
badges.push(<Badge key='admin' slug='admin' title='Admin' />);
|
||||
|
|
|
@ -292,13 +292,13 @@ class Status extends ImmutablePureComponent {
|
|||
|
||||
render() {
|
||||
let media = null;
|
||||
let poll = null;
|
||||
const poll = null;
|
||||
let statusAvatar, prepend, rebloggedByText, reblogContent;
|
||||
|
||||
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) {
|
||||
return null;
|
||||
|
|
|
@ -284,7 +284,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
const mutingConversation = status.get('muted');
|
||||
const ownAccount = status.getIn(['account', 'id']) === me;
|
||||
|
||||
let menu = [];
|
||||
const menu = [];
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.open), action: this.handleOpen });
|
||||
|
||||
|
@ -388,7 +388,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
'😩': messages.reactionWeary,
|
||||
}[meEmojiReact] || messages.favourite);
|
||||
|
||||
let menu = this._makeMenu(publicStatus);
|
||||
const menu = this._makeMenu(publicStatus);
|
||||
let reblogIcon = 'retweet';
|
||||
let replyIcon;
|
||||
let replyTitle;
|
||||
|
|
|
@ -50,8 +50,8 @@ class StatusContent extends React.PureComponent {
|
|||
|
||||
const links = node.querySelectorAll('a');
|
||||
|
||||
for (var i = 0; i < links.length; ++i) {
|
||||
let link = links[i];
|
||||
for (let i = 0; i < links.length; ++i) {
|
||||
const link = links[i];
|
||||
if (link.classList.contains('status-link')) {
|
||||
continue;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class StatusContent extends React.PureComponent {
|
|||
link.setAttribute('rel', 'nofollow noopener');
|
||||
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) {
|
||||
link.addEventListener('click', this.onMentionClick.bind(this, mention), false);
|
||||
|
|
|
@ -69,7 +69,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
|
||||
onReply(status, router) {
|
||||
dispatch((_, getState) => {
|
||||
let state = getState();
|
||||
const state = getState();
|
||||
if (state.getIn(['compose', 'text']).trim().length !== 0) {
|
||||
dispatch(openModal('CONFIRM', {
|
||||
message: intl.formatMessage(messages.replyMessage),
|
||||
|
|
|
@ -138,7 +138,7 @@ class Header extends ImmutablePureComponent {
|
|||
makeMenu() {
|
||||
const { account, intl, me, meAccount, version } = this.props;
|
||||
|
||||
let menu = [];
|
||||
const menu = [];
|
||||
|
||||
if (!account || !me) {
|
||||
return [];
|
||||
|
@ -245,7 +245,7 @@ class Header extends ImmutablePureComponent {
|
|||
makeInfo() {
|
||||
const { account, me } = this.props;
|
||||
|
||||
let info = [];
|
||||
const info = [];
|
||||
|
||||
if (!account || !me) return info;
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class MediaItem extends ImmutablePureComponent {
|
|||
/>
|
||||
);
|
||||
} else if (['gifv', 'video'].indexOf(attachment.get('type')) !== -1) {
|
||||
let conditionalAttributes = {};
|
||||
const conditionalAttributes = {};
|
||||
if (isIOS()) {
|
||||
conditionalAttributes.playsInline = '1';
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
|
|||
if (accountFetchError) {
|
||||
accountId = null;
|
||||
} 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;
|
||||
accountUsername = account ? account.getIn(['acct'], '') : '';
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
|
|||
if (accountFetchError) {
|
||||
accountId = null;
|
||||
} 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;
|
||||
accountUsername = account ? account.getIn(['acct'], '') : '';
|
||||
accountApId = account ? account.get('url') : '';
|
||||
|
|
|
@ -67,7 +67,7 @@ class ActionBar extends React.PureComponent {
|
|||
const { intl, onClickLogOut, meUsername, isStaff } = this.props;
|
||||
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.lists), to: '/lists' });
|
||||
|
|
|
@ -38,7 +38,7 @@ const getFrequentlyUsedEmojis = createSelector([
|
|||
.toArray();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ const regexSupplant = function(regex, flags) {
|
|||
regex = regex.source;
|
||||
}
|
||||
return new RegExp(regex.replace(/#\{(\w+)\}/g, function(match, name) {
|
||||
var newRegex = regexen[name] || '';
|
||||
let newRegex = regexen[name] || '';
|
||||
if (typeof newRegex !== 'string') {
|
||||
newRegex = newRegex.source;
|
||||
}
|
||||
|
|
|
@ -142,8 +142,8 @@ class EditProfile extends ImmutablePureComponent {
|
|||
|
||||
getFormdata = () => {
|
||||
const data = this.getParams();
|
||||
let formData = new FormData();
|
||||
for (let key in data) {
|
||||
const formData = new FormData();
|
||||
for (const key in data) {
|
||||
// Compact the submission. This should probably be done better.
|
||||
const shouldAppend = Boolean(data[key] !== undefined || key.startsWith('fields_attributes'));
|
||||
if (shouldAppend) formData.append(key, data[key] || '');
|
||||
|
|
|
@ -18,6 +18,8 @@ const emojify = (str, customEmojis = {}, autoplay = false) => {
|
|||
if (i === str.length) {
|
||||
break;
|
||||
} else if (str[i] === ':') {
|
||||
// FIXME: This is insane.
|
||||
/* eslint-disable no-loop-func */
|
||||
if (!(() => {
|
||||
rend = str.indexOf(':', i + 1) + 1;
|
||||
if (!rend) return false; // no pair of ':'
|
||||
|
@ -33,6 +35,7 @@ const emojify = (str, customEmojis = {}, autoplay = false) => {
|
|||
}
|
||||
return false;
|
||||
})()) rend = ++i;
|
||||
/* eslint-enable no-loop-func */
|
||||
} else if (tag >= 0) { // <, &
|
||||
rend = str.indexOf('>;'[tag], i + 1) + 1;
|
||||
if (!rend) {
|
||||
|
|
|
@ -87,7 +87,7 @@ Object.keys(emojiIndex.emojis).forEach(key => {
|
|||
}
|
||||
|
||||
const { native } = emoji;
|
||||
let { short_names, search, unified } = emojiMartData.emojis[key];
|
||||
const { short_names, search, unified } = emojiMartData.emojis[key];
|
||||
|
||||
if (short_names[0] !== key) {
|
||||
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.');
|
||||
}
|
||||
|
||||
short_names = short_names.slice(1); // first short name can be inferred from the key
|
||||
|
||||
const searchData = [native, short_names, search];
|
||||
const searchData = [
|
||||
native,
|
||||
short_names.slice(1), // first short name can be inferred from the key
|
||||
search,
|
||||
];
|
||||
|
||||
if (unicodeToUnifiedName(native) !== unified) {
|
||||
// unified name can't be derived from unicodeToUnifiedName
|
||||
|
|
|
@ -8,28 +8,22 @@ const emojis = {};
|
|||
|
||||
// decompress
|
||||
Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
|
||||
let [
|
||||
const [
|
||||
filenameData, // eslint-disable-line no-unused-vars
|
||||
searchData,
|
||||
] = shortCodesToEmojiData[shortCode];
|
||||
let [
|
||||
const [
|
||||
native,
|
||||
short_names,
|
||||
search,
|
||||
unified,
|
||||
] = searchData;
|
||||
|
||||
if (!unified) {
|
||||
// unified name can be derived from unicodeToUnifiedName
|
||||
unified = unicodeToUnifiedName(native);
|
||||
}
|
||||
|
||||
short_names = [shortCode].concat(short_names);
|
||||
emojis[shortCode] = {
|
||||
native,
|
||||
search,
|
||||
short_names,
|
||||
unified,
|
||||
short_names: [shortCode].concat(short_names),
|
||||
unified: unified || unicodeToUnifiedName(native),
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
import data from './emoji_mart_data_light';
|
||||
import { getData, getSanitizedData, uniq, intersect } from './emoji_utils';
|
||||
|
||||
let originalPool = {};
|
||||
const originalPool = {};
|
||||
let index = {};
|
||||
let emojisList = {};
|
||||
let emoticonsList = {};
|
||||
const emojisList = {};
|
||||
const emoticonsList = {};
|
||||
let customEmojisList = [];
|
||||
|
||||
for (let emoji in data.emojis) {
|
||||
let emojiData = data.emojis[emoji];
|
||||
let { short_names, emoticons } = emojiData;
|
||||
let id = short_names[0];
|
||||
for (const emoji in data.emojis) {
|
||||
const emojiData = data.emojis[emoji];
|
||||
const { short_names, emoticons } = emojiData;
|
||||
const id = short_names[0];
|
||||
|
||||
if (emoticons) {
|
||||
emoticons.forEach(emoticon => {
|
||||
|
@ -31,7 +31,7 @@ for (let emoji in data.emojis) {
|
|||
|
||||
function clearCustomEmojis(pool) {
|
||||
customEmojisList.forEach((emoji) => {
|
||||
let emojiId = emoji.id || emoji.short_names[0];
|
||||
const emojiId = emoji.id || emoji.short_names[0];
|
||||
|
||||
delete pool[emojiId];
|
||||
delete emojisList[emojiId];
|
||||
|
@ -42,7 +42,7 @@ export function addCustomToPool(custom, pool = originalPool) {
|
|||
if (customEmojisList.length) clearCustomEmojis(pool);
|
||||
|
||||
custom.forEach((emoji) => {
|
||||
let emojiId = emoji.id || emoji.short_names[0];
|
||||
const emojiId = emoji.id || emoji.short_names[0];
|
||||
|
||||
if (emojiId && !pool[emojiId]) {
|
||||
pool[emojiId] = getData(emoji);
|
||||
|
@ -85,8 +85,8 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
|
|||
pool = {};
|
||||
|
||||
data.categories.forEach(category => {
|
||||
let isIncluded = include && include.length ? include.indexOf(category.name.toLowerCase()) > -1 : true;
|
||||
let isExcluded = exclude && exclude.length ? exclude.indexOf(category.name.toLowerCase()) > -1 : false;
|
||||
const isIncluded = include && include.length ? include.indexOf(category.name.toLowerCase()) > -1 : true;
|
||||
const isExcluded = exclude && exclude.length ? exclude.indexOf(category.name.toLowerCase()) > -1 : false;
|
||||
if (!isIncluded || isExcluded) {
|
||||
return;
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
|
|||
});
|
||||
|
||||
if (custom.length) {
|
||||
let customIsIncluded = include && include.length ? include.indexOf('custom') > -1 : true;
|
||||
let customIsExcluded = exclude && exclude.length ? exclude.indexOf('custom') > -1 : false;
|
||||
const customIsIncluded = include && include.length ? include.indexOf('custom') > -1 : true;
|
||||
const customIsExcluded = exclude && exclude.length ? exclude.indexOf('custom') > -1 : false;
|
||||
if (customIsIncluded && !customIsExcluded) {
|
||||
addCustomToPool(custom, pool);
|
||||
}
|
||||
|
@ -116,13 +116,13 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
|
|||
aIndex = aIndex[char];
|
||||
|
||||
if (!aIndex.results) {
|
||||
let scores = {};
|
||||
const scores = {};
|
||||
|
||||
aIndex.results = [];
|
||||
aIndex.pool = {};
|
||||
|
||||
for (let id in aPool) {
|
||||
let emoji = aPool[id],
|
||||
for (const id in aPool) {
|
||||
const emoji = aPool[id],
|
||||
{ search } = emoji,
|
||||
sub = value.substr(0, length),
|
||||
subIndex = search.indexOf(sub);
|
||||
|
@ -139,7 +139,7 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
|
|||
}
|
||||
|
||||
aIndex.results.sort((a, b) => {
|
||||
let aScore = scores[a.id],
|
||||
const aScore = scores[a.id],
|
||||
bScore = scores[b.id];
|
||||
|
||||
return aScore - bScore;
|
||||
|
|
|
@ -15,19 +15,16 @@ const { unicodeToFilename } = require('./unicode_to_filename');
|
|||
const unicodeMapping = {};
|
||||
|
||||
function processEmojiMapData(emojiMapData, shortCode) {
|
||||
let [ native, filename ] = emojiMapData;
|
||||
if (!filename) {
|
||||
// filename name can be derived from unicodeToFilename
|
||||
filename = unicodeToFilename(native);
|
||||
}
|
||||
const [ native, filename ] = emojiMapData;
|
||||
|
||||
unicodeMapping[native] = {
|
||||
shortCode: shortCode,
|
||||
filename: filename,
|
||||
shortCode,
|
||||
filename: filename || unicodeToFilename(native),
|
||||
};
|
||||
}
|
||||
|
||||
Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
|
||||
let [ filenameData ] = shortCodesToEmojiData[shortCode];
|
||||
const [ filenameData ] = shortCodesToEmojiData[shortCode];
|
||||
filenameData.forEach(emojiMapData => processEmojiMapData(emojiMapData, shortCode));
|
||||
});
|
||||
emojisWithoutShortCodes.forEach(emojiMapData => processEmojiMapData(emojiMapData));
|
||||
|
|
|
@ -6,7 +6,7 @@ import data from './emoji_mart_data_light';
|
|||
const buildSearch = (data) => {
|
||||
const search = [];
|
||||
|
||||
let addToSearch = (strings, split) => {
|
||||
const addToSearch = (strings, split) => {
|
||||
if (!strings) {
|
||||
return;
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ const buildSearch = (data) => {
|
|||
const _String = String;
|
||||
|
||||
const stringFromCodePoint = _String.fromCodePoint || function() {
|
||||
let MAX_SIZE = 0x4000;
|
||||
let codeUnits = [];
|
||||
const MAX_SIZE = 0x4000;
|
||||
const codeUnits = [];
|
||||
let highSurrogate;
|
||||
let lowSurrogate;
|
||||
let index = -1;
|
||||
let length = arguments.length;
|
||||
const length = arguments.length;
|
||||
if (!length) {
|
||||
return '';
|
||||
}
|
||||
|
@ -80,16 +80,16 @@ const SKINS = [
|
|||
];
|
||||
|
||||
function unifiedToNative(unified) {
|
||||
let unicodes = unified.split('-'),
|
||||
const unicodes = unified.split('-'),
|
||||
codePoints = unicodes.map((u) => `0x${u}`);
|
||||
|
||||
return stringFromCodePoint.apply(null, codePoints);
|
||||
}
|
||||
|
||||
function sanitize(emoji) {
|
||||
let { name, short_names, skin_tone, skin_variations, emoticons, unified, custom, imageUrl } = emoji,
|
||||
id = emoji.id || short_names[0],
|
||||
colons = `:${id}:`;
|
||||
const { name, short_names, skin_tone, skin_variations, emoticons, unified, custom, imageUrl } = emoji;
|
||||
const id = emoji.id || short_names[0];
|
||||
const colons = `:${id}:`;
|
||||
|
||||
if (custom) {
|
||||
return {
|
||||
|
@ -102,14 +102,10 @@ function sanitize(emoji) {
|
|||
};
|
||||
}
|
||||
|
||||
if (skin_tone) {
|
||||
colons += `:skin-tone-${skin_tone}:`;
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
colons,
|
||||
colons: skin_tone ? `${colons}:skin-tone-${skin_tone}:` : colons,
|
||||
emoticons,
|
||||
unified: unified.toLowerCase(),
|
||||
skin: skin_tone || (skin_variations ? 1 : null),
|
||||
|
@ -125,7 +121,7 @@ function getData(emoji, skin, set) {
|
|||
let emojiData = {};
|
||||
|
||||
if (typeof emoji === 'string') {
|
||||
let matches = emoji.match(COLONS_REGEX);
|
||||
const matches = emoji.match(COLONS_REGEX);
|
||||
|
||||
if (matches) {
|
||||
emoji = matches[1];
|
||||
|
@ -168,7 +164,7 @@ function getData(emoji, skin, set) {
|
|||
if (emojiData.skin_variations && skin > 1 && set) {
|
||||
emojiData = JSON.parse(_JSON.stringify(emojiData));
|
||||
|
||||
let skinKey = SKINS[skin - 1],
|
||||
const skinKey = SKINS[skin - 1],
|
||||
variationData = emojiData.skin_variations[skinKey];
|
||||
|
||||
if (!variationData.variations && emojiData.variations) {
|
||||
|
@ -178,8 +174,8 @@ function getData(emoji, skin, set) {
|
|||
if (variationData[`has_img_${set}`]) {
|
||||
emojiData.skin_tone = skin;
|
||||
|
||||
for (let k in variationData) {
|
||||
let v = variationData[k];
|
||||
for (const k in variationData) {
|
||||
const v = variationData[k];
|
||||
emojiData[k] = v;
|
||||
}
|
||||
}
|
||||
|
@ -210,11 +206,11 @@ function intersect(a, b) {
|
|||
}
|
||||
|
||||
function deepMerge(a, b) {
|
||||
let o = {};
|
||||
const o = {};
|
||||
|
||||
for (let key in a) {
|
||||
let originalValue = a[key],
|
||||
value = originalValue;
|
||||
for (const key in a) {
|
||||
const originalValue = a[key];
|
||||
let value = originalValue;
|
||||
|
||||
if (b.hasOwnProperty(key)) {
|
||||
value = b[key];
|
||||
|
|
|
@ -96,7 +96,7 @@ class Filters extends ImmutablePureComponent {
|
|||
const { intl, dispatch } = this.props;
|
||||
const { phrase, whole_word, expires_at, irreversible } = this.state;
|
||||
const { home_timeline, public_timeline, notifications, conversations } = this.state;
|
||||
let context = [];
|
||||
const context = [];
|
||||
|
||||
if (home_timeline) {
|
||||
context.push('home');
|
||||
|
|
|
@ -28,7 +28,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
|
|||
if (accountFetchError) {
|
||||
accountId = null;
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const mapStateToProps = (state, { params, withReplies = false }) => {
|
|||
if (accountFetchError) {
|
||||
accountId = null;
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class HashtagTimeline extends React.PureComponent {
|
|||
};
|
||||
|
||||
title = () => {
|
||||
let title = [this.props.params.id];
|
||||
const title = [this.props.params.id];
|
||||
|
||||
if (this.additionalFor('any')) {
|
||||
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 = {}) {
|
||||
let any = (tags.any || []).map(tag => tag.value);
|
||||
let all = (tags.all || []).map(tag => tag.value);
|
||||
let none = (tags.none || []).map(tag => tag.value);
|
||||
const any = (tags.any || []).map(tag => tag.value);
|
||||
const all = (tags.all || []).map(tag => tag.value);
|
||||
const none = (tags.none || []).map(tag => tag.value);
|
||||
|
||||
[id, ...any].map(tag => {
|
||||
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 &&
|
||||
none.filter(tag => tags.includes(tag)).length === 0;
|
||||
|
|
|
@ -28,7 +28,7 @@ class CSVImporter extends ImmutablePureComponent {
|
|||
handleSubmit = (event) => {
|
||||
const { dispatch, action, intl } = this.props;
|
||||
|
||||
let params = new FormData();
|
||||
const params = new FormData();
|
||||
params.append('list', this.state.file);
|
||||
|
||||
this.setState({ isLoading: true });
|
||||
|
|
|
@ -22,7 +22,7 @@ export default class ColumnSettings extends React.PureComponent {
|
|||
onAllSoundsChange = (path, checked) => {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class MultiSettingToggle extends React.PureComponent {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class IconPickerMenu extends React.PureComponent {
|
|||
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 { modifierOpen } = this.state;
|
||||
|
||||
|
@ -209,7 +209,7 @@ class IconPickerDropdown extends React.PureComponent {
|
|||
const { intl, onPickEmoji, value } = this.props;
|
||||
const title = intl.formatMessage(messages.emoji);
|
||||
const { active, loading, placement } = this.state;
|
||||
let forkAwesomeIcons = require('../forkawesome.json');
|
||||
const forkAwesomeIcons = require('../forkawesome.json');
|
||||
|
||||
return (
|
||||
<div className='font-icon-picker-dropdown' onKeyDown={this.handleKeyDown}>
|
||||
|
|
|
@ -454,7 +454,7 @@ class ColorPicker extends React.PureComponent {
|
|||
|
||||
render() {
|
||||
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 (
|
||||
<div id='SketchPickerContainer' ref={this.setRef} style={{ ...style, marginLeft: margin_left_picker, position: 'absolute', zIndex: 1000 }}>
|
||||
|
|
|
@ -294,7 +294,7 @@ class ActionBar extends React.PureComponent {
|
|||
'😩': messages.reactionWeary,
|
||||
}[meEmojiReact] || messages.favourite);
|
||||
|
||||
let menu = [];
|
||||
const menu = [];
|
||||
|
||||
if (publicStatus) {
|
||||
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';
|
||||
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 (
|
||||
|
|
|
@ -179,7 +179,7 @@ export default class Card extends React.PureComponent {
|
|||
|
||||
let embed = '';
|
||||
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 (embedded) {
|
||||
|
|
|
@ -95,7 +95,7 @@ export default class DetailedStatus extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
let media = '';
|
||||
let poll = '';
|
||||
const poll = '';
|
||||
let statusTypeIcon = '';
|
||||
|
||||
if (this.props.measureHeight) {
|
||||
|
|
|
@ -59,7 +59,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
|
||||
onReply(status, router) {
|
||||
dispatch((_, getState) => {
|
||||
let state = getState();
|
||||
const state = getState();
|
||||
if (state.getIn(['compose', 'text']).trim().length !== 0) {
|
||||
dispatch(openModal('CONFIRM', {
|
||||
message: intl.formatMessage(messages.replyMessage),
|
||||
|
|
|
@ -90,7 +90,7 @@ const makeMapStateToProps = () => {
|
|||
const ids = [statusId];
|
||||
|
||||
while (ids.length > 0) {
|
||||
let id = ids.shift();
|
||||
const id = ids.shift();
|
||||
const replies = contextReplies.get(id);
|
||||
|
||||
if (statusId !== id) {
|
||||
|
@ -199,7 +199,7 @@ class Status extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
handleReplyClick = (status) => {
|
||||
let { askReplyConfirmation, dispatch, intl } = this.props;
|
||||
const { askReplyConfirmation, dispatch, intl } = this.props;
|
||||
if (askReplyConfirmation) {
|
||||
dispatch(openModal('CONFIRM', {
|
||||
message: intl.formatMessage(messages.replyMessage),
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class ColumnLoading extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
render() {
|
||||
let { title, icon } = this.props;
|
||||
const { title, icon } = this.props;
|
||||
return (
|
||||
<Column>
|
||||
<ColumnHeader icon={icon} title={title} focusable={false} />
|
||||
|
|
|
@ -103,7 +103,7 @@ class ProfileDropdown extends React.PureComponent {
|
|||
const { intl, account, otherAccounts } = this.props;
|
||||
const size = this.props.size || 16;
|
||||
|
||||
let menu = [];
|
||||
const menu = [];
|
||||
|
||||
menu.push({ text: this.renderAccount(account), to: `/@${account.get('acct')}` });
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class TabsBar extends React.PureComponent {
|
|||
|
||||
getNavLinks() {
|
||||
const { intl: { formatMessage }, logo, account, dashboardCount, notificationCount, chatsCount } = this.props;
|
||||
let links = [];
|
||||
const links = [];
|
||||
if (logo) {
|
||||
links.push(
|
||||
<Link key='logo' className='tabs-bar__link--logo' to='/' data-preview-title-id='column.home'>
|
||||
|
|
|
@ -208,7 +208,7 @@ class Video extends React.PureComponent {
|
|||
const x = (e.clientX - rect.left) / this.volWidth; //x position within the element.
|
||||
|
||||
if(!isNaN(x)) {
|
||||
var slideamt = x;
|
||||
let slideamt = x;
|
||||
if(x > 1) {
|
||||
slideamt = 1;
|
||||
} else if(x < 0) {
|
||||
|
|
|
@ -11,7 +11,7 @@ export function isMobile(width) {
|
|||
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
|
||||
let userTouching = false;
|
||||
let listenerOptions = supportsPassiveEvents ? { passive: true } : false;
|
||||
const listenerOptions = supportsPassiveEvents ? { passive: true } : false;
|
||||
|
||||
function touchListener() {
|
||||
userTouching = true;
|
||||
|
|
|
@ -12,8 +12,8 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
const parseItems = items => {
|
||||
let ids = [];
|
||||
let map = {};
|
||||
const ids = [];
|
||||
const map = {};
|
||||
|
||||
items.forEach(item => {
|
||||
ids.push(item.id);
|
||||
|
|
|
@ -113,7 +113,7 @@ const updateNotificationsQueue = (state, notification, intlMessages, intlLocale)
|
|||
const alreadyExists = queuedNotifications.has(notification.id) || listedNotifications.has(notification.id);
|
||||
if (alreadyExists) return state;
|
||||
|
||||
let newQueuedNotifications = queuedNotifications;
|
||||
const newQueuedNotifications = queuedNotifications;
|
||||
|
||||
return state.withMutations(mutable => {
|
||||
if (totalQueuedNotificationsCount <= MAX_QUEUED_NOTIFICATIONS) {
|
||||
|
|
|
@ -126,7 +126,7 @@ export const makeGetStatus = () => {
|
|||
const getAlertsBase = state => state.get('alerts');
|
||||
|
||||
export const getAlerts = createSelector([getAlertsBase], (base) => {
|
||||
let arr = [];
|
||||
const arr = [];
|
||||
|
||||
base.forEach(item => {
|
||||
arr.push({
|
||||
|
|
|
@ -3,7 +3,7 @@ import { List as ImmutableList } from 'immutable';
|
|||
|
||||
const guessDomain = account => {
|
||||
try {
|
||||
let re = /https?:\/\/(.*?)\//i;
|
||||
const re = /https?:\/\/(.*?)\//i;
|
||||
return re.exec(account.get('url'))[1];
|
||||
} catch(e) {
|
||||
return null;
|
||||
|
@ -50,7 +50,7 @@ export const getFollowDifference = (state, accountId, type) => {
|
|||
};
|
||||
|
||||
export const isLocal = account => {
|
||||
let domain = account.get('acct').split('@')[1];
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
return domain === undefined ? true : false;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ export const getFeatures = createSelector([
|
|||
});
|
||||
|
||||
export const parseVersion = version => {
|
||||
let regex = /^([\w\.]*)(?: \(compatible; ([\w]*) (.*)\))?$/;
|
||||
let match = regex.exec(version);
|
||||
const regex = /^([\w\.]*)(?: \(compatible; ([\w]*) (.*)\))?$/;
|
||||
const match = regex.exec(version);
|
||||
return {
|
||||
software: match[2] || 'Mastodon',
|
||||
version: match[3] || match[1],
|
||||
|
|
|
@ -29,12 +29,12 @@ function hexToRgb(hex) {
|
|||
// Taken from chromatism.js
|
||||
// https://github.com/graypegg/chromatism/blob/master/src/conversions/rgb.js
|
||||
const rgbToHsl = value => {
|
||||
var r = value.r / 255;
|
||||
var g = value.g / 255;
|
||||
var b = value.b / 255;
|
||||
var rgbOrdered = [ r, g, b ].sort();
|
||||
var l = ((rgbOrdered[0] + rgbOrdered[2]) / 2) * 100;
|
||||
var s, h;
|
||||
const r = value.r / 255;
|
||||
const g = value.g / 255;
|
||||
const b = value.b / 255;
|
||||
const rgbOrdered = [ r, g, b ].sort();
|
||||
const l = ((rgbOrdered[0] + rgbOrdered[2]) / 2) * 100;
|
||||
let s, h;
|
||||
if (rgbOrdered[0] === rgbOrdered[2]) {
|
||||
s = 0;
|
||||
h = 0;
|
||||
|
|
|
@ -25,7 +25,7 @@ const backendEndpoints = [
|
|||
];
|
||||
|
||||
const makeProxyConfig = () => {
|
||||
let proxyConfig = {};
|
||||
const proxyConfig = {};
|
||||
proxyConfig['/api/patron'] = {
|
||||
target: patronUrl,
|
||||
secure: secureProxy,
|
||||
|
|
|
@ -105,7 +105,7 @@ manageTranslations({
|
|||
/* eslint-disable no-console */
|
||||
|
||||
function findVariablesinAST(tree) {
|
||||
let result = new Set();
|
||||
const result = new Set();
|
||||
tree.forEach((element) => {
|
||||
switch (element.type) {
|
||||
case parser.TYPE.argument:
|
||||
|
@ -114,7 +114,7 @@ function findVariablesinAST(tree) {
|
|||
break;
|
||||
case parser.TYPE.plural:
|
||||
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) => {
|
||||
findVariablesinAST(subtree).forEach((variable) => {
|
||||
result.add(variable);
|
||||
|
@ -139,7 +139,7 @@ const extractedMessagesFiles = readMessageFiles(translationsDirectory);
|
|||
const extractedMessages = extractedMessagesFiles.reduce((acc, messageFile) => {
|
||||
messageFile.descriptors.forEach((descriptor) => {
|
||||
descriptor.descriptors.forEach((item) => {
|
||||
let variables = findVariables(item.defaultMessage);
|
||||
const variables = findVariables(item.defaultMessage);
|
||||
acc.push({
|
||||
id: item.id,
|
||||
defaultMessage: item.defaultMessage,
|
||||
|
@ -172,7 +172,7 @@ function pushIfUnique(arr, newItem) {
|
|||
const problems = translations.reduce((acc, translation) => {
|
||||
extractedMessages.forEach((message) => {
|
||||
try {
|
||||
let translationVariables = findVariables(translation.data[message.id]);
|
||||
const translationVariables = findVariables(translation.data[message.id]);
|
||||
if ([...difference(translationVariables, message.variables)].length > 0) {
|
||||
pushIfUnique(acc, {
|
||||
language: translation.language,
|
||||
|
@ -206,7 +206,7 @@ if (problems.length > 0) {
|
|||
console.error('-'.repeat(60));
|
||||
|
||||
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('\n');
|
||||
|
|
Loading…
Reference in a new issue