@remotion/eslint-plugin 4.0.0-prefetch.7 → 4.0.0-prefetchapi.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/eslint-plugin",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-prefetchapi.16+486ce6105",
|
|
4
4
|
"description": "A set of rules helping you avoid common pitfalls in Remotion.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc -d",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"typescript": "^4.7.0"
|
|
24
24
|
},
|
|
25
25
|
"private": false,
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "486ce6105d52f9494351e4fbf564f6cfb0b10408"
|
|
27
27
|
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
-
const createRule = utils_1.ESLintUtils.RuleCreator(() => {
|
|
5
|
-
return `https://github.com/remotion-dev/remotion`;
|
|
6
|
-
});
|
|
7
|
-
const UseGifComponent = [
|
|
8
|
-
"Use the <Gif> component for animated GIFs instead.",
|
|
9
|
-
].join("\n");
|
|
10
|
-
exports.default = createRule({
|
|
11
|
-
name: "use-gif-component",
|
|
12
|
-
meta: {
|
|
13
|
-
type: "problem",
|
|
14
|
-
docs: {
|
|
15
|
-
description: UseGifComponent,
|
|
16
|
-
recommended: "warn",
|
|
17
|
-
},
|
|
18
|
-
fixable: undefined,
|
|
19
|
-
schema: [],
|
|
20
|
-
messages: {
|
|
21
|
-
UseGifComponent: UseGifComponent,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
defaultOptions: [],
|
|
25
|
-
create: (context) => {
|
|
26
|
-
return {
|
|
27
|
-
JSXAttribute: (node) => {
|
|
28
|
-
if (node.type !== "JSXAttribute") {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (node.name.name !== "src") {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const value = node.value;
|
|
35
|
-
// src={"some string"}
|
|
36
|
-
if (!value) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const stringValue = value &&
|
|
40
|
-
value.type === "JSXExpressionContainer" &&
|
|
41
|
-
value.expression.type === "Literal"
|
|
42
|
-
? value.expression.value
|
|
43
|
-
: value.type === "Literal"
|
|
44
|
-
? value.value
|
|
45
|
-
: null;
|
|
46
|
-
// src="image.gif"
|
|
47
|
-
if (typeof stringValue === "string") {
|
|
48
|
-
const parent = node.parent;
|
|
49
|
-
if (!parent) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (parent.type !== "JSXOpeningElement") {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const name = parent.name;
|
|
56
|
-
if (name.type !== "JSXIdentifier") {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (name.name === "Img" || name.name === "img") {
|
|
60
|
-
// Network and inline URLs are okay
|
|
61
|
-
if (stringValue.includes(".gif")) {
|
|
62
|
-
context.report({
|
|
63
|
-
messageId: "UseGifComponent",
|
|
64
|
-
node,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (value.type === "JSXExpressionContainer" &&
|
|
70
|
-
value.expression.type === "CallExpression" &&
|
|
71
|
-
value.expression.callee.type === "Identifier" &&
|
|
72
|
-
value.expression.callee.name === "staticFile") {
|
|
73
|
-
const args = value.expression.arguments;
|
|
74
|
-
if (args.length === 0) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const firstArg = args[0];
|
|
78
|
-
if (firstArg.type === "Literal") {
|
|
79
|
-
const value = firstArg.value;
|
|
80
|
-
if (typeof value !== "string") {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (value.includes(".gif")) {
|
|
84
|
-
context.report({
|
|
85
|
-
messageId: "UseGifComponent",
|
|
86
|
-
node,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
});
|