Skip to content

Commit

Permalink
enhancement-506-3: fix some eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPostu committed Sep 16, 2024
1 parent 30c62ea commit 59d3dd6
Show file tree
Hide file tree
Showing 38 changed files with 188 additions and 230 deletions.
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export default [
// thousands of errors, for this reason, they have been marked as WARN
'prettier/prettier': 'error',

'prefer-const': 'warn',
'prefer-rest-params': 'warn',
'no-var': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-unused-expressions': 'warn',
Expand Down
3 changes: 0 additions & 3 deletions spec/helpers/helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */

const KEYMAP = {
'27': 'Escape',
'32': 'Space',
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/cards/cardsSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Cards', () => {
const fixture = `<div class="row">
<div class="col s12 m6">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/carousel/carouselSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Carousel', () => {
const fixture = `<div class="carousel carousel-slider" id="slider-no-wrap">
<div class="carousel-item">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/chips/chipsSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Chips', () => {
const fixture = `<div class="chips"><input></div>
<div class="chips chips-initial"><input></div>
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/collapsible/collapsibleSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Collapsible Plugin:', () => {
let collapsible, accordion, popout, expandable, expandablePreselect;

Expand Down
2 changes: 0 additions & 2 deletions spec/tests/datepicker/datepickerSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Datepicker Plugin', () => {
const fixture = `<div class="row">
<div class="input-field col s12">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/dropdown/dropdownSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Dropdown Plugin:', () => {
const fixture = `<div class="row">
<div class="input-field col s12">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/fab/fabSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Fab Plugin:', () => {
const fixture = `<div class="fixed-action-btn">
<a class="btn-floating btn-large red">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/forms/formsSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

const MULTILINE_TEXT =
'This is line 1.\nThis is line 2.\nThis is line 3.\nThis is line 4.\nThis is line 5.\nAnd this is line 6.';

Expand Down
2 changes: 0 additions & 2 deletions spec/tests/materialbox/materialboxSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Materialbox:', () => {
const fixture = `<div id="transformTest" style="transform: translate3d(1px,1px,1px)">
<img
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/modal/modalSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Modal:', () => {
let trigger1, modal1;

Expand Down
2 changes: 0 additions & 2 deletions spec/tests/select/selectSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Select Plugin:', () => {
const fixture = `<div class="row">
<div class="input-field col s12">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/sidenav/sidenavSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Sidenav Plugin', () => {
const fixture = `<ul id="slide-out" class="sidenav">
<li><div class="user-view">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/slider/sliderSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Slider Plugin:', () => {
const fixture = `<div class="slider simple-slider">
<ul class="slides">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/tabs/tabsSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Tabs Plugin', () => {
const fixture = `<div class="row">
<div class="col s12">
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/toast/toastSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Toasts:', () => {
describe('Toast javascript functions', () => {
it('should display and remove a toast', (done) => {
Expand Down
2 changes: 0 additions & 2 deletions spec/tests/tooltip/tooltipSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

describe('Tooltip:', () => {
const fixture = `<a
id="test"
Expand Down
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 @@ -218,11 +218,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
11 changes: 5 additions & 6 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 @@ -203,10 +203,9 @@ export class FloatingActionButton
}

_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 All @@ -217,7 +216,7 @@ export class FloatingActionButton

this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
this.offsetY = windowHeight - btnRect.bottom;
scaleFactor = windowWidth / backdrop[0].clientWidth;
const scaleFactor = windowWidth / backdrop[0].clientWidth;
this.btnBottom = btnRect.bottom;
this.btnLeft = btnRect.left;
this.btnWidth = btnRect.width;
Expand Down
37 changes: 16 additions & 21 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 @@ -150,7 +150,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 @@ -436,13 +436,12 @@ export class Carousel extends Component<CarouselOptions> {
}

_track = () => {
let now: number, elapsed: number, delta: number, v: number;
now = Date.now();
elapsed = now - this.timestamp;
const now = Date.now();
const elapsed = now - this.timestamp;
this.timestamp = now;
delta = this.offset - this.frame;
const delta = this.offset - this.frame;
this.frame = this.offset;
v = (1000 * delta) / (1 + elapsed);
const v = (1000 * delta) / (1 + elapsed);
this.velocity = 0.8 * v + 0.2 * this.velocity;
};

Expand Down Expand Up @@ -474,25 +473,21 @@ export class Carousel extends Component<CarouselOptions> {

// Start actual scroll
let i: number,
half: number,
delta: number,
dir: number,
tween: number,
el: HTMLElement,
alignment: string,
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);

delta = this.offset - this.center * this.dim;
dir = delta < 0 ? 1 : -1;
tween = (-dir * delta * 2) / this.dim;
half = this.count >> 1;
const delta = this.offset - this.center * this.dim;
const dir = delta < 0 ? 1 : -1;
const tween = (-dir * delta * 2) / this.dim;
const half = this.count >> 1;

if (this.options.fullWidth) {
alignment = 'translateX(0)';
Expand Down Expand Up @@ -528,7 +523,7 @@ export class Carousel extends Component<CarouselOptions> {
el.classList.add('active');
}

let transformString = `${alignment} translateX(${-delta / 2}px) translateX(${
const transformString = `${alignment} translateX(${-delta / 2}px) translateX(${
dir * this.options.shift * tween * i
}px) translateZ(${this.options.dist * tween}px)`;
this._updateItemStyle(el, centerTweenedOpacity, 0, transformString);
Expand All @@ -546,7 +541,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(${
const transformString = `${alignment} translateX(${
this.options.shift + (this.dim * i - delta) / 2
}px) translateZ(${zTranslation}px)`;
this._updateItemStyle(el, tweenedOpacity, -i, transformString);
Expand All @@ -562,7 +557,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(${
const transformString = `${alignment} translateX(${
-this.options.shift + (-this.dim * i - delta) / 2
}px) translateZ(${zTranslation}px)`;
this._updateItemStyle(el, tweenedOpacity, -i, transformString);
Expand All @@ -572,7 +567,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(${
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 @@ -99,7 +99,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 @@ -70,7 +70,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 @@ -45,7 +45,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
Loading

0 comments on commit 59d3dd6

Please sign in to comment.