Skip to content

Commit

Permalink
chore: fix eslint errors (#1345)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov authored Jun 28, 2024
1 parent 2bacfca commit 6f3ecbe
Show file tree
Hide file tree
Showing 26 changed files with 113 additions and 114 deletions.
4 changes: 2 additions & 2 deletions projects/angular/src/lib/maskito.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ describe('Maskito Angular package', () => {
fixture.detectChanges();
});

it('Null is treated as empty string', () => {
it('null is treated as empty string', () => {
expect(getText()).toBe('');
expect(getValue()).toBe('');
});

it('Formats new control value', () => {
it('formats new control value', () => {
fixture.componentInstance.control.setValue(12345.6789);
fixture.detectChanges();

Expand Down
4 changes: 2 additions & 2 deletions projects/core/src/lib/utils/test/pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('maskitoPipe', () => {
describe('Readonly arguments are passed to all processors', () => {
const elementState: ElementState = {value: '', selection: [0, 0]};

it('Preprocessor', () => {
it('preprocessor', () => {
const checkActionType: MaskitoPreprocessor = (data, actionType) => {
expect(actionType).toBe('deleteBackward');

Expand All @@ -186,7 +186,7 @@ describe('maskitoPipe', () => {
);
});

it('Postprocessor', () => {
it('postprocessor', () => {
const initialElementState: ElementState = {
value: '27',
selection: [2, 7],
Expand Down
2 changes: 1 addition & 1 deletion projects/core/src/lib/utils/test/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('maskitoTransform', () => {
});

describe('Drop / Browser autofill cases', () => {
it('US Phone mask | Drops "+1(21"', () => {
it('`US` Phone mask | Drops "+1(21"', () => {
expect(maskitoTransform('+1(21', usPhoneOptions)).toBe('+1 (21');
});
});
Expand Down
10 changes: 5 additions & 5 deletions projects/demo-integrations/src/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const {CYPRESS_CONFIG} = require('./../../cypress.config');
const {CYPRESS_CONFIG} = require('../../cypress.config');

module.exports = on => {
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push(
`--window-size=${CYPRESS_CONFIG.viewportWidth},${CYPRESS_CONFIG.viewportHeight}`,
'--force-device-scale-factor=2',
'--high-dpi-support=1',
'--disable-dev-shm-usage',
'--incognito',
);
launchOptions.args.push('--force-device-scale-factor=2');
launchOptions.args.push('--high-dpi-support=1');
launchOptions.args.push('--disable-dev-shm-usage');
launchOptions.args.push('--incognito');
}

if (browser.isHeadless) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import {isPlatformBrowser} from '@angular/common';
import {ChangeDetectionStrategy, Component, ElementRef, Inject, PLATFORM_ID} from '@angular/core';
import {ChangeDetectionStrategy, Component, ElementRef, inject, PLATFORM_ID} from '@angular/core';
import {createRoot} from 'react-dom/client';

import {App} from './react-app';

@Component({
selector: 'test-wrapper',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
@Component({standalone: true, selector: 'test-wrapper', template: '', changeDetection: ChangeDetectionStrategy.OnPush})
export class TestWrapper {
constructor(elementRef: ElementRef, @Inject(PLATFORM_ID) platformId: Record<string, unknown>) {
if (isPlatformBrowser(platformId)) {
createRoot(elementRef.nativeElement).render(<App />);
constructor() {
if (isPlatformBrowser(inject(PLATFORM_ID))) {
createRoot(inject(ElementRef).nativeElement).render(<App />);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {MaskitoElementPredicate, maskitoInitialCalibrationPlugin, MaskitoOptions} from '@maskito/core';
import type {MaskitoElementPredicate, MaskitoOptions} from '@maskito/core';
import {maskitoInitialCalibrationPlugin} from '@maskito/core';
import {maskitoTimeOptionsGenerator} from '@maskito/kit';
import {useMaskito} from '@maskito/react';
import {forwardRef, InputHTMLAttributes, useEffect, useState} from 'react';
import type {ComponentType, InputHTMLAttributes} from 'react';
import {forwardRef, useEffect, useState} from 'react';

const timeOptions = maskitoTimeOptionsGenerator({
mode: 'HH:MM',
Expand All @@ -15,19 +17,19 @@ const options: MaskitoOptions = {
const correctPredicate: MaskitoElementPredicate = host => host.querySelector<HTMLInputElement>('.real-input')!;
const wrongPredicate: MaskitoElementPredicate = host => host.querySelector('input')!;

const longCorrectPredicate: MaskitoElementPredicate = host =>
const longCorrectPredicate: MaskitoElementPredicate = async host =>
new Promise(resolve => {
setTimeout(() => {
resolve(correctPredicate(host));
}, 2_000);
});

const longInvalidPredicate: MaskitoElementPredicate = host =>
const longInvalidPredicate: MaskitoElementPredicate = async host =>
new Promise(resolve => {
setTimeout(() => resolve(wrongPredicate(host)), 7_000);
});

const fastValidPredicate: MaskitoElementPredicate = host =>
const fastValidPredicate: MaskitoElementPredicate = async host =>
new Promise(resolve => {
setTimeout(() => resolve(correctPredicate(host)), 500);
});
Expand All @@ -47,7 +49,7 @@ export const AwesomeInput = forwardRef<HTMLDivElement, InputHTMLAttributes<HTMLI
</div>
));

export const App = () => {
export const App: ComponentType = () => {
const [useCorrectPredicate, setUseCorrectPredicate] = useState(false);
const inputRef2sec = useMaskito({options, elementPredicate: longCorrectPredicate});
const inputRefRaceCondition = useMaskito({
Expand Down
6 changes: 3 additions & 3 deletions projects/demo/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {ComponentFixture} from '@angular/core/testing';
import {TestBed} from '@angular/core/testing';
import {Router} from '@angular/router';
import {DemoPath} from '@demo/constants';
import {beforeEach, describe, expect, it, xit} from '@jest/globals';
import {beforeEach, describe, expect, it} from '@jest/globals';

import {AppBrowserModule} from './app.browser.module';
import {AppComponent} from './app.component';
Expand All @@ -22,12 +22,12 @@ describe('Test dummy', () => {
fixture.detectChanges();
});

it('AppComponent compiles properly', () => {
it('appComponent compiles properly', () => {
expect(fixture.nativeElement.textContent).toContain('Getting started');
expect(fixture.nativeElement.textContent).toContain('Core concepts');
});

xit('Router works', async () => {
it.skip('router works', async () => {
/**
* Angular 14 regression
* ___
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {isPlatformBrowser} from '@angular/common';
import {Component, ElementRef, Inject, PLATFORM_ID} from '@angular/core';
import {Component, ElementRef, inject, PLATFORM_ID} from '@angular/core';
import {createRoot} from 'react-dom/client';

import {App} from './use-maskito-basic-usage';

@Component({
standalone: true,
selector: 'react-example-1',
template: '',
host: {
'comment-for-devtools': 'Everything inside this tag is really rendered by `react-dom` library',
},
standalone: true,
})
export class ReactExample1 {
constructor(elementRef: ElementRef, @Inject(PLATFORM_ID) platformId: Record<string, unknown>) {
if (isPlatformBrowser(platformId)) {
createRoot(elementRef.nativeElement).render(<App />);
constructor() {
if (isPlatformBrowser(inject(PLATFORM_ID))) {
createRoot(inject(ElementRef).nativeElement).render(<App />);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type {MaskitoOptions} from '@maskito/core';
import {useMaskito} from '@maskito/react';
import type {ComponentType} from 'react';

const digitsOnlyMask: MaskitoOptions = {
mask: /^\d+$/,
};

export const App = () => {
export const App: ComponentType = () => {
const inputRef = useMaskito({options: digitsOnlyMask});

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {forwardRef, InputHTMLAttributes} from 'react';
import type {InputHTMLAttributes} from 'react';
import {forwardRef} from 'react';

const hiddenInputStyles = {
display: 'none',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {isPlatformBrowser} from '@angular/common';
import {Component, ElementRef, Inject, PLATFORM_ID} from '@angular/core';
import {Component, ElementRef, inject, PLATFORM_ID} from '@angular/core';
import {createRoot} from 'react-dom/client';

import {App} from './index';

@Component({
standalone: true,
selector: 'react-example-2',
template: '',
host: {
'comment-for-devtools': 'Everything inside this tag is really rendered by `react-dom` library',
},
standalone: true,
})
export class ReactExample2 {
constructor(elementRef: ElementRef, @Inject(PLATFORM_ID) platformId: Record<string, unknown>) {
if (isPlatformBrowser(platformId)) {
createRoot(elementRef.nativeElement).render(<App />);
constructor() {
if (isPlatformBrowser(inject(PLATFORM_ID))) {
createRoot(inject(ElementRef).nativeElement).render(<App />);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {MaskitoElementPredicate} from '@maskito/core';
import {maskitoDateOptionsGenerator} from '@maskito/kit';
import {useMaskito} from '@maskito/react';
import type {ComponentType} from 'react';

import {AwesomeInput} from './awesome-input';

Expand All @@ -10,7 +11,7 @@ const options = maskitoDateOptionsGenerator({

const elementPredicate: MaskitoElementPredicate = host => host.querySelector<HTMLInputElement>('input.real-input')!;

export const App = () => {
export const App: ComponentType = () => {
const inputRef = useMaskito({options, elementPredicate});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('createLeadingZeroesValidationPostprocessor', () => {
expect(selection).toEqual(['−5,42'.length, '−5,42'.length]);
});

it('Empty string => Empty string', () => {
it('empty string => empty string', () => {
const {value, selection} = process('', [0, 0]);

expect(value).toBe('');
Expand Down
20 changes: 10 additions & 10 deletions projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ describe('Number (maskitoTransform)', () => {
});
});

it('Empty textfield => empty textfield', () => {
it('empty textfield => empty textfield', () => {
expect(maskitoTransform('', options)).toBe('');
});

it('Only postfix => Only postfix', () => {
it('only postfix => Only postfix', () => {
expect(maskitoTransform(' lbs.', options)).toBe(' lbs.');
});

Expand Down Expand Up @@ -144,11 +144,11 @@ describe('Number (maskitoTransform)', () => {
});
});

it('Empty textfield => empty textfield', () => {
it('empty textfield => empty textfield', () => {
expect(maskitoTransform('', options)).toBe('');
});

it('Only postfix => Only postfix', () => {
it('only postfix => Only postfix', () => {
expect(maskitoTransform(' lbs.', options)).toBe(' lbs.');
});

Expand Down Expand Up @@ -185,11 +185,11 @@ describe('Number (maskitoTransform)', () => {
});
});

it('Empty textfield => empty textfield', () => {
it('empty textfield => empty textfield', () => {
expect(maskitoTransform('', options)).toBe('');
});

it('Only prefix => Only prefix', () => {
it('only prefix => Only prefix', () => {
expect(maskitoTransform('lbs. ', options)).toBe('lbs. ');
});

Expand Down Expand Up @@ -222,11 +222,11 @@ describe('Number (maskitoTransform)', () => {
});
});

it('Empty textfield => empty textfield', () => {
it('empty textfield => empty textfield', () => {
expect(maskitoTransform('', options)).toBe('');
});

it('Only prefix => Only prefix', () => {
it('only prefix => Only prefix', () => {
expect(maskitoTransform('lbs. ', options)).toBe('lbs. ');
});

Expand Down Expand Up @@ -260,11 +260,11 @@ describe('Number (maskitoTransform)', () => {
});
});

it('Empty textfield => empty textfield', () => {
it('empty textfield => empty textfield', () => {
expect(maskitoTransform('', options)).toBe('');
});

it('Only prefix => prefix with zero-width space', () => {
it('only prefix => prefix with zero-width space', () => {
expect(maskitoTransform('lbs.', options)).toBe(
`lbs.${CHAR_ZERO_WIDTH_SPACE}`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,16 @@ describe('maskitoParseNumber', () => {
});

describe('NaN', () => {
it('Empty string => NaN', () => {
it('empty string => NaN', () => {
expect(maskitoParseNumber('')).toBeNaN();
});

it('Decimal separator only => NaN', () => {
it('decimal separator only => NaN', () => {
expect(maskitoParseNumber('.')).toBeNaN();
expect(maskitoParseNumber(',', ',')).toBeNaN();
});

it('Negative sign only => NaN', () => {
it('negative sign only => NaN', () => {
expect(maskitoParseNumber('\u2212')).toBeNaN(); // minus
expect(maskitoParseNumber('-')).toBeNaN();
expect(maskitoParseNumber('\u2013')).toBeNaN(); // en-dash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ describe('createMaxValidationPreprocessor', () => {
'insert',
).data || '';

it('All time segments valid', () => {
it('all time segments valid', () => {
expect(process('17:43:00')).toBe('17:43:00');
});

it('contains invalid time segment for hours', () => {
expect(process('30:30:30')).toBe('');
});

it('Invalid time segment for minutes', () => {
it('invalid time segment for minutes', () => {
expect(process('23:70:30')).toBe('');
});
});
Expand All @@ -48,15 +48,15 @@ describe('createMaxValidationPreprocessor', () => {
'validation',
).elementState.value;

it('All time segments valid', () => {
it('all time segments valid', () => {
expect(process('17:43:00')).toBe('17:43:00');
});

it('contains invalid time segment for hours', () => {
expect(process('30:30:30')).toBe('');
});

it('Invalid time segment for minutes', () => {
it('invalid time segment for minutes', () => {
expect(process('23:70:30')).toBe('');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ describe('FirstDateEndSeparatorPreprocessor', () => {
'validation',
).elementState.value;

it('Only complete date (without date end separator)', () => {
it('only complete date (without date end separator)', () => {
expect(preprocess('01.01.2000')).toBe('01.01.2000');
});

it('Only complete date + date end separator', () => {
it('only complete date + date end separator', () => {
expect(preprocess('01.01.2000~')).toBe('01.01.2000 ~ ');
});

Expand Down
Loading

0 comments on commit 6f3ecbe

Please sign in to comment.