zeiger-eslint-plugin 0.1.1 → 0.1.2
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/dist/index.cjs +19 -12
- package/dist/index.js +19 -12
- package/dist/rules/zeiger-deps.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -48,23 +48,30 @@ const rule = {
|
|
|
48
48
|
if ('Identifier' !== callee.type) return false;
|
|
49
49
|
const hookName = callee.name;
|
|
50
50
|
if (!hookName.startsWith('use')) return false;
|
|
51
|
+
const args = callNode.arguments;
|
|
52
|
+
if (0 === args.length) return false;
|
|
53
|
+
const lastArg = args[args.length - 1];
|
|
54
|
+
if ('ArrayExpression' !== lastArg.type) return false;
|
|
51
55
|
const scope = sourceCode.getScope(node);
|
|
52
56
|
const variable = scope.variables.find((v)=>v.name === hookName);
|
|
53
57
|
if (!variable) return false;
|
|
54
|
-
for (const def of variable.defs)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
for (const def of variable.defs){
|
|
59
|
+
if ('Variable' === def.type && def.node.init) {
|
|
60
|
+
const init = def.node.init;
|
|
61
|
+
if ('CallExpression' === init.type) {
|
|
62
|
+
const initCall = init;
|
|
63
|
+
const initCallee = initCall.callee;
|
|
64
|
+
if ('Identifier' === initCallee.type) {
|
|
65
|
+
const initName = initCallee.name;
|
|
66
|
+
if ('createCollectionPointer' === initName || 'createCollectionItemPointer' === initName) return true;
|
|
67
|
+
}
|
|
68
|
+
if ('MemberExpression' === initCallee.type) {
|
|
69
|
+
const member = initCallee;
|
|
70
|
+
if ('Identifier' === member.property.type && ('createCollectionPointer' === member.property.name || 'createCollectionItemPointer' === member.property.name)) return true;
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
}
|
|
74
|
+
if ('ImportBinding' === def.type) return true;
|
|
68
75
|
}
|
|
69
76
|
return false;
|
|
70
77
|
}
|
package/dist/index.js
CHANGED
|
@@ -20,23 +20,30 @@ const rule = {
|
|
|
20
20
|
if ('Identifier' !== callee.type) return false;
|
|
21
21
|
const hookName = callee.name;
|
|
22
22
|
if (!hookName.startsWith('use')) return false;
|
|
23
|
+
const args = callNode.arguments;
|
|
24
|
+
if (0 === args.length) return false;
|
|
25
|
+
const lastArg = args[args.length - 1];
|
|
26
|
+
if ('ArrayExpression' !== lastArg.type) return false;
|
|
23
27
|
const scope = sourceCode.getScope(node);
|
|
24
28
|
const variable = scope.variables.find((v)=>v.name === hookName);
|
|
25
29
|
if (!variable) return false;
|
|
26
|
-
for (const def of variable.defs)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
for (const def of variable.defs){
|
|
31
|
+
if ('Variable' === def.type && def.node.init) {
|
|
32
|
+
const init = def.node.init;
|
|
33
|
+
if ('CallExpression' === init.type) {
|
|
34
|
+
const initCall = init;
|
|
35
|
+
const initCallee = initCall.callee;
|
|
36
|
+
if ('Identifier' === initCallee.type) {
|
|
37
|
+
const initName = initCallee.name;
|
|
38
|
+
if ('createCollectionPointer' === initName || 'createCollectionItemPointer' === initName) return true;
|
|
39
|
+
}
|
|
40
|
+
if ('MemberExpression' === initCallee.type) {
|
|
41
|
+
const member = initCallee;
|
|
42
|
+
if ('Identifier' === member.property.type && ('createCollectionPointer' === member.property.name || 'createCollectionItemPointer' === member.property.name)) return true;
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
}
|
|
46
|
+
if ('ImportBinding' === def.type) return true;
|
|
40
47
|
}
|
|
41
48
|
return false;
|
|
42
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zeiger-deps.d.ts","sourceRoot":"","sources":["../../src/rules/zeiger-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"zeiger-deps.d.ts","sourceRoot":"","sources":["../../src/rules/zeiger-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAyYhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED