eslint-plugin-effector 0.10.0 → 0.10.1

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": "eslint-plugin-effector",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Enforcing best practices for Effector",
5
5
  "keywords": [
6
6
  "eslint",
@@ -31,10 +31,13 @@ module.exports = {
31
31
  });
32
32
  },
33
33
  CallExpression(node) {
34
- const currentMethodName = node.callee?.name ?? node.callee?.object.name;
34
+ const currentMethod = node?.callee?.name ?? node?.callee?.object.name;
35
35
  const importedDebugFromPatronum = importedFromPatronum.get("debug");
36
36
 
37
- if (currentMethodName !== importedDebugFromPatronum) {
37
+ if (
38
+ !importedDebugFromPatronum ||
39
+ currentMethod !== importedDebugFromPatronum
40
+ ) {
38
41
  return;
39
42
  }
40
43
 
@@ -71,7 +74,12 @@ function* removeDebugFromPatronum({
71
74
  const startToken = sourceCode.getTokenBefore(node);
72
75
 
73
76
  // remove line with debug
74
- yield fixer.removeRange([startToken.range[1], node.range[1] + 1]);
77
+ yield fixer.removeRange([startToken.range[1], node.range[1]]);
78
+ const semi = sourceCode.getTokenBefore(node, {
79
+ filter: (token) => token.value === ";",
80
+ });
81
+
82
+ if (semi) yield fixer.remove(semi);
75
83
 
76
84
  const importDebugNode = importNodes.get(targetMethod);
77
85
 
@@ -81,12 +89,13 @@ function* removeDebugFromPatronum({
81
89
 
82
90
  // remove import with debug
83
91
  const importParentNode = importDebugNode.parent;
92
+ const amountImportFromPatronum = importParentNode.specifiers.length;
84
93
 
85
94
  /**
86
95
  * import { debug } from 'patronum'
87
96
  * import { debug } from 'patronum/debug'
88
97
  */
89
- if (importParentNode.specifiers.length === 1) {
98
+ if (amountImportFromPatronum === 1) {
90
99
  yield fixer.removeRange([
91
100
  importParentNode.range[0],
92
101
  importParentNode.range[1] + 1,
@@ -95,9 +104,7 @@ function* removeDebugFromPatronum({
95
104
  return null;
96
105
  }
97
106
 
98
- const amountImportFromPatronum = importParentNode.specifiers.length;
99
107
  const importLast = importParentNode.specifiers[amountImportFromPatronum - 1];
100
-
101
108
  const filterTokenComma = { filter: (token) => token.value === "," };
102
109
 
103
110
  /**