diff --git a/sonar-project.properties b/sonar-project.properties index 23333a43cc..31ce8d776f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -6,7 +6,7 @@ sonar.organization=element-hq sonar.sources=src,res sonar.tests=test,playwright,src -sonar.test.inclusions=test/*,playwright/*,src/**/*.test.tsx +sonar.test.inclusions=test/*,playwright/*,src/**/*.test.* sonar.exclusions=__mocks__,docs,element.io,nginx sonar.cpd.exclusions=src/i18n/strings/*.json diff --git a/src/audio/Playback.ts b/src/audio/Playback.ts index 54d2c710d0..96930d43af 100644 --- a/src/audio/Playback.ts +++ b/src/audio/Playback.ts @@ -15,7 +15,7 @@ import { arrayFastResample } from "../utils/arrays"; import { type IDestroyable } from "../utils/IDestroyable"; import { PlaybackClock } from "./PlaybackClock"; import { createAudioContext, decodeOgg } from "./compat"; -import { clamp } from "../utils/numbers"; +import { clamp } from "../shared-components/utils/numbers"; import { DEFAULT_WAVEFORM, PLAYBACK_WAVEFORM_SAMPLES } from "./consts"; import { PlaybackEncoder } from "../PlaybackEncoder"; diff --git a/src/audio/RecorderWorklet.ts b/src/audio/RecorderWorklet.ts index ec4a143c4e..5f96e686ce 100644 --- a/src/audio/RecorderWorklet.ts +++ b/src/audio/RecorderWorklet.ts @@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details. */ import { type IAmplitudePayload, type ITimingPayload, PayloadEvent, WORKLET_NAME } from "./consts"; -import { percentageOf } from "../utils/numbers"; +import { percentageOf } from "../shared-components/utils/numbers"; // from AudioWorkletGlobalScope: https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope declare const currentTime: number; diff --git a/src/audio/VoiceRecording.ts b/src/audio/VoiceRecording.ts index bde86f9dd7..2c5788ef21 100644 --- a/src/audio/VoiceRecording.ts +++ b/src/audio/VoiceRecording.ts @@ -19,7 +19,7 @@ import { PayloadEvent, WORKLET_NAME } from "./consts"; import { UPDATE_EVENT } from "../stores/AsyncStore"; import { createAudioContext } from "./compat"; import { FixedRollingArray } from "../utils/FixedRollingArray"; -import { clamp } from "../utils/numbers"; +import { clamp } from "../shared-components/utils/numbers"; import recorderWorkletFactory from "./recorderWorkletFactory"; const CHANNELS = 1; // stereo isn't important diff --git a/src/components/views/audio_messages/PlaybackWaveform.tsx b/src/components/views/audio_messages/PlaybackWaveform.tsx index c1f470f4b1..895348fb51 100644 --- a/src/components/views/audio_messages/PlaybackWaveform.tsx +++ b/src/components/views/audio_messages/PlaybackWaveform.tsx @@ -11,7 +11,7 @@ import React from "react"; import { arraySeed, arrayTrimFill } from "../../../utils/arrays"; import Waveform from "./Waveform"; import { type Playback } from "../../../audio/Playback"; -import { percentageOf } from "../../../utils/numbers"; +import { percentageOf } from "../../../shared-components/utils/numbers"; import { PLAYBACK_WAVEFORM_SAMPLES } from "../../../audio/consts"; interface IProps { diff --git a/src/components/views/audio_messages/SeekBar.tsx b/src/components/views/audio_messages/SeekBar.tsx index 587975ce1b..c5ec63b359 100644 --- a/src/components/views/audio_messages/SeekBar.tsx +++ b/src/components/views/audio_messages/SeekBar.tsx @@ -10,7 +10,7 @@ import React, { type ChangeEvent, type CSSProperties, type ReactNode } from "rea import { type PlaybackInterface } from "../../../audio/Playback"; import { MarkedExecution } from "../../../utils/MarkedExecution"; -import { percentageOf } from "../../../utils/numbers"; +import { percentageOf } from "../../../shared-components/utils/numbers"; import { _t } from "../../../languageHandler"; interface IProps { diff --git a/src/components/views/emojipicker/EmojiPicker.tsx b/src/components/views/emojipicker/EmojiPicker.tsx index 71659d579b..13caa817ae 100644 --- a/src/components/views/emojipicker/EmojiPicker.tsx +++ b/src/components/views/emojipicker/EmojiPicker.tsx @@ -26,7 +26,7 @@ import { Type, } from "../../../accessibility/RovingTabIndex"; import { Key } from "../../../Keyboard"; -import { clamp } from "../../../utils/numbers"; +import { clamp } from "../../../shared-components/utils/numbers"; import { type ButtonEvent } from "../elements/AccessibleButton"; export const CATEGORY_HEADER_HEIGHT = 20; diff --git a/src/components/views/rooms/AppsDrawer.tsx b/src/components/views/rooms/AppsDrawer.tsx index a5c869c0c3..ac6328c3bf 100644 --- a/src/components/views/rooms/AppsDrawer.tsx +++ b/src/components/views/rooms/AppsDrawer.tsx @@ -22,7 +22,7 @@ import ResizeHandle from "../elements/ResizeHandle"; import Resizer, { type IConfig } from "../../../resizer/resizer"; import PercentageDistributor from "../../../resizer/distributors/percentage"; import { Container, WidgetLayoutStore } from "../../../stores/widgets/WidgetLayoutStore"; -import { clamp, percentageOf, percentageWithin } from "../../../utils/numbers"; +import { clamp, percentageOf, percentageWithin } from "../../../shared-components/utils/numbers"; import UIStore from "../../../stores/UIStore"; import { type ActionPayload } from "../../../dispatcher/payloads"; import Spinner from "../elements/Spinner"; diff --git a/test/unit-tests/utils/numbers-test.ts b/src/shared-components/utils/numbers.test.ts similarity index 99% rename from test/unit-tests/utils/numbers-test.ts rename to src/shared-components/utils/numbers.test.ts index 1de68ce499..928fd67ae0 100644 --- a/test/unit-tests/utils/numbers-test.ts +++ b/src/shared-components/utils/numbers.test.ts @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import { clamp, defaultNumber, percentageOf, percentageWithin, sum } from "../../../src/utils/numbers"; +import { clamp, defaultNumber, percentageOf, percentageWithin, sum } from "./numbers"; describe("numbers", () => { describe("defaultNumber", () => { diff --git a/src/utils/numbers.ts b/src/shared-components/utils/numbers.ts similarity index 100% rename from src/utils/numbers.ts rename to src/shared-components/utils/numbers.ts diff --git a/src/stores/widgets/WidgetLayoutStore.ts b/src/stores/widgets/WidgetLayoutStore.ts index eaea0957b0..bb1c8161bc 100644 --- a/src/stores/widgets/WidgetLayoutStore.ts +++ b/src/stores/widgets/WidgetLayoutStore.ts @@ -14,7 +14,7 @@ import { type IWidget } from "matrix-widget-api"; import SettingsStore from "../../settings/SettingsStore"; import WidgetStore, { type IApp } from "../WidgetStore"; import { WidgetType } from "../../widgets/WidgetType"; -import { clamp, defaultNumber, sum } from "../../utils/numbers"; +import { clamp, defaultNumber, sum } from "../../shared-components/utils/numbers"; import defaultDispatcher from "../../dispatcher/dispatcher"; import { ReadyWatchingStore } from "../ReadyWatchingStore"; import { SettingLevel } from "../../settings/SettingLevel"; diff --git a/src/utils/arrays.ts b/src/utils/arrays.ts index b54e0949f2..c87be4aee9 100644 --- a/src/utils/arrays.ts +++ b/src/utils/arrays.ts @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import { percentageOf, percentageWithin } from "./numbers"; +import { percentageOf, percentageWithin } from "../shared-components/utils/numbers"; /** * Quickly resample an array to have less/more data points. If an input which is larger