Skip to content

🎥 Make videos programmatically with React

fix linting

ChetanKarwa8399d3492d7b
diff --git a/packages/animation-utils/.eslintrc b/packages/animation-utils/.eslintrc
index 3ad72802a8..ba470b9606 100644
--- a/packages/animation-utils/.eslintrc
+++ b/packages/animation-utils/.eslintrc
@@ -1,3 +1,3 @@
{
- "extends": "@remotion"
+ "extends": "@jonny"
}
diff --git a/packages/animation-utils/src/transformation-helpers/make-transform/index.ts b/packages/animation-utils/src/transformation-helpers/make-transform/index.ts
index 81a32355d6..53a3f01305 100644
--- a/packages/animation-utils/src/transformation-helpers/make-transform/index.ts
+++ b/packages/animation-utils/src/transformation-helpers/make-transform/index.ts
@@ -1,4 +1,4 @@
-import { TransformFunctionReturnType } from "../../type";
+import type { TransformFunctionReturnType } from "../../type";
import {
matrix,
matrix3d,
diff --git a/packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts b/packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts
index c53f65f273..dd1887e040 100644
--- a/packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts
+++ b/packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts
@@ -1,6 +1,6 @@
/* eslint-disable max-params */
-import {
+import type {
TransformFunction,
LengthUnit,
LengthPercentageUnit,
diff --git a/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/index.tsx b/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/index.tsx
index 328ad23f75..3ec4440f8e 100644
--- a/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/index.tsx
+++ b/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/index.tsx
@@ -6,7 +6,7 @@ import {
interpolateColors,
} from "remotion";
import { breakDownValueIntoUnitNumberAndFunctions } from "./utils";
-import {
+import type {
CSSPropertiesKey,
CSSPropertiesValue,
InterpolateStylesParams,
@@ -27,18 +27,21 @@ const getInterpolatedPartValue = (
`The start and end values must be of the same type. Start value: ${startValue}, end value: ${endValue}`
);
}
+
if (startValuePart.color) {
if (!endValuePart.color) {
throw new TypeError(
`The start and end values must be of the same type. Start value: ${startValue}, end value: ${endValue}`
);
}
+
const interpolatedColor = interpolateColors(currentFrame, inputRange, [
startValuePart.color,
endValuePart.color as string,
]);
return `${interpolatedColor}`;
}
+
if (startValuePart.function) {
if (
!endValuePart?.function ||
@@ -48,6 +51,7 @@ const getInterpolatedPartValue = (
`The start and end values must be of the same type. Start value: ${startValue}, end value: ${endValue}`
);
}
+
const endValuePartFunction = endValuePart.function;
const endValuePartFunctionArgs = endValuePartFunction.values || [];
const interpolatedFunctionArgs = startValuePart.function.values.reduce(
@@ -73,11 +77,13 @@ const getInterpolatedPartValue = (
if (typeof startValuePart.number === "undefined") {
return `${startValuePart.unit}`;
}
+
if (startValuePart.unit !== endValuePart.unit) {
throw new TypeError(
`The units of the start and end values must match. Start value: ${startValue}, end value: ${endValue}`
);
}
+
const startNumber = startValuePart.number;
const endNumber = endValuePart.number || 0;
const interpolatedNumber = interpolate(currentFrame, inputRange, [
@@ -97,6 +103,7 @@ const getInterpolatedPropertyValue = (
if (typeof startValue !== typeof endValue) {
return startValue;
}
+
if (typeof startValue === "number") {
return interpolate(currentFrame, inputRange, [
startValue,
@@ -191,10 +198,12 @@ export const useInterpolateStyles = ({
if (!areInputsValid) {
return outputStyles[0] || {};
}
+
if (frame < interpolateFrameSteps[0]) {
setCurrentStyles(outputStyles[0]);
return;
}
+
if (frame >= interpolateFrameSteps[interpolateFrameSteps.length - 1]) {
setCurrentStyles(outputStyles[outputStyles.length - 1]);
return;
@@ -215,6 +224,7 @@ export const useInterpolateStyles = ({
);
setCurrentStyles(currentFrameStyles);
};
+
updateCurrentStyles();
}, [areInputsValid, frame, interpolateFrameSteps, outputStyles]);
diff --git a/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/utils.ts b/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/utils.ts
index 7d562bbbae..96773c25a4 100644
--- a/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/utils.ts
+++ b/packages/animation-utils/src/transformation-helpers/use-interpolate-styles/utils.ts
@@ -1,4 +1,4 @@
-import { CSSPropertiesValue, ColorMatchers } from "../../type";
+import type { CSSPropertiesValue, ColorMatchers } from "../../type";
import { NUMBER, PERCENTAGE, STANDARD_COLOR_NAMES } from "./constants";
function call(...args: unknown[]): string {
@@ -86,6 +86,7 @@ const classifyArgsOfFunction = (value: string) => {
currentValue += char;
}
}
+
if (currentValue) values.push(currentValue.trim());
// Classify each value
@@ -96,6 +97,7 @@ const classifyArgsOfFunction = (value: string) => {
const unit = numberUnitMatch[2];
return unit ? { number, unit } : { number };
}
+
return { unit: val };
});
};
@@ -104,6 +106,7 @@ const isColorValue = (value: string) => {
if (STANDARD_COLOR_NAMES.includes(value)) {
return true;
}
+
const matchers = getColorMatchers();
return (
matchers.rgb?.test(value) ||
@@ -152,6 +155,7 @@ const breakDownValueIntoUnitNumberAndFunctions = (
if (typeof value !== "string") {
return [];
}
+
const valueParts = extractOrderedPartsOfValue(value);
return classifyParts(valueParts);
};
diff --git a/packages/animation-utils/src/type.ts b/packages/animation-utils/src/type.ts
index 2c066f8d32..b8bee85116 100644
--- a/packages/animation-utils/src/type.ts
+++ b/packages/animation-utils/src/type.ts
@@ -1,4 +1,4 @@
-import {
+import type {
matrix,
matrix3d,
perspective,
@@ -21,7 +21,7 @@ import {
translateY,
translateZ,
} from "./transformation-helpers/make-transform";
-import { breakDownValueIntoUnitNumberAndFunctions } from "./transformation-helpers/use-interpolate-styles/utils";
+import type { breakDownValueIntoUnitNumberAndFunctions } from "./transformation-helpers/use-interpolate-styles/utils";
type TransformFunction = () => string;
type LengthUnit =