Skip to content

🎥 Make videos programmatically with React

@remotion/eslint-plugin: Fix volume-callback rule false positive for function references

copilot-swe-agent[bot]66a52dec0e09
diff --git a/packages/eslint-plugin/src/rules/volume-callback.ts b/packages/eslint-plugin/src/rules/volume-callback.ts
index 236a7dcc3e..09f2c59196 100644
--- a/packages/eslint-plugin/src/rules/volume-callback.ts
+++ b/packages/eslint-plugin/src/rules/volume-callback.ts
@@ -67,6 +67,12 @@ export default createRule<Options, MessageIds>({
if (expression.type === 'ArrowFunctionExpression') {
return;
}
+ if (expression.type === 'FunctionExpression') {
+ return;
+ }
+ if (expression.type === 'Identifier') {
+ return;
+ }
context.report({
messageId: 'VolumeCallback',
diff --git a/packages/eslint-plugin/src/tests/volume-callback.test.ts b/packages/eslint-plugin/src/tests/volume-callback.test.ts
index a1146aee03..67fe5791f5 100644
--- a/packages/eslint-plugin/src/tests/volume-callback.test.ts
+++ b/packages/eslint-plugin/src/tests/volume-callback.test.ts
@@ -46,6 +46,26 @@ export const Re = () => {
return (
<RandomComp volume={1} />
);
+}
+ `,
+ `
+import {Video} from 'remotion';
+
+const getVolume = (f) => f / 30;
+
+export const Re = () => {
+ return (
+ <Video volume={getVolume} />
+ );
+}
+ `,
+ `
+import {Audio} from 'remotion';
+
+export const Re = () => {
+ return (
+ <Audio volume={function(f) { return f / 30; }} />
+ );
}
`,
],
@@ -78,6 +98,24 @@ export const Re = () => {
return (
<Audio volume={frame / 20} />
);
+}
+ `,
+ errors: [
+ {
+ messageId: 'VolumeCallback',
+ },
+ ],
+ },
+ {
+ code: `
+import {Video, useCurrentFrame} from 'remotion';
+
+export const Re = () => {
+ const frame = useCurrentFrame();
+
+ return (
+ <Video volume={frame + 5} />
+ );
}
`,
errors: [