eslint-plugin-big-react-app-plugin 0.0.7 → 0.0.8

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.
Files changed (46) hide show
  1. package/.history/lib/rules/path-checker_20250906110609.js +76 -0
  2. package/.history/lib/rules/path-checker_20251016170231.js +76 -0
  3. package/.history/lib/rules/path-checker_20251016170238.js +76 -0
  4. package/.history/lib/rules/path-checker_20251016170240.js +76 -0
  5. package/.history/lib/rules/path-checker_20251016170512.js +76 -0
  6. package/.history/lib/rules/path-checker_20251016170543.js +78 -0
  7. package/.history/lib/rules/path-checker_20251016170608.js +81 -0
  8. package/.history/lib/rules/path-checker_20251016170627.js +81 -0
  9. package/.history/lib/rules/path-checker_20251016170714.js +81 -0
  10. package/.history/lib/rules/path-checker_20251016170716.js +83 -0
  11. package/.history/lib/rules/path-checker_20251016170723.js +84 -0
  12. package/.history/lib/rules/path-checker_20251016170726.js +84 -0
  13. package/.history/lib/rules/path-checker_20251016170750.js +85 -0
  14. package/.history/lib/rules/path-checker_20251016170808.js +85 -0
  15. package/.history/lib/rules/path-checker_20251016170811.js +85 -0
  16. package/.history/lib/rules/path-checker_20251016170821.js +85 -0
  17. package/.history/lib/rules/path-checker_20251016170941.js +86 -0
  18. package/.history/lib/rules/path-checker_20251016170953.js +86 -0
  19. package/.history/lib/rules/path-checker_20251016171234.js +87 -0
  20. package/.history/lib/rules/path-checker_20251016171235.js +87 -0
  21. package/.history/lib/rules/path-checker_20251016171244.js +87 -0
  22. package/.history/lib/rules/path-checker_20251016192227.js +89 -0
  23. package/.history/lib/rules/path-checker_20251016192245.js +89 -0
  24. package/.history/package_20250906110616.json +32 -0
  25. package/.history/package_20251016192249.json +32 -0
  26. package/.history/tests/lib/rules/path-checker_20250906083402.js +31 -0
  27. package/.history/tests/lib/rules/path-checker_20251016165925.js +33 -0
  28. package/.history/tests/lib/rules/path-checker_20251016170059.js +34 -0
  29. package/.history/tests/lib/rules/path-checker_20251016170109.js +34 -0
  30. package/.history/tests/lib/rules/path-checker_20251016170128.js +34 -0
  31. package/.history/tests/lib/rules/path-checker_20251016170147.js +34 -0
  32. package/.history/tests/lib/rules/path-checker_20251016170208.js +34 -0
  33. package/.history/tests/lib/rules/path-checker_20251016170246.js +34 -0
  34. package/.history/tests/lib/rules/path-checker_20251016170253.js +34 -0
  35. package/.history/tests/lib/rules/path-checker_20251016170255.js +34 -0
  36. package/.history/tests/lib/rules/path-checker_20251016170323.js +34 -0
  37. package/.history/tests/lib/rules/path-checker_20251016170411.js +38 -0
  38. package/.history/tests/lib/rules/path-checker_20251016170459.js +38 -0
  39. package/.history/tests/lib/rules/path-checker_20251016171025.js +43 -0
  40. package/.history/tests/lib/rules/path-checker_20251016171041.js +43 -0
  41. package/.history/tests/lib/rules/path-checker_20251016171053.js +43 -0
  42. package/.history/tests/lib/rules/path-checker_20251016171136.js +42 -0
  43. package/.history/tests/lib/rules/path-checker_20251016171410.js +44 -0
  44. package/lib/rules/path-checker.js +19 -6
  45. package/package.json +1 -1
  46. package/tests/lib/rules/path-checker.js +17 -4
