chore: Use isDevEnv() and isTestEnv() (#9264)

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mursaleen Nisar
2025-03-25 00:14:00 +05:30
committed by GitHub
parent 77aca48c84
commit e1bb59fb8f
16 changed files with 48 additions and 45 deletions
+3 -8
View File
@@ -1,6 +1,5 @@
import throttle from "lodash.throttle";
import { ENV } from "../constants";
import { isNonDeletedElement } from "../element";
import { isFrameLikeElement } from "../element/typeChecks";
import {
@@ -10,7 +9,7 @@ import {
} from "../fractionalIndex";
import { getElementsInGroup } from "../groups";
import { randomInteger } from "../random";
import { arrayToMap } from "../utils";
import { arrayToMap, isDevEnv, isTestEnv } from "../utils";
import { toBrandedType } from "../utils";
import { getSelectedElements } from "./selection";
@@ -57,14 +56,10 @@ const getNonDeletedElements = <T extends ExcalidrawElement>(
const validateIndicesThrottled = throttle(
(elements: readonly ExcalidrawElement[]) => {
if (
import.meta.env.DEV ||
import.meta.env.MODE === ENV.TEST ||
window?.DEBUG_FRACTIONAL_INDICES
) {
if (isDevEnv() || isTestEnv() || window?.DEBUG_FRACTIONAL_INDICES) {
validateFractionalIndices(elements, {
// throw only in dev & test, to remain functional on `DEBUG_FRACTIONAL_INDICES`
shouldThrow: import.meta.env.DEV || import.meta.env.MODE === ENV.TEST,
shouldThrow: isDevEnv() || isTestEnv(),
includeBoundTextValidation: true,
});
}