diff --git a/app/components/bs-form.js b/app/components/bs-form.js index 57cbdc16b..c2fe3d63e 100644 --- a/app/components/bs-form.js +++ b/app/components/bs-form.js @@ -11,7 +11,7 @@ export default class BsForm extends BaseBsForm { async validate(model) { const isInvalid = Object.getOwnPropertyNames( Object.getPrototypeOf(model), - ).any((potentialValidationKey) => { + ).some((potentialValidationKey) => { // Validation getters must be named `propertyValidation` by our convention if (!potentialValidationKey.endsWith('Validation')) { return false; diff --git a/app/components/create-options-dates.js b/app/components/create-options-dates.js index 5ba9c424e..32c5f1936 100644 --- a/app/components/create-options-dates.js +++ b/app/components/create-options-dates.js @@ -12,10 +12,14 @@ export default class CreateOptionsDates extends Component { // Options may contain the same date multiple times with different ime // Must filter out those duplicates as otherwise unselect would only // remove one entry but not all duplicates. - return this.args.options - .map(({ value }) => DateTime.fromISO(value).toISODate()) - .uniq() - .map((isoDate) => DateTime.fromISO(isoDate)); + return Array.from( + // using Set to remove duplicate values + new Set( + this.args.options.map(({ value }) => + DateTime.fromISO(value).toISODate(), + ), + ), + ).map((isoDate) => DateTime.fromISO(isoDate)); } get calendarCenterNext() { diff --git a/app/components/create-options-datetime.js b/app/components/create-options-datetime.js index 0a54a4264..4145a1fe0 100644 --- a/app/components/create-options-datetime.js +++ b/app/components/create-options-datetime.js @@ -35,7 +35,7 @@ class FormDataOption { const optionsForThisDay = formData.optionsGroupedByDay[day]; const isDuplicate = optionsForThisDay .slice(0, optionsForThisDay.indexOf(this)) - .any((option) => option.time == this.time); + .some((option) => option.time == this.time); if (isDuplicate) { return new IntlMessage('create.options-datetime.error.duplicatedDate'); } diff --git a/app/components/create-options.js b/app/components/create-options.js index 598854978..c8f9cb9ee 100644 --- a/app/components/create-options.js +++ b/app/components/create-options.js @@ -51,7 +51,7 @@ class FormData { return new IntlMessage('create.options.error.notEnoughDates'); } - if (options.any((option) => !option.isValid)) { + if (options.some((option) => !option.isValid)) { return new IntlMessage('create.options.error.invalidOption'); } diff --git a/app/controllers/create/settings.js b/app/controllers/create/settings.js index fa062ff0f..0288b8299 100644 --- a/app/controllers/create/settings.js +++ b/app/controllers/create/settings.js @@ -94,7 +94,7 @@ export default class CreateSettings extends Controller { // set timezone if there is atleast one option with time if ( poll.isFindADate && - poll.options.any((option) => { + poll.options.toArray().some((option) => { return option.hasTime; }) ) { diff --git a/app/controllers/poll-error.js b/app/controllers/poll-error.js index f27c132da..9fd3d4e74 100644 --- a/app/controllers/poll-error.js +++ b/app/controllers/poll-error.js @@ -7,6 +7,6 @@ export default class PollErrorController extends Controller { } get notFound() { - return this.model.errors.firstObject.status === '404'; + return this.model.errors[0].status === '404'; } } diff --git a/app/instance-initializers/i18n.js b/app/instance-initializers/i18n.js index e846f21f9..2221f104a 100644 --- a/app/instance-initializers/i18n.js +++ b/app/instance-initializers/i18n.js @@ -19,34 +19,27 @@ export default { }; function getLocale(availableLocales) { - let methods = [getSavedLocale, getLocaleByBrowser]; - let locale; - - methods.any((method) => { - let preferredLocales = method(); - let match; + for (const method of [getSavedLocale, getLocaleByBrowser]) { + const preferredLocales = method(); if (isEmpty(preferredLocales)) { - return false; + continue; } - match = preferredLocales.find((preferredLocale) => { - return availableLocales.indexOf(preferredLocale) !== -1; - }); + const supportedPreferredLocale = preferredLocales.find( + (preferredLocale) => { + return availableLocales.indexOf(preferredLocale) !== -1; + }, + ); - if (isEmpty(match)) { - return false; + if (isEmpty(supportedPreferredLocale)) { + continue; } - locale = match; - return true; - }); - - if (locale) { - return locale; - } else { - return 'en'; + return supportedPreferredLocale; } + + return 'en'; } function getLocaleByBrowser() { diff --git a/app/models/poll.js b/app/models/poll.js index 590aa88fb..d932fc218 100644 --- a/app/models/poll.js +++ b/app/models/poll.js @@ -73,7 +73,7 @@ export default class Poll extends Model { return false; } - return this.options.any((option) => { + return this.options.toArray().some((option) => { let dayStringLength = 10; // 'YYYY-MM-DD'.length return option.title.length > dayStringLength; }); diff --git a/app/templates/create/index.hbs b/app/templates/create/index.hbs index 004e16a54..adec14b98 100644 --- a/app/templates/create/index.hbs +++ b/app/templates/create/index.hbs @@ -2,7 +2,6 @@ diff --git a/config/environment.js b/config/environment.js index 089752343..2bb483893 100644 --- a/config/environment.js +++ b/config/environment.js @@ -8,7 +8,7 @@ module.exports = function (environment) { locationType: 'hash', EmberENV: { EXTEND_PROTOTYPES: { - Array: true, + Array: false, Date: false, String: false, Function: true, diff --git a/tests/acceptance/participate-in-a-poll-test.js b/tests/acceptance/participate-in-a-poll-test.js index c08d98ca5..979471812 100644 --- a/tests/acceptance/participate-in-a-poll-test.js +++ b/tests/acceptance/participate-in-a-poll-test.js @@ -71,9 +71,7 @@ module('Acceptance | participate in a poll', function (hooks) { assert.equal(currentRouteName(), 'poll.participation'); assert.equal(find('.name input').value, '', 'input for name is cleared'); assert.notOk( - findAll('input[type="radio"]') - .toArray() - .some((el) => el.checked), + findAll('input[type="radio"]').some((el) => el.checked), 'radios are cleared', );