eslint-plugin-big-react-app-plugin 0.1.7 → 0.1.9
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/.history/lib/rules/public-api-imports_20251029144926.js +0 -1
- package/.history/lib/rules/public-api-imports_20251029144953.js +0 -1
- package/.history/lib/rules/public-api-imports_20251029145009.js +0 -1
- package/.history/lib/rules/public-api-imports_20251029145022.js +0 -1
- package/.history/lib/rules/public-api-imports_20251029145049.js +0 -1
- package/.history/lib/rules/public-api-imports_20251030070810.js +76 -0
- package/.history/lib/rules/public-api-imports_20251030070822.js +76 -0
- package/.history/lib/rules/public-api-imports_20251030072017.js +77 -0
- package/.history/lib/rules/public-api-imports_20251030072333.js +76 -0
- package/.history/lib/rules/public-api-imports_20251030072413.js +76 -0
- package/.history/lib/rules/public-api-imports_20251030072442.js +76 -0
- package/.history/lib/rules/public-api-imports_20251030072512.js +76 -0
- package/.history/lib/rules/public-api-imports_20251030073010.js +77 -0
- package/.history/lib/rules/public-api-imports_20251030073013.js +77 -0
- package/.history/lib/rules/public-api-imports_20251030073246.js +77 -0
- package/.history/package_20251030070953.json +33 -0
- package/.history/package_20251030073306.json +33 -0
- package/.history/tests/lib/rules/path-checker_20251030070901.js +44 -0
- package/.history/tests/lib/rules/public-api-imports_20251030070849.js +96 -0
- package/.history/tests/lib/rules/public-api-imports_20251030071316.js +96 -0
- package/.history/tests/lib/rules/public-api-imports_20251030071331.js +96 -0
- package/.history/tests/lib/rules/public-api-imports_20251030073042.js +96 -0
- package/.history/tests/lib/rules/public-api-imports_20251030073103.js +96 -0
- package/.history/tests/lib/rules/public-api-imports_20251030073107.js +96 -0
- package/.history/tests/lib/rules/public-api-imports_20251030073112.js +96 -0
- package/lib/rules/public-api-imports.js +3 -2
- package/package.json +1 -1
- package/tests/lib/rules/path-checker.js +32 -32
- package/tests/lib/rules/public-api-imports.js +23 -23
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const micromatch = require("micromatch");
|
|
3
|
+
const {isPathRelative} = require("../helpers")
|
|
4
|
+
const path = require("path");
|
|
5
|
+
module.exports = {
|
|
6
|
+
meta: {
|
|
7
|
+
type: null,
|
|
8
|
+
docs: {
|
|
9
|
+
description: "description",
|
|
10
|
+
category: "Fill me in",
|
|
11
|
+
recommended: false,
|
|
12
|
+
url: null,
|
|
13
|
+
},
|
|
14
|
+
fixable: null,
|
|
15
|
+
schema: [
|
|
16
|
+
{
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
alias: {
|
|
20
|
+
type: 'string'
|
|
21
|
+
},
|
|
22
|
+
testFilesPatterns: {
|
|
23
|
+
type: 'array'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
create(context) {
|
|
32
|
+
const checkingLayers = {
|
|
33
|
+
"entities":"entities",
|
|
34
|
+
"features":"features",
|
|
35
|
+
"pages":"pages",
|
|
36
|
+
"widgets":"widgets",
|
|
37
|
+
}
|
|
38
|
+
const {alias='', testFilesPatterns=[]} = context.options[0] ?? {};
|
|
39
|
+
return {
|
|
40
|
+
ImportDeclaration(node) {
|
|
41
|
+
// example app/entities/Article
|
|
42
|
+
const value = node.source.value;
|
|
43
|
+
const importTo = alias ? value.replace(`${alias}/`, "") : value;
|
|
44
|
+
|
|
45
|
+
//если путь относительный то выходим
|
|
46
|
+
if(isPathRelative(importTo)){
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
//[enteties, article, ... далее еще что-то может быть]
|
|
50
|
+
const segments = importTo.split('/')
|
|
51
|
+
const layer = segments[0]//получаем слой
|
|
52
|
+
// проверяем что есть слой из массива
|
|
53
|
+
|
|
54
|
+
//[enteties, article, testing]
|
|
55
|
+
const isTestingPublicApi = segments[2] === 'testing';
|
|
56
|
+
|
|
57
|
+
if(!checkingLayers[layer]){
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const isImportNotFromPublicApi = segments.length > 2;
|
|
61
|
+
|
|
62
|
+
if(isImportNotFromPublicApi && !isTestingPublicApi ) {
|
|
63
|
+
context.report({node: node, message: 'Абсолютный импорт разрешен только из Public API (index.ts)'});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if(isTestingPublicApi){
|
|
67
|
+
const currentFilePath = context.getFilename();
|
|
68
|
+
const normalizedPath = currentFilePath.split(path.sep).join('/');
|
|
69
|
+
const isCurrentFileTesting = testFilesPatterns.some(pattern=>micromatch.isMatch(normalizedPath, pattern))
|
|
70
|
+
if(!isCurrentFileTesting){
|
|
71
|
+
context.report({node: node, message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const micromatch = require("micromatch");
|
|
3
|
+
const {isPathRelative} = require("../helpers")
|
|
4
|
+
const path = require("path");
|
|
5
|
+
module.exports = {
|
|
6
|
+
meta: {
|
|
7
|
+
type: null,
|
|
8
|
+
docs: {
|
|
9
|
+
description: "description",
|
|
10
|
+
category: "Fill me in",
|
|
11
|
+
recommended: false,
|
|
12
|
+
url: null,
|
|
13
|
+
},
|
|
14
|
+
fixable: null,
|
|
15
|
+
schema: [
|
|
16
|
+
{
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
alias: {
|
|
20
|
+
type: 'string'
|
|
21
|
+
},
|
|
22
|
+
testFilesPatterns: {
|
|
23
|
+
type: 'array'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
create(context) {
|
|
32
|
+
const checkingLayers = {
|
|
33
|
+
"entities":"entities",
|
|
34
|
+
"features":"features",
|
|
35
|
+
"pages":"pages",
|
|
36
|
+
"widgets":"widgets",
|
|
37
|
+
}
|
|
38
|
+
const {alias='', testFilesPatterns=[]} = context.options[0] ?? {};
|
|
39
|
+
return {
|
|
40
|
+
ImportDeclaration(node) {
|
|
41
|
+
// example app/entities/Article
|
|
42
|
+
const value = node.source.value;
|
|
43
|
+
const importTo = alias ? value.replace(`${alias}/`, "") : value;
|
|
44
|
+
|
|
45
|
+
//если путь относительный то выходим
|
|
46
|
+
if(isPathRelative(importTo)){
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
//[enteties, article, ... далее еще что-то может быть]
|
|
50
|
+
const segments = importTo.split('/')
|
|
51
|
+
const layer = segments[0]//получаем слой
|
|
52
|
+
// проверяем что есть слой из массива
|
|
53
|
+
|
|
54
|
+
//[enteties, article, testing]
|
|
55
|
+
const isTestingPublicApi = segments[2] === 'testing' && segments.length < 4;
|
|
56
|
+
|
|
57
|
+
if(!checkingLayers[layer]){
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const isImportNotFromPublicApi = segments.length > 2;
|
|
61
|
+
|
|
62
|
+
if(isImportNotFromPublicApi && !isTestingPublicApi ) {
|
|
63
|
+
context.report({node: node, message: 'Абсолютный импорт разрешен только из Public API (index.ts)'});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if(isTestingPublicApi){
|
|
67
|
+
const currentFilePath = context.getFilename();
|
|
68
|
+
const normalizedPath = currentFilePath.split(path.sep).join('/');
|
|
69
|
+
const isCurrentFileTesting = testFilesPatterns.some(pattern=>micromatch.isMatch(normalizedPath, pattern))
|
|
70
|
+
if(!isCurrentFileTesting){
|
|
71
|
+
context.report({node: node, message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-big-react-app-plugin",
|
|
3
|
+
"version": "0.1.8",
|
|
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
|
+
"micromatch": "^4.0.5",
|
|
18
|
+
"requireindex": "^1.2.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"eslint": "^8.0.1",
|
|
22
|
+
"eslint-plugin-eslint-plugin": "^4.0.1",
|
|
23
|
+
"eslint-plugin-node": "^11.1.0",
|
|
24
|
+
"mocha": "^9.1.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "12.x || 14.x || >= 16"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"eslint": ">=6"
|
|
31
|
+
},
|
|
32
|
+
"license": "ISC"
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-big-react-app-plugin",
|
|
3
|
+
"version": "0.1.9",
|
|
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
|
+
"micromatch": "^4.0.5",
|
|
18
|
+
"requireindex": "^1.2.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"eslint": "^8.0.1",
|
|
22
|
+
"eslint-plugin-eslint-plugin": "^4.0.1",
|
|
23
|
+
"eslint-plugin-node": "^11.1.0",
|
|
24
|
+
"mocha": "^9.1.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "12.x || 14.x || >= 16"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"eslint": ">=6"
|
|
31
|
+
},
|
|
32
|
+
"license": "ISC"
|
|
33
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview feature sliced relative path checker
|
|
3
|
+
* @author Vasilii
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
//------------------------------------------------------------------------------
|
|
8
|
+
// Requirements
|
|
9
|
+
//------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
const rule = require("../../../lib/rules/path-checker"),
|
|
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
|
+
ruleTester.run("path-checker", rule, {
|
|
23
|
+
valid: [
|
|
24
|
+
{
|
|
25
|
+
code: "import { HStack } from '../../../Stack/HStack/HStack'",
|
|
26
|
+
filename:'C:\\Users\\ADMIN\\Documents\\GitHub\\ulbi\big-react-app\\src\\shared\\ui\\Popups\\ui\\ListBox\\ListBox.tsx',
|
|
27
|
+
errors: [],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
invalid: [
|
|
32
|
+
{
|
|
33
|
+
code: "import { HStack } from 'shared/ui/Stack/index'",
|
|
34
|
+
filename:'C:\\Users\\ADMIN\\Documents\\GitHub\\ulbi\big-react-app\\src\\shared\\ui\\Popups\\ui\\ListBox\\ListBox.tsx',
|
|
35
|
+
errors: [{ message: "В рамках одного слайса все пути должны быть относительными" }],
|
|
36
|
+
options:[
|
|
37
|
+
{
|
|
38
|
+
alias:'@'
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
],
|
|
44
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
filename: 'D:\\KonovalovVasiliy\\GitHub\\ulbi\\big-react-app\\src\\shared\\config\\storybook\\StoreDecorator\\StoreDecorator.tsx',
|
|
37
|
+
code: "import { loginReducer } from '@/features/AuthByUsername/testing'",
|
|
38
|
+
errors: [],
|
|
39
|
+
options: [{
|
|
40
|
+
alias: '@',
|
|
41
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
42
|
+
}],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article'",
|
|
46
|
+
errors: [],
|
|
47
|
+
options: aliasOptions,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\file.test.ts',
|
|
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
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
60
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
61
|
+
errors: [],
|
|
62
|
+
options: [{
|
|
63
|
+
alias: '@',
|
|
64
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
65
|
+
}],
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
invalid: [
|
|
70
|
+
{
|
|
71
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/model/file.ts'",
|
|
72
|
+
errors: [{ message: "Абсолютный импорт разрешен только из Public API (index.ts)"}],
|
|
73
|
+
options: aliasOptions,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
77
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing/file.tsx'",
|
|
78
|
+
errors: [{message: 'Абсолютный импорт разрешен только из Public API (index.ts)'}],
|
|
79
|
+
options: [{
|
|
80
|
+
alias: '@',
|
|
81
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
82
|
+
}],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\forbidden.ts',
|
|
86
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
87
|
+
errors: [{message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'}],
|
|
88
|
+
options: [{
|
|
89
|
+
alias: '@',
|
|
90
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
91
|
+
}],
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
filename: 'D:\\KonovalovVasiliy\\GitHub\\ulbi\\big-react-app\\src\\shared\\config\\storybook\\StoreDecorator\\StoreDecorator.tsx',
|
|
37
|
+
code: "import { loginReducer } from '@/features/AuthByUsername/testing'",
|
|
38
|
+
errors: [],
|
|
39
|
+
options: [{
|
|
40
|
+
alias: '@',
|
|
41
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorators.tsx']
|
|
42
|
+
}],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article'",
|
|
46
|
+
errors: [],
|
|
47
|
+
options: aliasOptions,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\file.test.ts',
|
|
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
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
60
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
61
|
+
errors: [],
|
|
62
|
+
options: [{
|
|
63
|
+
alias: '@',
|
|
64
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
65
|
+
}],
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
invalid: [
|
|
70
|
+
{
|
|
71
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/model/file.ts'",
|
|
72
|
+
errors: [{ message: "Абсолютный импорт разрешен только из Public API (index.ts)"}],
|
|
73
|
+
options: aliasOptions,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
77
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing/file.tsx'",
|
|
78
|
+
errors: [{message: 'Абсолютный импорт разрешен только из Public API (index.ts)'}],
|
|
79
|
+
options: [{
|
|
80
|
+
alias: '@',
|
|
81
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
82
|
+
}],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\forbidden.ts',
|
|
86
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
87
|
+
errors: [{message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'}],
|
|
88
|
+
options: [{
|
|
89
|
+
alias: '@',
|
|
90
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
91
|
+
}],
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
filename: 'D:\\KonovalovVasiliy\\GitHub\\ulbi\\big-react-app\\src\\shared\\config\\storybook\\StoreDecorator\\StoreDecorator.tsx',
|
|
37
|
+
code: "import { loginReducer } from '@/features/AuthByUsername/testing'",
|
|
38
|
+
errors: [],
|
|
39
|
+
options: [{
|
|
40
|
+
alias: '@',
|
|
41
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
42
|
+
}],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article'",
|
|
46
|
+
errors: [],
|
|
47
|
+
options: aliasOptions,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\file.test.ts',
|
|
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
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
60
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
61
|
+
errors: [],
|
|
62
|
+
options: [{
|
|
63
|
+
alias: '@',
|
|
64
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
65
|
+
}],
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
invalid: [
|
|
70
|
+
{
|
|
71
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/model/file.ts'",
|
|
72
|
+
errors: [{ message: "Абсолютный импорт разрешен только из Public API (index.ts)"}],
|
|
73
|
+
options: aliasOptions,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
77
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing/file.tsx'",
|
|
78
|
+
errors: [{message: 'Абсолютный импорт разрешен только из Public API (index.ts)'}],
|
|
79
|
+
options: [{
|
|
80
|
+
alias: '@',
|
|
81
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
82
|
+
}],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\forbidden.ts',
|
|
86
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
87
|
+
errors: [{message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'}],
|
|
88
|
+
options: [{
|
|
89
|
+
alias: '@',
|
|
90
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
91
|
+
}],
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
filename: 'C:\Users\ADMIN\Documents\GitHub\ulbi\big-react-app\src\shared\config\storybook\StoreDecorator\StoreDecorator.tsx',
|
|
37
|
+
code: "import { loginReducer } from '@/features/AuthByUsername/testing'",
|
|
38
|
+
errors: [],
|
|
39
|
+
options: [{
|
|
40
|
+
alias: '@',
|
|
41
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
42
|
+
}],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article'",
|
|
46
|
+
errors: [],
|
|
47
|
+
options: aliasOptions,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\file.test.ts',
|
|
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
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
60
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
61
|
+
errors: [],
|
|
62
|
+
options: [{
|
|
63
|
+
alias: '@',
|
|
64
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
65
|
+
}],
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
invalid: [
|
|
70
|
+
{
|
|
71
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/model/file.ts'",
|
|
72
|
+
errors: [{ message: "Абсолютный импорт разрешен только из Public API (index.ts)"}],
|
|
73
|
+
options: aliasOptions,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\StoreDecorator.tsx',
|
|
77
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing/file.tsx'",
|
|
78
|
+
errors: [{message: 'Абсолютный импорт разрешен только из Public API (index.ts)'}],
|
|
79
|
+
options: [{
|
|
80
|
+
alias: '@',
|
|
81
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
82
|
+
}],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
filename: 'C:\\Users\\tim\\Desktop\\javascript\\production_project\\src\\entities\\forbidden.ts',
|
|
86
|
+
code: "import { addCommentFormActions, addCommentFormReducer } from '@/entities/Article/testing'",
|
|
87
|
+
errors: [{message: 'Тестовые данные необходимо импортировать из publicApi/testing.ts'}],
|
|
88
|
+
options: [{
|
|
89
|
+
alias: '@',
|
|
90
|
+
testFilesPatterns: ['**/*.test.ts', '**/*.test.ts', '**/StoreDecorator.tsx']
|
|
91
|
+
}],
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
|