From afe226e56f91e0b48e8188eeab239903b36c9bd8 Mon Sep 17 00:00:00 2001 From: Michel Palourdio Date: Fri, 29 Mar 2024 23:46:45 +0100 Subject: [PATCH] chore: Enforce eslint and fix warnings --- .eslintrc.json | 19 ++++++++++++++----- .../components/intl-tel-input.component.ts | 7 ++++--- src/lib/model/intl-tel-input.ts | 9 +++++++++ src/public_api.ts | 1 + 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 src/lib/model/intl-tel-input.ts diff --git a/.eslintrc.json b/.eslintrc.json index e20a357..3ea1294 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,24 +16,32 @@ "createDefaultProgram": true }, "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", "plugin:@angular-eslint/recommended", "plugin:@angular-eslint/template/process-inline-templates" ], "rules": { + "@typescript-eslint/explicit-function-return-type": [ + "error" + ], + "no-extra-boolean-cast": [ + "off" + ], "@angular-eslint/component-selector": [ "error", { + "type": "element", "prefix": "", - "style": "kebab-case", - "type": "element" + "style": "kebab-case" } ], "@angular-eslint/directive-selector": [ "error", { + "type": "attribute", "prefix": "", - "style": "camelCase", - "type": "attribute" + "style": "camelCase" } ], "comma-dangle": [ @@ -51,7 +59,8 @@ "*.html" ], "extends": [ - "plugin:@angular-eslint/template/recommended" + "plugin:@angular-eslint/template/recommended", + "plugin:@angular-eslint/template/accessibility" ], "rules": {} } diff --git a/src/lib/components/intl-tel-input.component.ts b/src/lib/components/intl-tel-input.component.ts index b46614d..29969d9 100644 --- a/src/lib/components/intl-tel-input.component.ts +++ b/src/lib/components/intl-tel-input.component.ts @@ -10,7 +10,8 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core'; import { ControlContainer, NgForm } from '@angular/forms'; import intlTelInput from 'intl-tel-input'; -import { CountryData, IntlTelInputOptions } from '../model/intl-tel-input-options'; +import { IntlTelInputOptions } from '../model/intl-tel-input-options'; +import { IntlTelInput } from "../model/intl-tel-input"; @Component({ selector: 'intl-tel-input', @@ -30,14 +31,14 @@ export class IntlTelInputComponent implements AfterViewInit { @Output() private E164PhoneNumberChange = new EventEmitter(); @ViewChild('intlTelInput') private _inputElement!: ElementRef; private _phoneNumber!: string; - private _intlTelInput: any; + private _intlTelInput!: IntlTelInput; ngAfterViewInit(): void { const intlTelInputInstance = intlTelInput; this._intlTelInput = intlTelInputInstance(this._inputElement.nativeElement, this.options); } - get intlTelInput(): any { + get intlTelInput(): IntlTelInput { return this._intlTelInput; } diff --git a/src/lib/model/intl-tel-input.ts b/src/lib/model/intl-tel-input.ts new file mode 100644 index 0000000..f97799d --- /dev/null +++ b/src/lib/model/intl-tel-input.ts @@ -0,0 +1,9 @@ +export type IntlTelInput = { + setNumber(a: string): void + + isValidNumber(): boolean + + getNumber(): string | null + + setCountry(a: string): void +} diff --git a/src/public_api.ts b/src/public_api.ts index 6124776..8782f66 100644 --- a/src/public_api.ts +++ b/src/public_api.ts @@ -4,4 +4,5 @@ export * from './lib/components/intl-tel-input.component'; export * from './lib/model/intl-tel-input-options'; +export * from './lib/model/intl-tel-input'; export * from './lib/intl-tel-input-ng.module';