@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.
Files changed (78) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/config.js +27 -27
  3. package/dist/configs/import-order/index.js +20 -20
  4. package/dist/configs/import-order/recommended.js +28 -28
  5. package/dist/configs/import-order/with-newlines-and-type-group.js +28 -28
  6. package/dist/configs/import-order/with-newlines.js +28 -28
  7. package/dist/configs/import-order/with-type-group.js +28 -28
  8. package/dist/configs/recommended.js +11 -11
  9. package/dist/configs/rules.js +11 -11
  10. package/dist/index.js +24 -24
  11. package/dist/lib/{fsd-lib → feature-sliced}/extract-feature-sliced-parts.js +18 -18
  12. package/dist/lib/{fsd-lib → feature-sliced}/extract-layer.js +21 -21
  13. package/dist/lib/{fsd-lib → feature-sliced}/extract-paths-info.js +59 -59
  14. package/dist/lib/{fsd-lib → feature-sliced}/extract-segment.js +18 -18
  15. package/dist/lib/{fsd-lib → feature-sliced}/extract-slice.js +10 -10
  16. package/dist/lib/{fsd-lib → feature-sliced}/index.js +10 -10
  17. package/dist/lib/{fsd-lib → feature-sliced}/layers.js +16 -16
  18. package/dist/lib/{fsd-lib → feature-sliced}/validate-extracted-feature-sliced-parts.js +29 -29
  19. package/dist/lib/{path-lib → path}/convert-to-absolute.js +18 -18
  20. package/dist/lib/{path-lib → path}/index.js +9 -9
  21. package/dist/lib/{path-lib → path}/is-path-relative.js +7 -7
  22. package/dist/lib/{path-lib → path}/join-path.js +12 -12
  23. package/dist/lib/{path-lib → path}/normalize-path.js +19 -19
  24. package/dist/lib/{rule-lib → rule}/create-rule.js +7 -7
  25. package/dist/lib/{rule-lib → rule}/extract-current-file-path.js +11 -11
  26. package/dist/lib/{rule-lib → rule}/extract-cwd.js +13 -13
  27. package/dist/lib/{rule-lib → rule}/extract-node-path.js +13 -13
  28. package/dist/lib/rule/extract-paths.js +21 -0
  29. package/dist/lib/{rule-lib → rule}/extract-rule-options.js +7 -7
  30. package/dist/lib/{rule-lib → rule}/get-source-range-without-quotes.js +7 -7
  31. package/dist/lib/{rule-lib/can-validate.js → rule/has-path.js} +11 -11
  32. package/dist/lib/{rule-lib → rule}/index.js +27 -23
  33. package/dist/lib/{rule-lib → rule}/is-ignored-current-file.js +12 -12
  34. package/dist/lib/rule/is-ignored-target.js +12 -0
  35. package/dist/lib/{rule-lib → rule}/is-ignored.js +12 -12
  36. package/dist/lib/rule/is-node-type.js +16 -0
  37. package/dist/lib/{rule-lib → rule}/models.js +2 -2
  38. package/dist/lib/shared/get-by-reg-exp.js +12 -12
  39. package/dist/lib/shared/index.js +11 -11
  40. package/dist/lib/shared/is-null.js +7 -7
  41. package/dist/lib/shared/is-object.js +7 -7
  42. package/dist/lib/shared/is-undefined.js +7 -7
  43. package/dist/rules/absolute-relative/config.js +2 -2
  44. package/dist/rules/absolute-relative/index.js +51 -52
  45. package/dist/rules/absolute-relative/model/{errors-lib.js → errors.js} +17 -17
  46. package/dist/rules/absolute-relative/model/index.js +5 -5
  47. package/dist/rules/absolute-relative/model/should-be-absolute.js +16 -16
  48. package/dist/rules/absolute-relative/model/should-be-relative.js +21 -21
  49. package/dist/rules/absolute-relative/model/validate-and-report.js +24 -24
  50. package/dist/rules/layers-slices/config.js +2 -2
  51. package/dist/rules/layers-slices/index.js +55 -56
  52. package/dist/rules/layers-slices/model/{errors-lib.js → errors.js} +22 -14
  53. package/dist/rules/layers-slices/model/index.js +5 -5
  54. package/dist/rules/layers-slices/model/is-not-suitable-for-validation.js +17 -0
  55. package/dist/rules/layers-slices/model/specifiers/extract-import-specifiers.js +8 -0
  56. package/dist/rules/layers-slices/model/specifiers/has-errors-at-all-specifiers.js +9 -0
  57. package/dist/rules/layers-slices/model/specifiers/index.js +7 -0
  58. package/dist/rules/layers-slices/model/specifiers/validate-specifiers.js +8 -0
  59. package/dist/rules/layers-slices/model/validate-and-report.js +46 -22
  60. package/dist/rules/layers-slices/model/validate-node/index.js +16 -0
  61. package/dist/rules/layers-slices/model/validate-node/valid-by-layer-order.js +10 -0
  62. package/dist/rules/layers-slices/model/validate-node/valid-by-type-import.js +9 -0
  63. package/dist/rules/public-api/config.js +2 -2
  64. package/dist/rules/public-api/index.js +65 -65
  65. package/dist/rules/public-api/model/convert-to-public-api.js +24 -24
  66. package/dist/rules/public-api/model/{errors-lib.js → errors.js} +34 -34
  67. package/dist/rules/public-api/model/index.js +5 -5
  68. package/dist/rules/public-api/model/is-index-file.js +7 -7
  69. package/dist/rules/public-api/model/is-layer-public-api.js +23 -23
  70. package/dist/rules/public-api/model/is-segments-public-api.js +11 -11
  71. package/dist/rules/public-api/model/is-slice-public-api.js +7 -7
  72. package/dist/rules/public-api/model/should-be-from-public-api.js +21 -21
  73. package/dist/rules/public-api/model/validate-and-report-program.js +15 -15
  74. package/dist/rules/public-api/model/validate-and-report.js +18 -18
  75. package/package.json +15 -14
  76. package/dist/lib/fsd-lib/extract-paths.js +0 -19
  77. package/dist/lib/rule-lib/is-node-type.js +0 -17
  78. package/dist/rules/layers-slices/model/can-import-layer.js +0 -22
