From 8a53446297d061331823da7d759b0c2a562976fd Mon Sep 17 00:00:00 2001 From: Geert Selderslaghs Date: Tue, 17 Dec 2024 20:12:42 +0100 Subject: [PATCH 01/27] (enhancement) eslint coding standards - automated fixes #506 --- src/autocomplete.ts | 6 +++--- src/buttons.ts | 8 +++---- src/carousel.ts | 16 +++++++------- src/characterCounter.ts | 2 +- src/chips.ts | 2 +- src/component.ts | 2 +- src/datepicker.ts | 34 ++++++++++++++--------------- src/forms.ts | 6 +++--- src/parallax.ts | 6 +++--- src/pushpin.ts | 10 ++++----- src/scrollspy.ts | 24 ++++++++++----------- src/select.ts | 2 +- src/slider.ts | 2 +- src/timepicker.ts | 48 ++++++++++++++++++++--------------------- src/toasts.ts | 16 +++++++------- src/tooltip.ts | 2 +- src/utils.ts | 42 ++++++++++++++++++------------------ 17 files changed, 114 insertions(+), 114 deletions(-) diff --git a/src/autocomplete.ts b/src/autocomplete.ts index e07ee62335..4acc566415 100644 --- a/src/autocomplete.ts +++ b/src/autocomplete.ts @@ -68,7 +68,7 @@ export interface AutocompleteOptions extends BaseOptions { dropdownOptions: Partial; }; -let _defaults: AutocompleteOptions = { +const _defaults: AutocompleteOptions = { data: [], // Autocomplete data set onAutocomplete: null, // Callback for when autocompleted dropdownOptions: { @@ -226,11 +226,11 @@ export class Autocomplete extends Component { this.el.parentElement.appendChild(this.container); // Initialize dropdown - let dropdownOptions = { + const dropdownOptions = { ...Autocomplete.defaults.dropdownOptions, ...this.options.dropdownOptions }; - let userOnItemClick = dropdownOptions.onItemClick; + const userOnItemClick = dropdownOptions.onItemClick; // Ensuring the select Option call when user passes custom onItemClick function to dropdown dropdownOptions.onItemClick = (li) => { if (!li) return; diff --git a/src/buttons.ts b/src/buttons.ts index 3d4a6a5853..5bca0b1eff 100644 --- a/src/buttons.ts +++ b/src/buttons.ts @@ -18,7 +18,7 @@ export interface FloatingActionButtonOptions extends BaseOptions { toolbarEnabled: boolean; }; -let _defaults: FloatingActionButtonOptions = { +const _defaults: FloatingActionButtonOptions = { direction: 'top', hoverEnabled: true, toolbarEnabled: false @@ -199,9 +199,9 @@ export class FloatingActionButton extends Component _animateInToolbar() { let scaleFactor; - let windowWidth = window.innerWidth; - let windowHeight = window.innerHeight; - let btnRect = this.el.getBoundingClientRect(); + const windowWidth = window.innerWidth; + const windowHeight = window.innerHeight; + const btnRect = this.el.getBoundingClientRect(); const backdrop = document.createElement('div'); backdrop.classList.add('fab-backdrop'); // $('
'); diff --git a/src/carousel.ts b/src/carousel.ts index e4d49ec530..d0a2f5dcfb 100644 --- a/src/carousel.ts +++ b/src/carousel.ts @@ -49,7 +49,7 @@ export interface CarouselOptions extends BaseOptions{ onCycleTo: (current: Element, dragged: boolean) => void; } -let _defaults: CarouselOptions = { +const _defaults: CarouselOptions = { duration: 200, // ms dist: -100, // zoom scale TODO: make this more intuitive as an option shift: 0, // spacing for center image @@ -152,7 +152,7 @@ export class Carousel extends Component { // Setup cross browser string this.xform = 'transform'; ['webkit', 'Moz', 'O', 'ms'].every((prefix) => { - var e = prefix + 'Transform'; + const e = prefix + 'Transform'; if (typeof document.body.style[e] !== 'undefined') { this.xform = e; return false; @@ -493,8 +493,8 @@ export class Carousel extends Component { zTranslation: number, tweenedOpacity: number, centerTweenedOpacity: number; - let lastCenter = this.center; - let numVisibleOffset = 1 / this.options.numVisible; + const lastCenter = this.center; + const numVisibleOffset = 1 / this.options.numVisible; this.offset = typeof x === 'number' ? x : this.offset; this.center = Math.floor((this.offset + this.dim / 2) / this.dim); @@ -537,7 +537,7 @@ export class Carousel extends Component { el.classList.add('active'); } - let transformString = `${alignment} translateX(${-delta / 2}px) translateX(${dir * + const transformString = `${alignment} translateX(${-delta / 2}px) translateX(${dir * this.options.shift * tween * i}px) translateZ(${this.options.dist * tween}px)`; @@ -556,7 +556,7 @@ export class Carousel extends Component { // Don't show wrapped items. if (!this.noWrap || this.center + i < this.count) { el = this.images[this._wrap(this.center + i)]; - let transformString = `${alignment} translateX(${this.options.shift + + const transformString = `${alignment} translateX(${this.options.shift + (this.dim * i - delta) / 2}px) translateZ(${zTranslation}px)`; this._updateItemStyle(el, tweenedOpacity, -i, transformString); } @@ -571,7 +571,7 @@ export class Carousel extends Component { // Don't show wrapped items. if (!this.noWrap || this.center - i >= 0) { el = this.images[this._wrap(this.center - i)]; - let transformString = `${alignment} translateX(${-this.options.shift + + const transformString = `${alignment} translateX(${-this.options.shift + (-this.dim * i - delta) / 2}px) translateZ(${zTranslation}px)`; this._updateItemStyle(el, tweenedOpacity, -i, transformString); } @@ -580,7 +580,7 @@ export class Carousel extends Component { // Don't show wrapped items. if (!this.noWrap || (this.center >= 0 && this.center < this.count)) { el = this.images[this._wrap(this.center)]; - let transformString = `${alignment} translateX(${-delta / 2}px) translateX(${dir * + const transformString = `${alignment} translateX(${-delta / 2}px) translateX(${dir * this.options.shift * tween}px) translateZ(${this.options.dist * tween}px)`; this._updateItemStyle(el, centerTweenedOpacity, 0, transformString); diff --git a/src/characterCounter.ts b/src/characterCounter.ts index 450e815b9c..5ab50fd254 100644 --- a/src/characterCounter.ts +++ b/src/characterCounter.ts @@ -91,7 +91,7 @@ export class CharacterCounter extends Component<{}> { } updateCounter = () => { - let maxLength = parseInt(this.el.getAttribute('maxlength')), + const maxLength = parseInt(this.el.getAttribute('maxlength')), actualLength = (this.el as HTMLInputElement).value.length; this.isValidLength = actualLength <= maxLength; diff --git a/src/chips.ts b/src/chips.ts index a63101ed8c..7f59098d3b 100644 --- a/src/chips.ts +++ b/src/chips.ts @@ -75,7 +75,7 @@ export interface ChipsOptions extends BaseOptions{ onChipDelete: (element: HTMLElement, chip: HTMLElement) => void; } -let _defaults: ChipsOptions = { +const _defaults: ChipsOptions = { data: [], placeholder: '', secondaryPlaceholder: '', diff --git a/src/component.ts b/src/component.ts index 2abc34959c..2f039c2b44 100644 --- a/src/component.ts +++ b/src/component.ts @@ -44,7 +44,7 @@ export class Component{ console.error(Error(el + ' is not an HTML Element')); } // If exists, destroy and reinitialize in child - let ins = classDef.getInstance(el); + const ins = classDef.getInstance(el); if (!!ins) { ins.destroy(); } diff --git a/src/datepicker.ts b/src/datepicker.ts index 3652018a7c..f7c6e0bc23 100644 --- a/src/datepicker.ts +++ b/src/datepicker.ts @@ -164,7 +164,7 @@ export interface DatepickerOptions extends BaseOptions { endRange?: any; } -let _defaults: DatepickerOptions = { +const _defaults: DatepickerOptions = { // Close when date is selected autoClose: false, // the default output format for the input field value @@ -311,7 +311,7 @@ export class Datepicker extends Component { this.options.defaultDate = new Date(Date.parse(this.el.value)); } - let defDate = this.options.defaultDate; + const defDate = this.options.defaultDate; if (Datepicker._isDate(defDate)) { if (this.options.setDefaultDate) { this.setDate(defDate, true); @@ -326,7 +326,7 @@ export class Datepicker extends Component { } if (this.options.isDateRange) { this.multiple = true; - let defEndDate = this.options.defaultEndDate; + const defEndDate = this.options.defaultEndDate; if(Datepicker._isDate(defEndDate)) { if (this.options.setDefaultEndDate) { @@ -368,7 +368,7 @@ export class Datepicker extends Component { } static _isWeekend(date) { - let day = date.getDay(); + const day = date.getDay(); return day === 0 || day === 6; } @@ -416,11 +416,11 @@ export class Datepicker extends Component { } destroySelects() { - let oldYearSelect = this.calendarEl.querySelector('.orig-select-year'); + const oldYearSelect = this.calendarEl.querySelector('.orig-select-year'); if (oldYearSelect) { FormSelect.getInstance(oldYearSelect as HTMLElement).destroy(); } - let oldMonthSelect = this.calendarEl.querySelector('.orig-select-month'); + const oldMonthSelect = this.calendarEl.querySelector('.orig-select-month'); if (oldMonthSelect) { FormSelect.getInstance(oldMonthSelect as HTMLElement).destroy(); } @@ -517,7 +517,7 @@ export class Datepicker extends Component { if (!Datepicker._isDate(date)) { return; } - let min = this.options.minDate, + const min = this.options.minDate, max = this.options.maxDate; if (Datepicker._isDate(min) && date < min) { date = min; @@ -593,7 +593,7 @@ export class Datepicker extends Component { return; } if (this.calendars) { - let firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1), + const firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1), lastVisibleDate = new Date( this.calendars[this.calendars.length - 1].year, this.calendars[this.calendars.length - 1].month, @@ -658,7 +658,7 @@ export class Datepicker extends Component { before += 7; } } - let previousMonth = month === 0 ? 11 : month - 1, + const previousMonth = month === 0 ? 11 : month - 1, nextMonth = month === 11 ? 0 : month + 1, yearOfPreviousMonth = month === 0 ? year - 1 : year, yearOfNextMonth = month === 11 ? year + 1 : year, @@ -710,7 +710,7 @@ export class Datepicker extends Component { } } - let dayConfig = { + const dayConfig = { day: dayNumber, month: monthNumber, year: yearNumber, @@ -739,7 +739,7 @@ export class Datepicker extends Component { } renderDay(opts) { - let arr = []; + const arr = []; let ariaSelected = 'false'; if (opts.isEmpty) { if (opts.showDaysInNextAndPreviousMonths) { @@ -873,7 +873,7 @@ export class Datepicker extends Component { yearHtml = ``; - let leftArrow = + const leftArrow = ''; html += `