eslint-plugin-big-react-app-plugin 0.0.2 → 0.0.4
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/lib/rules/path-checker.js +33 -23
- package/package.json +1 -1
|
@@ -1,27 +1,37 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
1
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
meta: {
|
|
7
|
+
type: null, // `problem`, `suggestion`, or `layout`
|
|
8
|
+
docs: {
|
|
9
|
+
description: "feature sliced relative path checker",
|
|
10
|
+
category: "Fill me in",
|
|
11
|
+
recommended: false,
|
|
12
|
+
url: null, // URL to the documentation page for this rule
|
|
13
|
+
},
|
|
14
|
+
fixable: null, // Or `code` or `whitespace`
|
|
15
|
+
schema: [], // Add a schema if the rule has options
|
|
10
16
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
|
|
18
|
+
create(context) {
|
|
19
|
+
return {
|
|
20
|
+
ImportDeclaration(node) {
|
|
21
|
+
// example app/entities/Article
|
|
22
|
+
const importTo = node.source.value;
|
|
23
|
+
|
|
24
|
+
// example C:\Users\tim\Desktop\javascript\production_project\src\entities\Article
|
|
25
|
+
const fromFilename = context.getFilename();
|
|
26
|
+
|
|
27
|
+
if(shouldBeRelative(fromFilename, importTo)) {
|
|
28
|
+
context.report(node, 'В рамках одного слайса все пути должны быть относительными');
|
|
29
|
+
}
|
|
21
30
|
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
25
35
|
const layers = {
|
|
26
36
|
"entities":"entities",
|
|
27
37
|
"features":"features",
|
|
@@ -38,7 +48,7 @@ const shouldBeRelative = (from, to)=>{
|
|
|
38
48
|
const toLayer = toArray[0];
|
|
39
49
|
//"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
|
|
40
50
|
const toSlice = toArray[1];
|
|
41
|
-
if(!toLayer || !toSlice || layers[toArray]){
|
|
51
|
+
if(!toLayer || !toSlice || !layers[toArray]){
|
|
42
52
|
return false
|
|
43
53
|
}
|
|
44
54
|
//нормализуем путь
|
|
@@ -47,7 +57,7 @@ const shouldBeRelative = (from, to)=>{
|
|
|
47
57
|
|
|
48
58
|
const fromLayer = fromArray[1];
|
|
49
59
|
const fromSlice = fromArray[2];
|
|
50
|
-
if(!fromLayer || !fromSlice || layers[fromArray]){
|
|
60
|
+
if(!fromLayer || !fromSlice || !layers[fromArray]){
|
|
51
61
|
return false
|
|
52
62
|
}
|
|
53
63
|
return toSlice === fromSlice && toLayer === fromLayer
|