From db451ad8e75abdf7815fab50fb0279243a82e0d4 Mon Sep 17 00:00:00 2001 From: Nikita Barsukov Date: Thu, 29 Feb 2024 10:34:19 +0300 Subject: [PATCH] chore: fix eslint --fix mistakes --- .eslintrc.js | 1 + projects/angular/src/lib/maskito.spec.ts | 4 ++-- .../src/lib/classes/mask-model/mask-model.ts | 10 +++++----- projects/core/src/lib/mask.ts | 2 +- .../core/src/lib/utils/dom/event-listener.ts | 4 ++-- .../date-range-mask-doc.component.ts | 15 ++++++++------- .../date-time/date-time-mask-doc.component.ts | 11 ++++++----- .../pages/kit/date/date-mask-doc.component.ts | 8 ++++---- .../kit/number/number-mask-doc.component.ts | 18 +++++++++--------- .../pages/kit/time/time-mask-doc.component.ts | 4 ++-- .../src/pages/phone/phone-doc.component.ts | 11 ++++------- .../src/pages/stackblitz/stackblitz.service.ts | 2 +- 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 29097b23f..6a92a2800 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,6 +22,7 @@ module.exports = { rules: { '@taiga-ui/experience/strict-tui-doc-example': 'off', '@typescript-eslint/consistent-type-assertions': 'off', + '@typescript-eslint/member-ordering': 'off', }, }, ], diff --git a/projects/angular/src/lib/maskito.spec.ts b/projects/angular/src/lib/maskito.spec.ts index 0581bde42..55460b0e2 100644 --- a/projects/angular/src/lib/maskito.spec.ts +++ b/projects/angular/src/lib/maskito.spec.ts @@ -18,8 +18,8 @@ describe('Maskito Angular package', () => { `, }) class TestComponent { - protected readonly control = new FormControl(); - protected options: MaskitoOptions | null = { + public readonly control = new FormControl(); + public options: MaskitoOptions | null = { mask: /^\d+(,\d{0,2})?$/, preprocessors: [ ({elementState, data}) => { diff --git a/projects/core/src/lib/classes/mask-model/mask-model.ts b/projects/core/src/lib/classes/mask-model/mask-model.ts index d4c9fecc2..ffba383ca 100644 --- a/projects/core/src/lib/classes/mask-model/mask-model.ts +++ b/projects/core/src/lib/classes/mask-model/mask-model.ts @@ -14,19 +14,19 @@ export class MaskModel implements ElementState { public selection: SelectionRange = [0, 0]; constructor( - protected readonly initialElementState: ElementState, + private readonly initialElementState: ElementState, private readonly maskOptions: Required, ) { const {value, selection} = calibrateValueByMask( - initialElementState, - this.getMaskExpression(initialElementState), + this.initialElementState, + this.getMaskExpression(this.initialElementState), ); this.value = value; this.selection = selection; } - protected addCharacters([from, to]: SelectionRange, newCharacters: string): void { + public addCharacters([from, to]: SelectionRange, newCharacters: string): void { const {value} = this; const maskExpression = this.getMaskExpression({ value: value.slice(0, from) + newCharacters + value.slice(to), @@ -78,7 +78,7 @@ export class MaskModel implements ElementState { this.selection = maskedElementState.selection; } - protected deleteCharacters([from, to]: SelectionRange): void { + public deleteCharacters([from, to]: SelectionRange): void { if (from === to || !to) { return; } diff --git a/projects/core/src/lib/mask.ts b/projects/core/src/lib/mask.ts index 01e936104..b4f711a78 100644 --- a/projects/core/src/lib/mask.ts +++ b/projects/core/src/lib/mask.ts @@ -133,7 +133,7 @@ export class Maskito extends MaskHistory { return maxLength === -1 ? Infinity : maxLength; } - protected destroy(): void { + public destroy(): void { this.eventListener.destroy(); this.teardowns.forEach(teardown => teardown?.()); } diff --git a/projects/core/src/lib/utils/dom/event-listener.ts b/projects/core/src/lib/utils/dom/event-listener.ts index 5fc313b2c..03e10925b 100644 --- a/projects/core/src/lib/utils/dom/event-listener.ts +++ b/projects/core/src/lib/utils/dom/event-listener.ts @@ -5,7 +5,7 @@ export class EventListener { constructor(private readonly element: HTMLElement) {} - protected listen( + public listen( eventType: E, fn: ( event: E extends 'beforeinput' | 'input' @@ -20,7 +20,7 @@ export class EventListener { this.listeners.push(() => this.element.removeEventListener(eventType, untypedFn)); } - protected destroy(): void { + public destroy(): void { this.listeners.forEach(stopListen => stopListen()); } } diff --git a/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts b/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts index 4b7ee2212..77da85f85 100644 --- a/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts @@ -93,15 +93,16 @@ export class DateRangeMaskDocComponent implements GeneratorOptions { {year: 1}, ]; - protected mode: MaskitoDateMode = this.modeOptions[0]; protected minStr = this.minMaxOptions[0]; protected maxStr = this.minMaxOptions[1]; - protected min = new Date(this.minStr); - protected max = new Date(this.maxStr); - protected minLength: Partial> = {}; - protected maxLength: Partial> = {}; - protected dateSeparator = '.'; - protected rangeSeparator = ' – '; + + public mode: MaskitoDateMode = this.modeOptions[0]; + public min = new Date(this.minStr); + public max = new Date(this.maxStr); + public minLength: Partial> = {}; + public maxLength: Partial> = {}; + public dateSeparator = '.'; + public rangeSeparator = ' – '; protected maskitoOptions: MaskitoOptions = maskitoDateRangeOptionsGenerator(this); diff --git a/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts b/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts index defa35ace..9217505ea 100644 --- a/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts @@ -68,13 +68,14 @@ export class DateTimeMaskDocComponent implements GeneratorOptions { '2025-05-10T18:30', ]; - protected dateMode: MaskitoDateMode = this.dateModeOptions[0]; - protected timeMode: MaskitoTimeMode = this.timeModeOptions[0]; - protected dateSeparator = '.'; protected minStr = this.minMaxOptions[0]; protected maxStr = this.minMaxOptions[1]; - protected min = new Date(this.minStr); - protected max = new Date(this.maxStr); + + public dateMode: MaskitoDateMode = this.dateModeOptions[0]; + public timeMode: MaskitoTimeMode = this.timeModeOptions[0]; + public dateSeparator = '.'; + public min = new Date(this.minStr); + public max = new Date(this.maxStr); protected maskitoOptions: MaskitoOptions = maskitoDateTimeOptionsGenerator(this); diff --git a/projects/demo/src/pages/kit/date/date-mask-doc.component.ts b/projects/demo/src/pages/kit/date/date-mask-doc.component.ts index 99bd7cf3d..1f4e434aa 100644 --- a/projects/demo/src/pages/kit/date/date-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/date/date-mask-doc.component.ts @@ -64,11 +64,11 @@ export class DateMaskDocComponent implements GeneratorOptions { protected minStr = this.minMaxOptions[0]; protected maxStr = this.minMaxOptions[1]; - protected mode: MaskitoDateMode = this.modeOptions[0]; - protected separator = this.separatorOptions[0]; + public mode: MaskitoDateMode = this.modeOptions[0]; + public separator = this.separatorOptions[0]; - protected min = new Date(this.minStr); - protected max = new Date(this.maxStr); + public min = new Date(this.minStr); + public max = new Date(this.maxStr); protected maskitoOptions: MaskitoOptions = maskitoDateOptionsGenerator(this); diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts index 78f1b56b4..7cedb6704 100644 --- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts @@ -88,15 +88,15 @@ export class NumberMaskDocComponent implements GeneratorOptions { protected readonly precisionOptions: number[] = [0, 1, 2, 5, 10, Infinity]; - protected precision = 0; - protected max = Number.MAX_SAFE_INTEGER; - protected min = Number.MIN_SAFE_INTEGER; - protected decimalSeparator = '.'; - protected decimalZeroPadding = false; - protected decimalPseudoSeparators = this.decimalPseudoSeparatorsOptions[0]; - protected thousandSeparator = ' '; - protected prefix = ''; - protected postfix = ''; + public precision = 0; + public max = Number.MAX_SAFE_INTEGER; + public min = Number.MIN_SAFE_INTEGER; + public decimalSeparator = '.'; + public decimalZeroPadding = false; + public decimalPseudoSeparators = this.decimalPseudoSeparatorsOptions[0]; + public thousandSeparator = ' '; + public prefix = ''; + public postfix = ''; protected maskitoOptions: MaskitoOptions = this.calculateMask(this); diff --git a/projects/demo/src/pages/kit/time/time-mask-doc.component.ts b/projects/demo/src/pages/kit/time/time-mask-doc.component.ts index 2daed0286..94049782c 100644 --- a/projects/demo/src/pages/kit/time/time-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/time/time-mask-doc.component.ts @@ -57,8 +57,8 @@ export class TimeMaskDocComponent implements GeneratorOptions { Partial> > = [{hours: 23, minutes: 59, seconds: 59, milliseconds: 999}, {hours: 11}]; - protected mode: MaskitoTimeMode = this.modeOptions[0]; - protected timeSegmentMaxValues: Partial> = + public mode: MaskitoTimeMode = this.modeOptions[0]; + public timeSegmentMaxValues: Partial> = this.timeSegmentMaxValuesOptions[0]; protected maskitoOptions: MaskitoOptions = maskitoTimeOptionsGenerator(this); diff --git a/projects/demo/src/pages/phone/phone-doc.component.ts b/projects/demo/src/pages/phone/phone-doc.component.ts index f755989d4..4ddc6d9b2 100644 --- a/projects/demo/src/pages/phone/phone-doc.component.ts +++ b/projects/demo/src/pages/phone/phone-doc.component.ts @@ -72,18 +72,15 @@ export class PhoneDocComponent implements GeneratorOptions { ), }; - protected metadata = metadata; - - protected strict = true; + public metadata = metadata; + public strict = true; + public countryIsoCode: CountryCode = 'RU'; + public separator = '-'; protected countryCodeVariants = getCountries(this.metadata); - protected countryIsoCode: CountryCode = 'RU'; - protected separatorVariants = ['-', ' ']; - protected separator = '-'; - protected maskitoOptions = maskitoPhoneOptionsGenerator(this); protected get pattern(): string { diff --git a/projects/demo/src/pages/stackblitz/stackblitz.service.ts b/projects/demo/src/pages/stackblitz/stackblitz.service.ts index 71e637381..08294f818 100644 --- a/projects/demo/src/pages/stackblitz/stackblitz.service.ts +++ b/projects/demo/src/pages/stackblitz/stackblitz.service.ts @@ -52,7 +52,7 @@ export class StackblitzService implements TuiCodeEditor { ); } - protected openStarter( + public openStarter( {title, description, files}: Pick, openOptions?: OpenOptions, ): void {