From 129fd55ae97a6a24874b0a11cda0f640a5039a60 Mon Sep 17 00:00:00 2001 From: Barsukov Nikita Date: Mon, 1 Aug 2022 15:32:19 +0300 Subject: [PATCH] refactor!: remove redundant exports of internal functions (reduction of public API) (#2253) --- package-lock.json | 181 ++++++++++++++++++ .../bar-chart/bar-chart.component.ts | 3 +- .../line-chart/line-chart.component.ts | 12 +- .../components/card/card.component.ts | 12 +- .../cdk/directives/media/media.directive.ts | 16 +- .../pagination/pagination.component.ts | 9 +- .../progress-segmented.component.ts | 20 +- 7 files changed, 207 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index f9942f66a38b..35d080257d48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "@nrwl/cli": "14.3.1", "@nrwl/eslint-plugin-nx": "14.3.1", "@nrwl/node": "14.3.1", + "@nrwl/nx-cloud": "14.2.0", "@nrwl/tao": "14.3.1", "@nrwl/workspace": "14.3.1", "@nx-cloud/runners": "1.1.0", @@ -5631,6 +5632,101 @@ "node": ">=10.13.0" } }, + "node_modules/@nrwl/nx-cloud": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@nrwl/nx-cloud/-/nx-cloud-14.2.0.tgz", + "integrity": "sha512-KnrNFDCII9mbLwFp0HgyKVlhMTXoN90CQzGgdtCNPPBP/Wg84pttcpynGdWyupkrBJxdqMNTJEC7HGib0ipxew==", + "dev": true, + "dependencies": { + "axios": "^0.21.1", + "chalk": "4.1.0", + "node-machine-id": "^1.1.12", + "strip-json-comments": "^3.1.1", + "tar": "6.1.11" + }, + "bin": { + "nx-cloud": "bin/nx-cloud.js" + } + }, + "node_modules/@nrwl/nx-cloud/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@nrwl/nx-cloud/node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/@nrwl/nx-cloud/node_modules/chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@nrwl/nx-cloud/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@nrwl/nx-cloud/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@nrwl/nx-cloud/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@nrwl/nx-cloud/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@nrwl/tao": { "version": "14.3.1", "resolved": "https://registry.npmjs.org/@nrwl/tao/-/tao-14.3.1.tgz", @@ -26887,6 +26983,12 @@ "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", "dev": true }, + "node_modules/node-machine-id": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz", + "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==", + "dev": true + }, "node_modules/node-releases": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", @@ -44220,6 +44322,79 @@ } } }, + "@nrwl/nx-cloud": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@nrwl/nx-cloud/-/nx-cloud-14.2.0.tgz", + "integrity": "sha512-KnrNFDCII9mbLwFp0HgyKVlhMTXoN90CQzGgdtCNPPBP/Wg84pttcpynGdWyupkrBJxdqMNTJEC7HGib0ipxew==", + "dev": true, + "requires": { + "axios": "^0.21.1", + "chalk": "4.1.0", + "node-machine-id": "^1.1.12", + "strip-json-comments": "^3.1.1", + "tar": "6.1.11" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "dev": true, + "requires": { + "follow-redirects": "^1.14.0" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "@nrwl/tao": { "version": "14.3.1", "resolved": "https://registry.npmjs.org/@nrwl/tao/-/tao-14.3.1.tgz", @@ -60699,6 +60874,12 @@ "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", "dev": true }, + "node-machine-id": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz", + "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==", + "dev": true + }, "node-releases": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", diff --git a/projects/addon-charts/components/bar-chart/bar-chart.component.ts b/projects/addon-charts/components/bar-chart/bar-chart.component.ts index a6a672e63cbf..97e12722a708 100644 --- a/projects/addon-charts/components/bar-chart/bar-chart.component.ts +++ b/projects/addon-charts/components/bar-chart/bar-chart.component.ts @@ -10,8 +10,7 @@ import { import {TuiHintMode, TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; -// eslint-disable-next-line @typescript-eslint/naming-convention -export function valueAssertion(value: ReadonlyArray): boolean { +function valueAssertion(value: ReadonlyArray): boolean { const valid = value.every(array => array.length === value[0].length); return valid; diff --git a/projects/addon-charts/components/line-chart/line-chart.component.ts b/projects/addon-charts/components/line-chart/line-chart.component.ts index 92d238acef37..88b6ccbe4f1b 100644 --- a/projects/addon-charts/components/line-chart/line-chart.component.ts +++ b/projects/addon-charts/components/line-chart/line-chart.component.ts @@ -25,13 +25,6 @@ import {distinctUntilChanged} from 'rxjs/operators'; import {TuiLineChartHintDirective} from './line-chart-hint.directive'; -// eslint-disable-next-line @typescript-eslint/naming-convention -export function smoothingAssertion(smoothingFactor: number): boolean { - return tuiInRange(smoothingFactor, 0, 100); -} - -const SMOOTHING_MESSAGE = `smoothingFactor must be between 0 and 100`; - @Component({ selector: `tui-line-chart`, templateUrl: `./line-chart.template.html`, @@ -66,7 +59,10 @@ export class TuiLineChartComponent { height = 0; @Input() - @tuiDefaultProp(smoothingAssertion, SMOOTHING_MESSAGE) + @tuiDefaultProp( + (smoothingFactor: number) => tuiInRange(smoothingFactor, 0, 100), + `smoothingFactor must be between 0 and 100`, + ) smoothingFactor = 0; @Input() diff --git a/projects/addon-commerce/components/card/card.component.ts b/projects/addon-commerce/components/card/card.component.ts index 9ca482c207e3..c6cfe0cda61d 100644 --- a/projects/addon-commerce/components/card/card.component.ts +++ b/projects/addon-commerce/components/card/card.component.ts @@ -3,13 +3,6 @@ import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/types'; import {tuiDefaultProp} from '@taiga-ui/cdk'; import {TuiSizeS} from '@taiga-ui/core'; -// eslint-disable-next-line @typescript-eslint/naming-convention -export function cardNumberAssertion({length}: string): boolean { - return !length || length === 4; -} - -export const cardNumberAssertionMessage = `cardNumber should contain 4 symbols`; - const icons: Record = { mir: `tuiIconMirMono`, visa: `tuiIconVisaMono`, @@ -35,7 +28,10 @@ export class TuiCardComponent { brandLogo = ``; @Input() - @tuiDefaultProp(cardNumberAssertion, cardNumberAssertionMessage) + @tuiDefaultProp( + ({length}: string) => !length || length === 4, + `cardNumber should contain 4 symbols`, + ) cardNumber = ``; @Input() diff --git a/projects/cdk/directives/media/media.directive.ts b/projects/cdk/directives/media/media.directive.ts index 6add5df19c62..f4df38a5b8ed 100644 --- a/projects/cdk/directives/media/media.directive.ts +++ b/projects/cdk/directives/media/media.directive.ts @@ -10,16 +10,6 @@ import { } from '@angular/core'; import {tuiDefaultProp, tuiRequiredSetter} from '@taiga-ui/cdk/decorators'; -// eslint-disable-next-line @typescript-eslint/naming-convention -export function nonNegativeFiniteAssertion(value: number): boolean { - return isFinite(value) && value >= 0; -} - -// eslint-disable-next-line @typescript-eslint/naming-convention -export function volumeAssertion(volume: number): boolean { - return isFinite(volume) && volume >= 0 && volume <= 1; -} - @Directive({ selector: `video[tuiMedia], audio[tuiMedia]`, exportAs: `tuiMedia`, @@ -29,7 +19,7 @@ export class TuiMediaDirective { @Input() @HostBinding(`volume`) - @tuiDefaultProp(volumeAssertion) + @tuiDefaultProp((volume: number) => isFinite(volume) && volume >= 0 && volume <= 1) volume = 1; @Input(`playbackRate`) @@ -111,3 +101,7 @@ export class TuiMediaDirective { this.elementRef.nativeElement.playbackRate = this.playbackRate; } } + +function nonNegativeFiniteAssertion(value: number): boolean { + return isFinite(value) && value >= 0; +} diff --git a/projects/kit/components/pagination/pagination.component.ts b/projects/kit/components/pagination/pagination.component.ts index 46d136312fc5..81be0b7476cb 100644 --- a/projects/kit/components/pagination/pagination.component.ts +++ b/projects/kit/components/pagination/pagination.component.ts @@ -39,11 +39,6 @@ import {Observable} from 'rxjs'; const DOTS_LENGTH = 1; const ACTIVE_ITEM_LENGTH = 1; -// eslint-disable-next-line @typescript-eslint/naming-convention -export function nonNegativeInteger(length: number): boolean { - return Number.isInteger(length) && length >= 0; -} - @Component({ selector: `tui-pagination`, templateUrl: `./pagination.template.html`, @@ -333,3 +328,7 @@ export class TuiPaginationComponent this.indexChange.emit(index); } } + +function nonNegativeInteger(length: number): boolean { + return Number.isInteger(length) && length >= 0; +} diff --git a/projects/kit/components/progress/progress-segmented/progress-segmented.component.ts b/projects/kit/components/progress/progress-segmented/progress-segmented.component.ts index ef38cd6cf487..7ee8e9c2ace5 100644 --- a/projects/kit/components/progress/progress-segmented/progress-segmented.component.ts +++ b/projects/kit/components/progress/progress-segmented/progress-segmented.component.ts @@ -2,16 +2,6 @@ import {ChangeDetectionStrategy, Component, HostBinding, Input} from '@angular/c import {tuiDefaultProp, tuiIsString} from '@taiga-ui/cdk'; import {TuiSizeS} from '@taiga-ui/core'; -// eslint-disable-next-line @typescript-eslint/naming-convention -export function nonNegativeInt(value: number): boolean { - return Number.isInteger(value) && value >= 0; -} - -// eslint-disable-next-line @typescript-eslint/naming-convention -export function positiveInt(value: number): boolean { - return Number.isInteger(value) && value > 0; -} - @Component({ selector: `tui-progress-segmented`, templateUrl: `./progress-segmented.template.html`, @@ -20,11 +10,17 @@ export function positiveInt(value: number): boolean { }) export class TuiProgressSegmentedComponent { @Input() - @tuiDefaultProp(nonNegativeInt, `Must be non-negative integer between 0 and max`) + @tuiDefaultProp( + (value: number) => Number.isInteger(value) && value >= 0, + `Must be non-negative integer between 0 and max`, + ) value = 0; @Input() - @tuiDefaultProp(positiveInt, `Must be positive integer`) + @tuiDefaultProp( + (value: number) => Number.isInteger(value) && value > 0, + `Must be positive integer`, + ) max = 1; @Input()