eslint-plugin-big-react-app-plugin 0.1.4 → 0.1.6

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 (103) hide show
  1. package/.history/lib/rules/{public-api-imports_20251018094512.js → public-api-imports_20251028164625.js} +19 -5
  2. package/.history/lib/rules/{public-api-imports_20251018094801.js → public-api-imports_20251028165757.js} +17 -4
  3. package/.history/lib/rules/{public-api-imports_20251018095046.js → public-api-imports_20251028165803.js} +17 -3
  4. package/.history/{package_20250906110616.json → package_20251028164641.json} +2 -1
  5. package/.history/{package_20251016192249.json → package_20251028165941.json} +2 -1
  6. package/lib/rules/public-api-imports.js +17 -3
  7. package/package.json +2 -1
  8. package/tests/lib/rules/public-api-imports.js +13 -4
  9. package/.history/.gitignore_20251018083109 +0 -0
  10. package/.history/.gitignore_20251018083124 +0 -1
  11. package/.history/lib/helpers/index_20251018083334.js +0 -0
  12. package/.history/lib/helpers/index_20251018083357.js +0 -6
  13. package/.history/lib/helpers/index_20251018083414.js +0 -6
  14. package/.history/lib/helpers/index_20251018083417.js +0 -6
  15. package/.history/lib/helpers/index_20251018083618.js +0 -6
  16. package/.history/lib/helpers/index_20251018092620.js +0 -6
  17. package/.history/lib/helpers/index_20251018092627.js +0 -6
  18. package/.history/lib/rules/path-checker_20250906110609.js +0 -76
  19. package/.history/lib/rules/path-checker_20251016170231.js +0 -76
  20. package/.history/lib/rules/path-checker_20251016170238.js +0 -76
  21. package/.history/lib/rules/path-checker_20251016170240.js +0 -76
  22. package/.history/lib/rules/path-checker_20251016170512.js +0 -76
  23. package/.history/lib/rules/path-checker_20251016170543.js +0 -78
  24. package/.history/lib/rules/path-checker_20251016170608.js +0 -81
  25. package/.history/lib/rules/path-checker_20251016170627.js +0 -81
  26. package/.history/lib/rules/path-checker_20251016170714.js +0 -81
  27. package/.history/lib/rules/path-checker_20251016170716.js +0 -83
  28. package/.history/lib/rules/path-checker_20251016170723.js +0 -84
  29. package/.history/lib/rules/path-checker_20251016170726.js +0 -84
  30. package/.history/lib/rules/path-checker_20251016170750.js +0 -85
  31. package/.history/lib/rules/path-checker_20251016170808.js +0 -85
  32. package/.history/lib/rules/path-checker_20251016170811.js +0 -85
  33. package/.history/lib/rules/path-checker_20251016170821.js +0 -85
  34. package/.history/lib/rules/path-checker_20251016170941.js +0 -86
  35. package/.history/lib/rules/path-checker_20251016170953.js +0 -86
  36. package/.history/lib/rules/path-checker_20251016171234.js +0 -87
  37. package/.history/lib/rules/path-checker_20251016171235.js +0 -87
  38. package/.history/lib/rules/path-checker_20251016171244.js +0 -87
  39. package/.history/lib/rules/path-checker_20251016192227.js +0 -89
  40. package/.history/lib/rules/path-checker_20251016192245.js +0 -89
  41. package/.history/lib/rules/path-checker_20251018083151.js +0 -89
  42. package/.history/lib/rules/path-checker_20251018083710.js +0 -87
  43. package/.history/lib/rules/public-api-imports_20251018083042.js +0 -44
  44. package/.history/lib/rules/public-api-imports_20251018083211.js +0 -50
  45. package/.history/lib/rules/public-api-imports_20251018083235.js +0 -43
  46. package/.history/lib/rules/public-api-imports_20251018083244.js +0 -51
  47. package/.history/lib/rules/public-api-imports_20251018083454.js +0 -51
  48. package/.history/lib/rules/public-api-imports_20251018083640.js +0 -40
  49. package/.history/lib/rules/public-api-imports_20251018083748.js +0 -42
  50. package/.history/lib/rules/public-api-imports_20251018083818.js +0 -42
  51. package/.history/lib/rules/public-api-imports_20251018084540.js +0 -41
  52. package/.history/lib/rules/public-api-imports_20251018084843.js +0 -44
  53. package/.history/lib/rules/public-api-imports_20251018084847.js +0 -44
  54. package/.history/lib/rules/public-api-imports_20251018084906.js +0 -44
  55. package/.history/lib/rules/public-api-imports_20251018084913.js +0 -43
  56. package/.history/lib/rules/public-api-imports_20251018085014.js +0 -48
  57. package/.history/lib/rules/public-api-imports_20251018085807.js +0 -48
  58. package/.history/lib/rules/public-api-imports_20251018090400.js +0 -58
  59. package/.history/lib/rules/public-api-imports_20251018091033.js +0 -60
  60. package/.history/lib/rules/public-api-imports_20251018092312.js +0 -61
  61. package/.history/lib/rules/public-api-imports_20251018092340.js +0 -62
  62. package/.history/lib/rules/public-api-imports_20251018093209.js +0 -62
  63. package/.history/lib/rules/public-api-imports_20251018093226.js +0 -62
  64. package/.history/lib/rules/public-api-imports_20251018093319.js +0 -63
  65. package/.history/lib/rules/public-api-imports_20251018094349.js +0 -62
  66. package/.history/lib/rules/public-api-imports_20251018094423.js +0 -62
  67. package/.history/lib/rules/public-api-imports_20251018094442.js +0 -62
  68. package/.history/lib/rules/public-api-imports_20251018094549.js +0 -62
  69. package/.history/lib/rules/public-api-imports_20251018094630.js +0 -62
  70. package/.history/lib/rules/public-api-imports_20251018094655.js +0 -62
  71. package/.history/lib/rules/public-api-imports_20251018094728.js +0 -62
  72. package/.history/lib/rules/public-api-imports_20251018094729.js +0 -62
  73. package/.history/package_20251018085916.json +0 -32
  74. package/.history/package_20251018090415.json +0 -32
  75. package/.history/package_20251018091504.json +0 -32
  76. package/.history/package_20251018092723.json +0 -32
  77. package/.history/package_20251018095035.json +0 -32
  78. package/.history/tests/lib/rules/path-checker_20250906083402.js +0 -31
  79. package/.history/tests/lib/rules/path-checker_20251016165925.js +0 -33
  80. package/.history/tests/lib/rules/path-checker_20251016170059.js +0 -34
  81. package/.history/tests/lib/rules/path-checker_20251016170109.js +0 -34
  82. package/.history/tests/lib/rules/path-checker_20251016170128.js +0 -34
  83. package/.history/tests/lib/rules/path-checker_20251016170147.js +0 -34
  84. package/.history/tests/lib/rules/path-checker_20251016170208.js +0 -34
  85. package/.history/tests/lib/rules/path-checker_20251016170246.js +0 -34
  86. package/.history/tests/lib/rules/path-checker_20251016170253.js +0 -34
  87. package/.history/tests/lib/rules/path-checker_20251016170255.js +0 -34
  88. package/.history/tests/lib/rules/path-checker_20251016170323.js +0 -34
  89. package/.history/tests/lib/rules/path-checker_20251016170411.js +0 -38
  90. package/.history/tests/lib/rules/path-checker_20251016170459.js +0 -38
  91. package/.history/tests/lib/rules/path-checker_20251016171025.js +0 -43
  92. package/.history/tests/lib/rules/path-checker_20251016171041.js +0 -43
  93. package/.history/tests/lib/rules/path-checker_20251016171053.js +0 -43
  94. package/.history/tests/lib/rules/path-checker_20251016171136.js +0 -42
  95. package/.history/tests/lib/rules/path-checker_20251016171410.js +0 -44
  96. package/.history/tests/lib/rules/public-api-imports_20251018083042.js +0 -31
  97. package/.history/tests/lib/rules/public-api-imports_20251018085128.js +0 -34
  98. package/.history/tests/lib/rules/public-api-imports_20251018085249.js +0 -34
  99. package/.history/tests/lib/rules/public-api-imports_20251018085350.js +0 -40
  100. package/.history/tests/lib/rules/public-api-imports_20251018085726.js +0 -36
  101. package/.history/tests/lib/rules/public-api-imports_20251018090807.js +0 -86
  102. package/.history/tests/lib/rules/public-api-imports_20251018094915.js +0 -86
  103. package/.history/tests/lib/rules/public-api-imports_20251018094931.js +0 -78
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
+ const micromatch = require("micromatch");
2
3
  const {isPathRelative} = require("../helpers")
