eslint-plugin-effector 0.14.0 → 0.16.0
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/config/scope.js
CHANGED
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ module.exports = {
|
|
|
18
18
|
"no-guard": require("./rules/no-guard/no-guard"),
|
|
19
19
|
"mandatory-scope-binding": require("./rules/mandatory-scope-binding/mandatory-scope-binding"),
|
|
20
20
|
"prefer-useUnit": require("./rules/prefer-useUnit/prefer-useUnit"),
|
|
21
|
+
"require-pickup-in-persist": require("./rules/require-pickup-in-persist/require-pickup-in-persist"),
|
|
21
22
|
"no-patronum-debug": require("./rules/no-patronum-debug/no-patronum-debug"),
|
|
22
23
|
},
|
|
23
24
|
configs: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-effector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Enforcing best practices for Effector",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": "^16 || ^17 || ^18 || ^19 || ^20 || ^21"
|
|
20
|
+
"node": "^16 || ^17 || ^18 || ^19 || ^20 || ^21 || ^22"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"effector": "^23",
|
|
24
|
-
"eslint": "
|
|
24
|
+
"eslint": "^8.57.0 || ^9.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"prettier": "^2.3.2"
|
package/rules/no-duplicate-clock-or-source-array-values/no-duplicate-clock-or-source-array-values.js
CHANGED
|
@@ -86,6 +86,10 @@ module.exports = {
|
|
|
86
86
|
function createMemberExpressionPath(node, chain = "") {
|
|
87
87
|
const compactStrings = (...args) => args.filter(Boolean).join(".");
|
|
88
88
|
|
|
89
|
+
if (!node) {
|
|
90
|
+
return chain;
|
|
91
|
+
}
|
|
92
|
+
|
|
89
93
|
if (node.type === "MemberExpression") {
|
|
90
94
|
const propertyName = node.property.name;
|
|
91
95
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const { createLinkToRule } = require("../../utils/create-link-to-rule");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
meta: {
|
|
5
|
+
type: "problem",
|
|
6
|
+
docs: {
|
|
7
|
+
category: "Quality",
|
|
8
|
+
url: createLinkToRule("require-pickup-in-persist"),
|
|
9
|
+
},
|
|
10
|
+
messages: {
|
|
11
|
+
pickupMissing:
|
|
12
|
+
"This `persist` call does not specify a `pickup` event that is required for scoped usage of `effector-storage`.",
|
|
13
|
+
},
|
|
14
|
+
schema: [],
|
|
15
|
+
},
|
|
16
|
+
create(context) {
|
|
17
|
+
const pickupImports = new Set();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Finds `effector-storage` packages, scoped and unscoped, including
|
|
21
|
+
* contents of these packages. See examples for a full list.
|
|
22
|
+
*/
|
|
23
|
+
const PACKAGE_NAME = /^@?effector-storage(\u002F[\w-]+)*$/;
|
|
24
|
+
|
|
25
|
+
const declarationSelector = `ImportDeclaration[source.value=${PACKAGE_NAME}]`;
|
|
26
|
+
const persistImportSelector = `ImportSpecifier[imported.name="persist"]`;
|
|
27
|
+
|
|
28
|
+
const configSelector = `[arguments.length=1][arguments.0.type="ObjectExpression"]`;
|
|
29
|
+
const callSelector = `[callee.type="Identifier"]`;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
[`${declarationSelector} > ${persistImportSelector}`](node) {
|
|
33
|
+
pickupImports.add(node.local.name);
|
|
34
|
+
},
|
|
35
|
+
[`CallExpression${configSelector}${callSelector}`](node) {
|
|
36
|
+
if (!pickupImports.has(node.callee.name)) return;
|
|
37
|
+
|
|
38
|
+
const config = node.arguments[0];
|
|
39
|
+
|
|
40
|
+
if (config.properties.some((prop) => prop.key?.name === "pickup"))
|
|
41
|
+
return;
|
|
42
|
+
|
|
43
|
+
context.report({ node, messageId: "pickupMissing" });
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|