@conarti/eslint-plugin-feature-sliced 1.0.4 → 1.0.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/CHANGELOG.md +9 -0
- package/dist/config.js +27 -27
- package/dist/configs/import-order/index.js +20 -20
- package/dist/configs/import-order/recommended.js +28 -28
- package/dist/configs/import-order/with-newlines-and-type-group.js +28 -28
- package/dist/configs/import-order/with-newlines.js +28 -28
- package/dist/configs/import-order/with-type-group.js +28 -28
- package/dist/configs/recommended.js +11 -11
- package/dist/configs/rules.js +11 -11
- package/dist/index.js +24 -24
- package/dist/lib/{fsd-lib → feature-sliced}/extract-feature-sliced-parts.js +18 -18
- package/dist/lib/{fsd-lib → feature-sliced}/extract-layer.js +21 -21
- package/dist/lib/{fsd-lib → feature-sliced}/extract-paths-info.js +59 -59
- package/dist/lib/{fsd-lib → feature-sliced}/extract-segment.js +18 -18
- package/dist/lib/{fsd-lib → feature-sliced}/extract-slice.js +10 -10
- package/dist/lib/{fsd-lib → feature-sliced}/index.js +10 -10
- package/dist/lib/{fsd-lib → feature-sliced}/layers.js +16 -16
- package/dist/lib/{fsd-lib → feature-sliced}/validate-extracted-feature-sliced-parts.js +29 -29
- package/dist/lib/{path-lib → path}/convert-to-absolute.js +18 -18
- package/dist/lib/{path-lib → path}/index.js +9 -9
- package/dist/lib/{path-lib → path}/is-path-relative.js +7 -7
- package/dist/lib/{path-lib → path}/join-path.js +12 -12
- package/dist/lib/{path-lib → path}/normalize-path.js +19 -19
- package/dist/lib/{rule-lib → rule}/create-rule.js +7 -7
- package/dist/lib/{rule-lib → rule}/extract-current-file-path.js +11 -11
- package/dist/lib/{rule-lib → rule}/extract-cwd.js +13 -13
- package/dist/lib/{rule-lib → rule}/extract-node-path.js +13 -13
- package/dist/lib/rule/extract-paths.js +21 -0
- package/dist/lib/{rule-lib → rule}/extract-rule-options.js +7 -7
- package/dist/lib/{rule-lib → rule}/get-source-range-without-quotes.js +7 -7
- package/dist/lib/{rule-lib/can-validate.js → rule/has-path.js} +11 -11
- package/dist/lib/{rule-lib → rule}/index.js +27 -23
- package/dist/lib/{rule-lib → rule}/is-ignored-current-file.js +12 -12
- package/dist/lib/rule/is-ignored-target.js +12 -0
- package/dist/lib/{rule-lib → rule}/is-ignored.js +12 -12
- package/dist/lib/rule/is-node-type.js +16 -0
- package/dist/lib/{rule-lib → rule}/models.js +2 -2
- package/dist/lib/shared/get-by-reg-exp.js +12 -12
- package/dist/lib/shared/index.js +11 -11
- package/dist/lib/shared/is-null.js +7 -7
- package/dist/lib/shared/is-object.js +7 -7
- package/dist/lib/shared/is-undefined.js +7 -7
- package/dist/rules/absolute-relative/config.js +2 -2
- package/dist/rules/absolute-relative/index.js +51 -52
- package/dist/rules/absolute-relative/model/{errors-lib.js → errors.js} +17 -17
- package/dist/rules/absolute-relative/model/index.js +5 -5
- package/dist/rules/absolute-relative/model/should-be-absolute.js +16 -16
- package/dist/rules/absolute-relative/model/should-be-relative.js +21 -21
- package/dist/rules/absolute-relative/model/validate-and-report.js +24 -24
- package/dist/rules/layers-slices/config.js +2 -2
- package/dist/rules/layers-slices/index.js +55 -56
- package/dist/rules/layers-slices/model/{errors-lib.js → errors.js} +22 -14
- package/dist/rules/layers-slices/model/index.js +5 -5
- package/dist/rules/layers-slices/model/is-not-suitable-for-validation.js +17 -0
- package/dist/rules/layers-slices/model/specifiers/extract-import-specifiers.js +8 -0
- package/dist/rules/layers-slices/model/specifiers/has-errors-at-all-specifiers.js +9 -0
- package/dist/rules/layers-slices/model/specifiers/index.js +7 -0
- package/dist/rules/layers-slices/model/specifiers/validate-specifiers.js +8 -0
- package/dist/rules/layers-slices/model/validate-and-report.js +46 -22
- package/dist/rules/layers-slices/model/validate-node/index.js +16 -0
- package/dist/rules/layers-slices/model/validate-node/valid-by-layer-order.js +10 -0
- package/dist/rules/layers-slices/model/validate-node/valid-by-type-import.js +9 -0
- package/dist/rules/public-api/config.js +2 -2
- package/dist/rules/public-api/index.js +65 -65
- package/dist/rules/public-api/model/convert-to-public-api.js +24 -24
- package/dist/rules/public-api/model/{errors-lib.js → errors.js} +34 -34
- package/dist/rules/public-api/model/index.js +5 -5
- package/dist/rules/public-api/model/is-index-file.js +7 -7
- package/dist/rules/public-api/model/is-layer-public-api.js +23 -23
- package/dist/rules/public-api/model/is-segments-public-api.js +11 -11
- package/dist/rules/public-api/model/is-slice-public-api.js +7 -7
- package/dist/rules/public-api/model/should-be-from-public-api.js +21 -21
- package/dist/rules/public-api/model/validate-and-report-program.js +15 -15
- package/dist/rules/public-api/model/validate-and-report.js +18 -18
- package/package.json +15 -14
- package/dist/lib/fsd-lib/extract-paths.js +0 -19
- package/dist/lib/rule-lib/is-node-type.js +0 -17
- package/dist/rules/layers-slices/model/can-import-layer.js +0 -22
|
@@ -1,22 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAndReport = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAndReport = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const feature_sliced_1 = require("../../../lib/feature-sliced");
|
|
6
|
+
const rule_1 = require("../../../lib/rule");
|
|
7
|
+
const errors_1 = require("./errors");
|
|
8
|
+
const is_not_suitable_for_validation_1 = require("./is-not-suitable-for-validation");
|
|
9
|
+
const specifiers_1 = require("./specifiers");
|
|
10
|
+
const extract_import_specifiers_1 = require("./specifiers/extract-import-specifiers");
|
|
11
|
+
const validate_node_1 = require("./validate-node");
|
|
12
|
+
function validate(node, pathsInfo, allowTypeImports) {
|
|
13
|
+
if ((0, validate_node_1.validateNode)(node, pathsInfo, allowTypeImports)) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const isImportExpression = utils_1.ASTUtils.isNodeOfType(utils_1.AST_NODE_TYPES.ImportExpression)(node);
|
|
17
|
+
if (isImportExpression) {
|
|
18
|
+
return [node];
|
|
19
|
+
}
|
|
20
|
+
const specifiers = (0, extract_import_specifiers_1.extractImportSpecifiers)(node);
|
|
21
|
+
const invalidSpecifiers = (0, specifiers_1.validateSpecifiers)(specifiers, allowTypeImports);
|
|
22
|
+
if ((0, specifiers_1.hasErrorsAtAllSpecifiers)(specifiers, invalidSpecifiers)) {
|
|
23
|
+
return [node];
|
|
24
|
+
}
|
|
25
|
+
return invalidSpecifiers;
|
|
26
|
+
}
|
|
27
|
+
function reportValidationErrors(nodes, context, pathsInfo) {
|
|
28
|
+
nodes.forEach((node) => (0, errors_1.reportCanNotImportLayer)(context, node, pathsInfo));
|
|
29
|
+
}
|
|
30
|
+
function validateAndReport(node, context, optionsWithDefault) {
|
|
31
|
+
if (!(0, rule_1.hasPath)(node)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const isIgnoredForValidation = (0, rule_1.isIgnoredTarget)(node, optionsWithDefault) || (0, rule_1.isIgnoredCurrentFile)(context, optionsWithDefault);
|
|
35
|
+
if (isIgnoredForValidation) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const pathsInfo = (0, feature_sliced_1.extractPathsInfo)(node, context);
|
|
39
|
+
if ((0, is_not_suitable_for_validation_1.isNotSuitableForValidation)(pathsInfo)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const { allowTypeImports } = (0, rule_1.extractRuleOptions)(optionsWithDefault);
|
|
43
|
+
const nodesToReport = validate(node, pathsInfo, allowTypeImports);
|
|
44
|
+
reportValidationErrors(nodesToReport, context, pathsInfo);
|
|
45
|
+
}
|
|
46
|
+
exports.validateAndReport = validateAndReport;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateNode = void 0;
|
|
4
|
+
const valid_by_layer_order_1 = require("./valid-by-layer-order");
|
|
5
|
+
const valid_by_type_import_1 = require("./valid-by-type-import");
|
|
6
|
+
function validateNode(node, pathsInfo, allowTypeImports) {
|
|
7
|
+
const { fsdPartsOfTarget, fsdPartsOfCurrentFile, } = pathsInfo;
|
|
8
|
+
if ((0, valid_by_type_import_1.validByTypeImport)(node, allowTypeImports)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if ((0, valid_by_layer_order_1.validByLayerOrder)(fsdPartsOfTarget, fsdPartsOfCurrentFile)) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
exports.validateNode = validateNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validByLayerOrder = void 0;
|
|
4
|
+
const feature_sliced_1 = require("../../../../lib/feature-sliced");
|
|
5
|
+
function validByLayerOrder(fsdPartsOfTarget, fsdPartsOfCurrentFile) {
|
|
6
|
+
const importLayerOrder = (0, feature_sliced_1.getLayerWeight)(fsdPartsOfTarget.layer);
|
|
7
|
+
const currentFileLayerOrder = (0, feature_sliced_1.getLayerWeight)(fsdPartsOfCurrentFile.layer);
|
|
8
|
+
return currentFileLayerOrder > importLayerOrder;
|
|
9
|
+
}
|
|
10
|
+
exports.validByLayerOrder = validByLayerOrder;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validByTypeImport = void 0;
|
|
4
|
+
const rule_1 = require("../../../../lib/rule");
|
|
5
|
+
function validByTypeImport(node, allowTypeImports) {
|
|
6
|
+
const isType = (0, rule_1.isNodeType)(node);
|
|
7
|
+
return allowTypeImports && isType;
|
|
8
|
+
}
|
|
9
|
+
exports.validByTypeImport = validByTypeImport;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const model_1 = require("./model");
|
|
5
|
-
const validate_and_report_program_1 = require("./model/validate-and-report-program");
|
|
6
|
-
exports.default = (0,
|
|
7
|
-
name: 'public-api',
|
|
8
|
-
meta: {
|
|
9
|
-
type: 'problem',
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Check for module imports from public api',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
["
|
|
17
|
-
["
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
enum: [
|
|
26
|
-
"segments",
|
|
27
|
-
"slices",
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
ignoreInFilesPatterns: {
|
|
31
|
-
type: 'array',
|
|
32
|
-
items: {
|
|
33
|
-
type: 'string',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
defaultOptions: [
|
|
41
|
-
{
|
|
42
|
-
level: "slices",
|
|
43
|
-
ignoreInFilesPatterns: [],
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
create(context, optionsWithDefault) {
|
|
47
|
-
return {
|
|
48
|
-
ImportDeclaration(node) {
|
|
49
|
-
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
50
|
-
},
|
|
51
|
-
ImportExpression(node) {
|
|
52
|
-
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
53
|
-
},
|
|
54
|
-
ExportAllDeclaration(node) {
|
|
55
|
-
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
56
|
-
},
|
|
57
|
-
ExportNamedDeclaration(node) {
|
|
58
|
-
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
59
|
-
},
|
|
60
|
-
Program(node) {
|
|
61
|
-
(0, validate_and_report_program_1.validateAndReportProgram)(node, context, optionsWithDefault);
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rule_1 = require("../../lib/rule");
|
|
4
|
+
const model_1 = require("./model");
|
|
5
|
+
const validate_and_report_program_1 = require("./model/validate-and-report-program");
|
|
6
|
+
exports.default = (0, rule_1.createRule)({
|
|
7
|
+
name: 'public-api',
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'problem',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Check for module imports from public api',
|
|
12
|
+
},
|
|
13
|
+
hasSuggestions: true,
|
|
14
|
+
messages: {
|
|
15
|
+
["should-be-from-public-api"]: 'Absolute imports are only allowed from public api ("{{ fixedPath }}")',
|
|
16
|
+
["remove-suggestion"]: 'Remove the "{{ valueToRemove }}"',
|
|
17
|
+
["layers-public-api-not-allowed"]: 'The layer public API is not allowed. It harms both architecturally and practically (code splitting)',
|
|
18
|
+
},
|
|
19
|
+
schema: [
|
|
20
|
+
{
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
level: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
enum: [
|
|
26
|
+
"segments",
|
|
27
|
+
"slices",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
ignoreInFilesPatterns: {
|
|
31
|
+
type: 'array',
|
|
32
|
+
items: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
defaultOptions: [
|
|
41
|
+
{
|
|
42
|
+
level: "slices",
|
|
43
|
+
ignoreInFilesPatterns: [],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
create(context, optionsWithDefault) {
|
|
47
|
+
return {
|
|
48
|
+
ImportDeclaration(node) {
|
|
49
|
+
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
50
|
+
},
|
|
51
|
+
ImportExpression(node) {
|
|
52
|
+
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
53
|
+
},
|
|
54
|
+
ExportAllDeclaration(node) {
|
|
55
|
+
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
56
|
+
},
|
|
57
|
+
ExportNamedDeclaration(node) {
|
|
58
|
+
(0, model_1.validateAndReport)(node, context, optionsWithDefault);
|
|
59
|
+
},
|
|
60
|
+
Program(node) {
|
|
61
|
+
(0, validate_and_report_program_1.validateAndReportProgram)(node, context, optionsWithDefault);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToPublicApi = void 0;
|
|
4
|
-
const shared_1 = require("../../../lib/shared");
|
|
5
|
-
function addSlashToStart(targetPath) {
|
|
6
|
-
if ((0, shared_1.isNull)(targetPath)) {
|
|
7
|
-
return '';
|
|
8
|
-
}
|
|
9
|
-
return `/${targetPath}`;
|
|
10
|
-
}
|
|
11
|
-
function extractValueToRemove(pathsInfo) {
|
|
12
|
-
const { isSameSlice, fsdPartsOfTarget, } = pathsInfo;
|
|
13
|
-
if (isSameSlice) {
|
|
14
|
-
return fsdPartsOfTarget.segmentFiles;
|
|
15
|
-
}
|
|
16
|
-
return `${fsdPartsOfTarget.segment}${addSlashToStart(fsdPartsOfTarget.segmentFiles)}`;
|
|
17
|
-
}
|
|
18
|
-
function convertToPublicApi(pathsInfo) {
|
|
19
|
-
const { normalizedTargetPath } = pathsInfo;
|
|
20
|
-
const valueToRemove = extractValueToRemove(pathsInfo);
|
|
21
|
-
const publicApiPath = normalizedTargetPath.replace(`/${valueToRemove}`, '');
|
|
22
|
-
return [publicApiPath, valueToRemove];
|
|
23
|
-
}
|
|
24
|
-
exports.convertToPublicApi = convertToPublicApi;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToPublicApi = void 0;
|
|
4
|
+
const shared_1 = require("../../../lib/shared");
|
|
5
|
+
function addSlashToStart(targetPath) {
|
|
6
|
+
if ((0, shared_1.isNull)(targetPath)) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
return `/${targetPath}`;
|
|
10
|
+
}
|
|
11
|
+
function extractValueToRemove(pathsInfo) {
|
|
12
|
+
const { isSameSlice, fsdPartsOfTarget, } = pathsInfo;
|
|
13
|
+
if (isSameSlice) {
|
|
14
|
+
return fsdPartsOfTarget.segmentFiles;
|
|
15
|
+
}
|
|
16
|
+
return `${fsdPartsOfTarget.segment}${addSlashToStart(fsdPartsOfTarget.segmentFiles)}`;
|
|
17
|
+
}
|
|
18
|
+
function convertToPublicApi(pathsInfo) {
|
|
19
|
+
const { normalizedTargetPath } = pathsInfo;
|
|
20
|
+
const valueToRemove = extractValueToRemove(pathsInfo);
|
|
21
|
+
const publicApiPath = normalizedTargetPath.replace(`/${valueToRemove}`, '');
|
|
22
|
+
return [publicApiPath, valueToRemove];
|
|
23
|
+
}
|
|
24
|
+
exports.convertToPublicApi = convertToPublicApi;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reportLayersPublicApiNotAllowed = exports.reportShouldBeFromPublicApi = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const convert_to_public_api_1 = require("./convert-to-public-api");
|
|
7
|
-
function reportShouldBeFromPublicApi(node, context) {
|
|
8
|
-
const pathsInfo = (0,
|
|
9
|
-
const [fixedPath, valueToRemove] = (0, convert_to_public_api_1.convertToPublicApi)(pathsInfo);
|
|
10
|
-
context.report({
|
|
11
|
-
node: node.source,
|
|
12
|
-
messageId: "should-be-from-public-api",
|
|
13
|
-
data: {
|
|
14
|
-
fixedPath,
|
|
15
|
-
},
|
|
16
|
-
suggest: [
|
|
17
|
-
{
|
|
18
|
-
messageId: "remove-suggestion",
|
|
19
|
-
data: {
|
|
20
|
-
valueToRemove,
|
|
21
|
-
},
|
|
22
|
-
fix: (fixer) => fixer.replaceTextRange((0,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.reportShouldBeFromPublicApi = reportShouldBeFromPublicApi;
|
|
28
|
-
function reportLayersPublicApiNotAllowed(node, context) {
|
|
29
|
-
context.report({
|
|
30
|
-
node,
|
|
31
|
-
messageId: "layers-public-api-not-allowed",
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
exports.reportLayersPublicApiNotAllowed = reportLayersPublicApiNotAllowed;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reportLayersPublicApiNotAllowed = exports.reportShouldBeFromPublicApi = void 0;
|
|
4
|
+
const feature_sliced_1 = require("../../../lib/feature-sliced");
|
|
5
|
+
const rule_1 = require("../../../lib/rule");
|
|
6
|
+
const convert_to_public_api_1 = require("./convert-to-public-api");
|
|
7
|
+
function reportShouldBeFromPublicApi(node, context) {
|
|
8
|
+
const pathsInfo = (0, feature_sliced_1.extractPathsInfo)(node, context);
|
|
9
|
+
const [fixedPath, valueToRemove] = (0, convert_to_public_api_1.convertToPublicApi)(pathsInfo);
|
|
10
|
+
context.report({
|
|
11
|
+
node: node.source,
|
|
12
|
+
messageId: "should-be-from-public-api",
|
|
13
|
+
data: {
|
|
14
|
+
fixedPath,
|
|
15
|
+
},
|
|
16
|
+
suggest: [
|
|
17
|
+
{
|
|
18
|
+
messageId: "remove-suggestion",
|
|
19
|
+
data: {
|
|
20
|
+
valueToRemove,
|
|
21
|
+
},
|
|
22
|
+
fix: (fixer) => fixer.replaceTextRange((0, rule_1.getSourceRangeWithoutQuotes)(node.source.range), fixedPath),
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.reportShouldBeFromPublicApi = reportShouldBeFromPublicApi;
|
|
28
|
+
function reportLayersPublicApiNotAllowed(node, context) {
|
|
29
|
+
context.report({
|
|
30
|
+
node,
|
|
31
|
+
messageId: "layers-public-api-not-allowed",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.reportLayersPublicApiNotAllowed = reportLayersPublicApiNotAllowed;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAndReport = void 0;
|
|
4
|
-
var validate_and_report_1 = require("./validate-and-report");
|
|
5
|
-
Object.defineProperty(exports, "validateAndReport", { enumerable: true, get: function () { return validate_and_report_1.validateAndReport; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAndReport = void 0;
|
|
4
|
+
var validate_and_report_1 = require("./validate-and-report");
|
|
5
|
+
Object.defineProperty(exports, "validateAndReport", { enumerable: true, get: function () { return validate_and_report_1.validateAndReport; } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isIndexFile = void 0;
|
|
4
|
-
function isIndexFile(segmentFiles) {
|
|
5
|
-
return /^index\.\w+/i.test(segmentFiles);
|
|
6
|
-
}
|
|
7
|
-
exports.isIndexFile = isIndexFile;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isIndexFile = void 0;
|
|
4
|
+
function isIndexFile(segmentFiles) {
|
|
5
|
+
return /^index\.\w+/i.test(segmentFiles);
|
|
6
|
+
}
|
|
7
|
+
exports.isIndexFile = isIndexFile;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isLayerPublicApi = void 0;
|
|
7
|
-
const picomatch_1 = __importDefault(require("picomatch"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const shared_1 = require("../../../lib/shared");
|
|
11
|
-
function isLayerPublicApi(context) {
|
|
12
|
-
const normalizedCurrentFilePath = (0,
|
|
13
|
-
const cwd = (0,
|
|
14
|
-
const layer = (0,
|
|
15
|
-
if ((0, shared_1.isNull)(layer)) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const matcher = (0, picomatch_1.default)([
|
|
19
|
-
`**/${layer}/index.*`,
|
|
20
|
-
]);
|
|
21
|
-
return matcher(normalizedCurrentFilePath);
|
|
22
|
-
}
|
|
23
|
-
exports.isLayerPublicApi = isLayerPublicApi;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isLayerPublicApi = void 0;
|
|
7
|
+
const picomatch_1 = __importDefault(require("picomatch"));
|
|
8
|
+
const feature_sliced_1 = require("../../../lib/feature-sliced");
|
|
9
|
+
const rule_1 = require("../../../lib/rule");
|
|
10
|
+
const shared_1 = require("../../../lib/shared");
|
|
11
|
+
function isLayerPublicApi(context) {
|
|
12
|
+
const normalizedCurrentFilePath = (0, rule_1.extractCurrentFilePath)(context);
|
|
13
|
+
const cwd = (0, rule_1.extractCwd)(context);
|
|
14
|
+
const layer = (0, feature_sliced_1.extractLayer)(normalizedCurrentFilePath, cwd);
|
|
15
|
+
if ((0, shared_1.isNull)(layer)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const matcher = (0, picomatch_1.default)([
|
|
19
|
+
`**/${layer}/index.*`,
|
|
20
|
+
]);
|
|
21
|
+
return matcher(normalizedCurrentFilePath);
|
|
22
|
+
}
|
|
23
|
+
exports.isLayerPublicApi = isLayerPublicApi;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSegmentsPublicApi = void 0;
|
|
4
|
-
const is_index_file_1 = require("./is-index-file");
|
|
5
|
-
function isSegmentsPublicApi(pathsInfo) {
|
|
6
|
-
const { fsdPartsOfTarget, validatedFeatureSlicedPartsOfTarget, isSameSegment, } = pathsInfo;
|
|
7
|
-
const isSegmentPublicApi = validatedFeatureSlicedPartsOfTarget.hasNotSegmentFiles
|
|
8
|
-
|| (0, is_index_file_1.isIndexFile)(fsdPartsOfTarget.segmentFiles);
|
|
9
|
-
return isSameSegment || isSegmentPublicApi;
|
|
10
|
-
}
|
|
11
|
-
exports.isSegmentsPublicApi = isSegmentsPublicApi;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSegmentsPublicApi = void 0;
|
|
4
|
+
const is_index_file_1 = require("./is-index-file");
|
|
5
|
+
function isSegmentsPublicApi(pathsInfo) {
|
|
6
|
+
const { fsdPartsOfTarget, validatedFeatureSlicedPartsOfTarget, isSameSegment, } = pathsInfo;
|
|
7
|
+
const isSegmentPublicApi = validatedFeatureSlicedPartsOfTarget.hasNotSegmentFiles
|
|
8
|
+
|| (0, is_index_file_1.isIndexFile)(fsdPartsOfTarget.segmentFiles);
|
|
9
|
+
return isSameSegment || isSegmentPublicApi;
|
|
10
|
+
}
|
|
11
|
+
exports.isSegmentsPublicApi = isSegmentsPublicApi;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSlicePublicApi = void 0;
|
|
4
|
-
function isSlicePublicApi(pathsInfo) {
|
|
5
|
-
return pathsInfo.validatedFeatureSlicedPartsOfTarget.hasNotSegment;
|
|
6
|
-
}
|
|
7
|
-
exports.isSlicePublicApi = isSlicePublicApi;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSlicePublicApi = void 0;
|
|
4
|
+
function isSlicePublicApi(pathsInfo) {
|
|
5
|
+
return pathsInfo.validatedFeatureSlicedPartsOfTarget.hasNotSegment;
|
|
6
|
+
}
|
|
7
|
+
exports.isSlicePublicApi = isSlicePublicApi;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shouldBeFromPublicApi = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const is_segments_public_api_1 = require("./is-segments-public-api");
|
|
7
|
-
const is_slice_public_api_1 = require("./is-slice-public-api");
|
|
8
|
-
function shouldBeFromSlicePublicApi(pathsInfo) {
|
|
9
|
-
const isFromAnotherSlice = !pathsInfo.isSameSlice;
|
|
10
|
-
return isFromAnotherSlice && !(0, is_slice_public_api_1.isSlicePublicApi)(pathsInfo);
|
|
11
|
-
}
|
|
12
|
-
function shouldBeFromSegmentsPublicApi(pathsInfo, validateOptions) {
|
|
13
|
-
const needValidateSegments = validateOptions.level === "segments";
|
|
14
|
-
return needValidateSegments && !(0, is_segments_public_api_1.isSegmentsPublicApi)(pathsInfo);
|
|
15
|
-
}
|
|
16
|
-
function shouldBeFromPublicApi(node, context, optionsWithDefault) {
|
|
17
|
-
const pathsInfo = (0,
|
|
18
|
-
const ruleOptions = (0,
|
|
19
|
-
return shouldBeFromSlicePublicApi(pathsInfo) || shouldBeFromSegmentsPublicApi(pathsInfo, ruleOptions);
|
|
20
|
-
}
|
|
21
|
-
exports.shouldBeFromPublicApi = shouldBeFromPublicApi;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldBeFromPublicApi = void 0;
|
|
4
|
+
const feature_sliced_1 = require("../../../lib/feature-sliced");
|
|
5
|
+
const rule_1 = require("../../../lib/rule");
|
|
6
|
+
const is_segments_public_api_1 = require("./is-segments-public-api");
|
|
7
|
+
const is_slice_public_api_1 = require("./is-slice-public-api");
|
|
8
|
+
function shouldBeFromSlicePublicApi(pathsInfo) {
|
|
9
|
+
const isFromAnotherSlice = !pathsInfo.isSameSlice;
|
|
10
|
+
return isFromAnotherSlice && !(0, is_slice_public_api_1.isSlicePublicApi)(pathsInfo);
|
|
11
|
+
}
|
|
12
|
+
function shouldBeFromSegmentsPublicApi(pathsInfo, validateOptions) {
|
|
13
|
+
const needValidateSegments = validateOptions.level === "segments";
|
|
14
|
+
return needValidateSegments && !(0, is_segments_public_api_1.isSegmentsPublicApi)(pathsInfo);
|
|
15
|
+
}
|
|
16
|
+
function shouldBeFromPublicApi(node, context, optionsWithDefault) {
|
|
17
|
+
const pathsInfo = (0, feature_sliced_1.extractPathsInfo)(node, context);
|
|
18
|
+
const ruleOptions = (0, rule_1.extractRuleOptions)(optionsWithDefault);
|
|
19
|
+
return shouldBeFromSlicePublicApi(pathsInfo) || shouldBeFromSegmentsPublicApi(pathsInfo, ruleOptions);
|
|
20
|
+
}
|
|
21
|
+
exports.shouldBeFromPublicApi = shouldBeFromPublicApi;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAndReportProgram = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const is_layer_public_api_1 = require("./is-layer-public-api");
|
|
7
|
-
function validateAndReportProgram(node, context, optionsWithDefault) {
|
|
8
|
-
if ((0,
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if ((0, is_layer_public_api_1.isLayerPublicApi)(context)) {
|
|
12
|
-
(0,
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.validateAndReportProgram = validateAndReportProgram;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAndReportProgram = void 0;
|
|
4
|
+
const rule_1 = require("../../../lib/rule");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const is_layer_public_api_1 = require("./is-layer-public-api");
|
|
7
|
+
function validateAndReportProgram(node, context, optionsWithDefault) {
|
|
8
|
+
if ((0, rule_1.isIgnoredCurrentFile)(context, optionsWithDefault)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if ((0, is_layer_public_api_1.isLayerPublicApi)(context)) {
|
|
12
|
+
(0, errors_1.reportLayersPublicApiNotAllowed)(node, context);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.validateAndReportProgram = validateAndReportProgram;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAndReport = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const should_be_from_public_api_1 = require("./should-be-from-public-api");
|
|
7
|
-
function validateAndReport(node, context, optionsWithDefault) {
|
|
8
|
-
if (!(0,
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if ((0,
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if ((0, should_be_from_public_api_1.shouldBeFromPublicApi)(node, context, optionsWithDefault)) {
|
|
15
|
-
(0,
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.validateAndReport = validateAndReport;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAndReport = void 0;
|
|
4
|
+
const rule_1 = require("../../../lib/rule");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const should_be_from_public_api_1 = require("./should-be-from-public-api");
|
|
7
|
+
function validateAndReport(node, context, optionsWithDefault) {
|
|
8
|
+
if (!(0, rule_1.hasPath)(node)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if ((0, rule_1.isIgnoredCurrentFile)(context, optionsWithDefault)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if ((0, should_be_from_public_api_1.shouldBeFromPublicApi)(node, context, optionsWithDefault)) {
|
|
15
|
+
(0, errors_1.reportShouldBeFromPublicApi)(node, context);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.validateAndReport = validateAndReport;
|