Skip to content

Commit

Permalink
repair linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryD committed Feb 13, 2024
1 parent f2a2bca commit c16b403
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
7 changes: 1 addition & 6 deletions ember-flatpickr/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,12 @@ module.exports = {
// Typescript files
{
parser: '@typescript-eslint/parser',
files: ['addon/**/*.ts'],
files: ['src/**/*.ts'],
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
'prefer-rest-params': 'off',
},
},
{
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
],
};
15 changes: 8 additions & 7 deletions ember-flatpickr/src/components/ember-flatpickr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import flatpickr from 'flatpickr';
/* Replace getOwner from @ember/application to @ember/owner when we can do a conditional macro for ember < 4.10 or ember 4.x is not supported by ember-flatpickr anymore */
import { getOwner } from '@ember/application';


interface EmberFlatpickrArgs extends FlatpickrOptions {
date: FlatpickrOptions['defaultDate'];
disabled: boolean;
}

type FastbootService = {
isFastBoot: boolean;
}
};

/**
* Ember component that wraps the lightweight [`flatpickr`](https://flatpickr.js.org) datetime
Expand Down Expand Up @@ -92,27 +91,29 @@ export default class EmberFlatpickr extends Component<EmberFlatpickrArgs> {
// Require that users pass a date
assert(
'<EmberFlatpickr> requires a `date` to be passed as the value for flatpickr.',
date !== undefined
date !== undefined,
);

// Require that users pass an onChange
assert(
'<EmberFlatpickr> requires an `onChange` action or null for no action.',
onChange !== undefined
onChange !== undefined,
);

// Wrap is not supported
assert(
'<EmberFlatpickr> does not support the wrap option. Please see documentation for an alternative.',
wrap !== true
wrap !== true,
);

// Pass all values and setup flatpickr
scheduleOnce('afterRender', this, this._setFlatpickrOptions, element);
}

_setFlatpickrOptions(element: HTMLInputElement): void {
const fastboot = getOwner(this)?.lookup('service:fastboot') as unknown as (FastbootService | undefined);
const fastboot = getOwner(this)?.lookup('service:fastboot') as unknown as
| FastbootService
| undefined;

if (fastboot && fastboot['isFastBoot']) {
return;
Expand All @@ -129,7 +130,7 @@ export default class EmberFlatpickr extends Component<EmberFlatpickrArgs> {
} = this.args;

const config: Partial<FlatpickrOptions> = Object.fromEntries(
Object.entries(rest).filter((entry) => entry[1] !== undefined)
Object.entries(rest).filter((entry) => entry[1] !== undefined),
);

this.flatpickrRef = flatpickr(element, {
Expand Down
6 changes: 3 additions & 3 deletions ember-flatpickr/src/initializers/ember-flatpickr.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import flatpickr from "flatpickr";
import flatpickr from 'flatpickr';

export function initialize() {
if (window) {
window.flatpickr = flatpickr;
}
};
}

export default {
initialize
initialize,
};

0 comments on commit c16b403

Please sign in to comment.