Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Update eslint (#1916)
Browse files Browse the repository at this point in the history
* Update eslint

* Fix eslint version

* Follow-up issue to fix this

* Undo redux change

* Oopsie
  • Loading branch information
gideonthomas committed Nov 20, 2017
1 parent 6046f6e commit 56133f4
Show file tree
Hide file tree
Showing 17 changed files with 202 additions and 196 deletions.
17 changes: 10 additions & 7 deletions .eslintrc
Expand Up @@ -5,8 +5,7 @@
"no-empty": [1],
"no-lonely-if": [2],
"no-inner-declarations": [2, "both"],
"space-after-keywords": [2],
"space-before-keywords": [2, "always"],
"keyword-spacing": [2, {"before": true, "after": true}],
"space-before-blocks": [2],
"space-before-function-paren": [2, "never"],
"no-console": [0],
Expand All @@ -21,7 +20,8 @@
"no-eq-null": [2],
"no-return-assign": [2],
"radix": [2],
"handle-callback-err": [2]
"handle-callback-err": [2],
"react/jsx-uses-vars": [2]
},
"env": {
"es6": true,
Expand All @@ -36,12 +36,15 @@
"StripeCheckout"
},
"extends": "eslint:recommended",
"ecmaFeatures": {
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true,
"modules": true
"experimentalObjectRestSpread": true
}
},
"plugins": [
"react"
]
}
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -56,7 +56,7 @@
"css-loader": "0.23.1",
"enhanced-require": "0.5.0-beta6",
"enzyme": "2.7.0",
"eslint": "1.10.3",
"eslint": "4.11.0",
"eslint-loader": "1.1.1",
"eslint-plugin-react": "3.14.0",
"exports-loader": "0.6.2",
Expand Down
54 changes: 27 additions & 27 deletions server/routes/index.js
Expand Up @@ -548,38 +548,38 @@ var routes = {

// kick off a Promise Chain
Promise.resolve()
.then(function() {
.then(function() {
// close the dispute automatically if it's not lost already
if (event === 'charge.dispute.created' && dispute.status === 'lost') {
return Promise.resolve();
}

return stripe.closeDispute(dispute.id)
.catch(function(closeDisputeError) {
if (closeDisputeError.message === 'This dispute is already closed') {
return console.log(closeDisputeError.message);
if (event === 'charge.dispute.created' && dispute.status === 'lost') {
return Promise.resolve();
}

return Promise.reject("Could not close the dispute");
});
})
.then(function() {
basket.queue({
event_type: event.type,
transaction_id: dispute.charge,
reason: dispute.reason,
status: dispute.status
});
return stripe.closeDispute(dispute.id)
.catch(function(closeDisputeError) {
if (closeDisputeError.message === 'This dispute is already closed') {
return console.log(closeDisputeError.message);
}

reply("dispute processed");
})
.catch(function(err) {
if (err.isBoom) {
return reply(err);
}
return Promise.reject("Could not close the dispute");
});
})
.then(function() {
basket.queue({
event_type: event.type,
transaction_id: dispute.charge,
reason: dispute.reason,
status: dispute.status
});

return reply(boom.badImplementation('An error occurred while handling the dispute webhook', err));
});
reply("dispute processed");
})
.catch(function(err) {
if (err.isBoom) {
return reply(err);
}

return reply(boom.badImplementation('An error occurred while handling the dispute webhook', err));
});


},
Expand Down
2 changes: 1 addition & 1 deletion server/services.js
Expand Up @@ -44,7 +44,7 @@ var services = [
connectSrc: ['self', 'https://checkout.stripe.com', '206878104.log.optimizely.com', 'https://api.stripe.com', 'https://pontoon.mozilla.org'],
fontSrc: ['self', 'https://fonts.gstatic.com', 'https://maxcdn.bootstrapcdn.com', 'https://pontoon.mozilla.org'],
frameSrc: ['https://js.stripe.com', 'https://checkout.stripe.com', 'https://pontoon.mozilla.org',
'https://app.optimizely.com'],
'https://app.optimizely.com'],
imgSrc: ['self', 'https://www.google-analytics.com', 'https://q.stripe.com', 'https://pontoon.mozilla.org', 'https://*.shpg.org/',
'https://cdn.optimizely.com'],
scriptSrc: ['self', 'unsafe-inline', 'unsafe-eval', 'https://cdn.optimizely.com', 'https://app.optimizely.com',
Expand Down
67 changes: 35 additions & 32 deletions src/components/amount-buttons.js
Expand Up @@ -18,7 +18,7 @@ var AmountButton = React.createClass({
category: "User Flow",
action: "Changed Amount",
label: e.currentTarget.value
});
});
},

