Skip to content

Commit

Permalink
(enhancement) eslint coding standards - automated fixes #506
Browse files Browse the repository at this point in the history
  • Loading branch information
gselderslaghs committed Dec 18, 2024
1 parent 8e59a9d commit 8a53446
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 114 deletions.
6 changes: 3 additions & 3 deletions src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface AutocompleteOptions extends BaseOptions {
dropdownOptions: Partial<DropdownOptions>;
};

let _defaults: AutocompleteOptions = {
const _defaults: AutocompleteOptions = {
data: [], // Autocomplete data set
onAutocomplete: null, // Callback for when autocompleted
dropdownOptions: {
Expand Down Expand Up @@ -226,11 +226,11 @@ export class Autocomplete extends Component<AutocompleteOptions> {
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;
Expand Down
8 changes: 4 additions & 4 deletions src/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface FloatingActionButtonOptions extends BaseOptions {
toolbarEnabled: boolean;
};

let _defaults: FloatingActionButtonOptions = {
const _defaults: FloatingActionButtonOptions = {
direction: 'top',
hoverEnabled: true,
toolbarEnabled: false
Expand Down Expand Up @@ -199,9 +199,9 @@ export class FloatingActionButton extends Component<FloatingActionButtonOptions>

_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'); // $('<div class="fab-backdrop"></div>');
Expand Down
16 changes: 8 additions & 8 deletions src/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -152,7 +152,7 @@ export class Carousel extends Component<CarouselOptions> {
// 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;
Expand Down Expand Up @@ -493,8 +493,8 @@ export class Carousel extends Component<CarouselOptions> {
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);
Expand Down Expand Up @@ -537,7 +537,7 @@ export class Carousel extends Component<CarouselOptions> {
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)`;
Expand All @@ -556,7 +556,7 @@ export class Carousel extends Component<CarouselOptions> {
// 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);
}
Expand All @@ -571,7 +571,7 @@ export class Carousel extends Component<CarouselOptions> {
// 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);
}
Expand All @@ -580,7 +580,7 @@ export class Carousel extends Component<CarouselOptions> {
// 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);
Expand Down
2 changes: 1 addition & 1 deletion src/characterCounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/chips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface ChipsOptions extends BaseOptions{
onChipDelete: (element: HTMLElement, chip: HTMLElement) => void;
}

let _defaults: ChipsOptions = {
const _defaults: ChipsOptions = {
data: [],
placeholder: '',
secondaryPlaceholder: '',
Expand Down
2 changes: 1 addition & 1 deletion src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Component<O extends BaseOptions>{
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();
}
Expand Down
34 changes: 17 additions & 17 deletions src/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -311,7 +311,7 @@ export class Datepicker extends Component<DatepickerOptions> {
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);
Expand All @@ -326,7 +326,7 @@ export class Datepicker extends Component<DatepickerOptions> {
}
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) {
Expand Down Expand Up @@ -368,7 +368,7 @@ export class Datepicker extends Component<DatepickerOptions> {
}

static _isWeekend(date) {
let day = date.getDay();
const day = date.getDay();
return day === 0 || day === 6;
}

Expand Down Expand Up @@ -416,11 +416,11 @@ export class Datepicker extends Component<DatepickerOptions> {
}

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();
}
Expand Down Expand Up @@ -517,7 +517,7 @@ export class Datepicker extends Component<DatepickerOptions> {
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;
Expand Down Expand Up @@ -593,7 +593,7 @@ export class Datepicker extends Component<DatepickerOptions> {
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,
Expand Down Expand Up @@ -658,7 +658,7 @@ export class Datepicker extends Component<DatepickerOptions> {
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,
Expand Down Expand Up @@ -710,7 +710,7 @@ export class Datepicker extends Component<DatepickerOptions> {
}
}

let dayConfig = {
const dayConfig = {
day: dayNumber,
month: monthNumber,
year: yearNumber,
Expand Down Expand Up @@ -739,7 +739,7 @@ export class Datepicker extends Component<DatepickerOptions> {
}

renderDay(opts) {
let arr = [];
const arr = [];
let ariaSelected = 'false';
if (opts.isEmpty) {
if (opts.showDaysInNextAndPreviousMonths) {
Expand Down Expand Up @@ -873,7 +873,7 @@ export class Datepicker extends Component<DatepickerOptions> {

yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${arr.join('')}</select>`;

let leftArrow =
const leftArrow =
'<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg>';
html += `<button class="month-prev${
prev ? '' : ' is-disabled'
Expand All @@ -895,7 +895,7 @@ export class Datepicker extends Component<DatepickerOptions> {
next = false;
}

let rightArrow =
const rightArrow =
'<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg>';
html += `<button class="month-next${
next ? '' : ' is-disabled'
Expand Down Expand Up @@ -957,8 +957,8 @@ export class Datepicker extends Component<DatepickerOptions> {
this.calendarEl.innerHTML = html;

// Init Materialize Select
let yearSelect = this.calendarEl.querySelector('.orig-select-year') as HTMLSelectElement;
let monthSelect = this.calendarEl.querySelector('.orig-select-month') as HTMLSelectElement;
const yearSelect = this.calendarEl.querySelector('.orig-select-year') as HTMLSelectElement;
const monthSelect = this.calendarEl.querySelector('.orig-select-month') as HTMLSelectElement;
FormSelect.init(yearSelect, {
classes: 'select-year',
dropdownOptions: { container: document.body, constrainWidth: false }
Expand Down Expand Up @@ -1009,7 +1009,7 @@ export class Datepicker extends Component<DatepickerOptions> {
return date.getDate();
},
dd: (date: Date) => {
let d = date.getDate();
const d = date.getDate();
return (d < 10 ? '0' : '') + d;
},
ddd: (date: Date) => {
Expand All @@ -1022,7 +1022,7 @@ export class Datepicker extends Component<DatepickerOptions> {
return date.getMonth() + 1;
},
mm: (date: Date) => {
let m = date.getMonth() + 1;
const m = date.getMonth() + 1;
return (m < 10 ? '0' : '') + m;
},
mmm: (date: Date) => {
Expand Down
6 changes: 3 additions & 3 deletions src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export class Forms {
return;
}

let hasLength = textfield.getAttribute('data-length') !== null;
let lenAttr = parseInt(textfield.getAttribute('data-length'));
let len = textfield.value.length;
const hasLength = textfield.getAttribute('data-length') !== null;
const lenAttr = parseInt(textfield.getAttribute('data-length'));
const len = textfield.value.length;

if (len === 0 && textfield.validity.badInput === false && !textfield.required && textfield.classList.contains('validate')) {
textfield.classList.remove('invalid');
Expand Down
6 changes: 3 additions & 3 deletions src/parallax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface ParallaxOptions extends BaseOptions {
responsiveThreshold: number;
}

let _defaults: ParallaxOptions = {
const _defaults: ParallaxOptions = {
responsiveThreshold: 0 // breakpoint for swipeable
};

Expand Down Expand Up @@ -75,14 +75,14 @@ export class Parallax extends Component<ParallaxOptions> {

static _handleScroll() {
for (let i = 0; i < Parallax._parallaxes.length; i++) {
let parallaxInstance = Parallax._parallaxes[i];
const parallaxInstance = Parallax._parallaxes[i];
parallaxInstance._updateParallax.call(parallaxInstance);
}
}

static _handleWindowResize() {
for (let i = 0; i < Parallax._parallaxes.length; i++) {
let parallaxInstance = Parallax._parallaxes[i];
const parallaxInstance = Parallax._parallaxes[i];
parallaxInstance._enabled =
window.innerWidth > parallaxInstance.options.responsiveThreshold;
}
Expand Down
10 changes: 5 additions & 5 deletions src/pushpin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface PushpinOptions extends BaseOptions {
onPositionChange: (position: "pinned" | "pin-top" | "pin-bottom") => void;
}

let _defaults = {
const _defaults = {
top: 0,
bottom: Infinity,
offset: 0,
Expand Down Expand Up @@ -86,7 +86,7 @@ export class Pushpin extends Component<PushpinOptions> {
(this.el as HTMLElement).style.top = null;
this._removePinClasses();
// Remove pushpin Inst
let index = Pushpin._pushpins.indexOf(this);
const index = Pushpin._pushpins.indexOf(this);
Pushpin._pushpins.splice(index, 1);
if (Pushpin._pushpins.length === 0) {
this._removeEventHandlers();
Expand All @@ -95,8 +95,8 @@ export class Pushpin extends Component<PushpinOptions> {
}

static _updateElements() {
for (let elIndex in Pushpin._pushpins) {
let pInstance = Pushpin._pushpins[elIndex];
for (const elIndex in Pushpin._pushpins) {
const pInstance = Pushpin._pushpins[elIndex];
pInstance._updatePosition();
}
}
Expand All @@ -110,7 +110,7 @@ export class Pushpin extends Component<PushpinOptions> {
}

_updatePosition() {
let scrolled = Utils.getDocumentScrollTop() + this.options.offset;
const scrolled = Utils.getDocumentScrollTop() + this.options.offset;

if (
this.options.top <= scrolled &&
Expand Down
Loading

0 comments on commit 8a53446

Please sign in to comment.