Skip to content

feat: typecov(all in one PR) #1141

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 303 additions & 0 deletions packages/plasma-b2c/package-lock.json

Large diffs are not rendered by default.

30 changes: 10 additions & 20 deletions packages/plasma-b2c/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
"build:esm": "BABEL_ENV=esm SC_NAMESPACE=plasma-b2c babel ./src --out-dir ./es --source-maps --extensions .ts,.tsx",
"storybook": "start-storybook -s .storybook/public -p ${PORT:-7007} -c .storybook",
"storybook:build": "build-storybook -s .storybook/public -c .storybook -o build-sb",
"test": "jest"
"test": "jest",
"typescript-coverage": "npx typescript-coverage-report"
},
"typeCoverage": {
"ignoreFiles": ["src/**/*component-test.tsx", "src/**/*stories.tsx", "src/**/*test.*"],
"atLeast": 100
},
"dependencies": {
"@popperjs/core": "2.9.2",
Expand Down Expand Up @@ -78,25 +83,10 @@
"styled-components": "5.3.1",
"ts-jest": "27.0.6",
"ts-node": "10.3.0",
"typescript": "3.9.10"
"typescript": "3.9.10",
"typescript-coverage-report": "0.6.4"
},
"keywords": [
"design-system",
"react-components",
"ui-kit",
"react"
],
"files": [
"components",
"es",
"hocs",
"hooks",
"mixins",
"tokens",
"types",
"utils",
"index.d.ts",
"index.js"
],
"keywords": ["design-system", "react-components", "ui-kit", "react"],
"files": ["components", "es", "hocs", "hooks", "mixins", "tokens", "types", "utils", "index.d.ts", "index.js"],
"sideEffects": false
}
4 changes: 2 additions & 2 deletions packages/plasma-b2c/src/components/Editable/Editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type RefElement = HTMLDivElement | HTMLSpanElement;

export interface EditableProps {
value?: string;
onChange?: React.ChangeEventHandler<RefElement>;
onChange?: React.FormEventHandler<HTMLDivElement>;
onBlur?: React.FocusEventHandler<HTMLDivElement>;
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
spellCheck?: 'true' | 'false';
Expand Down Expand Up @@ -144,7 +144,7 @@ export const Editable: React.FC<EditableProps> = ({
[maxLength],
);

const handleChange = useCallback(
const handleChange = useCallback<React.FormEventHandler<HTMLDivElement>>(
(e) => {
if (!inputRef.current) return;

Expand Down
11 changes: 6 additions & 5 deletions packages/plasma-b2c/src/components/Slider/Double.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { DraggableData } from 'react-draggable';

import { SliderBase } from './SliderBase';
import { Handle } from './Handle';
Expand Down Expand Up @@ -65,15 +66,15 @@ export const Slider: React.FC<SliderProps> = ({ min, max, value, disabled, onCha
}));
}, [value, state.stepSize, min]);

const setStepSize = React.useCallback((newStepSize) => {
const setStepSize = React.useCallback((newStepSize: number) => {
setState((prevState) => ({
...prevState,
stepSize: newStepSize,
}));
}, []);

const onFirstHandleChange = React.useCallback(
(handleValue, data) => {
(handleValue: number, data: DraggableData) => {
if (secondHandleRef?.current) {
const newHandleXPosition = data.x;
const secondHandleXPosition = getXCenterHandle(secondHandleRef.current);
Expand All @@ -95,7 +96,7 @@ export const Slider: React.FC<SliderProps> = ({ min, max, value, disabled, onCha
);

const onFirstHandleChangeCommited = React.useCallback(
(handleValue, data) => {
(handleValue: number, data: DraggableData) => {
onChangeCommitted([handleValue, value[1]]);

setState((prevState) => ({
Expand All @@ -108,7 +109,7 @@ export const Slider: React.FC<SliderProps> = ({ min, max, value, disabled, onCha
);

const onSecondHandleChange = React.useCallback(
(handleValue, data) => {
(handleValue: number, data: DraggableData) => {
if (firstHandleRef?.current) {
const firstXHandleXPosition = getXCenterHandle(firstHandleRef.current);

Expand All @@ -131,7 +132,7 @@ export const Slider: React.FC<SliderProps> = ({ min, max, value, disabled, onCha
);

const onSecondHandleChangeCommited = React.useCallback(
(handleValue, data) => {
(handleValue: number, data: DraggableData) => {
onChangeCommitted([value[0], handleValue]);
setState((prevState) => ({
...prevState,
Expand Down
6 changes: 3 additions & 3 deletions packages/plasma-b2c/src/components/Slider/Handle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import styled from 'styled-components';
import Draggable, { DraggableData } from 'react-draggable';
import Draggable, { DraggableData, DraggableEventHandler } from 'react-draggable';
import { surfaceLiquid03, white } from '@sberdevices/plasma-core';

import { handleDiameter, handleBorderWidth } from './SliderBase';
Expand Down Expand Up @@ -77,7 +77,7 @@ export const Handle = React.forwardRef<HTMLDivElement, HandleProps>(
({ stepSize, onChangeCommitted, onChange, xPosition, min, max, bounds = [], zIndex, disabled, side }, ref) => {
const lastOnChangeValue = React.useRef<number | null>(null);

const onDrag = React.useCallback(
const onDrag = React.useCallback<DraggableEventHandler>(
(_, data) => {
const newHandleXPosition = data.lastX;

Expand All @@ -92,7 +92,7 @@ export const Handle = React.forwardRef<HTMLDivElement, HandleProps>(
[onChange, stepSize, min, max],
);

const onStop = React.useCallback(
const onStop = React.useCallback<DraggableEventHandler>(
(_, data) => {
const newHandleXPosition = data.lastX;
const newValue = getValue(newHandleXPosition, stepSize, min, max);
Expand Down
7 changes: 4 additions & 3 deletions packages/plasma-b2c/src/components/Slider/Single.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { DraggableData } from 'react-draggable';

import { SliderBase } from './SliderBase';
import { Handle } from './Handle';
Expand Down Expand Up @@ -48,15 +49,15 @@ export const Slider: React.FC<SliderProps> = ({ min, max, value, disabled, onCha
}));
}, [value, state.stepSize, min]);

const setStepSize = React.useCallback((newStepSize) => {
const setStepSize = React.useCallback((newStepSize: number) => {
setState((prevState) => ({
...prevState,
stepSize: newStepSize,
}));
}, []);

const onHandleChange = React.useCallback(
(handleValue, data) => {
(handleValue: number, data: DraggableData) => {
const newHandleXPosition = data.x;

setState((prevState) => ({
Expand All @@ -72,7 +73,7 @@ export const Slider: React.FC<SliderProps> = ({ min, max, value, disabled, onCha
);

const onHandleChangeCommited = React.useCallback(
(handleValue, data) => {
(handleValue: number, data: { lastX: number }) => {
onChangeCommitted(handleValue);
setState((prevState) => ({
...prevState,
Expand Down
5 changes: 4 additions & 1 deletion packages/plasma-b2c/src/utils/selectText.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
interface Body extends HTMLElement {
createTextRange: () => any;
createTextRange: () => {
moveToElementText: (node: Node) => void;
select: () => void;
};
}

export function selectText(node: Node) {
Expand Down
Loading