@@ -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,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getByRegExp = void 0;
4
- function getByRegExp(target, regExp, fromEnd = false) {
5
- const results = target.match(regExp) || [];
6
- if (fromEnd) {
7
- const lastResult = results[results.length - 1];
8
- return lastResult || null;
9
- }
10
- return results[0] || null;
11
- }
12
- exports.getByRegExp = getByRegExp;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getByRegExp = void 0;
4
+ function getByRegExp(target, regExp, fromEnd = false) {
5
+ const results = target.match(regExp) || [];
6
+ if (fromEnd) {
7
+ const lastResult = results[results.length - 1];
8
+ return lastResult || null;
9
+ }
10
+ return results[0] || null;
11
+ }
12
+ exports.getByRegExp = getByRegExp;
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isUndefined = exports.isNull = exports.isObject = exports.getByRegExp = void 0;
4
- var get_by_reg_exp_1 = require("./get-by-reg-exp");
5
- Object.defineProperty(exports, "getByRegExp", { enumerable: true, get: function () { return get_by_reg_exp_1.getByRegExp; } });
6
- var is_object_1 = require("./is-object");
7
- Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return is_object_1.isObject; } });
8
- var is_null_1 = require("./is-null");
9
- Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return is_null_1.isNull; } });
10
- var is_undefined_1 = require("./is-undefined");
11
- Object.defineProperty(exports, "isUndefined", { enumerable: true, get: function () { return is_undefined_1.isUndefined; } });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUndefined = exports.isNull = exports.isObject = exports.getByRegExp = void 0;
4
+ var get_by_reg_exp_1 = require("./get-by-reg-exp");
5
+ Object.defineProperty(exports, "getByRegExp", { enumerable: true, get: function () { return get_by_reg_exp_1.getByRegExp; } });
6
+ var is_object_1 = require("./is-object");
7
+ Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return is_object_1.isObject; } });
8
+ var is_null_1 = require("./is-null");
9
+ Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return is_null_1.isNull; } });
10
+ var is_undefined_1 = require("./is-undefined");
11
+ Object.defineProperty(exports, "isUndefined", { enumerable: true, get: function () { return is_undefined_1.isUndefined; } });
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNull = void 0;
4
- function isNull(target) {
5
- return target === null;
6
- }
7
- exports.isNull = isNull;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNull = void 0;
4
+ function isNull(target) {
5
+ return target === null;
6
+ }
7
+ exports.isNull = isNull;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isObject = void 0;
4
- function isObject(target) {
5
- return (typeof target === 'object' || typeof target === 'function') && (target !== null);
6
- }
7
- exports.isObject = isObject;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObject = void 0;
4
+ function isObject(target) {
5
+ return (typeof target === 'object' || typeof target === 'function') && (target !== null);
6
+ }
7
+ exports.isObject = isObject;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isUndefined = void 0;
4
- function isUndefined(target) {
5
- return target === undefined;
6
- }
7
- exports.isUndefined = isUndefined;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUndefined = void 0;
4
+ function isUndefined(target) {
5
+ return target === undefined;
6
+ }
7
+ exports.isUndefined = isUndefined;
@@ -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,52 +1,51 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const rule_lib_1 = require("../../lib/rule-lib");
4
- const model_1 = require("./model");
5
- exports.default = (0, rule_lib_1.createRule)({
6
- name: 'absolute-relative',
7
- meta: {
8
- type: 'problem',
9
- docs: {
10
- description: 'Checks for absolute and relative paths',
11
- recommended: false,
12
- },
13
- messages: {
14
- ["must-be-relative-path"]: 'There must be relative paths',
15
- ["must-be-absolute-path"]: 'There must be absolute paths',
16
- },
17
- schema: [
18
- {
19
- type: 'object',
20
- properties: {
21
- ignoreInFilesPatterns: {
22
- type: 'array',
23
- items: {
24
- type: 'string',
25
- },
26
- },
27
- },
28
- },
29
- ],
30
- },
31
- defaultOptions: [
32
- {
33
- ignoreInFilesPatterns: [],
34
- },
35
- ],
36
- create(context, optionsWithDefault) {
37
- return {
38
- ImportDeclaration(node) {
39
- (0, model_1.validateAndReport)(node, context, optionsWithDefault);
40
- },
41
- ImportExpression(node) {
42
- (0, model_1.validateAndReport)(node, context, optionsWithDefault);
43
- },
44
- ExportAllDeclaration(node) {
45
- (0, model_1.validateAndReport)(node, context, optionsWithDefault, { needCheckForAbsolute: false });
46
- },
47
- ExportNamedDeclaration(node) {
48
- (0, model_1.validateAndReport)(node, context, optionsWithDefault, { needCheckForAbsolute: false });
49
- },
50
- };
51
- },
52
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const rule_1 = require("../../lib/rule");
4
+ const model_1 = require("./model");
5
+ exports.default = (0, rule_1.createRule)({
6
+ name: 'absolute-relative',
7
+ meta: {
8
+ type: 'problem',
9
+ docs: {
10
+ description: 'Checks for absolute and relative paths',
11
+ },
12
+ messages: {
13
+ ["must-be-relative-path"]: 'There must be relative paths',
14
+ ["must-be-absolute-path"]: 'There must be absolute paths',
15
+ },
16
+ schema: [
17
+ {
18
+ type: 'object',
19
+ properties: {
20
+ ignoreInFilesPatterns: {
21
+ type: 'array',
22
+ items: {
23
+ type: 'string',
24
+ },
25
+ },
26
+ },
27
+ },
28
+ ],
29
+ },
30
+ defaultOptions: [
31
+ {
32
+ ignoreInFilesPatterns: [],
33
+ },
34
+ ],
35
+ create(context, optionsWithDefault) {
36
+ return {
37
+ ImportDeclaration(node) {
38
+ (0, model_1.validateAndReport)(node, context, optionsWithDefault);
39
+ },
40
+ ImportExpression(node) {
41
+ (0, model_1.validateAndReport)(node, context, optionsWithDefault);
42
+ },
43
+ ExportAllDeclaration(node) {
44
+ (0, model_1.validateAndReport)(node, context, optionsWithDefault, { needCheckForAbsolute: false });
45
+ },
46
+ ExportNamedDeclaration(node) {
47
+ (0, model_1.validateAndReport)(node, context, optionsWithDefault, { needCheckForAbsolute: false });
48
+ },
49
+ };
50
+ },
51
+ });
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reportShouldBeAbsolute = exports.reportShouldBeRelative = void 0;
4
- function reportShouldBeRelative(node, context) {
5
- context.report({
6
- node: node.source,
7
- messageId: "must-be-relative-path",
8
- });
9
- }
10
- exports.reportShouldBeRelative = reportShouldBeRelative;
11
- function reportShouldBeAbsolute(node, context) {
12
- context.report({
13
- node: node.source,
14
- messageId: "must-be-absolute-path",
15
- });
16
- }
17
- exports.reportShouldBeAbsolute = reportShouldBeAbsolute;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reportShouldBeAbsolute = exports.reportShouldBeRelative = void 0;
4
+ function reportShouldBeRelative(node, context) {
5
+ context.report({
6
+ node: node.source,
7
+ messageId: "must-be-relative-path",
8
+ });
9
+ }
10
+ exports.reportShouldBeRelative = reportShouldBeRelative;
11
+ function reportShouldBeAbsolute(node, context) {
12
+ context.report({
13
+ node: node.source,
14
+ messageId: "must-be-absolute-path",
15
+ });
16
+ }
17
+ exports.reportShouldBeAbsolute = reportShouldBeAbsolute;
@@ -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,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldBeAbsolute = void 0;
4
- const path_lib_1 = require("../../../lib/path-lib");
5
- function shouldBeAbsolute(pathsInfo) {
6
- const { normalizedTargetPath, fsdPartsOfTarget, fsdPartsOfCurrentFile, hasUnknownLayers, } = pathsInfo;
7
- const isAbsolute = !(0, path_lib_1.isPathRelative)(normalizedTargetPath);
8
- if (isAbsolute) {
9
- return false;
10
- }
11
- if (hasUnknownLayers) {
12
- return false;
13
- }
14
- return fsdPartsOfCurrentFile.layer !== fsdPartsOfTarget.layer;
15
- }
16
- exports.shouldBeAbsolute = shouldBeAbsolute;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldBeAbsolute = void 0;
4
+ const path_1 = require("../../../lib/path");
5
+ function shouldBeAbsolute(pathsInfo) {
6
+ const { normalizedTargetPath, fsdPartsOfTarget, fsdPartsOfCurrentFile, hasUnknownLayers, } = pathsInfo;
7
+ const isAbsolute = !(0, path_1.isPathRelative)(normalizedTargetPath);
8
+ if (isAbsolute) {
9
+ return false;
10
+ }
11
+ if (hasUnknownLayers) {
12
+ return false;
13
+ }
14
+ return fsdPartsOfCurrentFile.layer !== fsdPartsOfTarget.layer;
15
+ }
16
+ exports.shouldBeAbsolute = shouldBeAbsolute;
@@ -1,21 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldBeRelative = void 0;
4
- const path_lib_1 = require("../../../lib/path-lib");
5
- function shouldBeRelative(pathsInfo) {
6
- const { validatedFeatureSlicedPartsOfCurrentFile, normalizedTargetPath, isSameLayerWithoutSlices, isSameLayer, isSameSlice, } = pathsInfo;
7
- const isRelative = (0, path_lib_1.isPathRelative)(normalizedTargetPath);
8
- if (isRelative) {
9
- return false;
10
- }
11
- const isImportToLayerPublicApi = validatedFeatureSlicedPartsOfCurrentFile.hasNotSlice && isSameLayer;
12
- if (isImportToLayerPublicApi) {
13
- return true;
14
- }
15
- if (isSameLayerWithoutSlices) {
16
- return true;
17
- }
18
- const isSameLayerAndSlice = isSameLayer && isSameSlice;
19
- return isSameLayerAndSlice;
20
- }
21
- exports.shouldBeRelative = shouldBeRelative;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldBeRelative = void 0;
4
+ const path_1 = require("../../../lib/path");
5
+ function shouldBeRelative(pathsInfo) {
6
+ const { validatedFeatureSlicedPartsOfCurrentFile, normalizedTargetPath, isSameLayerWithoutSlices, isSameLayer, isSameSlice, } = pathsInfo;
7
+ const isRelative = (0, path_1.isPathRelative)(normalizedTargetPath);
8
+ if (isRelative) {
9
+ return false;
10
+ }
11
+ const isImportToLayerPublicApi = validatedFeatureSlicedPartsOfCurrentFile.hasNotSlice && isSameLayer;
12
+ if (isImportToLayerPublicApi) {
13
+ return true;
14
+ }
15
+ if (isSameLayerWithoutSlices) {
16
+ return true;
17
+ }
18
+ const isSameLayerAndSlice = isSameLayer && isSameSlice;
19
+ return isSameLayerAndSlice;
20
+ }
21
+ exports.shouldBeRelative = shouldBeRelative;
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateAndReport = void 0;
4
- const fsd_lib_1 = require("../../../lib/fsd-lib");
5
- const rule_lib_1 = require("../../../lib/rule-lib");
6
- const errors_lib_1 = require("./errors-lib");
7
- const should_be_absolute_1 = require("./should-be-absolute");
8
- const should_be_relative_1 = require("./should-be-relative");
9
- function validateAndReport(node, context, optionsWithDefault, options = { needCheckForAbsolute: true }) {
10
- if (!(0, rule_lib_1.canValidate)(node)) {
11
- return;
12
- }
13
- if ((0, rule_lib_1.isIgnoredCurrentFile)(context, optionsWithDefault)) {
14
- return;
15
- }
16
- const pathsInfo = (0, fsd_lib_1.extractPathsInfo)(node, context);
17
- if ((0, should_be_relative_1.shouldBeRelative)(pathsInfo)) {
18
- (0, errors_lib_1.reportShouldBeRelative)(node, context);
19
- }
20
- if (options.needCheckForAbsolute && (0, should_be_absolute_1.shouldBeAbsolute)(pathsInfo)) {
21
- (0, errors_lib_1.reportShouldBeAbsolute)(node, context);
22
- }
23
- }
24
- exports.validateAndReport = validateAndReport;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAndReport = void 0;
4
+ const feature_sliced_1 = require("../../../lib/feature-sliced");
5
+ const rule_1 = require("../../../lib/rule");
6
+ const errors_1 = require("./errors");
7
+ const should_be_absolute_1 = require("./should-be-absolute");
8
+ const should_be_relative_1 = require("./should-be-relative");
9
+ function validateAndReport(node, context, optionsWithDefault, options = { needCheckForAbsolute: true }) {
10
+ if (!(0, rule_1.hasPath)(node)) {
11
+ return;
12
+ }
13
+ if ((0, rule_1.isIgnoredCurrentFile)(context, optionsWithDefault)) {
14
+ return;
15
+ }
16
+ const pathsInfo = (0, feature_sliced_1.extractPathsInfo)(node, context);
17
+ if ((0, should_be_relative_1.shouldBeRelative)(pathsInfo)) {
18
+ (0, errors_1.reportShouldBeRelative)(node, context);
19
+ }
20
+ if (options.needCheckForAbsolute && (0, should_be_absolute_1.shouldBeAbsolute)(pathsInfo)) {
21
+ (0, errors_1.reportShouldBeAbsolute)(node, context);
22
+ }
23
+ }
24
+ exports.validateAndReport = validateAndReport;
@@ -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,56 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const rule_lib_1 = require("../../lib/rule-lib");
4
- const model_1 = require("./model");
5
- exports.default = (0, rule_lib_1.createRule)({
6
- name: 'layers-slices',
7
- meta: {
8
- type: 'problem',
9
- docs: {
10
- description: 'Checks layer imports',
11
- recommended: false,
12
- },
13
- messages: {
14
- ["can-not-import"]: 'You cannot import layer "{{ importLayer }}" into "{{ currentFileLayer }}" (shared -> entities -> features -> widgets -> pages -> processes -> app)',
15
- },
16
- schema: [
17
- {
18
- type: 'object',
19
- properties: {
20
- allowTypeImports: {
21
- type: 'boolean',
22
- },
23
- ignorePatterns: {
24
- type: 'array',
25
- items: {
26
- type: 'string',
27
- },
28
- },
29
- ignoreInFilesPatterns: {
30
- type: 'array',
31
- items: {
32
- type: 'string',
33
- },
34
- },
35
- },
36
- },
37
- ],
38
- },
39
- defaultOptions: [
40
- {
41
- allowTypeImports: true,
42
- ignorePatterns: [],
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
- };
55
- },
56
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const rule_1 = require("../../lib/rule");
4
+ const model_1 = require("./model");
5
+ exports.default = (0, rule_1.createRule)({
6
+ name: 'layers-slices',
7
+ meta: {
8
+ type: 'problem',
9
+ docs: {
10
+ description: 'Checks layer imports',
11
+ },
12
+ messages: {
13
+ ["can-not-import"]: 'You cannot import layer "{{ importLayer }}" into "{{ currentFileLayer }}" (shared -> entities -> features -> widgets -> pages -> processes -> app)',
14
+ },
15
+ schema: [
16
+ {
17
+ type: 'object',
18
+ properties: {
19
+ allowTypeImports: {
20
+ type: 'boolean',
21
+ },
22
+ ignorePatterns: {
23
+ type: 'array',
24
+ items: {
25
+ type: 'string',
26
+ },
27
+ },
28
+ ignoreInFilesPatterns: {
29
+ type: 'array',
30
+ items: {
31
+ type: 'string',
32
+ },
33
+ },
34
+ },
35
+ },
36
+ ],
37
+ },
38
+ defaultOptions: [
39
+ {
40
+ allowTypeImports: true,
41
+ ignorePatterns: [],
42
+ ignoreInFilesPatterns: [],
43
+ },
44
+ ],
45
+ create(context, optionsWithDefault) {
46
+ return {
47
+ ImportDeclaration(node) {
48
+ (0, model_1.validateAndReport)(node, context, optionsWithDefault);
49
+ },
50
+ ImportExpression(node) {
51
+ (0, model_1.validateAndReport)(node, context, optionsWithDefault);
52
+ },
53
+ };
54
+ },
55
+ });
@@ -1,14 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reportCanNotImportLayer = void 0;
4
- function reportCanNotImportLayer(context, node, pathsInfo) {
5
- context.report({
6
- node: node.source,
7
- messageId: "can-not-import",
8
- data: {
9
- importLayer: pathsInfo.fsdPartsOfTarget.layer,
10
- currentFileLayer: pathsInfo.fsdPartsOfCurrentFile.layer,
11
- },
12
- });
13
- }
14
- exports.reportCanNotImportLayer = reportCanNotImportLayer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reportCanNotImportLayer = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ function reportCanNotImportLayer(context, node, pathsInfo) {
6
+ function getReportPosition(validatedNode) {
7
+ const isSpecifier = validatedNode.type === utils_1.AST_NODE_TYPES.ImportSpecifier;
8
+ if (isSpecifier) {
9
+ return validatedNode;
10
+ }
11
+ return validatedNode.source;
12
+ }
13
+ context.report({
14
+ node: getReportPosition(node),
15
+ messageId: "can-not-import",
16
+ data: {
17
+ importLayer: pathsInfo.fsdPartsOfTarget.layer,
18
+ currentFileLayer: pathsInfo.fsdPartsOfCurrentFile.layer,
19
+ },
20
+ });
21
+ }
22
+ exports.reportCanNotImportLayer = reportCanNotImportLayer;
@@ -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; } });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNotSuitableForValidation = void 0;
4
+ function isNotSuitableForValidation(pathsInfo) {
5
+ const { isSameSlice, isSameLayerWithoutSlices, hasUnknownLayers, } = pathsInfo;
6
+ if (hasUnknownLayers) {
7
+ return true;
8
+ }
9
+ if (isSameSlice) {
10
+ return true;
11
+ }
12
+ if (isSameLayerWithoutSlices) {
13
+ return true;
14
+ }
15
+ return false;
16
+ }
17
+ exports.isNotSuitableForValidation = isNotSuitableForValidation;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractImportSpecifiers = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ function extractImportSpecifiers(node) {
6
+ return node.specifiers.filter((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier);
7
+ }
8
+ exports.extractImportSpecifiers = extractImportSpecifiers;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasErrorsAtAllSpecifiers = void 0;
4
+ function hasErrorsAtAllSpecifiers(specifiers, invalidSpecifiers) {
5
+ const allSpecifiersCount = specifiers.length;
6
+ const invalidSpecifiersCount = invalidSpecifiers.length;
7
+ return invalidSpecifiersCount === allSpecifiersCount;
8
+ }
9
+ exports.hasErrorsAtAllSpecifiers = hasErrorsAtAllSpecifiers;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasErrorsAtAllSpecifiers = exports.validateSpecifiers = void 0;
4
+ var validate_specifiers_1 = require("./validate-specifiers");
5
+ Object.defineProperty(exports, "validateSpecifiers", { enumerable: true, get: function () { return validate_specifiers_1.validateSpecifiers; } });
6
+ var has_errors_at_all_specifiers_1 = require("./has-errors-at-all-specifiers");
7
+ Object.defineProperty(exports, "hasErrorsAtAllSpecifiers", { enumerable: true, get: function () { return has_errors_at_all_specifiers_1.hasErrorsAtAllSpecifiers; } });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSpecifiers = void 0;
4
+ const valid_by_type_import_1 = require("../validate-node/valid-by-type-import");
5
+ function validateSpecifiers(specifiers, allowTypeImports) {
6
+ return specifiers.filter((specifier) => !(0, valid_by_type_import_1.validByTypeImport)(specifier, allowTypeImports));
7
+ }
8
+ exports.validateSpecifiers = validateSpecifiers;