1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-19 08:52:25 +01:00

(style) eslint all code

This commit is contained in:
Sylvain 2022-03-29 17:21:29 +02:00
parent 9832f9f19a
commit 7e9745a761
25 changed files with 119 additions and 120 deletions

View File

@ -3,7 +3,7 @@ import { AxiosResponse } from 'axios';
import { Space } from '../models/space';
export default class SpaceAPI {
static async index (): Promise<Array<any>> {
static async index (): Promise<Array<Space>> {
const res: AxiosResponse<Array<Space>> = await apiClient.get('/api/spaces');
return res?.data;
}
@ -12,5 +12,4 @@ export default class SpaceAPI {
const res: AxiosResponse<Space> = await apiClient.get(`/api/spaces/${id}`);
return res?.data;
}
}

View File

@ -5,6 +5,7 @@
* creating namespaces and moduled for controllers, filters, services, and directives.
*/
// eslint-disable-next-line no-var -- Application is a global variable.
var Application = Application || {};
Application.Components = angular.module('application.components', []);

View File

@ -14,6 +14,7 @@ import WalletAPI from '../../api/wallet';
import { Invoice } from '../../models/invoice';
import SettingAPI from '../../api/setting';
import { SettingName } from '../../models/setting';
import { GoogleTagManager } from '../../models/gtm';
import { ComputePriceResult } from '../../models/price';
import { Wallet } from '../../models/wallet';
import FormatLib from '../../lib/format';
@ -52,7 +53,7 @@ interface AbstractPaymentModalProps {
modalSize?: ModalSize,
}
declare const GTM: any;
declare const GTM: GoogleTagManager;
/**
* This component is an abstract modal that must be extended by each payment gateway to include its payment form.

View File

@ -11,7 +11,7 @@ import { PaymentSchedule } from '../../../models/payment-schedule';
* A form component to collect the credit card details and to create the payment method on Stripe.
* The form validation button must be created elsewhere, using the attribute form={formId}.
*/
export const StripeForm: React.FC<GatewayFormProps> = ({ onSubmit, onSuccess, onError, children, className, paymentSchedule = false, cart, customer, operator, formId }) => {
export const StripeForm: React.FC<GatewayFormProps> = ({ onSubmit, onSuccess, onError, children, className, paymentSchedule = false, cart, formId }) => {
const { t } = useTranslation('shared');
const stripe = useStripe();

View File

@ -26,7 +26,6 @@ interface FreeExtendModalProps {
* Modal dialog shown to extend the current subscription of a customer, for free
*/
const FreeExtendModal: React.FC<FreeExtendModalProps> = ({ isOpen, toggleModal, subscription, customerId, onError, onSuccess }) => {
// we do not render the modal if the subscription was not provided
if (!subscription) return null;

View File

@ -4,7 +4,7 @@
no-undef,
no-unreachable,
no-unused-vars,
standard/no-callback-literal,
n/no-callback-literal,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
@ -179,7 +179,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param $event {Object} jQuery event object
* @param datePicker {Object} settings object of the concerned datepicker. Must have an 'opened' property
*/
var toggleDatePicker = function ($event, datePicker) {
const toggleDatePicker = function ($event, datePicker) {
$event.preventDefault();
$event.stopPropagation();
return datePicker.opened = !datePicker.opened;
@ -188,7 +188,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
/**
* Query elasticSearch according to the current parameters and update the chart
*/
var refreshChart = function () {
const refreshChart = function () {
if ($scope.selectedIndex && !$scope.preventRefresh) {
return query($scope.selectedIndex, function (aggregations, error) {
if (error) {
@ -239,7 +239,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* Format aggregations as retuned by elasticSearch to an understandable format for NVD3
* @param aggs {Object} as returned by elasticsearch
*/
var formatAggregations = function (aggs) {
const formatAggregations = function (aggs) {
const format = {};
angular.forEach(aggs, function (type, type_key) { // go through aggs[$TYPE] where $TYPE = month|year|hour|booking|...
@ -254,7 +254,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
const cur_subtype = cur_type.subtypes[it_st];
if (subgroup.key === cur_subtype.key) { // ... which match $SUBTYPE
// then we construct NVD3 dataSource according to these information
var dataSource = {
const dataSource = {
values: [],
key: cur_subtype.label,
total: 0,
@ -292,7 +292,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param limit {number} limit the number of stats in the bar chart
* @param typeKey {String} field name witch results are grouped by
*/
var formatRankingAggregations = function (aggs, limit, typeKey) {
const formatRankingAggregations = function (aggs, limit, typeKey) {
const format =
{ ranking: [] };
@ -325,7 +325,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param key {string} raw value of the label
* @param typeKey {string} name of the field the results are grouped by
*/
var getRankingLabel = function (key, typeKey) {
const getRankingLabel = function (key, typeKey) {
if ($scope.selectedIndex) {
if (typeKey === 'subType') {
for (const type of Array.from($scope.selectedIndex.types)) {
@ -356,7 +356,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param callback {function} function be to run after results were retrieved,
* it will receive two parameters : results {Array}, error {String} (if any)
*/
var query = function (index, callback) {
const query = function (index, callback) {
// invalid callback handeling
if (typeof (callback) !== 'function') {
console.error('[graphsController::query] Error: invalid callback provided');
@ -384,7 +384,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
let type_it = 0;
const results = {};
let error = '';
var recursiveCb = function () {
const recursiveCb = function () {
if (type_it < stat_types.length) {
return queryElasticStats(index.es_type_key, stat_types[type_it], function (prevResults, prevError) {
if (prevError) {
@ -418,7 +418,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param callback {function} function be to run after results were retrieved,
* it will receive two parameters : results {Array}, error {String} (if any)
*/
var queryElasticStats = function (esType, statType, callback) {
const queryElasticStats = function (esType, statType, callback) {
// handle invalid callback
if (typeof (callback) !== 'function') {
console.error('[graphsController::queryElasticStats] Error: invalid callback provided');
@ -457,7 +457,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param callback {function} function be to run after results were retrieved,
* it will receive two parameters : results {Array}, error {String} (if any)
*/
var queryElasticRanking = function (esType, groupKey, sortKey, callback) {
const queryElasticRanking = function (esType, groupKey, sortKey, callback) {
// handle invalid callback
if (typeof (callback) !== 'function') {
return console.error('[graphsController::queryElasticRanking] Error: invalid callback provided');
@ -497,15 +497,13 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param intervalBegin {moment} statitics interval beginning (moment.js type)
* @param intervalEnd {moment} statitics interval ending (moment.js type)
*/
var buildElasticAggregationsQuery = function (type, interval, intervalBegin, intervalEnd) {
const buildElasticAggregationsQuery = function (type, interval, intervalBegin, intervalEnd) {
const q = {
query: {
bool: {
must: [
{
match: {
type: type
}
match: { type }
},
{
range: {
@ -527,7 +525,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
intervals: {
date_histogram: {
field: 'date',
interval: interval,
interval,
min_doc_count: 0,
extended_bounds: {
min: intervalBegin.valueOf(),
@ -566,7 +564,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param intervalBegin {moment} statitics interval beginning (moment.js type)
* @param intervalEnd {moment} statitics interval ending (moment.js type)
*/
var buildElasticAggregationsRankingQuery = function (groupKey, sortKey, intervalBegin, intervalEnd) {
const buildElasticAggregationsRankingQuery = function (groupKey, sortKey, intervalBegin, intervalEnd) {
const q = {
query: {
bool: {
@ -635,7 +633,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param data {Array} array of NVD3 dataSources
* @param type {String} which chart to update (statistic type key)
*/
var updateChart = function (chart_type, data, type) {
const updateChart = function (chart_type, data, type) {
const id = `#chart-${type} svg`;
// clean old charts
@ -695,7 +693,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
/**
* Given an NVD3 line chart axis, scale it to display ordinated dates, according to the given arguments
*/
var setTimeScale = function (nvd3Axis, nvd3Scale, argsArray) {
const setTimeScale = function (nvd3Axis, nvd3Scale, argsArray) {
const scale = d3.time.scale();
nvd3Axis.scale(scale);
@ -710,7 +708,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
/**
* Translate line chart data in dates row to bar chart data, one bar per type.
*/
var prepareDataForBarChart = function (data, type) {
const prepareDataForBarChart = function (data, type) {
const newData = [{
key: type,
values: []
@ -738,7 +736,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
* @param getValue {function} the callback which will return the value on which the sort will occurs
* @returns {Array}
*/
var stableSort = function (array, order, getValue) {
const stableSort = function (array, order, getValue) {
// prepare sorting
const keys_order = [];
const result = [];

View File

@ -55,13 +55,13 @@ Application.Controllers.controller('GroupsController', ['$scope', 'groupsPromise
$scope.saveGroup = function (data, id) {
if (id != null) {
return Group.update({ id }, { group: data }, response => growl.success(_t('app.admin.members.group_form.changes_successfully_saved'))
, error => growl.error(_t('app.admin.members.group_form.an_error_occurred_while_saving_changes')));
, () => growl.error(_t('app.admin.members.group_form.an_error_occurred_while_saving_changes')));
} else {
return Group.save({ group: data }, function (resp) {
growl.success(_t('app.admin.members.group_form.new_group_successfully_saved'));
return $scope.groups[$scope.groups.length - 1].id = resp.id;
}
, function (error) {
, function () {
growl.error(_t('app.admin.members.group_form.an_error_occurred_when_saving_the_new_group'));
return $scope.groups.splice($scope.groups.length - 1, 1);
});
@ -77,7 +77,7 @@ Application.Controllers.controller('GroupsController', ['$scope', 'groupsPromise
growl.success(_t('app.admin.members.group_form.group_successfully_deleted'));
return $scope.groups.splice(index, 1);
}
, error => growl.error(_t('app.admin.members.group_form.unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it')));
, () => growl.error(_t('app.admin.members.group_form.unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it')));
/**
* Enable/disable the group at the specified index
@ -92,7 +92,7 @@ Application.Controllers.controller('GroupsController', ['$scope', 'groupsPromise
$scope.groups[index] = response;
return growl.success(_t('app.admin.members.group_form.group_successfully_enabled_disabled', { STATUS: response.disabled }));
}
, error => growl.error(_t('app.admin.members.group_form.unable_to_enable_disable_group', { STATUS: !group.disabled })));
, () => growl.error(_t('app.admin.members.group_form.unable_to_enable_disable_group', { STATUS: !group.disabled })));
}
};
}

View File

@ -1247,7 +1247,7 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
function (avoir) { // success
$uibModalInstance.close({ avoir, invoice: $scope.invoice });
},
function (err) { // failed
function () { // failed
growl.error(_t('app.admin.invoices.unable_to_create_the_refund'));
}
);

View File

@ -403,7 +403,7 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state',
$scope.spaceCredits[$scope.spaceCredits.length - 1].id = resp.id;
return growl.success(_t('app.admin.pricing.credit_was_successfully_saved'));
}
, function (err) {
, function () {
$scope.spaceCredits.pop();
return growl.error(_t('app.admin.pricing.error_creating_credit'));
});

View File

@ -2,7 +2,7 @@
no-constant-condition,
no-return-assign,
no-undef,
standard/no-callback-literal,
n/no-callback-literal,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
@ -522,9 +522,7 @@ Application.Controllers.controller('StatisticsController', ['$scope', '$state',
bool: {
must: [
{
term: {
type: type
}
term: { type }
},
{
range: {

View File

@ -45,13 +45,13 @@ Application.Controllers.controller('TagsController', ['$scope', 'tagsPromise', '
$scope.saveTag = function (data, id) {
if (id != null) {
return Tag.update({ id }, { tag: data }, response => growl.success(_t('app.admin.members.tag_form.changes_successfully_saved'))
, error => growl.error(_t('app.admin.members.tag_form.an_error_occurred_while_saving_changes')));
, () => growl.error(_t('app.admin.members.tag_form.an_error_occurred_while_saving_changes')));
} else {
return Tag.save({ tag: data }, function (resp) {
growl.success(_t('app.admin.members.tag_form.new_tag_successfully_saved'));
return $scope.tags[$scope.tags.length - 1].id = resp.id;
}
, function (error) {
, function () {
growl.error(_t('app.admin.members.tag_form.an_error_occurred_while_saving_the_new_tag'));
return $scope.tags.splice($scope.tags.length - 1, 1);
});
@ -78,7 +78,7 @@ Application.Controllers.controller('TagsController', ['$scope', 'tagsPromise', '
growl.success(_t('app.admin.members.tag_form.tag_successfully_deleted'));
return $scope.tags.splice(index, 1);
}
, error => growl.error(_t('app.admin.members.tag_form.an_error_occurred_and_the_tag_deletion_failed')));
, () => growl.error(_t('app.admin.members.tag_form.an_error_occurred_and_the_tag_deletion_failed')));
});
}

View File

@ -323,7 +323,7 @@ Application.Controllers.controller('ShowProfileController', ['$scope', 'memberPr
* and return the filtered networks
* @return {Array}
*/
var filterNetworks = function () {
const filterNetworks = function () {
const networks = [];
for (const network of Array.from(SocialNetworks)) {
if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) {

View File

@ -618,7 +618,7 @@ Application.Controllers.controller('ShowProjectController', ['$scope', '$state',
growl.success(_t('app.public.projects_show.your_report_was_successful_thanks'));
return $uibModalInstance.close(res);
}
, function (error) {
, function () {
// creation failed...
growl.error(_t('app.public.projects_show.an_error_occured_while_sending_your_report'));
}

View File

@ -4,9 +4,9 @@ Application.Directives.directive('bsJasnyFileinput', [function () {
return {
require: ['ngModel'],
link: function ($scope, elm, attrs, requiredCtrls) {
var ngModelCtrl = requiredCtrls[0];
var fileinput = elm.parents('[data-provides=fileinput]');
var filetypeRegex = attrs.bsJasnyFileinput;
const ngModelCtrl = requiredCtrls[0];
const fileinput = elm.parents('[data-provides=fileinput]');
const filetypeRegex = attrs.bsJasnyFileinput;
fileinput.on('clear.bs.fileinput', function (e) {
if (ngModelCtrl) {
ngModelCtrl.$setViewValue(null);

View File

@ -11,7 +11,7 @@
'Auth',
'$rootScope',
function ($uibModal, $http, Auth, $rootScope) {
var promise = null;
let promise = null;
function reset () {
promise = null;
}

View File

@ -46,7 +46,7 @@ angular.module('angularUtils.directives.dirDisqus', [])
// get the remote Disqus script and insert it into the DOM, but only if it not already loaded (as that will cause warnings)
if (!$window.DISQUS) {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
const dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + scope.disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
} else {

View File

@ -9,7 +9,7 @@ export default class FormatLib {
*/
static date = (date: Date): string => {
return Intl.DateTimeFormat().format(moment(date).toDate());
}
};
/**
* Return the formatted localized time for the given date
@ -23,12 +23,12 @@ export default class FormatLib {
*/
static duration = (interval: unitOfTime.DurationConstructor, intervalCount: number): string => {
return moment.duration(intervalCount, interval).locale(Fablab.moment_locale).humanize();
}
};
/**
* Return the formatted localized amount for the given price (eg. 20.5 => "20,50 €")
*/
static price = (price: number): string => {
return new Intl.NumberFormat(Fablab.intl_locale, { style: 'currency', currency: Fablab.intl_currency }).format(price);
}
};
}

View File

@ -30,7 +30,7 @@
GTM.trackPurchase = function (transactionId, value) {
gtag('event', 'purchase', {
transaction_id: transactionId,
value: value,
value,
currency: Fablab.intl_currency
});
};

View File

@ -1,23 +1,21 @@
(function () {
var Humanize, isArray, isFinite, isNaN, objectRef, timeFormats, toString;
const objectRef = new function () {}();
objectRef = new function () {}();
const toString = objectRef.toString;
toString = objectRef.toString;
isNaN = function (value) {
const isNaN = function (value) {
return Number.isNaN(value);
};
isFinite = function (value) {
const isFinite = function (value) {
return ((typeof window !== 'undefined' && window !== null ? window.isFinite : undefined) || global.isFinite)(value) && !isNaN(parseFloat(value));
};
isArray = function (value) {
const isArray = function (value) {
return toString.call(value) === '[object Array]';
};
timeFormats = [
const timeFormats = [
{
name: 'second',
value: 1e3
@ -36,7 +34,7 @@
}
];
Humanize = {};
const Humanize = {};
Humanize.intword = function (number, charWidth, decimals) {
if (decimals == null) {
@ -51,18 +49,18 @@
};
Humanize.compactInteger = function (input, decimals) {
var bigNumPrefixes, decimalIndex, decimalPart, decimalPartArray, length, number, numberLength, numberLengths, output, outputNumber, signString, unsignedNumber, unsignedNumberCharacterArray, unsignedNumberString, wholePart, wholePartArray, _i, _len, _length;
let decimalPart, length, output, outputNumber, unsignedNumberString, _i, _len, _length;
if (decimals == null) {
decimals = 0;
}
decimals = Math.max(decimals, 0);
number = parseInt(input, 10);
signString = number < 0 ? '-' : '';
unsignedNumber = Math.abs(number);
const number = parseInt(input, 10);
const signString = number < 0 ? '-' : '';
const unsignedNumber = Math.abs(number);
unsignedNumberString = '' + unsignedNumber;
numberLength = unsignedNumberString.length;
numberLengths = [13, 10, 7, 4];
bigNumPrefixes = ['T', 'B', 'M', 'k'];
const numberLength = unsignedNumberString.length;
const numberLengths = [13, 10, 7, 4];
const bigNumPrefixes = ['T', 'B', 'M', 'k'];
if (unsignedNumber < 1000) {
if (decimals > 0) {
unsignedNumberString += '.' + (Array(decimals + 1).join('0'));
@ -79,11 +77,11 @@
break;
}
}
decimalIndex = numberLength - length + 1;
unsignedNumberCharacterArray = unsignedNumberString.split('');
wholePartArray = unsignedNumberCharacterArray.slice(0, decimalIndex);
decimalPartArray = unsignedNumberCharacterArray.slice(decimalIndex, decimalIndex + decimals + 1);
wholePart = wholePartArray.join('');
const decimalIndex = numberLength - length + 1;
const unsignedNumberCharacterArray = unsignedNumberString.split('');
const wholePartArray = unsignedNumberCharacterArray.slice(0, decimalIndex);
const decimalPartArray = unsignedNumberCharacterArray.slice(decimalIndex, decimalIndex + decimals + 1);
const wholePart = wholePartArray.join('');
decimalPart = decimalPartArray.join('');
if (decimalPart.length < decimals) {
decimalPart += '' + (Array(decimals - decimalPart.length + 1).join('0'));
@ -105,7 +103,7 @@
};
Humanize.filesize = Humanize.fileSize = function (filesize) {
var sizeStr;
let sizeStr;
if (filesize >= 1073741824) {
sizeStr = Humanize.formatNumber(filesize / 1073741824, 2, '') + ' GB';
} else if (filesize >= 1048576) {
@ -119,7 +117,6 @@
};
Humanize.formatNumber = function (number, precision, thousand, decimal) {
var base; var commas; var decimals; var firstComma; var mod; var negative; var usePrecision;
if (precision == null) {
precision = 0;
}
@ -129,36 +126,35 @@
if (decimal == null) {
decimal = '.';
}
firstComma = function (number, thousand, position) {
const firstComma = function (number, thousand, position) {
if (position) {
return number.substr(0, position) + thousand;
} else {
return '';
}
};
commas = function (number, thousand, position) {
const commas = function (number, thousand, position) {
return number.substr(position).replace(/(\d{3})(?=\d)/g, '$1' + thousand);
};
decimals = function (number, decimal, usePrecision) {
const decimals = function (number, decimal, usePrecision) {
if (usePrecision) {
return decimal + Humanize.toFixed(Math.abs(number), usePrecision).split('.')[1];
} else {
return '';
}
};
usePrecision = Humanize.normalizePrecision(precision);
negative = number < 0 ? '-' : '';
base = parseInt(Humanize.toFixed(Math.abs(number || 0), usePrecision), 10) + '';
mod = base.length > 3 ? base.length % 3 : 0;
const usePrecision = Humanize.normalizePrecision(precision);
const negative = number < 0 ? '-' : '';
const base = parseInt(Humanize.toFixed(Math.abs(number || 0), usePrecision), 10) + '';
const mod = base.length > 3 ? base.length % 3 : 0;
return negative + firstComma(base, thousand, mod) + commas(base, thousand, mod) + decimals(number, decimal, usePrecision);
};
Humanize.toFixed = function (value, precision) {
var power;
if (precision == null) {
precision = Humanize.normalizePrecision(precision, 0);
}
power = Math.pow(10, precision);
const power = Math.pow(10, precision);
return (Math.round(value * power) / power).toFixed(precision);
};
@ -172,16 +168,16 @@
};
Humanize.ordinal = function (value) {
var end, leastSignificant, number, specialCase;
number = parseInt(value, 10);
let end;
const number = parseInt(value, 10);
if (number === 0) {
return value;
}
specialCase = number % 100;
const specialCase = number % 100;
if (specialCase === 11 || specialCase === 12 || specialCase === 13) {
return '' + number + 'th';
}
leastSignificant = number % 10;
const leastSignificant = number % 10;
switch (leastSignificant) {
case 1:
end = 'st';
@ -199,7 +195,7 @@
};
Humanize.times = function (value, overrides) {
var number, smallTimes, _ref;
let number, smallTimes, _ref;
if (overrides == null) {
overrides = {};
}
@ -243,8 +239,8 @@
};
Humanize.truncatewords = Humanize.truncateWords = function (string, length) {
var array, i, result;
array = string.split(' ');
let i, result;
const array = string.split(' ');
result = '';
i = 0;
while (i < length) {
@ -259,7 +255,7 @@
};
Humanize.truncatenumber = Humanize.boundedNumber = function (num, bound, ending) {
var result;
let result;
if (bound == null) {
bound = 100;
}
@ -276,8 +272,8 @@
};
Humanize.oxford = function (items, limit, limitStr) {
var extra, limitIndex, numItems;
numItems = items.length;
let extra, limitIndex;
const numItems = items.length;
if (numItems < 2) {
return '' + items;
} else if (numItems === 2) {
@ -296,7 +292,7 @@
};
Humanize.dictionary = function (object, joiner, separator) {
var defs, key, result, val;
let defs, key, result, val;
if (joiner == null) {
joiner = ' is ';
}
@ -316,12 +312,12 @@
};
Humanize.frequency = function (list, verb) {
var len, str, times;
let str;
if (!isArray(list)) {
return;
}
len = list.length;
times = Humanize.times(len);
const len = list.length;
const times = Humanize.times(len);
if (len === 0) {
str = '' + times + ' ' + verb;
} else {
@ -331,7 +327,7 @@
};
Humanize.pace = function (value, intervalMs, unit) {
var f, prefix, rate, relativePace, roundedPace, timeUnit, _i, _len;
let f, prefix, relativePace, timeUnit, _i, _len;
if (unit == null) {
unit = 'time';
}
@ -340,7 +336,7 @@
}
prefix = 'Approximately';
timeUnit = null;
rate = value / intervalMs;
const rate = value / intervalMs;
for (_i = 0, _len = timeFormats.length; _i < _len; _i++) {
f = timeFormats[_i];
relativePace = rate * f.value;
@ -354,7 +350,7 @@
relativePace = 1;
timeUnit = timeFormats[timeFormats.length - 1].name;
}
roundedPace = Math.round(relativePace);
const roundedPace = Math.round(relativePace);
unit = Humanize.pluralize(roundedPace, unit);
return '' + prefix + ' ' + roundedPace + ' ' + unit + ' per ' + timeUnit;
};
@ -387,21 +383,20 @@
};
Humanize.titlecase = Humanize.titleCase = function (string) {
var doTitleCase; var internalCaps; var smallWords; var splitOnHyphensRegex; var splitOnWhiteSpaceRegex;
smallWords = /\b(a|an|and|at|but|by|de|en|for|if|in|of|on|or|the|to|via|vs?\.?)\b/i;
internalCaps = /\S+[A-Z]+\S*/;
splitOnWhiteSpaceRegex = /\s+/;
splitOnHyphensRegex = /-/;
doTitleCase = function (_string, hyphenated, firstOrLast) {
var index, stringArray, titleCasedArray, word, _i, _len;
const smallWords = /\b(a|an|and|at|but|by|de|en|for|if|in|of|on|or|the|to|via|vs?\.?)\b/i;
const internalCaps = /\S+[A-Z]+\S*/;
const splitOnWhiteSpaceRegex = /\s+/;
const splitOnHyphensRegex = /-/;
const doTitleCase = function (_string, hyphenated, firstOrLast) {
let index, word, _i, _len;
if (hyphenated == null) {
hyphenated = false;
}
if (firstOrLast == null) {
firstOrLast = true;
}
titleCasedArray = [];
stringArray = _string.split(hyphenated ? splitOnHyphensRegex : splitOnWhiteSpaceRegex);
const titleCasedArray = [];
const stringArray = _string.split(hyphenated ? splitOnHyphensRegex : splitOnWhiteSpaceRegex);
for (index = _i = 0, _len = stringArray.length; _i < _len; index = ++_i) {
word = stringArray[index];
if (word.indexOf('-') !== -1) {

View File

@ -7,13 +7,13 @@ if (typeof Object.assign !== 'function') {
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
const to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
for (let index = 1; index < arguments.length; index++) {
const nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
for (const nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];

View File

@ -18,5 +18,5 @@ export default class UserLib {
}
return false;
}
};
}

View File

@ -16,5 +16,5 @@ export default class WalletLib {
} else {
return price - this.wallet.amount;
}
}
};
}

View File

@ -0,0 +1,6 @@
export interface GoogleTagManager {
enableAnalytics: (trackingId: string) => void,
trackPage: (url: string, title: string) => void,
trackLogin: () => void,
trackPurchase: (transactionId: number, value: number) => void,
}

View File

@ -14,7 +14,7 @@ Application.Services.service('Diacritics', [
* @returns {string} without diacritics
*/
remove: function (str) {
var defaultDiacriticsRemovalap = [
const defaultDiacriticsRemovalap = [
{ base: 'A', letters: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F' },
{ base: 'AA', letters: '\uA732' },
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
@ -103,10 +103,10 @@ Application.Services.service('Diacritics', [
{ base: 'z', letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763' }
];
var diacriticsMap = {};
for (var i = 0; i < defaultDiacriticsRemovalap.length; i++) {
var letters = defaultDiacriticsRemovalap[i].letters.split('');
for (var j = 0; j < letters.length; j++) {
const diacriticsMap = {};
for (let i = 0; i < defaultDiacriticsRemovalap.length; i++) {
const letters = defaultDiacriticsRemovalap[i].letters.split('');
for (let j = 0; j < letters.length; j++) {
diacriticsMap[letters[j]] = defaultDiacriticsRemovalap[i].base;
}
}

View File

@ -32,7 +32,9 @@ const customConfig = {
process: 'process/browser'
}),
isDevelopment && new (require('@pmmmwh/react-refresh-webpack-plugin'))(),
isDevelopment && new (require('eslint-webpack-plugin'))()
isDevelopment && new (require('eslint-webpack-plugin'))({
extensions: ['js', 'ts', 'tsx'],
})
].filter(Boolean),
module: {
rules: [