Commit c6d99bd5 authored by Nicolas Frandeboeuf's avatar Nicolas Frandeboeuf
Browse files

Upgrade prettier & related plugins

parent d2e8b8d5
Pipeline #296538 passed with stages
in 7 minutes
......@@ -34,12 +34,17 @@
- files: 'server/**/*.js'
rules:
prefer-const:
- 2
- 2
rules:
prettier/prettier:
- 2
- { printWidth: 100, tabWidth: 4, singleQuote: true, jsxBracketSameLine: true }
-
printWidth: 100
tabWidth: 4
singleQuote: true
jsxBracketSameLine: true
arrowParens: "avoid"
# Possible errors
#######################################################################
no-cond-assign:
......@@ -475,9 +480,10 @@
- "always"
space-before-function-paren:
- 2
# There's an incompatibility between eslint and prettier, so just
# accept spaces before async arrow functions.
- {anonymous: "never", named: "never", asyncArrow: "always"}
# There's an incompatibility between eslint and prettier (which forces spaces before
# parens for declaration functions and arrow functions), so just accept spaces in
# these cases.
- {anonymous: "always", named: "never", asyncArrow: "always"}
space-in-parens:
- 2
- "never"
......
......@@ -16,7 +16,7 @@ const DeleteAccessButton = connect(null, (dispatch, props) => {
return {
handleClick() {
actions.showModal(dispatch, DELETE_ACCESS_MODAL_SLUG, props.accessId);
}
},
};
})(props => {
return (
......@@ -31,14 +31,14 @@ const DeleteAccessButton = connect(null, (dispatch, props) => {
DeleteAccessButton.propTypes = {
// The account's unique id.
accessId: PropTypes.number.isRequired
accessId: PropTypes.number.isRequired,
};
export default connect(
(state, props) => {
return {
access: get.accessById(state, props.accessId),
isDemoEnabled: get.isDemoMode(state)
isDemoEnabled: get.isDemoMode(state),
};
},
(dispatch, props) => {
......@@ -60,7 +60,7 @@ export default connect(
handleOpenDisableModal(event) {
event.preventDefault();
actions.showModal(dispatch, DISABLE_MODAL_SLUG, props.accessId);
}
},
};
},
(stateToProps, dispatchToProp) => {
......@@ -73,7 +73,7 @@ export default connect(
},
setAccessCustomLabel(customLabel) {
return setAccessCustomLabel(stateToProps.access.customLabel, customLabel);
}
},
};
}
)(props => {
......
......@@ -13,7 +13,7 @@ import BankAccessItem from './access';
export default connect(state => {
return {
accessIds: get.accessIds(state),
isDemoMode: get.isDemoMode(state)
isDemoMode: get.isDemoMode(state),
};
})(props => {
let accesses = props.accessIds.map(id => <BankAccessItem key={id} accessId={id} />);
......
......@@ -18,16 +18,16 @@ const AccountLabelComponent = connect(null, (dispatch, props) => {
dispatch,
props.item.id,
{
customLabel: label
customLabel: label,
},
{
customLabel: props.item.customLabel
customLabel: props.item.customLabel,
}
);
},
getLabel() {
return props.item.label.trim();
}
},
};
})(LabelComponent);
......@@ -35,7 +35,7 @@ const DeleteAccountButton = connect(null, (dispatch, props) => {
return {
handleClick() {
actions.showModal(dispatch, DELETE_ACCOUNT_MODAL_SLUG, props.accountId);
}
},
};
})(props => {
return (
......@@ -50,14 +50,14 @@ const DeleteAccountButton = connect(null, (dispatch, props) => {
DeleteAccountButton.propTypes = {
// The account's unique id.
accountId: PropTypes.number.isRequired
accountId: PropTypes.number.isRequired,
};
const SyncAccountButton = connect(null, (dispatch, props) => {
return {
handleShowSyncModal() {
actions.showModal(dispatch, SYNC_ACCOUNT_MODAL_SLUG, props.accountId);
}
},
};
})(props => {
return (
......@@ -72,10 +72,10 @@ const SyncAccountButton = connect(null, (dispatch, props) => {
SyncAccountButton.propTypes = {
// The unique identifier of the account for which the balance has to be synced.
accountId: PropTypes.number.isRequired
accountId: PropTypes.number.isRequired,
};
const formatIBAN = function(iban) {
const formatIBAN = iban => {
return iban.replace(/(.{4})(?!$)/g, '$1\xa0');
};
......@@ -84,7 +84,7 @@ export default connect(
return {
isDefaultAccount: get.defaultAccountId(state) === props.accountId,
account: get.accountById(state, props.accountId),
isDemoEnabled: get.isDemoMode(state)
isDemoEnabled: get.isDemoMode(state),
};
},
......@@ -98,7 +98,7 @@ export default connect(
},
updateAccount(update, previousAttributes) {
actions.updateAccount(dispatch, props.accountId, update, previousAttributes);
}
},
};
},
......@@ -112,13 +112,13 @@ export default connect(
handleExcludeFromBalance() {
dispatchToProps.updateAccount(
{
excludeFromBalance: !currentExcludeFromBalance
excludeFromBalance: !currentExcludeFromBalance,
},
{
excludeFromBalance: currentExcludeFromBalance
excludeFromBalance: currentExcludeFromBalance,
}
);
}
},
};
}
)(props => {
......
......@@ -19,7 +19,7 @@ const ConfirmDeleteModal = connect(
return {
label,
customLabel,
accessId
accessId,
};
},
......@@ -27,7 +27,7 @@ const ConfirmDeleteModal = connect(
return {
deleteAccess(accessId) {
actions.deleteAccess(dispatch, accessId);
}
},
};
},
......@@ -37,7 +37,7 @@ const ConfirmDeleteModal = connect(
customLabel,
handleDelete() {
deleteAccess(accessId);
}
},
};
}
)(props => {
......
......@@ -17,7 +17,7 @@ const ConfirmDeleteModal = connect(
let label = account ? displayLabel(account) : null;
return {
accountId,
label
label,
};
},
......@@ -25,7 +25,7 @@ const ConfirmDeleteModal = connect(
return {
deleteAccount(accountId) {
actions.deleteAccount(dispatch, accountId);
}
},
};
},
......@@ -34,7 +34,7 @@ const ConfirmDeleteModal = connect(
label,
handleDelete() {
deleteAccount(accountId);
}
},
};
}
)(props => {
......
......@@ -121,7 +121,7 @@ CustomBankField.propTypes /* remove-proptypes */ = {
// A function to be called when the user changes the input. The function
// has the following signature: function(name, value)
onChange: PropTypes.func
onChange: PropTypes.func,
};
export default CustomBankField;
......@@ -11,7 +11,7 @@ import ModalContent from '../ui/modal/content';
const DisableAccessModal = connect(
state => {
return {
accessId: get.modal(state).state
accessId: get.modal(state).state,
};
},
......@@ -24,7 +24,7 @@ const DisableAccessModal = connect(
} catch (err) {
// TODO properly report.
}
}
},
};
},
......@@ -32,7 +32,7 @@ const DisableAccessModal = connect(
return {
async handleConfirm() {
await disableAccess(accessId);
}
},
};
}
)(props => {
......
......@@ -20,7 +20,7 @@ const EditAccessModal = connect(
let access = get.accessById(state, accessId);
return {
access,
bankDesc: get.bankByUuid(state, access.vendorId)
bankDesc: get.bankByUuid(state, access.vendorId),
};
},
......@@ -40,7 +40,7 @@ const EditAccessModal = connect(
} catch (err) {
// TODO properly report.
}
}
},
};
},
......@@ -50,7 +50,7 @@ const EditAccessModal = connect(
bankDesc,
async handleSave(login, password, customFields) {
await updateAndFetchAccess(access.id, login, password, customFields);
}
},
};
}
)(
......@@ -82,7 +82,7 @@ const EditAccessModal = connect(
this.state = {
customFields,
login: props.access.login,
password: null
password: null,
};
}
......@@ -101,7 +101,7 @@ const EditAccessModal = connect(
// Make sure to create a copy to trigger a re-render.
let customFields = Object.assign({}, this.state.customFields, { [name]: value });
this.setState({
customFields
customFields,
});
};
......@@ -114,7 +114,7 @@ const EditAccessModal = connect(
);
return {
name: field.name,
value: this.state.customFields[field.name]
value: this.state.customFields[field.name],
};
});
this.props.handleSave(this.state.login, this.state.password, customFields);
......
......@@ -63,7 +63,7 @@ class NewAccessForm extends React.Component {
customFields: null,
// Validity fields.
isEmailValid
isEmailValid,
};
}
......@@ -140,7 +140,7 @@ class NewAccessForm extends React.Component {
handleChangeEmail = event => {
this.setState({
emailRecipient: event.target.value,
isEmailValid: event.target.validity.valid
isEmailValid: event.target.validity.valid,
});
};
......@@ -152,7 +152,7 @@ class NewAccessForm extends React.Component {
// Make sure to create a copy to trigger a re-render.
let customFields = Object.assign({}, this.state.customFields, { [name]: value });
this.setState({
customFields
customFields,
});
};
......@@ -169,7 +169,7 @@ class NewAccessForm extends React.Component {
assert(value || field.optional, 'null value for a required custom field');
return {
name: field.name,
value
value,
};
})
// Filter out optional values not set to any value, to not increase
......@@ -207,7 +207,7 @@ class NewAccessForm extends React.Component {
render() {
let bankOptions = this.props.banks.map(bank => ({
value: bank.uuid,
label: bank.name
label: bank.name,
}));
let { bankDesc } = this.state;
......@@ -328,11 +328,11 @@ class NewAccessForm extends React.Component {
NewAccessForm.propTypes /* remove-proptypes */ = {
// Whether this form is displayed for onboarding or not (settings section).
isOnboarding: PropTypes.bool
isOnboarding: PropTypes.bool,
};
NewAccessForm.defaultProps = {
isOnboarding: false
isOnboarding: false,
};
const Export = connect(
......@@ -341,7 +341,7 @@ const Export = connect(
banks: get.activeBanks(state),
emailEnabled: get.boolSetting(state, 'emails-enabled'),
emailRecipient: get.setting(state, 'email-recipient'),
categories: get.categories(state)
categories: get.categories(state),
};
},
dispatch => {
......@@ -358,7 +358,7 @@ const Export = connect(
);
},
saveEmail: email => actions.setSetting(dispatch, 'email-recipient', email),
createDefaultCategories: () => actions.createDefaultCategories(dispatch)
createDefaultCategories: () => actions.createDefaultCategories(dispatch),
};
}
)(NewAccessForm);
......
......@@ -15,7 +15,7 @@ const SyncBalanceModal = connect(
let label = account ? displayLabel(account) : null;
return {
label,
accountId
accountId,
};
},
dispatch => {
......@@ -27,7 +27,7 @@ const SyncBalanceModal = connect(
} catch (err) {
// TODO properly report.
}
}
},
};
},
({ label, accountId }, { resyncBalance }) => {
......@@ -35,7 +35,7 @@ const SyncBalanceModal = connect(
label,
async handleConfirm() {
await resyncBalance(accountId);
}
},
};
}
)(props => {
......
......@@ -17,7 +17,7 @@ class Budget extends React.Component {
this.state = {
showBudgetWithoutThreshold: this.props.displayNoThreshold,
displayInPercent: this.props.displayPercent
displayInPercent: this.props.displayPercent,
};
}
......@@ -30,7 +30,7 @@ class Budget extends React.Component {
let newValue = !this.state.showBudgetWithoutThreshold;
this.props.updateDisplayNoThreshold(newValue);
this.setState({
showBudgetWithoutThreshold: newValue
showBudgetWithoutThreshold: newValue,
});
};
......@@ -38,7 +38,7 @@ class Budget extends React.Component {
let newValue = !this.state.displayInPercent;
this.props.updateDisplayPercent(newValue);
this.setState({
displayInPercent: newValue
displayInPercent: newValue,
});
};
......@@ -252,7 +252,7 @@ Budget.propTypes = {
showOperations: PropTypes.func.isRequired,
// An array of the months/years tuples available since the first operation.
periods: PropTypes.array.isRequired
periods: PropTypes.array.isRequired,
};
const categoriesNamesSelector = createSelector(
......@@ -296,7 +296,7 @@ const Export = connect(
if (!periods.some(p => p.month === currentMonth && p.year === currentYear)) {
periods.push({
month: currentMonth,
year: currentYear
year: currentYear,
});
}
......@@ -324,7 +324,7 @@ const Export = connect(
periods,
currentAccountId,
displayPercent,
displayNoThreshold
displayNoThreshold,
};
},
dispatch => {
......@@ -345,7 +345,7 @@ const Export = connect(
actions.setSearchFields(dispatch, {
dateLow: fromDate,
dateHigh: toDate,
categoryIds: [categoryId]
categoryIds: [categoryId],
});
},
......@@ -363,7 +363,7 @@ const Export = connect(
} catch (err) {
// TODO do something with it!
}
}
},
};
}
)(Budget);
......
......@@ -35,12 +35,12 @@ function getBars(threshold, amount, warningThresholdInPct) {
if (amount === 0) {
bars.set('successRange', {
classes: 'stacked-progress-part-success',
width: 100
width: 100,
});
} else {
bars.set('dangerRange', {
classes: 'stacked-progress-part-danger',
width: 100
width: 100,
});
}
} else if (threshold > 0) {
......@@ -56,7 +56,7 @@ function getBars(threshold, amount, warningThresholdInPct) {
bars.set('successRange', {
classes: `stacked-progress-part-${state}`,
width: amountPct !== 0 ? Math.min(100, Math.abs(amountPct)) : 100
width: amountPct !== 0 ? Math.min(100, Math.abs(amountPct)) : 100,
});
} else {
let successRange = 0;
......@@ -89,7 +89,7 @@ function getBars(threshold, amount, warningThresholdInPct) {
if (successRange > 0) {
bars.set('successRange', {
classes: 'stacked-progress-part-success',
width: successRange
width: successRange,
});
}
......@@ -98,7 +98,7 @@ function getBars(threshold, amount, warningThresholdInPct) {
let progressive = dangerRange ? 'progressive' : '';
bars.set('warningRange', {
classes: `stacked-progress-part-warning ${progressive}`.trim(),
width: warningRange
width: warningRange,
});
}
......@@ -106,7 +106,7 @@ function getBars(threshold, amount, warningThresholdInPct) {
if (dangerRange > 0) {
bars.set('dangerRange', {
classes: 'stacked-progress-part-danger',
width: dangerRange
width: dangerRange,
});
}
}
......@@ -115,7 +115,7 @@ function getBars(threshold, amount, warningThresholdInPct) {
}
export const testing = {
getBars
getBars,
};
class BudgetListItem extends React.Component {
......@@ -129,7 +129,7 @@ class BudgetListItem extends React.Component {
categoryId: this.props.budget.categoryId,
year: this.props.budget.year,
month: this.props.budget.month,
threshold: newThreshold
threshold: newThreshold,
});
};
......@@ -239,7 +239,7 @@ BudgetListItem.propTypes = {
showOperations: PropTypes.func.isRequired,
// A string indicating which account is active.
currentAccountId: PropTypes.number.isRequired
currentAccountId: PropTypes.number.isRequired,
};
const Export = connect(
......@@ -247,7 +247,7 @@ const Export = connect(
const category = get.categoryById(state, ownProps.budget.categoryId);
return {
category,
...ownProps
...ownProps,
};
},
dispatch => ({
......@@ -255,7 +255,7 @@ const Export = connect(
updateBudget: (former, newer) => {
actions.updateBudget(dispatch, former, newer);
}
},
})
)(BudgetListItem);
export default Export;
......@@ -18,7 +18,7 @@ const ConfirmDeleteModal = connect(
categoryId,
label,
numOperations,
categories: get.categoriesButNone(state)
categories: get.categoriesButNone(state),
};
},
......@@ -26,7 +26,7 @@ const ConfirmDeleteModal = connect(
return {
handleDelete(catId, replaceByCatId) {
actions.deleteCategory(dispatch, catId, replaceByCatId);
}
},
};
}
)(
......@@ -59,7 +59,7 @@ const ConfirmDeleteModal = connect(
<p className="alerts info">
{$t('client.category.attached_transactions', {
// eslint-disable-next-line camelcase
smart_count: this.props.numOperations
smart_count: this.props.numOperations,
})}
<br />
{$t('client.category.replace_with_info')}
......
......@@ -11,7 +11,7 @@ import CancelAndDelete from '../ui/modal/cancel-and-delete-buttons';
const DeleteUnusedCategoriesModal = connect(
state => {
return {
categories: get.modal(state).state
categories: get.modal(state).state,
};
},