@@ -0,0 +1,76 @@
1
+ "use strict";
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
16
+ },
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
+ if(shouldBeRelative(fromFilename, importTo)) {
27
+ context.report(node, 'В рамках одного слайса все пути должны быть относительными');
28
+ }
29
+ }
30
+ };
31
+ },
32
+ };
33
+
34
+ const layers = {
35
+ "entities":"entities",
36
+ "features":"features",
37
+ "pages":"pages",
38
+ "shared":"shared",
39
+ "widgets":"widgets",
40
+ }
41
+ const shouldBeRelative = (from, to)=>{
42
+ if(pathRelative(to)){
43
+ return false
44
+ }
45
+ const toArray = to.split('/')
46
+ //app/entities/Article
47
+ const toLayer = toArray[0];
48
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
49
+ const toSlice = toArray[1];
50
+ if(!toLayer || !toSlice || !layers[toLayer]){
51
+ return false
52
+ }
53
+ //нормализуем путь
54
+ const normalizationPath = path.toNamespacedPath(from);
55
+ const projFrom = normalizationPath.split('src')[1]
56
+ const fromArray = projFrom.split('\\')
57
+
58
+ const fromLayer = fromArray[1];
59
+ const fromSlice = fromArray[2];
60
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
61
+ return false
62
+ }
63
+
64
+ return toSlice === fromSlice && toLayer === fromLayer
65
+ }
66
+ const pathRelative = (path)=>{
67
+ return path = path.startsWith('.' || './' || './/')
68
+ }
69
+
70
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
71
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
72
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
73
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
74
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
75
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))
@@ -0,0 +1,76 @@
1
+ "use strict";
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
16
+ },
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
+ if(shouldBeRelative(fromFilename, importTo)) {
27
+ context.report({node: node, message: 'В рамках одного слайса все пути должны быть относительными'});
28
+ }
29
+ }
30
+ };
31
+ },
32
+ };
33
+
34
+ const layers = {
35
+ "entities":"entities",
36
+ "features":"features",
37
+ "pages":"pages",
38
+ "shared":"shared",
39
+ "widgets":"widgets",
40
+ }
41
+ const shouldBeRelative = (from, to)=>{
42
+ if(pathRelative(to)){
43
+ return false
44
+ }
45
+ const toArray = to.split('/')
46
+ //app/entities/Article
47
+ const toLayer = toArray[0];
48
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
49
+ const toSlice = toArray[1];
50
+ if(!toLayer || !toSlice || !layers[toLayer]){
51
+ return false
52
+ }
53
+ //нормализуем путь
54
+ const normalizationPath = path.toNamespacedPath(from);
55
+ const projFrom = normalizationPath.split('src')[1]
56
+ const fromArray = projFrom.split('\\')
57
+
58
+ const fromLayer = fromArray[1];
59
+ const fromSlice = fromArray[2];
60
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
61
+ return false
62
+ }
63
+
64
+ return toSlice === fromSlice && toLayer === fromLayer
65
+ }
66
+ const pathRelative = (path)=>{
67
+ return path = path.startsWith('.' || './' || './/')
68
+ }
69
+
70
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
71
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
72
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
73
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
74
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
75
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))
@@ -0,0 +1,76 @@
1
+ "use strict";
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
16
+ },
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
+ if(shouldBeRelative(fromFilename, importTo)) {
27
+ context.report({node: node, message: 'В рамках одного слайса все пути должны быть относительными'});
28
+ }
29
+ }
30
+ };
31
+ },
32
+ };
33
+
34
+ const layers = {
35
+ "entities":"entities",
36
+ "features":"features",
37
+ "pages":"pages",
38
+ "shared":"shared",
39
+ "widgets":"widgets",
40
+ }
41
+ const shouldBeRelative = (from, to)=>{
42
+ if(pathRelative(to)){
43
+ return false
44
+ }
45
+ const toArray = to.split('/')
46
+ //app/entities/Article
47
+ const toLayer = toArray[0];
48
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
49
+ const toSlice = toArray[1];
50
+ if(!toLayer || !toSlice || !layers[toLayer]){
51
+ return false
52
+ }
53
+ //нормализуем путь
54
+ const normalizationPath = path.toNamespacedPath(from);
55
+ const projFrom = normalizationPath.split('src')[1]
56
+ const fromArray = projFrom.split('\\')
57
+
58
+ const fromLayer = fromArray[1];
59
+ const fromSlice = fromArray[2];
60
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
61
+ return false
62
+ }
63
+
64
+ return toSlice === fromSlice && toLayer === fromLayer
65
+ }
66
+ const pathRelative = (path)=>{
67
+ return path = path.startsWith('.' || './' || './/')
68
+ }
69
+
70
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
71
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
72
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
73
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
74
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
75
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))
@@ -0,0 +1,76 @@
1
+ "use strict";
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
16
+ },
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
+ if(shouldBeRelative(fromFilename, importTo)) {
27
+ context.report({node: node, message: 'В рамках одного слайса все пути должны быть относительными'});
28
+ }
29
+ }
30
+ };
31
+ },
32
+ };
33
+
34
+ const layers = {
35
+ "entities":"entities",
36
+ "features":"features",
37
+ "pages":"pages",
38
+ "shared":"shared",
39
+ "widgets":"widgets",
40
+ }
41
+ const shouldBeRelative = (from, to)=>{
42
+ if(pathRelative(to)){
43
+ return false
44
+ }
45
+ const toArray = to.split('/')
46
+ //app/entities/Article
47
+ const toLayer = toArray[0];
48
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
49
+ const toSlice = toArray[1];
50
+ if(!toLayer || !toSlice || !layers[toLayer]){
51
+ return false
52
+ }
53
+ //нормализуем путь
54
+ const normalizationPath = path.toNamespacedPath(from);
55
+ const projFrom = normalizationPath.split('src')[1]
56
+ const fromArray = projFrom.split('\\')
57
+
58
+ const fromLayer = fromArray[1];
59
+ const fromSlice = fromArray[2];
60
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
61
+ return false
62
+ }
63
+
64
+ return toSlice === fromSlice && toLayer === fromLayer
65
+ }
66
+ const pathRelative = (path)=>{
67
+ return path = path.startsWith('.' || './' || './/')
68
+ }
69
+
70
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
71
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
72
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
73
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
74
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
75
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))
@@ -0,0 +1,76 @@
1
+ "use strict";
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
16
+ },
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
+ if(shouldBeRelative(fromFilename, importTo)) {
27
+ context.report({node: node, message: 'В рамках одного слайса все пути должны быть относительными'});
28
+ }
29
+ }
30
+ };
31
+ },
32
+ };
33
+
34
+ const layers = {
35
+ "entities":"entities",
36
+ "features":"features",
37
+ "pages":"pages",
38
+ "shared":"shared",
39
+ "widgets":"widgets",
40
+ }
41
+ const shouldBeRelative = (from, to)=>{
42
+ if(pathRelative(to)){
43
+ return false
44
+ }
45
+ const toArray = to.split('/')
46
+ //app/entities/Article
47
+ const toLayer = toArray[0];
48
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
49
+ const toSlice = toArray[1];
50
+ if(!toLayer || !toSlice || !layers[toLayer]){
51
+ return false
52
+ }
53
+ //нормализуем путь
54
+ const normalizationPath = path.toNamespacedPath(from);
55
+ const projFrom = normalizationPath.split('src')[1]
56
+ const fromArray = projFrom.split('\\')
57
+
58
+ const fromLayer = fromArray[1];
59
+ const fromSlice = fromArray[2];
60
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
61
+ return false
62
+ }
63
+
64
+ return toSlice === fromSlice && toLayer === fromLayer
65
+ }
66
+ const pathRelative = (path)=>{
67
+ return path = path.startsWith('.' || './' || './/')
68
+ }
69
+
70
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
71
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
72
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
73
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
74
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
75
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))
@@ -0,0 +1,78 @@
1
+ "use strict";
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: [
16
+ type:"object"
17
+ ], // Add a schema if the rule has options
18
+ },
19
+
20
+ create(context) {
21
+ return {
22
+ ImportDeclaration(node) {
23
+ // example app/entities/Article
24
+ const importTo = node.source.value;
25
+
26
+ // example C:\Users\tim\Desktop\javascript\production_project\src\entities\Article
27
+ const fromFilename = context.getFilename();
28
+ if(shouldBeRelative(fromFilename, importTo)) {
29
+ context.report({node: node, message: 'В рамках одного слайса все пути должны быть относительными'});
30
+ }
31
+ }
32
+ };
33
+ },
34
+ };
35
+
36
+ const layers = {
37
+ "entities":"entities",
38
+ "features":"features",
39
+ "pages":"pages",
40
+ "shared":"shared",
41
+ "widgets":"widgets",
42
+ }
43
+ const shouldBeRelative = (from, to)=>{
44
+ if(pathRelative(to)){
45
+ return false
46
+ }
47
+ const toArray = to.split('/')
48
+ //app/entities/Article
49
+ const toLayer = toArray[0];
50
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
51
+ const toSlice = toArray[1];
52
+ if(!toLayer || !toSlice || !layers[toLayer]){
53
+ return false
54
+ }
55
+ //нормализуем путь
56
+ const normalizationPath = path.toNamespacedPath(from);
57
+ const projFrom = normalizationPath.split('src')[1]
58
+ const fromArray = projFrom.split('\\')
59
+
60
+ const fromLayer = fromArray[1];
61
+ const fromSlice = fromArray[2];
62
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
63
+ return false
64
+ }
65
+
66
+ return toSlice === fromSlice && toLayer === fromLayer
67
+ }
68
+ const pathRelative = (path)=>{
69
+ return path = path.startsWith('.' || './' || './/')
70
+ }
71
+
72
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
73
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
74
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
75
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
77
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
78
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ const path = require('path');
4
+
5
+ module.exports = {
6
+ meta: {
7
+ type: null,
8
+ docs: {
9
+ description: "feature sliced relative path checker",
10
+ category: "Fill me in",
11
+ recommended: false,
12
+ url: null,
13
+ },
14
+ fixable: null,
15
+ schema: [
16
+ type:"object",
17
+ properties:{
18
+
19
+ }
20
+ ],
21
+ },
22
+
23
+ create(context) {
24
+ return {
25
+ ImportDeclaration(node) {
26
+ // example app/entities/Article
27
+ const importTo = node.source.value;
28
+
29
+ // example C:\Users\tim\Desktop\javascript\production_project\src\entities\Article
30
+ const fromFilename = context.getFilename();
31
+ if(shouldBeRelative(fromFilename, importTo)) {
32
+ context.report({node: node, message: 'В рамках одного слайса все пути должны быть относительными'});
33
+ }
34
+ }
35
+ };
36
+ },
37
+ };
38
+
39
+ const layers = {
40
+ "entities":"entities",
41
+ "features":"features",
42
+ "pages":"pages",
43
+ "shared":"shared",
44
+ "widgets":"widgets",
45
+ }
46
+ const shouldBeRelative = (from, to)=>{
47
+ if(pathRelative(to)){
48
+ return false
49
+ }
50
+ const toArray = to.split('/')
51
+ //app/entities/Article
52
+ const toLayer = toArray[0];
53
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
54
+ const toSlice = toArray[1];
55
+ if(!toLayer || !toSlice || !layers[toLayer]){
56
+ return false
57
+ }
58
+ //нормализуем путь
59
+ const normalizationPath = path.toNamespacedPath(from);
60
+ const projFrom = normalizationPath.split('src')[1]
61
+ const fromArray = projFrom.split('\\')
62
+
63
+ const fromLayer = fromArray[1];
64
+ const fromSlice = fromArray[2];
65
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
66
+ return false
67
+ }
68
+
69
+ return toSlice === fromSlice && toLayer === fromLayer
70
+ }
71
+ const pathRelative = (path)=>{
72
+ return path = path.startsWith('.' || './' || './/')
73
+ }
74
+
75
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
77
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
78
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
79
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
80
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
81
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ const path = require('path');
4
+
5
+ module.exports = {
6
+ meta: {
7
+ type: null,
8
+ docs: {
9
+ description: "feature sliced relative path checker",
10
+ category: "Fill me in",
11
+ recommended: false,
12
+ url: null,
13
+ },
14
+ fixable: null,
15
+ schema: [
16
+ type:"object",
17
+ properties:{
18
+ alias:'string'
19
+ }
20
+ ],
21
+ },
22
+
23
+ create(context) {
24
+ return {
25
+ ImportDeclaration(node) {
26
+ // example app/entities/Article
27
+ const importTo = node.source.value;
28
+
29
+ // example C:\Users\tim\Desktop\javascript\production_project\src\entities\Article
30
+ const fromFilename = context.getFilename();
31
+ if(shouldBeRelative(fromFilename, importTo)) {
32
+ context.report({node: node, message: 'В рамках одного слайса все пути должны быть относительными'});
33
+ }
34
+ }
35
+ };
36
+ },
37
+ };
38
+
39
+ const layers = {
40
+ "entities":"entities",
41
+ "features":"features",
42
+ "pages":"pages",
43
+ "shared":"shared",
44
+ "widgets":"widgets",
45
+ }
46
+ const shouldBeRelative = (from, to)=>{
47
+ if(pathRelative(to)){
48
+ return false
49
+ }
50
+ const toArray = to.split('/')
51
+ //app/entities/Article
52
+ const toLayer = toArray[0];
53
+ //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
54
+ const toSlice = toArray[1];
55
+ if(!toLayer || !toSlice || !layers[toLayer]){
56
+ return false
57
+ }
58
+ //нормализуем путь
59
+ const normalizationPath = path.toNamespacedPath(from);
60
+ const projFrom = normalizationPath.split('src')[1]
61
+ const fromArray = projFrom.split('\\')
62
+
63
+ const fromLayer = fromArray[1];
64
+ const fromSlice = fromArray[2];
65
+ if(!fromLayer || !fromSlice || !layers[fromLayer]){
66
+ return false
67
+ }
68
+
69
+ return toSlice === fromSlice && toLayer === fromLayer
70
+ }
71
+ const pathRelative = (path)=>{
72
+ return path = path.startsWith('.' || './' || './/')
73
+ }
74
+
75
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/Article/fasfasfas'))
76
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'entities/ASdasd/fasfasfas'))
77
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'features/Article/fasfasfas'))
78
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\features\\Article', 'features/Article/fasfasfas'))
79
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', 'app/index.tsx'))
80
+ // console.log(shouldBeRelative('C:/Users/tim/Desktop/javascript/GOOD_COURSE_test/src/entities/Article', 'entities/Article/asfasf/asfasf'))
81
+ // console.log(shouldBeRelative('C:\\Users\\tim\\Desktop\\javascript\\GOOD_COURSE_test\\src\\entities\\Article', '../../model/selectors/getSidebarItems'))