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

Commit

Permalink
Merge pull request deriv-com#487 from matin-org/fix_eslint
Browse files Browse the repository at this point in the history
Matin/Fix ESLint warnings
  • Loading branch information
matin-deriv authored Jun 2, 2022
2 parents 30e8acb + 5b9d42c commit 2f47075
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 70 deletions.
90 changes: 45 additions & 45 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions src/javascript/app/base/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,13 @@ const Header = (() => {
const loginid_demo_select = createElement('div');
Client.getAllLoginids().forEach((loginid) => {
if (!Client.get('is_disabled', loginid) && Client.get('token', loginid)) {
// const account_title = Client.getAccountTitle(loginid);
const is_real = /undefined|gaming|financial/.test(Client.getAccountType(loginid)); // this function only returns virtual/gaming/financial types
const currency = Client.get('currency', loginid);
// const localized_type = localize('[_1] Account', is_real && currency ? currency : account_title);
const icon = Url.urlForStatic(`${header_icon_base_path}ic-currency-${is_real ? (currency ? currency.toLowerCase() : 'unknown') : 'virtual'}.svg`);
const getIcon = (() => {
if (is_real) return currency ? currency.toLowerCase() : 'unknown';
return 'virtual';
});
const icon = Url.urlForStatic(`${header_icon_base_path}ic-currency-${getIcon()}.svg`);
const is_current = loginid === Client.get('loginid');

if (is_current) { // default account
Expand Down Expand Up @@ -683,11 +685,12 @@ const Header = (() => {
upgrade_link_txt = localize('Click here to open a Real Account');
upgrade_btn_txt = localize('Open a Real Account');
} else if (upgrade_info.can_upgrade_to.length === 1) {
upgrade_link_txt = upgrade_info.type[0] === 'financial'
? localize('Click here to open a Financial Account')
: upgrade_info.can_upgrade_to[0] === 'malta' ?
upgrade_link_txt = (() => {
if (upgrade_info.type[0] === 'financial') return localize('Click here to open a Financial Account');
return upgrade_info.can_upgrade_to[0] === 'malta' ?
localize('Click here to open a Gaming account') :
localize('Click here to open a Real Account');
});
upgrade_btn_txt = upgrade_info.type[0] === 'financial'
? localize('Open a Financial Account')
: localize('Open a Real Account');
Expand Down
1 change: 1 addition & 0 deletions src/javascript/app/common/chart_settings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-nested-ternary */
const addComma = require('./currency').addComma;
const isCallputspread = require('../pages/trade/callputspread').isCallputspread;
const isReset = require('../pages/trade/reset').isReset;
Expand Down
6 changes: 4 additions & 2 deletions src/javascript/app/pages/cashier/account_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ const AccountTransfer = (() => {
* @returns {*}
*/
const sortAccounts = (accounts) => {
const sortBy = (key) => (a, b) => (a[key] > b[key]) ? 1 : ((b[key] > a[key]) ? -1 : 0);

const sortBy = (key) => (a, b) => {
if (a[key] > b[key]) return 1;
return b[key] > a[key] ? -1 : 0;
};
return accounts.concat().sort(sortBy('currency'));
};

Expand Down
16 changes: 8 additions & 8 deletions src/javascript/app/pages/cashier/cashier.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ const Cashier = (() => {
// Set messages based on currency being crypto or fiat
// If fiat, set message based on if they're allowed to change currency or not
// Condition is to have no MT5 accounts *and* have no transactions
const currency_message = Currency.isCryptocurrency(currency)
? localize('This is your [_1] account.', `${Currency.getCurrencyDisplayCode(currency)}`)
: has_no_mt5 && has_no_transaction
const currency_message = (() => {
if (Currency.isCryptocurrency(currency)) return localize('This is your [_1] account.', `${Currency.getCurrencyDisplayCode(currency)}`);
return has_no_mt5 && has_no_transaction
? localize('Your fiat account\'s currency is currently set to [_1].', `${currency}`)
: localize('Your fiat account\'s currency is set to [_1].', `${currency}`);

const currency_hint = Currency.isCryptocurrency(currency)
? localize('Don\'t want to trade in [_1]? You can open another cryptocurrency account.', `${Currency.getCurrencyDisplayCode(currency)}`) + account_action_text
: has_no_mt5 && has_no_transaction
});
const currency_hint = (() => {
if (Currency.isCryptocurrency(currency)) return localize('Don\'t want to trade in [_1]? You can open another cryptocurrency account.', `${Currency.getCurrencyDisplayCode(currency)}`) + account_action_text;
return has_no_mt5 && has_no_transaction
? localize('You can [_1]set a new currency[_2] before you deposit for the first time or create an MT5 account.', can_change ? [`<a href=${Url.urlFor('user/accounts')}>`, '</a>'] : ['', ''])
: missingCriteria(!has_no_mt5, !has_no_transaction);

});
elementInnerHtml(el_current_currency, currency_message);
elementInnerHtml(el_current_hint, currency_hint);
el_currency_image.src = Url.urlForStatic(`/images/pages/cashier/icons/icon-${currency}.svg`);
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/app/pages/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Endpoint = (() => {

$('#frm_endpoint').on('submit', (e) => {
e.preventDefault();
const server_url = $server_url.val().trim().toLowerCase().replace(/[><()\/\"\']/g, '');
const server_url = $server_url.val().trim().toLowerCase().replace(/[><()/"']/g, '');
const app_id = $app_id.val().trim();
if (server_url) localStorage.setItem('config.server_url', server_url);
if (app_id && !isNaN(app_id)) localStorage.setItem('config.app_id', parseInt(app_id));
Expand Down
6 changes: 5 additions & 1 deletion src/javascript/app/pages/trade/charts/highchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@ const Highchart = (() => {
// if we disable a symbol in API, it will be missing from active symbols so we can't retrieve its pip
// so we should handle getting an undefined display_decimals
const display_decimals = await getUnderlyingPipSize(contract.underlying);
const getExitTime = (() => {
if (exit_tick_time) return exit_tick_time * 1000;
return exit_time ? exit_time * 1000 : null;
});
chart_options = {
data,
display_decimals,
type,
entry_time: (entry_tick_time || start_time) * 1000,
exit_time : exit_tick_time ? exit_tick_time * 1000 : exit_time ? exit_time * 1000 : null, // eslint-disable-line do-not-nest-ternary
exit_time : getExitTime(),
has_zone : true,
height : Math.max(el.parentElement.offsetHeight, 450),
radius : 2,
Expand Down
6 changes: 4 additions & 2 deletions src/javascript/app/pages/user/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ const Accounts = (() => {
real : new_account_type === 'real',
financial: new_account_type === 'financial',
};
const new_account_title = new_account_type === 'financial' ? localize('Financial Account') :
upgrade_info.can_upgrade_to[index] === 'malta' ? localize('Gaming Account') : localize('Real Account');
const new_account_title = (() => {
if (new_account_type === 'financial') return localize('Financial Account');
return upgrade_info.can_upgrade_to[index] === 'malta' ? localize('Gaming Account') : localize('Real Account');
});
$(form_id).find('tbody')
.append($('<tr/>')
.append($('<td/>', { datath: table_headers.account }).html($('<span/>', {
Expand Down
10 changes: 8 additions & 2 deletions src/javascript/app/pages/user/metatrader/metatrader.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ const MetaTraderUI = (() => {
const region = server_info && server_info.geolocation.region;
const sequence = server_info && server_info.geolocation.sequence;
const is_synthetic = getAccountsInfo(acc_type).market_type === 'gaming' || getAccountsInfo(acc_type).market_type === 'synthetic';
const label_text = server_info ? sequence > 1 ? `${region} ${sequence}` : region : getAccountsInfo(acc_type).info.display_server;
const label_text = (() => {
if (server_info) return sequence > 1 ? `${region} ${sequence}` : region;
return getAccountsInfo(acc_type).info.display_server;
});
setMTAccountText();
$acc_item.find('.mt-login').text(`(${getAccountsInfo(acc_type).info.display_login})`);
if (
Expand Down Expand Up @@ -346,7 +349,10 @@ const MetaTraderUI = (() => {
const server_info = getAccountsInfo(acc_type).info.server_info;
const region = server_info && server_info.geolocation.region;
const sequence = server_info && server_info.geolocation.sequence;
const label_text = server_info ? sequence > 1 ? `${region} ${sequence}` : region : getAccountsInfo(acc_type).info.display_server;
const label_text = (() => {
if (server_info) return sequence > 1 ? `${region} ${sequence}` : region;
return getAccountsInfo(acc_type).info.display_server;
});
$detail.find('.real-only').setVisibility(!is_demo);
// Update account info
$detail.find('.acc-info div[data]').map(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/landing_pages/graduate_program.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const GraduateProgram = () => {
<p>{('Our graduate programme is designed to tap into your true potential, give you deep insights into our business, and provide you with a platform to do amazing work.')}</p>
<div className='inline-flex'>
<img className='icon-lg margin-left-0' src={it.url_for('images/graduate_program/program1_icon.svg')} />
<p>{(`We\'ll kick things off with orientation week ${String.fromCharCode(8212)} a week spent away from the office that\'s all about learning and having fun. You\'ll participate in team building exercises, learn how to navigate your new workplace, and join a mini hackathon where you\'ll get the chance to make pull requests and contribute to our codebase.`)}</p>
<p>{(`We'll kick things off with orientation week ${String.fromCharCode(8212)} a week spent away from the office that's all about learning and having fun. You'll participate in team building exercises, learn how to navigate your new workplace, and join a mini hackathon where you'll get the chance to make pull requests and contribute to our codebase.`)}</p>
</div>
<div className='inline-flex'>
<img className='icon-lg margin-left-0' src={it.url_for('images/graduate_program/program2_icon.svg')} />
Expand Down
2 changes: 1 addition & 1 deletion src/templates/static/about/group_history.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const GroupHistory = () => (
<div className='timeline'>
<UL items={[
{ className: 'year center-text', text: '2019' },
{ className: 'event featured', header: it.L('Deriv.com launched'), text: it.L('[_1] was launched as the next-generation online trading platform. [_2] and Deriv collectively handle over 200 million transactions, with a turnover of over 1 USD billion a year.', `<a target=\'_blank\' href=\'https://${it.derivDomainName()}\' rel=\'noopener noreferrer\'>Deriv.com</a>`, it.website_name) },
{ className: 'event featured', header: it.L('Deriv.com launched'), text: it.L('[_1] was launched as the next-generation online trading platform. [_2] and Deriv collectively handle over 200 million transactions, with a turnover of over 1 USD billion a year.', `<a target='_blank' href='https://${it.derivDomainName()}' rel='noopener noreferrer'>Deriv.com</a>`, it.website_name) },
{ className: 'event right', header: it.L('New office in Dubai, UAE'), text: it.L('[_1] opens a new office at the world-class Jumeirah Lake Towers free zone to expand our reach in the region.', it.website_name) },
{ className: 'event', header: it.L('New office in Asunción, Paraguay'), text: it.L('[_1] opens new hub of operations in the capital of Paraguay to drive our growth in South America.', it.website_name) },
{ className: 'year center-text', text: '2018' },
Expand Down
2 changes: 1 addition & 1 deletion src/templates/static/about/job_applicant_policy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const JobApplicantPrivacyPolicy = () => (
<li>{it.L('Responding to and defending against legal claims')}</li>
</ul>
<p>{it.L('The Company also collects and processes the applicant’s data to decide whether to enter into a contract with the applicant.')}</p>
<p>{it.L('In some cases, the Company needs to process the applicant\’s personal data to comply with the Company\’s legal obligations, for example conducting necessary checks in relation to the right to work in a specific jurisdiction.')}</p>
<p>{it.L('In some cases, the Company needs to process the applicant’s personal data to comply with the Company’s legal obligations, for example conducting necessary checks in relation to the right to work in a specific jurisdiction.')}</p>
<p>{it.L('The applicant is under no statutory or contractual obligation to provide data to the Company during the recruitment process. However, if the applicant chooses not to provide any necessary information, the Company may not be able to proceed with their application.')}</p>

<h2 data-anchor='confidentiality'>{it.L('Confidentiality')}</h2>
Expand Down

0 comments on commit 2f47075

Please sign in to comment.