eslint-plugin-big-react-app-plugin 0.1.2 → 0.1.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.
Files changed (26) hide show
  1. package/.history/lib/helpers/index_20251018092620.js +6 -0
  2. package/.history/lib/helpers/index_20251018092627.js +6 -0
  3. package/.history/lib/rules/public-api-imports_20251018092312.js +61 -0
  4. package/.history/lib/rules/public-api-imports_20251018092340.js +62 -0
  5. package/.history/lib/rules/public-api-imports_20251018093209.js +62 -0
  6. package/.history/lib/rules/public-api-imports_20251018093226.js +62 -0
  7. package/.history/lib/rules/public-api-imports_20251018093319.js +63 -0
  8. package/.history/lib/rules/public-api-imports_20251018094349.js +62 -0
  9. package/.history/lib/rules/public-api-imports_20251018094423.js +62 -0
  10. package/.history/lib/rules/public-api-imports_20251018094442.js +62 -0
  11. package/.history/lib/rules/public-api-imports_20251018094512.js +62 -0
  12. package/.history/lib/rules/public-api-imports_20251018094549.js +62 -0
  13. package/.history/lib/rules/public-api-imports_20251018094630.js +62 -0
  14. package/.history/lib/rules/public-api-imports_20251018094655.js +62 -0
  15. package/.history/lib/rules/public-api-imports_20251018094728.js +62 -0
  16. package/.history/lib/rules/public-api-imports_20251018094729.js +62 -0
  17. package/.history/lib/rules/public-api-imports_20251018094801.js +62 -0
  18. package/.history/lib/rules/public-api-imports_20251018095046.js +61 -0
  19. package/.history/package_20251018092723.json +32 -0
  20. package/.history/package_20251018095035.json +32 -0
  21. package/.history/tests/lib/rules/public-api-imports_20251018094915.js +86 -0
  22. package/.history/tests/lib/rules/public-api-imports_20251018094931.js +78 -0
  23. package/lib/helpers/index.js +1 -1
  24. package/lib/rules/public-api-imports.js +10 -9
  25. package/package.json +1 -1
  26. package/tests/lib/rules/public-api-imports.js +3 -11
