Skip to content
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
1 change: 0 additions & 1 deletion .prettierrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ const /** @type {import("prettier").Config} */ config = {
],
}

// eslint-disable-next-line import-x/no-default-export
export default config
7 changes: 5 additions & 2 deletions configs/eslint/rules/import.ts
Original file line number Diff line number Diff line change
@@ -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([
Expand All @@ -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',
Expand Down Expand Up @@ -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' } },
])
1 change: 0 additions & 1 deletion configs/eslint/rules/react.ts
Original file line number Diff line number Diff line change
@@ -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([
Expand Down
1 change: 1 addition & 0 deletions configs/eslint/rules/reactNative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
3 changes: 3 additions & 0 deletions configs/eslint/rules/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import-x/namespace */
/* eslint-disable import-x/no-deprecated */
import { registerRootComponent } from 'expo'

import {
Expand Down
6 changes: 1 addition & 5 deletions src/components/Checkbox/__tests__/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<CheckboxProps>]> = [
Expand Down
1 change: 0 additions & 1 deletion src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DialogProps> = ({
Expand Down
7 changes: 3 additions & 4 deletions src/components/Input/InputOtp/InputOtp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const InputOtp = memo<InputOtpProps>(
)

const renderArray = useMemo(
() => Array.from({ length }).fill(null),
() => Array.from({ length }, (_, i) => `Otp-Item-${i}`),
[length]
)

Expand All @@ -105,13 +105,12 @@ export const InputOtp = memo<InputOtpProps>(
{({ pressed }) => (
<>
<View style={styles.content}>
{renderArray.map((_, index) => (
{renderArray.map((key, index) => (
<InputOtpItem
disabled={disabled}
error={error}
focused={isFocused ? index === activeIndex : false}
// eslint-disable-next-line react/no-array-index-key
key={index}
key={key}
pressed={pressed}
testID={`${testID}Item`}
value={value[index]}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Input/__tests__/InputGroupAddon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ describe('InputGroup component tests', () => {

fireEvent.press(pressable)

expect(onPress).toHaveBeenCalled()
expect(onPress).toHaveBeenCalledWith()
})
})
9 changes: 6 additions & 3 deletions src/components/Input/__tests__/InputTextBase.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -31,7 +32,7 @@ describe('InputTextBase component functionality tests', () => {

fireEvent(input, 'focus')

expect(onFocusMock).toHaveBeenCalled()
expect(onFocusMock).toHaveBeenCalledWith(undefined)
})

test('should handle blur event', () => {
Expand All @@ -41,7 +42,7 @@ describe('InputTextBase component functionality tests', () => {

fireEvent(input, 'blur')

expect(onBlurMock).toHaveBeenCalled()
expect(onBlurMock).toHaveBeenCalledWith(undefined)
})

test('should handle text change', () => {
Expand Down Expand Up @@ -123,7 +124,9 @@ describe('InputTextBase component functionality tests', () => {

render(<InputTextBase renderTextInput={renderTextInput} />)

expect(renderTextInput).toHaveBeenCalled()
expect(renderTextInput).toHaveBeenCalledWith(
expect.objectContaining({ testID: InputTextBaseTestId.default })
)
expect(renderTextInput.mock.calls[0]).toMatchSnapshot()
})

Expand Down
2 changes: 0 additions & 2 deletions src/components/ProgressSpinner/ProgressSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/components/RadioButton/__tests__/RadioButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RadioButtonProps>]> = [
Expand Down
13 changes: 8 additions & 5 deletions src/components/Rating/Rating.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -75,6 +75,11 @@ export const Rating = memo<RatingProps>(
[onChange]
)

const renderArray = useMemo(
() => Array.from({ length: maxRating }, (_, i) => `Rating-Item-${i}`),
[maxRating]
)

return (
<View style={styles.container}>
<RatingClear
Expand All @@ -84,12 +89,10 @@ export const Rating = memo<RatingProps>(
onPress={onClear}
{...rest}
/>
{new Array(maxRating).fill(null).map((_, index) => (
{renderArray.map((key, index) => (
<RatingItem
checked={index < rating}
// Использовать индекс массива в качестве ключа - единственно возможное и правильное решение
// eslint-disable-next-line react/no-array-index-key
key={`RatingItem-${index}`}
key={key}
paddings={paddings}
testID={`RatingItem-${index + 1}`}
onPress={handleItemPress(index)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Rating/__tests__/Rating.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Rating component tests', () => {
const clearButton = getByTestId('RatingClear')
fireEvent.press(clearButton)

expect(mockOnClear).toHaveBeenCalled()
expect(mockOnClear).toHaveBeenCalledWith()
})

test('renders correctly with a different maxRating', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Rating/__tests__/RatingItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ describe('RatingItem component tests', () => {

await user.press(pressableContainer)

expect(mockedOnPress).toHaveBeenCalled()
expect(mockedOnPress).toHaveBeenCalledWith(expect.any(Object))
})
})
2 changes: 1 addition & 1 deletion src/components/Tabs/__tests__/Tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ describe('Tabs component tests', () => {

await user.press(container)

expect(mockedOnTapTabItem).toHaveBeenCalled()
expect(mockedOnTapTabItem).toHaveBeenCalledWith(testableIndex)
})
})
5 changes: 2 additions & 3 deletions src/components/Timer/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -43,6 +42,8 @@ export const Timer = memo<TimerProps>(({ countFrom, onFinish }) => {

const circleAnimatedProps = useAnimatedProps(() => ({
strokeDashoffset: -circleAnimation.value * circumferenceLength,
origin: [center, center],
rotation: -90,
}))

useEffect(() => {
Expand Down Expand Up @@ -83,9 +84,7 @@ export const Timer = memo<TimerProps>(({ countFrom, onFinish }) => {
cx={center}
cy={center}
fill='none'
origin={[center, center]}
r={circumferenceRadius}
rotation={-90}
stroke={styles.circle.color}
strokeDasharray={circumferenceLength}
strokeLinecap='round'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Timer/__tests__/Timer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Timer', () => {
jest.runAllTimers()
})

expect(mockedOnFinish).toHaveBeenCalled()
expect(mockedOnFinish).toHaveBeenCalledWith()
})

test('should NOT call onFinish until the timer expires', () => {
Expand Down
7 changes: 2 additions & 5 deletions src/components/ToggleButton/__tests__/ToggleButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ToggleButtonProps>]> = [
Expand Down Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`ToggleButton snapshots checked = false, disabled = false, iconOnly = false, size = small, with Icon, with label, iconPos = left 1`] = `
<Pressable
disabled={false}
onPress={[Function]}
onPress={[MockFunction]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Expand Down Expand Up @@ -209,7 +209,7 @@ exports[`ToggleButton snapshots checked = false, disabled = false, iconOnly = fa
exports[`ToggleButton snapshots checked = false, disabled = false, iconOnly = false, size = small, with Icon, with label, iconPos = right 1`] = `
<Pressable
disabled={false}
onPress={[Function]}
onPress={[MockFunction]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Expand Down Expand Up @@ -415,7 +415,7 @@ exports[`ToggleButton snapshots checked = false, disabled = false, iconOnly = fa
exports[`ToggleButton snapshots checked = false, disabled = false, iconOnly = true, size = base, with Icon, with label 1`] = `
<Pressable
disabled={false}
onPress={[Function]}
onPress={[MockFunction]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Expand Down Expand Up @@ -594,7 +594,7 @@ exports[`ToggleButton snapshots checked = false, disabled = false, iconOnly = tr
exports[`ToggleButton snapshots checked = false, disabled = true, iconOnly = false, size = large, with Icon, with label 1`] = `
<Pressable
disabled={true}
onPress={[Function]}
onPress={[MockFunction]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Expand Down Expand Up @@ -807,7 +807,7 @@ exports[`ToggleButton snapshots checked = false, disabled = true, iconOnly = fal
exports[`ToggleButton snapshots checked = true, disabled = false, iconOnly = false, size = xlarge, with style, with Icon 1`] = `
<Pressable
disabled={false}
onPress={[Function]}
onPress={[MockFunction]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Expand Down Expand Up @@ -991,7 +991,7 @@ exports[`ToggleButton snapshots checked = true, disabled = false, iconOnly = fal

exports[`ToggleButton snapshots default 1`] = `
<Pressable
onPress={[Function]}
onPress={[MockFunction]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Expand Down
Loading