4
+ const path = require("path");
3
5
  module.exports = {
4
6
  meta: {
5
7
  type: null,
@@ -33,7 +35,7 @@ module.exports = {
33
35
  "pages":"pages",
34
36
  "widgets":"widgets",
35
37
  }
36
- const alias = context.options[0]?.alias ?? "";
38
+ const {alias='', testFilesPatterns=[]} = context.options[0] ?? {};
37
39
  return {
38
40
  ImportDeclaration(node) {
39
41
  // example app/entities/Article
@@ -47,14 +49,26 @@ module.exports = {
47
49
  const segments = importTo.split('/')
48
50
  const layer = segments[0]//получаем слой
49
51
  // проверяем что есть слой из массива
52
+
53
+ //[enteties, article, testing]
54
+ const isTestingPublicApi = segments[2] === 'testing' && segments.length < 4;
55
+
50
56
  if(!checkingLayers[layer]){
51
57
  return;
52
58
  }
53
- console.log("Работает")
54
- const isImportNotFromPublicApi = segments.lenght > 2;
59
+ const isImportNotFromPublicApi = segments.length > 2;
55
60
 
56
- if(isImportNotFromPublicApi) {
57
- context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
61
+ if(isImportNotFromPublicApi && !isTestingPublicApi ) {
62
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public API (index.ts)'});
63
+ }
64
+
65
+ if(isTestingPublicApi){
66
+ const currentFilePath = context.getFilename();
67
+ const normalizedPath = path.toNamespacedPath(currentFilePath);
68
+ const isCurrentFileTesting = testFilesPatterns.some(pattern=>micromatch.isMatch(normalizedPath, pattern))
69
+ if(!isCurrentFileTesting){
70
+ context.report({node: node, message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'});
71
+ }
58
72
  }
59
73
  }
60
74
  };
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
+ const micromatch = require("micromatch");
2
3
  const {isPathRelative} = require("../helpers")
4
+ const path = require("path");
3
5
  module.exports = {
4
6
  meta: {
5
7
  type: null,
@@ -33,7 +35,7 @@ module.exports = {
33
35
  "pages":"pages",
34
36
  "widgets":"widgets",
35
37
  }
36
- const alias = context.options[0]?.alias ?? "";
38
+ const {alias='', testFilesPatterns=[]} = context.options[0] ?? {};
37
39
  return {
38
40
  ImportDeclaration(node) {
39
41
  // example app/entities/Article
@@ -47,14 +49,25 @@ module.exports = {
47
49
  const segments = importTo.split('/')
48
50
  const layer = segments[0]//получаем слой
49
51
  // проверяем что есть слой из массива
52
+
53
+ //[enteties, article, testing]
54
+ const isTestingPublicApi = segments[2] === 'testing' && segments.length < 4;
55
+
50
56
  if(!checkingLayers[layer]){
51
57
  return;
52
58
  }
53
- console.log("Работает" + segments.length)
54
59
  const isImportNotFromPublicApi = segments.length > 2;
55
60
 
56
- if(isImportNotFromPublicApi) {
57
- context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
61
+ if(isImportNotFromPublicApi && !isTestingPublicApi ) {
62
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public API (index.ts)'});
63
+ }
64
+
65
+ if(isTestingPublicApi){
66
+ const currentFilePath = context.getFilename();
67
+ const isCurrentFileTesting = testFilesPatterns.some(pattern=>micromatch.isMatch(normalizedPath, pattern))
68
+ if(!isCurrentFileTesting){
69
+ context.report({node: node, message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'});
70
+ }
58
71
  }
59
72
  }
60
73
  };
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
+ const micromatch = require("micromatch");
2
3
  const {isPathRelative} = require("../helpers")
4
+ const path = require("path");
3
5
  module.exports = {
4
6
  meta: {
5
7
  type: null,
@@ -33,7 +35,7 @@ module.exports = {
33
35
  "pages":"pages",
34
36
  "widgets":"widgets",
35
37
  }
36
- const alias = context.options[0]?.alias ?? "";
38
+ const {alias='', testFilesPatterns=[]} = context.options[0] ?? {};
37
39
  return {
38
40
  ImportDeclaration(node) {
39
41
  // example app/entities/Article
@@ -47,13 +49,25 @@ module.exports = {
47
49
  const segments = importTo.split('/')
48
50
  const layer = segments[0]//получаем слой
49
51
  // проверяем что есть слой из массива
52
+
53
+ //[enteties, article, testing]
54
+ const isTestingPublicApi = segments[2] === 'testing' && segments.length < 4;
55
+
50
56
  if(!checkingLayers[layer]){
51
57
  return;
52
58
  }
53
59
  const isImportNotFromPublicApi = segments.length > 2;
54
60
 
55
- if(isImportNotFromPublicApi) {
56
- context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
61
+ if(isImportNotFromPublicApi && !isTestingPublicApi ) {
62
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public API (index.ts)'});
63
+ }
64
+
65
+ if(isTestingPublicApi){
66
+ const currentFilePath = context.getFilename();
67
+ const isCurrentFileTesting = testFilesPatterns.some(pattern=>micromatch.isMatch(currentFilePath, pattern))
68
+ if(!isCurrentFileTesting){
69
+ context.report({node: node, message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'});
70
+ }
57
71
  }
58
72
  }
59
73
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-big-react-app-plugin",
3
- "version": "0.0.7",
3
+ "version": "0.1.5",
4
4
  "description": "plugin for prod proj",
5
5
  "keywords": [
6
6
  "eslint",
@@ -14,6 +14,7 @@
14
14
  "test": "mocha tests --recursive"
15
15
  },
16
16
  "dependencies": {
17
+ "micromatch": "^4.0.5",
17
18
  "requireindex": "^1.2.0"
18
19
  },
19
20
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-big-react-app-plugin",
3
- "version": "0.0.8",
3
+ "version": "0.1.6",
4
4
  "description": "plugin for prod proj",
5
5
  "keywords": [
6
6
  "eslint",
@@ -14,6 +14,7 @@
14
14
  "test": "mocha tests --recursive"
15
15
  },
16
16
  "dependencies": {
17
+ "micromatch": "^4.0.5",
17
18
  "requireindex": "^1.2.0"
18
19
  },
19
20
  "devDependencies": {
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
+ const micromatch = require("micromatch");
2
3
  const {isPathRelative} = require("../helpers")
4
+ const path = require("path");
3
5
  module.exports = {
4
6
  meta: {
5
7
  type: null,
@@ -33,7 +35,7 @@ module.exports = {
33
35
  "pages":"pages",
34
36
  "widgets":"widgets",
35
37
  }
36
- const alias = context.options[0]?.alias ?? "";
38
+ const {alias='', testFilesPatterns=[]} = context.options[0] ?? {};
37
39
  return {
38
40
  ImportDeclaration(node) {
39
41
  // example app/entities/Article
@@ -47,13 +49,25 @@ module.exports = {
47
49
  const segments = importTo.split('/')
48
50
  const layer = segments[0]//получаем слой
49
51
  // проверяем что есть слой из массива
52
+
53
+ //[enteties, article, testing]
54
+ const isTestingPublicApi = segments[2] === 'testing' && segments.length < 4;
55
+
50
56
  if(!checkingLayers[layer]){
51
57
  return;
52
58
  }
53
59
  const isImportNotFromPublicApi = segments.length > 2;
54
60
 
55
- if(isImportNotFromPublicApi) {
56
- context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
61
+ if(isImportNotFromPublicApi && !isTestingPublicApi ) {
62
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public API (index.ts)'});
63
+ }
64
+
65
+ if(isTestingPublicApi){
66
+ const currentFilePath = context.getFilename();
67
+ const isCurrentFileTesting = testFilesPatterns.some(pattern=>micromatch.isMatch(currentFilePath, pattern))
68
+ if(!isCurrentFileTesting){
69
+ context.report({node: node, message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'});
70
+ }
57
71
  }
58
72
  }
59
73
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-big-react-app-plugin",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "plugin for prod proj",
5
5
  "keywords": [
6
6
  "eslint",
@@ -14,6 +14,7 @@
14
14
  "test": "mocha tests --recursive"
15
15
  },
16
16
  "dependencies": {
17
+ "micromatch": "^4.0.5",
17
18
  "requireindex": "^1.2.0"
18
19
  },
19
20
  "devDependencies": {
@@ -28,7 +28,7 @@ const aliasOptions = [
28
28
 
29
29
  ruleTester.run("public-api-imports", rule, {
30
30
  valid: [
31
- {
31
+ {
32
32
  code: "import { addCommentFormActions, addCommentFormReducer } from '../../model/slices/addCommentFormSlice'",
33
33
  errors: [],
34
34
  },
@@ -58,20 +58,29 @@ ruleTester.run("public-api-imports", rule, {
58
58
  ],
59
59
 
60
60
  invalid: [
61
- {
61
+ {
62
62
  code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/model/file.ts'",
63
- errors: [{ message: "Абсолютный импорт разрешен только из Public Api(index.ts)"}],
63
+ errors: [{ message: "Абсолютный импорт разрешен только из Public API (index.ts)"}],
64
64
  options: aliasOptions,
65
65
  },
66
66
  {
67
67
  filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
68
68
  code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing/file.tsx'",
69
- errors: [{message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'}],
69
+ errors: [{message: 'Абсолютный импорт разрешен только из Public API (index.ts)'}],
70
70
  options: [{
71
71
  alias: '@',
72
72
  testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
73
73
  }],
74
74
  },
75
+ {
76
+ filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\forbidden.ts',
77
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
78
+ errors: [{message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'}],
79
+ options: [{
80
+ alias: '@',
81
+ testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
82
+ }],
83
+ }
75
84
 
76
85
  ],
77
86
  });
File without changes
@@ -1 +0,0 @@
1
- .history
File without changes
@@ -1,6 +0,0 @@
1
- export const pathRelative = (path)=>{
2
- return path = path.startsWith('.' || './' || './/')
3
- }
4
- module.exports = {
5
- pathRelative
6
- }
@@ -1,6 +0,0 @@
1
- const pathRelative = (path)=>{
2
- return path = path.startsWith('.' || './' || './/')
3
- }
4
- module.exports = {
5
- pathRelative
6
- }
@@ -1,6 +0,0 @@
1
- const pathRelative = (path)=>{
2
- return path = path.startsWith('.' || './' || './/')
3
- }
4
- module.exports = {
5
- pathRelative
6
- }
@@ -1,6 +0,0 @@
1
- const isPathRelative = (path)=>{
2
- return path = path.startsWith('.' || './' || './/')
3
- }
4
- module.exports = {
5
- isPathRelative
6
- }
@@ -1,6 +0,0 @@
1
- const isPathRelative = (path)=>{
2
- return path = path.startsWith('.' || './' || '.ю//')
3
- }
4
- module.exports = {
5
- isPathRelative
6
- }
@@ -1,6 +0,0 @@
1
- const isPathRelative = (path)=>{
2
- return path = path.startsWith('.' || './' || '..//')
3
- }
4
- module.exports = {
5
- isPathRelative
6
- }
@@ -1,76 +0,0 @@
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'))
@@ -1,76 +0,0 @@
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'))
@@ -1,76 +0,0 @@
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'))
@@ -1,76 +0,0 @@
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'))