@@ -0,0 +1,6 @@
1
+ const isPathRelative = (path)=>{
2
+ return path = path.startsWith('.' || './' || '.ю//')
3
+ }
4
+ module.exports = {
5
+ isPathRelative
6
+ }
@@ -0,0 +1,6 @@
1
+ const isPathRelative = (path)=>{
2
+ return path = path.startsWith('.' || './' || '..//')
3
+ }
4
+ module.exports = {
5
+ isPathRelative
6
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ if(!checkingLayers[layer]){
50
+ return;
51
+ }
52
+
53
+ const isImportNotFromPublicApi = segments.lenght > 2;
54
+
55
+ if(isImportNotFromPublicApi) {
56
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
57
+ }
58
+ }
59
+ };
60
+ },
61
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает")
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ console.log("Работает")
31
+ const checkingLayers = {
32
+ "entities":"entities",
33
+ "features":"features",
34
+ "pages":"pages",
35
+ "widgets":"widgets",
36
+ }
37
+ const alias = context.options[0]?.alias ?? "";
38
+ return {
39
+ ImportDeclaration(node) {
40
+ // example app/entities/Article
41
+ const value = node.source.value;
42
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
43
+ //если путь относительный то выходим
44
+ if(isPathRelative(importTo)){
45
+ return;
46
+ }
47
+ //[enteties, article, ... далее еще что-то может быть]
48
+ const segments = importTo.split('/')
49
+ const layer = segments[0]//получаем слой
50
+ // проверяем что есть слой из массива
51
+ if(!checkingLayers[layer]){
52
+ return;
53
+ }
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ console.log("Работает")
31
+ const checkingLayers = {
32
+ "entities":"entities",
33
+ "features":"features",
34
+ "pages":"pages",
35
+ "widgets":"widgets",
36
+ }
37
+ const alias = context.options[0]?.alias ?? "";
38
+ return {
39
+ ImportDeclaration(node) {
40
+ // example app/entities/Article
41
+ const value = node.source.value;
42
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
43
+ //если путь относительный то выходим
44
+ if(isPathRelative(importTo)){
45
+ return;
46
+ }
47
+ //[enteties, article, ... далее еще что-то может быть]
48
+ const segments = importTo.split('/')
49
+ const layer = segments[0]//получаем слой
50
+ // проверяем что есть слой из массива
51
+ if(!checkingLayers[layer]){
52
+ return;
53
+ }
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
63
+ create()
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ console.log("Работает")
31
+ const checkingLayers = {
32
+ "entities":"entities",
33
+ "features":"features",
34
+ "pages":"pages",
35
+ "widgets":"widgets",
36
+ }
37
+ const alias = context.options[0]?.alias ?? "";
38
+ return {
39
+ ImportDeclaration(node) {
40
+ // example app/entities/Article
41
+ const value = node.source.value;
42
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
43
+ //если путь относительный то выходим
44
+ if(isPathRelative(importTo)){
45
+ return;
46
+ }
47
+ //[enteties, article, ... далее еще что-то может быть]
48
+ const segments = importTo.split('/')
49
+ const layer = segments[0]//получаем слой
50
+ // проверяем что есть слой из массива
51
+ if(!checkingLayers[layer]){
52
+ return;
53
+ }
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ console.log("Работает")
44
+ if(isPathRelative(importTo)){
45
+ return;
46
+ }
47
+ //[enteties, article, ... далее еще что-то может быть]
48
+ const segments = importTo.split('/')
49
+ const layer = segments[0]//получаем слой
50
+ // проверяем что есть слой из массива
51
+ if(!checkingLayers[layer]){
52
+ return;
53
+ }
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ console.log("Работает")
47
+ //[enteties, article, ... далее еще что-то может быть]
48
+ const segments = importTo.split('/')
49
+ const layer = segments[0]//получаем слой
50
+ // проверяем что есть слой из массива
51
+ if(!checkingLayers[layer]){
52
+ return;
53
+ }
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает")
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает" + importTo)
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает" + segments.lenght)
54
+ const isImportNotFromPublicApi = segments.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает" + segments?.lenght)
54
+ const isImportNotFromPublicApi = segments?.lenght > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает" + segments?.length)
54
+ const isImportNotFromPublicApi = segments?.length > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает" + segments?.length)
54
+ const isImportNotFromPublicApi = segments?.length > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ console.log("Работает" + segments.length)
54
+ const isImportNotFromPublicApi = segments.length > 2;
55
+
56
+ if(isImportNotFromPublicApi) {
57
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
58
+ }
59
+ }
60
+ };
61
+ },
62
+ };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ alias: {
18
+ type: 'string'
19
+ },
20
+ testFilesPatterns: {
21
+ type: 'array'
22
+ }
23
+ }
24
+ }
25
+ ],
26
+ },
27
+
28
+
29
+ create(context) {
30
+ const checkingLayers = {
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
+ return {
38
+ ImportDeclaration(node) {
39
+ // example app/entities/Article
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
43
+ if(isPathRelative(importTo)){
44
+ return;
45
+ }
46
+ //[enteties, article, ... далее еще что-то может быть]
47
+ const segments = importTo.split('/')
48
+ const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
50
+ if(!checkingLayers[layer]){
51
+ return;
52
+ }
53
+ const isImportNotFromPublicApi = segments.length > 2;
54
+
55
+ if(isImportNotFromPublicApi) {
56
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
57
+ }
58
+ }
59
+ };
60
+ },
61
+ };
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "eslint-plugin-big-react-app-plugin",
3
+ "version": "0.1.3",
4
+ "description": "plugin for prod proj",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintplugin",
8
+ "eslint-plugin"
9
+ ],
10
+ "author": "Vasilii",
11
+ "main": "lib/index.js",
12
+ "scripts": {
13
+ "lint": "eslint .",
14
+ "test": "mocha tests --recursive"
15
+ },
16
+ "dependencies": {
17
+ "requireindex": "^1.2.0"
18
+ },
19
+ "devDependencies": {
20
+ "eslint": "^8.0.1",
21
+ "eslint-plugin-eslint-plugin": "^4.0.1",
22
+ "eslint-plugin-node": "^11.1.0",
23
+ "mocha": "^9.1.3"
24
+ },
25
+ "engines": {
26
+ "node": "12.x || 14.x || >= 16"
27
+ },
28
+ "peerDependencies": {
29
+ "eslint": ">=6"
30
+ },
31
+ "license": "ISC"
32
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "eslint-plugin-big-react-app-plugin",
3
+ "version": "0.1.4",
4
+ "description": "plugin for prod proj",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintplugin",
8
+ "eslint-plugin"
9
+ ],
10
+ "author": "Vasilii",
11
+ "main": "lib/index.js",
12
+ "scripts": {
13
+ "lint": "eslint .",
14
+ "test": "mocha tests --recursive"
15
+ },
16
+ "dependencies": {
17
+ "requireindex": "^1.2.0"
18
+ },
19
+ "devDependencies": {
20
+ "eslint": "^8.0.1",
21
+ "eslint-plugin-eslint-plugin": "^4.0.1",
22
+ "eslint-plugin-node": "^11.1.0",
23
+ "mocha": "^9.1.3"
24
+ },
25
+ "engines": {
26
+ "node": "12.x || 14.x || >= 16"
27
+ },
28
+ "peerDependencies": {
29
+ "eslint": ">=6"
30
+ },
31
+ "license": "ISC"
32
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @fileoverview public API path checker
3
+ * @author vasilii
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const rule = require("../../../lib/rules/public-api-imports"),
12
+ RuleTester = require("eslint").RuleTester;
13
+
14
+
15
+ //------------------------------------------------------------------------------
16
+ // Tests
17
+ //------------------------------------------------------------------------------
18
+
19
+ const ruleTester = new RuleTester({
20
+ parserOptions: {ecmaVersion: 6, sourceType: 'module'}
21
+ });
22
+
23
+ const aliasOptions = [
24
+ {
25
+ alias: '@'
26
+ }
27
+ ]
28
+
29
+ ruleTester.run("public-api-imports", rule, {
30
+ valid: [
31
+ {
32
+ code: "import { addCommentFormActions, addCommentFormReducer } from '../../model/slices/addCommentFormSlice'",
33
+ errors: [],
34
+ },
35
+ {
36
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article'",
37
+ errors: [],
38
+ options: aliasOptions,
39
+ },
40
+ {
41
+ filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\file.test.ts',
42
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
43
+ errors: [],
44
+ options: [{
45
+ alias: '@',
46
+ testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
47
+ }],
48
+ },
49
+ {
50
+ filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
51
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
52
+ errors: [],
53
+ options: [{
54
+ alias: '@',
55
+ testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
56
+ }],
57
+ }
58
+ ],
59
+
60
+ invalid: [
61
+ {
62
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/model/file.ts'",
63
+ errors: [{ message: "Абсолютный импорт разрешен только из Public Api(index.ts)"}],
64
+ options: aliasOptions,
65
+ },
66
+ {
67
+ filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
68
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing/file.tsx'",
69
+ errors: [{message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'}],
70
+ options: [{
71
+ alias: '@',
72
+ testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
73
+ }],
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
+ }
84
+ ],
85
+ });
86
+
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @fileoverview public API path checker
3
+ * @author vasilii
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const rule = require("../../../lib/rules/public-api-imports"),
12
+ RuleTester = require("eslint").RuleTester;
13
+
14
+
15
+ //------------------------------------------------------------------------------
16
+ // Tests
17
+ //------------------------------------------------------------------------------
18
+
19
+ const ruleTester = new RuleTester({
20
+ parserOptions: {ecmaVersion: 6, sourceType: 'module'}
21
+ });
22
+
23
+ const aliasOptions = [
24
+ {
25
+ alias: '@'
26
+ }
27
+ ]
28
+
29
+ ruleTester.run("public-api-imports", rule, {
30
+ valid: [
31
+ {
32
+ code: "import { addCommentFormActions, addCommentFormReducer } from '../../model/slices/addCommentFormSlice'",
33
+ errors: [],
34
+ },
35
+ {
36
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article'",
37
+ errors: [],
38
+ options: aliasOptions,
39
+ },
40
+ {
41
+ filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\file.test.ts',
42
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
43
+ errors: [],
44
+ options: [{
45
+ alias: '@',
46
+ testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
47
+ }],
48
+ },
49
+ {
50
+ filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
51
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
52
+ errors: [],
53
+ options: [{
54
+ alias: '@',
55
+ testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
56
+ }],
57
+ }
58
+ ],
59
+
60
+ invalid: [
61
+ {
62
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/model/file.ts'",
63
+ errors: [{ message: "Абсолютный импорт разрешен только из Public Api(index.ts)"}],
64
+ options: aliasOptions,
65
+ },
66
+ {
67
+ filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
68
+ code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing/file.tsx'",
69
+ errors: [{message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'}],
70
+ options: [{
71
+ alias: '@',
72
+ testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
73
+ }],
74
+ },
75
+
76
+ ],
77
+ });
78
+
@@ -1,5 +1,5 @@
1
1
  const isPathRelative = (path)=>{
2
- return path = path.startsWith('.' || './' || './/')
2
+ return path = path.startsWith('.' || './' || '..//')
3
3
  }
4
4
  module.exports = {
5
5
  isPathRelative
@@ -28,28 +28,29 @@ module.exports = {
28
28
 
29
29
  create(context) {
30
30
  const checkingLayers = {
31
- "entities":"entities",
32
- "features":"features",
33
- "pages":"pages",
34
- "widgets":"widgets",
35
- }
36
- const alias = context.options[0]?.alias ?? "";
31
+ "entities":"entities",
32
+ "features":"features",
33
+ "pages":"pages",
34
+ "widgets":"widgets",
35
+ }
36
+ const alias = context.options[0]?.alias ?? "";
37
37
  return {
38
38
  ImportDeclaration(node) {
39
39
  // example app/entities/Article
40
40
  const value = node.source.value;
41
41
  const importTo = alias ? value.replace(`${alias}/`, "") : value;
42
+ //если путь относительный то выходим
42
43
  if(isPathRelative(importTo)){
43
44
  return;
44
45
  }
45
46
  //[enteties, article, ... далее еще что-то может быть]
46
47
  const segments = importTo.split('/')
47
48
  const layer = segments[0]//получаем слой
49
+ // проверяем что есть слой из массива
48
50
  if(!checkingLayers[layer]){
49
51
  return;
50
52
  }
51
-
52
- const isImportNotFromPublicApi = segments.lenght > 2;
53
+ const isImportNotFromPublicApi = segments.length > 2;
53
54
 
54
55
  if(isImportNotFromPublicApi) {
55
56
  context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
@@ -57,4 +58,4 @@ module.exports = {
57
58
  }
58
59
  };
59
60
  },
60
- };
61
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-big-react-app-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "plugin for prod proj",
5
5
  "keywords": [
6
6
  "eslint",
@@ -60,27 +60,19 @@ ruleTester.run("public-api-imports", rule, {
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
78