eslint-plugin-path-checker-relative 0.0.8 → 0.0.10
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.
|
@@ -32,11 +32,8 @@ module.exports = {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
-
],
|
|
36
|
-
messages:
|
|
37
|
-
"Слой может импортировать в себя только нижележащие слои (shared, entities, features, widgets, pages, app)":
|
|
38
|
-
"Слой может импортировать в себя только нижележащие слои (shared, entities, features, widgets, pages, app)",
|
|
39
|
-
}, // Add messageId and message
|
|
35
|
+
],
|
|
36
|
+
messages: [],
|
|
40
37
|
},
|
|
41
38
|
|
|
42
39
|
create(context) {
|
|
@@ -103,10 +100,14 @@ module.exports = {
|
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
if (!layers[currentFileLayer]?.includes(importLayer)) {
|
|
103
|
+
const allowedLayersMessage = `Слой "${currentFileLayer}" может импортировать в себя только нижележащие слои (${layers[
|
|
104
|
+
currentFileLayer
|
|
105
|
+
].join(", ")})`;
|
|
106
|
+
|
|
106
107
|
context.report({
|
|
107
108
|
node: node,
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
// eslint-disable-next-line eslint-plugin/prefer-message-ids
|
|
110
|
+
message: allowedLayersMessage,
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
},
|
|
@@ -9,6 +9,9 @@ const path = require("path");
|
|
|
9
9
|
const isPathRelative = require("../helpers");
|
|
10
10
|
const micromatch = require("micromatch");
|
|
11
11
|
|
|
12
|
+
const PUBLIC_ERROR = "PUBLIC_ERROR";
|
|
13
|
+
const TESTING_PUBLIC_ERROR = "TESTING_PUBLIC_ERROR";
|
|
14
|
+
|
|
12
15
|
/** @type {import('eslint').Rule.RuleModule} */
|
|
13
16
|
module.exports = {
|
|
14
17
|
meta: {
|
|
@@ -18,7 +21,7 @@ module.exports = {
|
|
|
18
21
|
recommended: false,
|
|
19
22
|
url: null, // URL to the documentation page for this rule
|
|
20
23
|
},
|
|
21
|
-
fixable:
|
|
24
|
+
fixable: "code", // Or `code` or `whitespace`
|
|
22
25
|
schema: [
|
|
23
26
|
{
|
|
24
27
|
type: "object",
|
|
@@ -33,9 +36,9 @@ module.exports = {
|
|
|
33
36
|
},
|
|
34
37
|
],
|
|
35
38
|
messages: {
|
|
36
|
-
|
|
39
|
+
PUBLIC_ERROR:
|
|
37
40
|
"Абсолютный импорт разрешен только из Public API (index.ts)",
|
|
38
|
-
|
|
41
|
+
TESTING_PUBLIC_ERROR:
|
|
39
42
|
"Тестовые данные необходимо импортировать из publicApi/testing.ts",
|
|
40
43
|
},
|
|
41
44
|
},
|
|
@@ -62,6 +65,7 @@ module.exports = {
|
|
|
62
65
|
const segment = importTo.split("/");
|
|
63
66
|
|
|
64
67
|
const layer = segment[0];
|
|
68
|
+
const slice = segment[1];
|
|
65
69
|
|
|
66
70
|
if (!checkingLayers[layer]) {
|
|
67
71
|
return;
|
|
@@ -75,8 +79,10 @@ module.exports = {
|
|
|
75
79
|
if (isImportNotFromPublicApi && !isTestingPublicApi) {
|
|
76
80
|
context.report({
|
|
77
81
|
node,
|
|
78
|
-
messageId:
|
|
79
|
-
|
|
82
|
+
messageId: PUBLIC_ERROR,
|
|
83
|
+
fix: (fixer) => {
|
|
84
|
+
return fixer.replaceText(node.source, `'${alias}/${layer}/${slice}'`)
|
|
85
|
+
}
|
|
80
86
|
});
|
|
81
87
|
}
|
|
82
88
|
|
|
@@ -90,8 +96,7 @@ module.exports = {
|
|
|
90
96
|
if (!isCurrentFileTesting) {
|
|
91
97
|
context.report({
|
|
92
98
|
node,
|
|
93
|
-
messageId:
|
|
94
|
-
"Тестовые данные необходимо импортировать из publicApi/testing.ts",
|
|
99
|
+
messageId: TESTING_PUBLIC_ERROR,
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
}
|