render: function() {
Expand All @@ -31,12 +31,12 @@ var AmountButton = React.createClass({
<input onChange={this.props.onChange} onClick={this.onClickEvent} checked={checked} className="amount-radio" type="radio" name="donation_amount" value={this.props.value} id={"amount-" + this.props.value}/>
<label htmlFor={"amount-" + this.props.value} className="amount-button large-label-size">
{ this.props.currencyCode && this.props.value ?
<FormattedNumber
minimumFractionDigits={0}
value={this.props.value}
style="currency"
currency={this.props.currencyCode}
/> : <span>&nbsp;</span> }
<FormattedNumber
minimumFractionDigits={0}
value={this.props.value}
style="currency"
currency={this.props.currencyCode}
/> : <span>&nbsp;</span> }
</label>
</div>
);
Expand Down Expand Up @@ -68,7 +68,7 @@ var AmountOtherButton = React.createClass({
category: "User Flow",
action: "Changed Amount",
label: "Other"
});
});
},
onInputClick: function() {
document.querySelector("#amount-other").click();
Expand All @@ -85,13 +85,16 @@ var AmountOtherButton = React.createClass({
var inputValue = e.currentTarget.value;
var amount = "";

if (/^[\d]*[\.]?\d{0,2}$/.test(inputValue)) {
// TODO: This needs to be refactored to use regex replace
// and needs documentation for what they are matching.
// See https://github.com/mozilla/donate.mozilla.org/issues/1917
if (/^[\d]*[.]?\d{0,2}$/.test(inputValue)) {
amount = inputValue.replace(/,/g, "");
} else if (/^[\d]*[,]?\d{0,2}$/.test(inputValue)) {
amount = inputValue.replace(/\./g, "").replace(",", ".");
} else if (/^[\d,]*[\.]?\d{0,2}$/.test(inputValue)) {
} else if (/^[\d,]*[.]?\d{0,2}$/.test(inputValue)) {
amount = inputValue.replace(/,/g, "");
} else if (/^[\d\.]*[,]?\d{0,2}$/.test(inputValue)) {
} else if (/^[\d.]*[,]?\d{0,2}$/.test(inputValue)) {
amount = inputValue.replace(/\./g, "").replace(",", ".");
} else {
inputValue = this.state.inputValue;
Expand Down Expand Up @@ -182,12 +185,12 @@ var AmountButtons = React.createClass({
values={{minAmount:
<span>
{ this.props.currency.code ?
<FormattedNumber
maximumFractionDigits={2}
value={this.props.currency.minAmount}
style="currency"
currency={this.props.currency.code}
/> : "" }
<FormattedNumber
maximumFractionDigits={2}
value={this.props.currency.minAmount}
style="currency"
currency={this.props.currency.code}
/> : "" }
</span>
}}
/>
Expand Down Expand Up @@ -240,18 +243,18 @@ var AmountButtons = React.createClass({
});

module.exports = connect(
function(state) {
return {
amount: state.donateForm.amount,
presets: state.donateForm.presets,
currency: state.donateForm.currency,
amountError: state.donateForm.amountError
};
},
function(dispatch) {
return {
setAmount: function(data) {
dispatch(setAmount(data));
}
};
})(AmountButtons);
function(state) {
return {
amount: state.donateForm.amount,
presets: state.donateForm.presets,
currency: state.donateForm.currency,
amountError: state.donateForm.amountError
};
},
function(dispatch) {
return {
setAmount: function(data) {
dispatch(setAmount(data));
}
};
})(AmountButtons);
24 changes: 12 additions & 12 deletions src/components/currency-dropdown.js
Expand Up @@ -32,15 +32,15 @@ var CurrencyDropdown = React.createClass({
});

module.exports = connect(
function(state) {
return {
currency: state.donateForm.currency
};
},
function(dispatch) {
return {
setCurrency: function(data) {
dispatch(setCurrency(data));
}
};
})(CurrencyDropdown);
function(state) {
return {
currency: state.donateForm.currency
};
},
function(dispatch) {
return {
setCurrency: function(data) {
dispatch(setCurrency(data));
}
};
})(CurrencyDropdown);
12 changes: 6 additions & 6 deletions src/components/donate-button.js
Expand Up @@ -29,9 +29,9 @@ var DonateButton = React.createClass({
});

module.exports = connect(
function(state) {
return {
amount: state.donateForm.amount,
currency: state.donateForm.currency
};
})(DonateButton);
function(state) {
return {
amount: state.donateForm.amount,
currency: state.donateForm.currency
};
})(DonateButton);
24 changes: 12 additions & 12 deletions src/components/donation-frequency.js
Expand Up @@ -45,15 +45,15 @@ var DonationFrequency = React.createClass({
});

module.exports = connect(
function(state) {
return {
frequency: state.donateForm.frequency
};
},
function(dispatch) {
return {
setFrequency: function(data) {
dispatch(setFrequency(data));
}
};
})(DonationFrequency);
function(state) {
return {
frequency: state.donateForm.frequency
};
},
function(dispatch) {
return {
setFrequency: function(data) {
dispatch(setFrequency(data));
}
};
})(DonationFrequency);
30 changes: 15 additions & 15 deletions src/components/email-input.js
Expand Up @@ -33,18 +33,18 @@ var EmailInput = React.createClass({
});

module.exports = connect(
function(state) {
return {
email: state.signupForm.email,
emailError: state.signupForm.emailError
};
},
function(dispatch) {
return {
setEmail: function(data) {
dispatch(setEmail(data));
}
};
}, null, {
withRef: true
})(EmailInput);
function(state) {
return {
email: state.signupForm.email,
emailError: state.signupForm.emailError
};
},
function(dispatch) {
return {
setEmail: function(data) {
dispatch(setEmail(data));
}
};
}, null, {
withRef: true
})(EmailInput);
26 changes: 13 additions & 13 deletions src/components/privacy-checkbox.js
Expand Up @@ -26,16 +26,16 @@ var PrivacyPolicyCheckbox = React.createClass({
});

module.exports = connect(
function(state) {
return {
privacyPolicy: state.signupForm.privacyPolicy,
privacyPolicyError: state.signupForm.privacyPolicyError
};
},
function(dispatch) {
return {
setPrivacyPolicy: function(data) {
dispatch(setPrivacyPolicy(data));
}
};
})(PrivacyPolicyCheckbox);
function(state) {
return {
privacyPolicy: state.signupForm.privacyPolicy,
privacyPolicyError: state.signupForm.privacyPolicyError
};
},
function(dispatch) {
return {
setPrivacyPolicy: function(data) {
dispatch(setPrivacyPolicy(data));
}
};
})(PrivacyPolicyCheckbox);

0 comments on commit 56133f4

Please sign in to comment.