eslint-plugin-big-react-app-plugin 0.1.3 → 0.1.5
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/public-api-imports.js +25 -11
- package/package.json +2 -1
- package/tests/lib/rules/public-api-imports.js +3 -2
- package/.history/.gitignore_20251018083109 +0 -0
- package/.history/.gitignore_20251018083124 +0 -1
- package/.history/lib/helpers/index_20251018083334.js +0 -0
- package/.history/lib/helpers/index_20251018083357.js +0 -6
- package/.history/lib/helpers/index_20251018083414.js +0 -6
- package/.history/lib/helpers/index_20251018083417.js +0 -6
- package/.history/lib/helpers/index_20251018083618.js +0 -6
- package/.history/lib/helpers/index_20251018092620.js +0 -6
- package/.history/lib/helpers/index_20251018092627.js +0 -6
- package/.history/lib/rules/path-checker_20250906110609.js +0 -76
- package/.history/lib/rules/path-checker_20251016170231.js +0 -76
- package/.history/lib/rules/path-checker_20251016170238.js +0 -76
- package/.history/lib/rules/path-checker_20251016170240.js +0 -76
- package/.history/lib/rules/path-checker_20251016170512.js +0 -76
- package/.history/lib/rules/path-checker_20251016170543.js +0 -78
- package/.history/lib/rules/path-checker_20251016170608.js +0 -81
- package/.history/lib/rules/path-checker_20251016170627.js +0 -81
- package/.history/lib/rules/path-checker_20251016170714.js +0 -81
- package/.history/lib/rules/path-checker_20251016170716.js +0 -83
- package/.history/lib/rules/path-checker_20251016170723.js +0 -84
- package/.history/lib/rules/path-checker_20251016170726.js +0 -84
- package/.history/lib/rules/path-checker_20251016170750.js +0 -85
- package/.history/lib/rules/path-checker_20251016170808.js +0 -85
- package/.history/lib/rules/path-checker_20251016170811.js +0 -85
- package/.history/lib/rules/path-checker_20251016170821.js +0 -85
- package/.history/lib/rules/path-checker_20251016170941.js +0 -86
- package/.history/lib/rules/path-checker_20251016170953.js +0 -86
- package/.history/lib/rules/path-checker_20251016171234.js +0 -87
- package/.history/lib/rules/path-checker_20251016171235.js +0 -87
- package/.history/lib/rules/path-checker_20251016171244.js +0 -87
- package/.history/lib/rules/path-checker_20251016192227.js +0 -89
- package/.history/lib/rules/path-checker_20251016192245.js +0 -89
- package/.history/lib/rules/path-checker_20251018083151.js +0 -89
- package/.history/lib/rules/path-checker_20251018083710.js +0 -87
- package/.history/lib/rules/public-api-imports_20251018083042.js +0 -44
- package/.history/lib/rules/public-api-imports_20251018083211.js +0 -50
- package/.history/lib/rules/public-api-imports_20251018083235.js +0 -43
- package/.history/lib/rules/public-api-imports_20251018083244.js +0 -51
- package/.history/lib/rules/public-api-imports_20251018083454.js +0 -51
- package/.history/lib/rules/public-api-imports_20251018083640.js +0 -40
- package/.history/lib/rules/public-api-imports_20251018083748.js +0 -42
- package/.history/lib/rules/public-api-imports_20251018083818.js +0 -42
- package/.history/lib/rules/public-api-imports_20251018084540.js +0 -41
- package/.history/lib/rules/public-api-imports_20251018084843.js +0 -44
- package/.history/lib/rules/public-api-imports_20251018084847.js +0 -44
- package/.history/lib/rules/public-api-imports_20251018084906.js +0 -44
- package/.history/lib/rules/public-api-imports_20251018084913.js +0 -43
- package/.history/lib/rules/public-api-imports_20251018085014.js +0 -48
- package/.history/lib/rules/public-api-imports_20251018085807.js +0 -48
- package/.history/lib/rules/public-api-imports_20251018090400.js +0 -58
- package/.history/lib/rules/public-api-imports_20251018091033.js +0 -60
- package/.history/lib/rules/public-api-imports_20251018092312.js +0 -61
- package/.history/lib/rules/public-api-imports_20251018092340.js +0 -62
- package/.history/package_20250906110616.json +0 -32
- package/.history/package_20251016192249.json +0 -32
- package/.history/package_20251018085916.json +0 -32
- package/.history/package_20251018090415.json +0 -32
- package/.history/package_20251018091504.json +0 -32
- package/.history/package_20251018092723.json +0 -32
- package/.history/tests/lib/rules/path-checker_20250906083402.js +0 -31
- package/.history/tests/lib/rules/path-checker_20251016165925.js +0 -33
- package/.history/tests/lib/rules/path-checker_20251016170059.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170109.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170128.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170147.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170208.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170246.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170253.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170255.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170323.js +0 -34
- package/.history/tests/lib/rules/path-checker_20251016170411.js +0 -38
- package/.history/tests/lib/rules/path-checker_20251016170459.js +0 -38
- package/.history/tests/lib/rules/path-checker_20251016171025.js +0 -43
- package/.history/tests/lib/rules/path-checker_20251016171041.js +0 -43
- package/.history/tests/lib/rules/path-checker_20251016171053.js +0 -43
- package/.history/tests/lib/rules/path-checker_20251016171136.js +0 -42
- package/.history/tests/lib/rules/path-checker_20251016171410.js +0 -44
- package/.history/tests/lib/rules/public-api-imports_20251018083042.js +0 -31
- package/.history/tests/lib/rules/public-api-imports_20251018085128.js +0 -34
- package/.history/tests/lib/rules/public-api-imports_20251018085249.js +0 -34
- package/.history/tests/lib/rules/public-api-imports_20251018085350.js +0 -40
- package/.history/tests/lib/rules/public-api-imports_20251018085726.js +0 -36
- package/.history/tests/lib/rules/public-api-imports_20251018090807.js +0 -86
|
@@ -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,
|
|
@@ -28,12 +30,12 @@ module.exports = {
|
|
|
28
30
|
|
|
29
31
|
create(context) {
|
|
30
32
|
const checkingLayers = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
33
|
+
"entities":"entities",
|
|
34
|
+
"features":"features",
|
|
35
|
+
"pages":"pages",
|
|
36
|
+
"widgets":"widgets",
|
|
37
|
+
}
|
|
38
|
+
const {alias='', testFilesPatterns=[]} = context.options[0] ?? {};
|
|
37
39
|
return {
|
|
38
40
|
ImportDeclaration(node) {
|
|
39
41
|
// example app/entities/Article
|
|
@@ -47,16 +49,28 @@ 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
|
-
|
|
54
|
-
const isImportNotFromPublicApi = segments.lenght > 2;
|
|
59
|
+
const isImportNotFromPublicApi = segments.length > 2;
|
|
55
60
|
|
|
56
|
-
if(isImportNotFromPublicApi) {
|
|
57
|
-
context.report({node: node, message: 'Абсолютный импорт разрешен только из Public
|
|
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
|
};
|
|
61
75
|
},
|
|
62
|
-
};
|
|
76
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-big-react-app-plugin",
|
|
3
|
-
"version": "0.1.
|
|
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": {
|
|
@@ -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,7 +58,7 @@ 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
63
|
errors: [{ message: "Абсолютный импорт разрешен только из Public API (index.ts)"}],
|
|
64
64
|
options: aliasOptions,
|
|
@@ -81,6 +81,7 @@ ruleTester.run("public-api-imports", rule, {
|
|
|
81
81
|
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
82
82
|
}],
|
|
83
83
|
}
|
|
84
|
+
|
|
84
85
|
],
|
|
85
86
|
});
|
|
86
87
|
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.history
|
|
File without changes
|
|
@@ -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'))
|
|
@@ -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,78 +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: [
|
|
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'))
|