eslint-plugin-effector 0.7.4 → 0.7.5
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/README.md +1 -1
- package/package.json +1 -1
- package/rules/no-forward/no-forward.js +1 -1
- package/rules/no-guard/no-guard.js +1 -1
- package/rules/prefer-sample-over-forward-with-mapping/prefer-sample-over-forward-with-mapping.js +1 -1
- package/utils/extract-imported-from.js +4 -0
- package/utils/replace-by-sample.js +5 -1
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ This preset is recommended for projects that use [React](https://reactjs.org) wi
|
|
|
72
72
|
|
|
73
73
|
#### plugin:effector/future
|
|
74
74
|
|
|
75
|
-
This preset contains rules
|
|
75
|
+
This preset contains rules, which enforce _future-effector_ code-style.
|
|
76
76
|
|
|
77
77
|
- [effector/no-forward](rules/no-forward/no-forward.md)
|
|
78
78
|
- [effector/no-guard](rules/no-guard/no-guard.md)
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
|
16
16
|
messages: {
|
|
17
17
|
noForward:
|
|
18
18
|
"Instead of `forward` you can use `sample`, it is more extendable.",
|
|
19
|
-
replaceWithSample: "
|
|
19
|
+
replaceWithSample: "Replace `forward` with `sample`.",
|
|
20
20
|
},
|
|
21
21
|
schema: [],
|
|
22
22
|
hasSuggestions: true,
|
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
|
16
16
|
messages: {
|
|
17
17
|
noGuard:
|
|
18
18
|
"Instead of `guard` you can use `sample`, it is more extendable.",
|
|
19
|
-
replaceWithSample: "
|
|
19
|
+
replaceWithSample: "Replace `guard` with `sample`.",
|
|
20
20
|
},
|
|
21
21
|
schema: [],
|
|
22
22
|
hasSuggestions: true,
|
package/rules/prefer-sample-over-forward-with-mapping/prefer-sample-over-forward-with-mapping.js
CHANGED
|
@@ -21,7 +21,7 @@ module.exports = {
|
|
|
21
21
|
"Instead of `forward` with `{{ eventName }}.map` you can use `sample`",
|
|
22
22
|
overPrepend:
|
|
23
23
|
"Instead of `forward` with `{{ eventName }}.prepend` you can use `sample`",
|
|
24
|
-
replaceWithSample: "
|
|
24
|
+
replaceWithSample: "Replace `forward` with `sample`.",
|
|
25
25
|
},
|
|
26
26
|
schema: [],
|
|
27
27
|
hasSuggestions: true,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
function extractImportedFrom({ importMap, nodeMap, node, packageName }) {
|
|
2
2
|
if (node.source.value === packageName) {
|
|
3
3
|
for (const s of node.specifiers) {
|
|
4
|
+
if (s.type === "ImportDefaultSpecifier") {
|
|
5
|
+
continue;
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
importMap.set(s.imported.name, s.local.name);
|
|
5
9
|
nodeMap?.set(s.imported.name, s);
|
|
6
10
|
}
|
|
@@ -88,7 +88,11 @@ function* replaceBySample(
|
|
|
88
88
|
})})`
|
|
89
89
|
);
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
const importNode = importNodes.get(methodName);
|
|
92
|
+
|
|
93
|
+
if (!importNodes.has("sample")) {
|
|
94
|
+
yield fixer.insertTextAfter(importNode, ", sample");
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
module.exports = { replaceForwardBySample, replaceGuardBySample };
|