From c98131784d69c98b1d6ef72d00a550a9c21a1df4 Mon Sep 17 00:00:00 2001 From: Sokolovskii Ivan Date: Wed, 17 Dec 2025 19:45:43 +0300 Subject: [PATCH] =?UTF-8?q?chore(eslint):=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=81=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20=D1=87=D0=B0=D1=81=D1=82=D1=8C=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=87=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=BB=D0=B8?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D1=80=D0=B0=20=D0=B8=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierrc.mjs | 1 - configs/eslint/rules/import.ts | 7 +++++-- configs/eslint/rules/react.ts | 1 - configs/eslint/rules/reactNative.ts | 1 + configs/eslint/rules/typescript.ts | 3 +++ index.js | 2 -- src/components/Checkbox/__tests__/Checkbox.test.tsx | 6 +----- src/components/Dialog/Dialog.tsx | 1 - src/components/Input/InputOtp/InputOtp.tsx | 7 +++---- .../Input/__tests__/InputGroupAddon.test.tsx | 2 +- .../Input/__tests__/InputTextBase.test.tsx | 9 ++++++--- src/components/ProgressSpinner/ProgressSpinner.tsx | 2 -- .../RadioButton/__tests__/RadioButton.test.tsx | 5 +---- src/components/Rating/Rating.tsx | 13 ++++++++----- src/components/Rating/__tests__/Rating.test.tsx | 2 +- src/components/Rating/__tests__/RatingItem.test.tsx | 2 +- src/components/Tabs/__tests__/Tabs.test.tsx | 2 +- src/components/Timer/Timer.tsx | 5 ++--- src/components/Timer/__tests__/Timer.test.tsx | 2 +- .../ToggleButton/__tests__/ToggleButton.test.tsx | 7 ++----- .../__snapshots__/ToggleButton.test.tsx.snap | 12 ++++++------ 21 files changed, 43 insertions(+), 49 deletions(-) diff --git a/.prettierrc.mjs b/.prettierrc.mjs index 2a22c35..d9fc6e1 100644 --- a/.prettierrc.mjs +++ b/.prettierrc.mjs @@ -25,5 +25,4 @@ const /** @type {import("prettier").Config} */ config = { ], } -// eslint-disable-next-line import-x/no-default-export export default config diff --git a/configs/eslint/rules/import.ts b/configs/eslint/rules/import.ts index 6917a7f..76503a5 100644 --- a/configs/eslint/rules/import.ts +++ b/configs/eslint/rules/import.ts @@ -1,7 +1,6 @@ import { defineConfig } from 'eslint/config' import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript' -// eslint-disable-next-line import-x/no-named-as-default import importX from 'eslint-plugin-import-x' export const importConfig = defineConfig([ @@ -27,7 +26,7 @@ export const importConfig = defineConfig([ 'import-x/export': 'error', // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-deprecated.md - 'import-x/no-deprecated': 'warn', + 'import-x/no-deprecated': 'off', // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-empty-named-blocks.md 'import-x/no-empty-named-blocks': 'error', @@ -213,13 +212,17 @@ export const importConfig = defineConfig([ '**/*.d.ts', 'eslint/**', '*prettier.config*', + '.prettierrc*', + 'configs/eslint/**/*', ], rules: { 'import-x/no-namespace': 'off', 'import-x/no-default-export': 'off', + 'import-x/no-named-as-default': 'off', 'import-x/no-named-as-default-member': 'off', 'import-x/no-anonymous-default-export': 'off', 'import-x/no-nodejs-modules': 'off', }, }, + { files: ['index.js'], rules: { 'import-x/namespace': 'off' } }, ]) diff --git a/configs/eslint/rules/react.ts b/configs/eslint/rules/react.ts index 69141ef..22bd3bd 100644 --- a/configs/eslint/rules/react.ts +++ b/configs/eslint/rules/react.ts @@ -1,7 +1,6 @@ import { defineConfig } from 'eslint/config' import react from 'eslint-plugin-react' -// eslint-disable-next-line import-x/no-namespace import * as reactHooks from 'eslint-plugin-react-hooks' export const reactConfig = defineConfig([ diff --git a/configs/eslint/rules/reactNative.ts b/configs/eslint/rules/reactNative.ts index bf99a89..ed397e5 100644 --- a/configs/eslint/rules/reactNative.ts +++ b/configs/eslint/rules/reactNative.ts @@ -48,6 +48,7 @@ export const reactNativeConfig = defineConfig([ { files: ['**/*.stories.{js,jsx,cjs,mjs,ts,tsx,mts,cts}'], rules: { + 'react-native/no-color-literals': 'off', 'react-native/no-inline-styles': 'off', 'react-native/no-raw-text': 'off', }, diff --git a/configs/eslint/rules/typescript.ts b/configs/eslint/rules/typescript.ts index b090ca5..ad1e5d2 100644 --- a/configs/eslint/rules/typescript.ts +++ b/configs/eslint/rules/typescript.ts @@ -120,6 +120,9 @@ export const typescriptConfig = defineConfig([ // https://typescript-eslint.io/rules/no-confusing-non-null-assertion/ '@typescript-eslint/no-confusing-non-null-assertion': 'error', + // https://typescript-eslint.io/rules/no-deprecated/ + '@typescript-eslint/no-deprecated': 'warn', + // https://typescript-eslint.io/rules/no-dupe-class-members/ 'no-dupe-class-members': 'off', '@typescript-eslint/no-dupe-class-members': 'off', diff --git a/index.js b/index.js index b3d98d6..825b6ec 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,3 @@ -/* eslint-disable import-x/namespace */ -/* eslint-disable import-x/no-deprecated */ import { registerRootComponent } from 'expo' import { diff --git a/src/components/Checkbox/__tests__/Checkbox.test.tsx b/src/components/Checkbox/__tests__/Checkbox.test.tsx index 7156861..786c861 100644 --- a/src/components/Checkbox/__tests__/Checkbox.test.tsx +++ b/src/components/Checkbox/__tests__/Checkbox.test.tsx @@ -3,11 +3,7 @@ import { render } from '@testing-library/react-native' import { Checkbox, type CheckboxProps } from '../Checkbox' describe('Checkbox', () => { - const defaultProps: CheckboxProps = { - // eslint-disable-next-line @typescript-eslint/no-empty-function - onPress: () => {}, - state: 'default', - } + const defaultProps: CheckboxProps = { onPress: jest.fn(), state: 'default' } describe('snapshots', () => { const snapshotCases: Array<[string, Partial]> = [ diff --git a/src/components/Dialog/Dialog.tsx b/src/components/Dialog/Dialog.tsx index 681c190..3e404b8 100644 --- a/src/components/Dialog/Dialog.tsx +++ b/src/components/Dialog/Dialog.tsx @@ -25,7 +25,6 @@ export interface DialogProps extends DialogComponentProps { readonly testID?: string } -// eslint-disable-next-line import-x/no-deprecated const AnimatedPressable = Animated.createAnimatedComponent(Pressable) export const Dialog: React.FC = ({ diff --git a/src/components/Input/InputOtp/InputOtp.tsx b/src/components/Input/InputOtp/InputOtp.tsx index 1e5f7ae..a209cf6 100644 --- a/src/components/Input/InputOtp/InputOtp.tsx +++ b/src/components/Input/InputOtp/InputOtp.tsx @@ -90,7 +90,7 @@ export const InputOtp = memo( ) const renderArray = useMemo( - () => Array.from({ length }).fill(null), + () => Array.from({ length }, (_, i) => `Otp-Item-${i}`), [length] ) @@ -105,13 +105,12 @@ export const InputOtp = memo( {({ pressed }) => ( <> - {renderArray.map((_, index) => ( + {renderArray.map((key, index) => ( { fireEvent.press(pressable) - expect(onPress).toHaveBeenCalled() + expect(onPress).toHaveBeenCalledWith() }) }) diff --git a/src/components/Input/__tests__/InputTextBase.test.tsx b/src/components/Input/__tests__/InputTextBase.test.tsx index bd63414..904989c 100644 --- a/src/components/Input/__tests__/InputTextBase.test.tsx +++ b/src/components/Input/__tests__/InputTextBase.test.tsx @@ -4,6 +4,7 @@ import { TextInput } from 'react-native-gesture-handler' import { lightTheme } from '../../../theme' import { InputTextBase } from '../InputTextBase/InputTextBase' +import { InputTextBaseTestId } from '../InputTextBase/testIds' import type { RenderTextInputArgs } from '../InputTextBase/types' describe('InputTextBase component functionality tests', () => { @@ -31,7 +32,7 @@ describe('InputTextBase component functionality tests', () => { fireEvent(input, 'focus') - expect(onFocusMock).toHaveBeenCalled() + expect(onFocusMock).toHaveBeenCalledWith(undefined) }) test('should handle blur event', () => { @@ -41,7 +42,7 @@ describe('InputTextBase component functionality tests', () => { fireEvent(input, 'blur') - expect(onBlurMock).toHaveBeenCalled() + expect(onBlurMock).toHaveBeenCalledWith(undefined) }) test('should handle text change', () => { @@ -123,7 +124,9 @@ describe('InputTextBase component functionality tests', () => { render() - expect(renderTextInput).toHaveBeenCalled() + expect(renderTextInput).toHaveBeenCalledWith( + expect.objectContaining({ testID: InputTextBaseTestId.default }) + ) expect(renderTextInput.mock.calls[0]).toMatchSnapshot() }) diff --git a/src/components/ProgressSpinner/ProgressSpinner.tsx b/src/components/ProgressSpinner/ProgressSpinner.tsx index cda41f9..0658ac5 100644 --- a/src/components/ProgressSpinner/ProgressSpinner.tsx +++ b/src/components/ProgressSpinner/ProgressSpinner.tsx @@ -12,9 +12,7 @@ import Svg, { Circle } from 'react-native-svg' import { makeStyles } from '../../utils/makeStyles' -// eslint-disable-next-line import-x/no-deprecated const AnimatedSvg = Animated.createAnimatedComponent(Svg) -// eslint-disable-next-line import-x/no-deprecated const AnimatedCircle = Animated.createAnimatedComponent(Circle) const STROKE_WIDTH = 2 diff --git a/src/components/RadioButton/__tests__/RadioButton.test.tsx b/src/components/RadioButton/__tests__/RadioButton.test.tsx index 8c22ddb..4da1a8e 100644 --- a/src/components/RadioButton/__tests__/RadioButton.test.tsx +++ b/src/components/RadioButton/__tests__/RadioButton.test.tsx @@ -3,10 +3,7 @@ import { render } from '@testing-library/react-native' import { RadioButton, type RadioButtonProps } from '../RadioButton' describe('RadioButton', () => { - const defaultProps: RadioButtonProps = { - // eslint-disable-next-line @typescript-eslint/no-empty-function - onPress: () => {}, - } + const defaultProps: RadioButtonProps = { onPress: jest.fn() } describe('snapshots', () => { const snapshotCases: Array<[string, Partial]> = [ diff --git a/src/components/Rating/Rating.tsx b/src/components/Rating/Rating.tsx index 207a158..1e6f1bc 100644 --- a/src/components/Rating/Rating.tsx +++ b/src/components/Rating/Rating.tsx @@ -1,4 +1,4 @@ -import { memo, useCallback } from 'react' +import { memo, useCallback, useMemo } from 'react' import { type AccessibilityProps, View, type ViewProps } from 'react-native' import { makeStyles } from '../../utils/makeStyles' @@ -75,6 +75,11 @@ export const Rating = memo( [onChange] ) + const renderArray = useMemo( + () => Array.from({ length: maxRating }, (_, i) => `Rating-Item-${i}`), + [maxRating] + ) + return ( ( onPress={onClear} {...rest} /> - {new Array(maxRating).fill(null).map((_, index) => ( + {renderArray.map((key, index) => ( { const clearButton = getByTestId('RatingClear') fireEvent.press(clearButton) - expect(mockOnClear).toHaveBeenCalled() + expect(mockOnClear).toHaveBeenCalledWith() }) test('renders correctly with a different maxRating', () => { diff --git a/src/components/Rating/__tests__/RatingItem.test.tsx b/src/components/Rating/__tests__/RatingItem.test.tsx index 4d3e66e..75870a5 100644 --- a/src/components/Rating/__tests__/RatingItem.test.tsx +++ b/src/components/Rating/__tests__/RatingItem.test.tsx @@ -32,6 +32,6 @@ describe('RatingItem component tests', () => { await user.press(pressableContainer) - expect(mockedOnPress).toHaveBeenCalled() + expect(mockedOnPress).toHaveBeenCalledWith(expect.any(Object)) }) }) diff --git a/src/components/Tabs/__tests__/Tabs.test.tsx b/src/components/Tabs/__tests__/Tabs.test.tsx index 74f82fc..0e9b306 100644 --- a/src/components/Tabs/__tests__/Tabs.test.tsx +++ b/src/components/Tabs/__tests__/Tabs.test.tsx @@ -198,6 +198,6 @@ describe('Tabs component tests', () => { await user.press(container) - expect(mockedOnTapTabItem).toHaveBeenCalled() + expect(mockedOnTapTabItem).toHaveBeenCalledWith(testableIndex) }) }) diff --git a/src/components/Timer/Timer.tsx b/src/components/Timer/Timer.tsx index 6fd9e9f..a56e426 100644 --- a/src/components/Timer/Timer.tsx +++ b/src/components/Timer/Timer.tsx @@ -14,7 +14,6 @@ import { makeStyles } from '../../utils/makeStyles' import { TimerFlip } from './TimerFlip' import { COUNTER_SIZE } from './constants' -// eslint-disable-next-line import-x/no-deprecated const AnimatedCircle = Animated.createAnimatedComponent(Circle) interface TimerProps { @@ -43,6 +42,8 @@ export const Timer = memo(({ countFrom, onFinish }) => { const circleAnimatedProps = useAnimatedProps(() => ({ strokeDashoffset: -circleAnimation.value * circumferenceLength, + origin: [center, center], + rotation: -90, })) useEffect(() => { @@ -83,9 +84,7 @@ export const Timer = memo(({ countFrom, onFinish }) => { cx={center} cy={center} fill='none' - origin={[center, center]} r={circumferenceRadius} - rotation={-90} stroke={styles.circle.color} strokeDasharray={circumferenceLength} strokeLinecap='round' diff --git a/src/components/Timer/__tests__/Timer.test.tsx b/src/components/Timer/__tests__/Timer.test.tsx index 40eb7af..ffdb62f 100644 --- a/src/components/Timer/__tests__/Timer.test.tsx +++ b/src/components/Timer/__tests__/Timer.test.tsx @@ -45,7 +45,7 @@ describe('Timer', () => { jest.runAllTimers() }) - expect(mockedOnFinish).toHaveBeenCalled() + expect(mockedOnFinish).toHaveBeenCalledWith() }) test('should NOT call onFinish until the timer expires', () => { diff --git a/src/components/ToggleButton/__tests__/ToggleButton.test.tsx b/src/components/ToggleButton/__tests__/ToggleButton.test.tsx index 4a9ebc4..60f1df2 100644 --- a/src/components/ToggleButton/__tests__/ToggleButton.test.tsx +++ b/src/components/ToggleButton/__tests__/ToggleButton.test.tsx @@ -8,10 +8,7 @@ import { } from '../ToggleButton' describe('ToggleButton', () => { - const defaultProps: ToggleButtonProps = { - // eslint-disable-next-line @typescript-eslint/no-empty-function - onPress: () => {}, - } + const defaultProps: ToggleButtonProps = { onPress: jest.fn() } describe('snapshots', () => { const snapshotCases: Array<[string, Partial]> = [ @@ -101,7 +98,7 @@ describe('ToggleButton', () => { await user.press(pressable) - expect(mockedOnPress).toHaveBeenCalled() + expect(mockedOnPress).toHaveBeenCalledWith(expect.any(Object)) }) test('should NOT handle press', async () => { diff --git a/src/components/ToggleButton/__tests__/__snapshots__/ToggleButton.test.tsx.snap b/src/components/ToggleButton/__tests__/__snapshots__/ToggleButton.test.tsx.snap index 66e7e5e..0f327a3 100644 --- a/src/components/ToggleButton/__tests__/__snapshots__/ToggleButton.test.tsx.snap +++ b/src/components/ToggleButton/__tests__/__snapshots__/ToggleButton.test.tsx.snap @@ -3,7 +3,7 @@ exports[`ToggleButton snapshots checked = false, disabled = false, iconOnly = false, size = small, with Icon, with label, iconPos = left 1`] = `