eslint: extend 'eslint:recommended'
This commit is contained in:
parent
ad2db4e7bc
commit
594cf088ed
11
.eslintrc.js
11
.eslintrc.js
|
@ -1,6 +1,8 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
|
||||
extends: 'eslint:recommended',
|
||||
|
||||
env: {
|
||||
browser: true,
|
||||
node: true,
|
||||
|
@ -79,8 +81,10 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
'no-extra-semi': 'error',
|
||||
'no-const-assign': 'error',
|
||||
'no-fallthrough': 'error',
|
||||
'no-irregular-whitespace': 'error',
|
||||
'no-loop-func': 'error',
|
||||
'no-mixed-spaces-and-tabs': 'error',
|
||||
'no-nested-ternary': 'warn',
|
||||
'no-trailing-spaces': 'warn',
|
||||
|
@ -95,6 +99,8 @@ module.exports = {
|
|||
ignoreRestSiblings: true,
|
||||
},
|
||||
],
|
||||
'no-useless-escape': 'warn',
|
||||
'no-var': 'error',
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'padded-blocks': [
|
||||
'error',
|
||||
|
@ -102,14 +108,11 @@ module.exports = {
|
|||
classes: 'always',
|
||||
},
|
||||
],
|
||||
'prefer-const': 'error',
|
||||
quotes: ['error', 'single'],
|
||||
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'],
|
||||
|
|
|
@ -35,7 +35,9 @@ function Blurhash({
|
|||
|
||||
useEffect(() => {
|
||||
const { current: canvas } = canvasRef;
|
||||
canvas.width = canvas.width; // resets canvas
|
||||
|
||||
// resets canvas
|
||||
canvas.width = canvas.width; // eslint-disable-line no-self-assign
|
||||
|
||||
if (dummy || !hash) return;
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class RelativeTimestamp extends React.Component {
|
|||
this.state.now !== nextState.now;
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
UNSAFE_componentWillReceiveProps(prevProps) {
|
||||
if (this.props.timestamp !== prevProps.timestamp) {
|
||||
this.setState({ now: Date.now() });
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class RelativeTimestamp extends React.Component {
|
|||
this._scheduleNextUpdate(this.props, this.state);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
UNSAFE_componentWillUpdate() {
|
||||
this._scheduleNextUpdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,6 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
allowedEmoji: ImmutablePropTypes.list,
|
||||
emojiSelectorFocused: PropTypes.bool,
|
||||
handleEmojiSelectorUnfocus: PropTypes.func.isRequired,
|
||||
emojiSelectorFocused: PropTypes.bool,
|
||||
handleEmojiSelectorUnfocus: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
@ -245,7 +243,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
} catch (e) {
|
||||
|
||||
// Do nothing
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class ReportStatus extends ImmutablePureComponent {
|
|||
|
||||
if (status.get('media_attachments').size > 0) {
|
||||
if (status.get('media_attachments').some(item => item.get('type') === 'unknown')) {
|
||||
|
||||
// Do nothing
|
||||
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
|
||||
const video = status.getIn(['media_attachments', 0]);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ const stringSupplant = function(str, values) {
|
|||
};
|
||||
|
||||
export const urlRegex = (function() {
|
||||
regexen.spaces_group = /\x09-\x0D\x20\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000/;
|
||||
regexen.spaces_group = /\x09-\x0D\x20\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000/; // eslint-disable-line no-control-regex
|
||||
regexen.invalid_chars_group = /\uFFFE\uFEFF\uFFFF\u202A-\u202E/;
|
||||
regexen.punct = /\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$/;
|
||||
regexen.validUrlPrecedingChars = regexSupplant(/(?:[^A-Za-z0-9@@$###{invalid_chars_group}]|^)/);
|
||||
|
|
|
@ -70,7 +70,6 @@ const stringFromCodePoint = _String.fromCodePoint || function() {
|
|||
return result;
|
||||
};
|
||||
|
||||
|
||||
const _JSON = JSON;
|
||||
|
||||
const COLONS_REGEX = /^(?:\:([^\:]+)\:)(?:\:skin-tone-(\d)\:)?$/;
|
||||
|
@ -131,19 +130,19 @@ function getData(emoji, skin, set) {
|
|||
}
|
||||
}
|
||||
|
||||
if (data.short_names.hasOwnProperty(emoji)) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.short_names, emoji)) {
|
||||
emoji = data.short_names[emoji];
|
||||
}
|
||||
|
||||
if (data.emojis.hasOwnProperty(emoji)) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.emojis, emoji)) {
|
||||
emojiData = data.emojis[emoji];
|
||||
}
|
||||
} else if (emoji.id) {
|
||||
if (data.short_names.hasOwnProperty(emoji.id)) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.short_names, emoji.id)) {
|
||||
emoji.id = data.short_names[emoji.id];
|
||||
}
|
||||
|
||||
if (data.emojis.hasOwnProperty(emoji.id)) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.emojis, emoji.id)) {
|
||||
emojiData = data.emojis[emoji.id];
|
||||
skin = skin || emoji.skin;
|
||||
}
|
||||
|
@ -212,7 +211,7 @@ function deepMerge(a, b) {
|
|||
const originalValue = a[key];
|
||||
let value = originalValue;
|
||||
|
||||
if (b.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(b, key)) {
|
||||
value = b[key];
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class StatusCheckBox extends React.PureComponent {
|
|||
|
||||
if (status.get('media_attachments').size > 0) {
|
||||
if (status.get('media_attachments').some(item => item.get('type') === 'unknown')) {
|
||||
|
||||
// Do nothing
|
||||
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
|
||||
const video = status.getIn(['media_attachments', 0]);
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ class ActionBar extends React.PureComponent {
|
|||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
} catch (e) {
|
||||
|
||||
// Do nothing
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ class UI extends React.PureComponent {
|
|||
try {
|
||||
e.dataTransfer.dropEffect = 'copy';
|
||||
} catch (err) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -164,9 +164,11 @@ describe('auth reducer', () => {
|
|||
};
|
||||
|
||||
const state = fromJS({
|
||||
users: { '4567': { id: '4567', access_token: 'ABCDEFG' } },
|
||||
users: { '8901': { id: '1234', access_token: 'ABCDEFG' } },
|
||||
users: { '5432': { id: '5432', access_token: 'HIJKLMN' } },
|
||||
users: {
|
||||
'4567': { id: '4567', access_token: 'ABCDEFG' },
|
||||
'8901': { id: '1234', access_token: 'ABCDEFG' },
|
||||
'5432': { id: '5432', access_token: 'HIJKLMN' },
|
||||
},
|
||||
});
|
||||
|
||||
const expected = fromJS({
|
||||
|
|
|
@ -137,7 +137,6 @@ describe('list_editor reducer', () => {
|
|||
});
|
||||
|
||||
it('should handle LIST_UPDATE_FAIL', () => {
|
||||
debugger;
|
||||
const state = ImmutableMap({
|
||||
isSubmitting: true,
|
||||
});
|
||||
|
|
|
@ -19,7 +19,6 @@ describe('modal reducer', () => {
|
|||
modalType: 'type1',
|
||||
modalProps: { props1: '1' },
|
||||
};
|
||||
debugger;
|
||||
expect(reducer(state, action)).toMatchObject({
|
||||
modalType: 'type1',
|
||||
modalProps: { props1: '1' },
|
||||
|
@ -34,7 +33,6 @@ describe('modal reducer', () => {
|
|||
const action = {
|
||||
type: MODAL_CLOSE,
|
||||
};
|
||||
debugger;
|
||||
expect(reducer(state, action)).toMatchObject({
|
||||
modalType: null,
|
||||
modalProps: {},
|
||||
|
|
|
@ -55,6 +55,9 @@ const notificationToMap = notification => ImmutableMap({
|
|||
// https://gitlab.com/soapbox-pub/soapbox-fe/-/issues/424
|
||||
const isValid = notification => Boolean(notification.account.id);
|
||||
|
||||
const countUnseen = notifications => notifications.reduce((acc, cur) =>
|
||||
get(cur, ['pleroma', 'is_seen'], false) === false ? acc + 1 : acc, 0);
|
||||
|
||||
const normalizeNotification = (state, notification) => {
|
||||
const top = state.get('top');
|
||||
|
||||
|
@ -78,12 +81,16 @@ const processRawNotifications = notifications => (
|
|||
|
||||
const expandNormalizedNotifications = (state, notifications, next) => {
|
||||
const items = processRawNotifications(notifications);
|
||||
const unread = state.get('unread');
|
||||
const legacyUnread = countUnseen(notifications);
|
||||
|
||||
return state.withMutations(mutable => {
|
||||
mutable.update('items', map => map.merge(items).sort(comparator));
|
||||
|
||||
if (!next) mutable.set('hasMore', false);
|
||||
mutable.set('isLoading', false);
|
||||
|
||||
mutable.set('unread', Math.max(legacyUnread, unread));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -127,9 +134,6 @@ const updateNotificationsQueue = (state, notification, intlMessages, intlLocale)
|
|||
});
|
||||
};
|
||||
|
||||
const countUnseen = notifications => notifications.reduce((acc, cur) =>
|
||||
get(cur, ['pleroma', 'is_seen'], false) === false ? acc + 1 : acc, 0);
|
||||
|
||||
export default function notifications(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case NOTIFICATIONS_EXPAND_REQUEST:
|
||||
|
@ -150,9 +154,7 @@ export default function notifications(state = initialState, action) {
|
|||
mutable.set('totalQueuedNotificationsCount', 0);
|
||||
});
|
||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
||||
const legacyUnread = countUnseen(action.notifications);
|
||||
return expandNormalizedNotifications(state, action.notifications, action.next)
|
||||
.merge({ unread: Math.max(legacyUnread, state.get('unread')) });
|
||||
return expandNormalizedNotifications(state, action.notifications, action.next);
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
return filterNotifications(state, action.relationship);
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
|
|
|
@ -8,13 +8,18 @@ const initialState = ImmutableMap({
|
|||
tokens: ImmutableList(),
|
||||
});
|
||||
|
||||
const deleteToken = (state, tokenId) => {
|
||||
return state.update('tokens', tokens => {
|
||||
return tokens.filterNot(token => token.get('id') === tokenId);
|
||||
});
|
||||
};
|
||||
|
||||
export default function security(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case FETCH_TOKENS_SUCCESS:
|
||||
return state.set('tokens', fromJS(action.tokens));
|
||||
case REVOKE_TOKEN_SUCCESS:
|
||||
const idx = state.get('tokens').findIndex(t => t.get('id') === action.id);
|
||||
return state.deleteIn(['tokens', idx]);
|
||||
return deleteToken(state, action.id);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ export default class Settings {
|
|||
try {
|
||||
localStorage.removeItem(key);
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
return data;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import { FormattedNumber } from 'react-intl';
|
||||
|
||||
const isNumber = number => typeof number === 'number' && number !== NaN;
|
||||
const isNumber = number => typeof number === 'number' && !isNaN(number);
|
||||
|
||||
export const shortNumberFormat = number => {
|
||||
if (!isNumber(number)) return '•';
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-case-declarations */
|
||||
import EXIF from 'exif-js';
|
||||
|
||||
const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px
|
||||
|
|
|
@ -114,12 +114,11 @@ function findVariablesinAST(tree) {
|
|||
break;
|
||||
case parser.TYPE.plural:
|
||||
result.add(element.value);
|
||||
const subTrees = Object.values(element.options).map((option) => option.value);
|
||||
subTrees.forEach((subtree) => {
|
||||
findVariablesinAST(subtree).forEach((variable) => {
|
||||
result.add(variable);
|
||||
});
|
||||
});
|
||||
Object.values(element.options)
|
||||
.map(option => option.value)
|
||||
.forEach(subtree =>
|
||||
findVariablesinAST(subtree)
|
||||
.forEach(variable => result.add(variable)));
|
||||
break;
|
||||
case parser.TYPE.literal:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue