@pdg/react-hook 2.0.11 → 2.0.13
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/eslint-plugin.d.ts +3 -3
- package/dist/eslint-plugin.js +26 -7
- package/package.json +1 -1
package/dist/eslint-plugin.d.ts
CHANGED
|
@@ -68,10 +68,10 @@ declare const plugin: {
|
|
|
68
68
|
};
|
|
69
69
|
configs: {
|
|
70
70
|
recommended: {
|
|
71
|
-
plugins:
|
|
71
|
+
plugins: "@pdg/react-hooks"[];
|
|
72
72
|
rules: {
|
|
73
|
-
'@pdg/react-hooks/rules-of-hooks':
|
|
74
|
-
'@pdg/react-hooks/exhaustive-deps':
|
|
73
|
+
'@pdg/react-hooks/rules-of-hooks': "error";
|
|
74
|
+
'@pdg/react-hooks/exhaustive-deps': "error";
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
};
|
package/dist/eslint-plugin.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactHooksPlugin = require('eslint-plugin-react-hooks');
|
|
1
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
6
2
|
|
|
7
3
|
const plugin = {
|
|
8
4
|
rules: {
|
|
@@ -11,7 +7,30 @@ const plugin = {
|
|
|
11
7
|
return Object.assign(Object.assign({}, originalRule), { CallExpression(node) {
|
|
12
8
|
const callbackName = node.callee.name;
|
|
13
9
|
if (callbackName === 'useChanged') {
|
|
14
|
-
const
|
|
10
|
+
const depsNode = node.arguments[0];
|
|
11
|
+
if (!depsNode || depsNode.type !== 'ArrayExpression') {
|
|
12
|
+
context.report({
|
|
13
|
+
node: node.callee, // useChanged 함수 이름 위치에 표시
|
|
14
|
+
message: 'useChanged 훅의 첫 번째 인자는 반드시 배열 리터럴(예: [a, b]) 형태여야 합니다.',
|
|
15
|
+
});
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const elements = depsNode.elements.filter((e) => e && e.type === 'Identifier');
|
|
19
|
+
const fakeCallback = {
|
|
20
|
+
type: 'ArrowFunctionExpression',
|
|
21
|
+
expression: false,
|
|
22
|
+
generator: false,
|
|
23
|
+
async: false,
|
|
24
|
+
params: [],
|
|
25
|
+
body: {
|
|
26
|
+
type: 'BlockStatement',
|
|
27
|
+
body: elements.map((el) => ({
|
|
28
|
+
type: 'ExpressionStatement',
|
|
29
|
+
expression: el,
|
|
30
|
+
})),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const fakeNode = Object.assign(Object.assign({}, node), { arguments: [fakeCallback, depsNode] });
|
|
15
34
|
return originalRule.CallExpression(fakeNode);
|
|
16
35
|
}
|
|
17
36
|
return originalRule.CallExpression(node);
|
|
@@ -30,4 +49,4 @@ const plugin = {
|
|
|
30
49
|
},
|
|
31
50
|
};
|
|
32
51
|
|
|
33
|
-
|
|
52
|
+
export { plugin as default };
|
package/package.json
CHANGED