eslint-plugin-zozu-plugin 0.0.7 → 0.0.9
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.
|
@@ -10,7 +10,7 @@ module.exports = {
|
|
|
10
10
|
recommended: false,
|
|
11
11
|
url: null,
|
|
12
12
|
},
|
|
13
|
-
fixable:
|
|
13
|
+
fixable: 'code',
|
|
14
14
|
schema: [
|
|
15
15
|
{
|
|
16
16
|
type: 'object',
|
|
@@ -36,7 +36,24 @@ module.exports = {
|
|
|
36
36
|
const fromFilename = context.getFilename();
|
|
37
37
|
|
|
38
38
|
if (shouldBeRelative(fromFilename, importTo)) {
|
|
39
|
-
context.report({
|
|
39
|
+
context.report({
|
|
40
|
+
node: node,
|
|
41
|
+
message: 'В рамках одного слайса пути должны быть относительные',
|
|
42
|
+
fix: (fixer) => {
|
|
43
|
+
const normalizedPath = getNormalizedCurrentFilePath(fromFilename)
|
|
44
|
+
.split('/')
|
|
45
|
+
.slice(0, -1)
|
|
46
|
+
.join('/');
|
|
47
|
+
let relativePath = path.relative(normalizedPath, `/${importTo}`)
|
|
48
|
+
.split('\\')
|
|
49
|
+
.join('/');
|
|
50
|
+
|
|
51
|
+
if(!relativePath.startsWith('.')) {
|
|
52
|
+
relativePath = './' + relativePath;
|
|
53
|
+
}
|
|
54
|
+
return fixer.replaceText(node.source, `'${relativePath}'`)
|
|
55
|
+
}
|
|
56
|
+
});
|
|
40
57
|
}
|
|
41
58
|
}
|
|
42
59
|
};
|
|
@@ -51,6 +68,12 @@ const layers = {
|
|
|
51
68
|
'widgets': 'widgets',
|
|
52
69
|
}
|
|
53
70
|
|
|
71
|
+
function getNormalizedCurrentFilePath(currentFilePath) {
|
|
72
|
+
const normalizedPath = path.toNamespacedPath(currentFilePath);
|
|
73
|
+
const projectFrom = normalizedPath.split('src')[1];
|
|
74
|
+
return projectFrom.split('\\').join('/');
|
|
75
|
+
}
|
|
76
|
+
|
|
54
77
|
function shouldBeRelative(from, to) {
|
|
55
78
|
if (isPathRelative(to)) {
|
|
56
79
|
return false;
|
|
@@ -64,9 +87,8 @@ function shouldBeRelative(from, to) {
|
|
|
64
87
|
return false;
|
|
65
88
|
}
|
|
66
89
|
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const fromArray = projectFrom.split('\\');
|
|
90
|
+
const projectFrom = getNormalizedCurrentFilePath(from);
|
|
91
|
+
const fromArray = projectFrom.split('/');
|
|
70
92
|
|
|
71
93
|
const fromLayer = fromArray[1];
|
|
72
94
|
const fromSlice = fromArray[2];
|
|
@@ -17,8 +17,8 @@ module.exports = {
|
|
|
17
17
|
},
|
|
18
18
|
fixable: 'code', // Or `code` or `whitespace`
|
|
19
19
|
messages: {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
PUBLIC_ERROR: 'Абсолютный импорт разрешен только из Public API (index.ts)',
|
|
21
|
+
TESTING_PUBLIC_ERROR: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'
|
|
22
22
|
},
|
|
23
23
|
schema: [
|
|
24
24
|
{
|
|
@@ -33,7 +33,6 @@ module.exports = {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
|
-
messages: {}, // Add messageId and message
|
|
37
36
|
},
|
|
38
37
|
|
|
39
38
|
create(context) {
|