Skip to content

🎥 Make videos programmatically with React

fix eslint rule

Jonny Burgerbc398a37e332
diff --git a/packages/eslint-plugin/src/rules/no-from-0.ts b/packages/eslint-plugin/src/rules/no-from-0.ts
index 0cfb0af351..c489c1cf81 100644
--- a/packages/eslint-plugin/src/rules/no-from-0.ts
+++ b/packages/eslint-plugin/src/rules/no-from-0.ts
@@ -6,22 +6,22 @@ const createRule = ESLintUtils.RuleCreator(() => {
type Options = [];
-type MessageIds = "From";
+type MessageIds = "From0";
-const From = "0 is now the default, so you can remove the prop.";
+const From0 = "0 is now the default, so you can remove the prop.";
export default createRule<Options, MessageIds>({
name: "from",
meta: {
type: "problem",
docs: {
- description: From,
+ description: From0,
recommended: "warn",
},
fixable: "code",
schema: [],
messages: {
- From,
+ From0,
},
},
defaultOptions: [],
@@ -41,12 +41,13 @@ export default createRule<Options, MessageIds>({
}
const expression = value.expression;
- if (!expression || expression.type !== "Identifier") {
+ if (!expression || expression.type !== "Literal") {
return;
}
- const stringValue = expression.name;
- if (typeof stringValue !== "string") {
+ const stringValue = expression.value;
+
+ if (stringValue !== 0) {
return;
}
@@ -66,9 +67,9 @@ export default createRule<Options, MessageIds>({
if (name.name !== "Sequence") {
return;
}
- if (stringValue === "0") {
+ if (stringValue === 0) {
context.report({
- messageId: "From",
+ messageId: "From0",
node,
fix: (fixer) => {
return fixer.removeRange([node.name.range[0], value.range[1]]);
diff --git a/packages/eslint-plugin/src/tests/no-duration-frames-infinity.test.ts b/packages/eslint-plugin/src/tests/no-duration-frames-infinity.test.ts
index b9513a6c0b..bf0252cf43 100644
--- a/packages/eslint-plugin/src/tests/no-duration-frames-infinity.test.ts
+++ b/packages/eslint-plugin/src/tests/no-duration-frames-infinity.test.ts
@@ -1,5 +1,5 @@
import { ESLintUtils } from "@typescript-eslint/utils";
-import rule from "../rules//no-duration-frames-infinity";
+import rule from "../rules/no-duration-frames-infinity";
const ruleTester = new ESLintUtils.RuleTester({
parser: "@typescript-eslint/parser",
diff --git a/packages/eslint-plugin/src/tests/no-from-0.test.ts b/packages/eslint-plugin/src/tests/no-from-0.test.ts
new file mode 100644
index 0000000000..1dfe811c26
--- /dev/null
+++ b/packages/eslint-plugin/src/tests/no-from-0.test.ts
@@ -0,0 +1,58 @@
+import { ESLintUtils } from "@typescript-eslint/utils";
+import rule from "../rules/no-from-0";
+
+const ruleTester = new ESLintUtils.RuleTester({
+ parser: "@typescript-eslint/parser",
+ parserOptions: {
+ ecmaFeatures: {
+ jsx: true,
+ },
+ },
+});
+
+ruleTester.run("no-duration-frames-infinity", rule, {
+ valid: [
+ `
+ import {Sequence} from 'remotion';
+
+ export const Re = () => {
+ return (
+ <Sequence durationInFrames={1} from={1}>
+ Hi
+ </Sequence>
+ );
+ }
+ `,
+ ],
+ invalid: [
+ {
+ code: `
+ import {Composition, Sequence} from 'remotion';
+
+ export const Re = () => {
+ return (
+ <Sequence from={0}>
+ Hi
+ </Sequence>
+ );
+ }
+ `,
+ output: `
+ import {Composition, Sequence} from 'remotion';
+
+ export const Re = () => {
+ return (
+ <Sequence >
+ Hi
+ </Sequence>
+ );
+ }
+ `,
+ errors: [
+ {
+ messageId: "From0",
+ },
+ ],
+ },
+ ],
+});