@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
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.0.5](https://github.com/conarti/eslint-plugin-fsd/compare/v1.0.4...v1.0.5) (2023-08-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **layers-slices:** work with inline type imports ([247883e](https://github.com/conarti/eslint-plugin-fsd/commit/247883ec4154c229dadd540d22f04b9920763b3e))
7
+ * **public-api:** add missed 'type' field at options validation schema ([54ec4e2](https://github.com/conarti/eslint-plugin-fsd/commit/54ec4e2b425d154e2118475fc7ba56699bcbd131))
8
+
9
+
1
10
  ## [1.0.4](https://github.com/conarti/eslint-plugin-fsd/compare/v1.0.3...v1.0.4) (2023-07-03)
2
11
 
3
12
 
package/dist/config.js CHANGED
@@ -1,27 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RULE_DOCS_URL = exports.pathSeparator = exports.segments = exports.layersWithSlices = exports.layersWithoutSlices = exports.layers = void 0;
4
- exports.layers = [
5
- 'shared',
6
- 'entities',
7
- 'features',
8
- 'widgets',
9
- 'pages',
10
- 'processes',
11
- 'app',
12
- ];
13
- exports.layersWithoutSlices = [
14
- 'shared',
15
- 'app',
16
- ];
17
- exports.layersWithSlices = exports.layers.filter((layer) => !exports.layersWithoutSlices.includes(layer));
18
- exports.segments = [
19
- 'ui',
20
- 'model',
21
- 'lib',
22
- 'api',
23
- 'config',
24
- 'assets',
25
- ];
26
- exports.pathSeparator = '/';
27
- exports.RULE_DOCS_URL = 'https://example.com/rule/';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RULE_DOCS_URL = exports.pathSeparator = exports.segments = exports.layersWithSlices = exports.layersWithoutSlices = exports.layers = void 0;
4
+ exports.layers = [
5
+ 'shared',
6
+ 'entities',
7
+ 'features',
8
+ 'widgets',
9
+ 'pages',
10
+ 'processes',
11
+ 'app',
12
+ ];
13
+ exports.layersWithoutSlices = [
14
+ 'shared',
15
+ 'app',
16
+ ];
17
+ exports.layersWithSlices = exports.layers.filter((layer) => !exports.layersWithoutSlices.includes(layer));
18
+ exports.segments = [
19
+ 'ui',
20
+ 'model',
21
+ 'lib',
22
+ 'api',
23
+ 'config',
24
+ 'assets',
25
+ ];
26
+ exports.pathSeparator = '/';
27
+ exports.RULE_DOCS_URL = 'https://example.com/rule/';
@@ -1,20 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const recommended_1 = __importDefault(require("./recommended"));
6
- const with_newlines_1 = __importDefault(require("./with-newlines"));
7
- const with_newlines_and_type_group_1 = __importDefault(require("./with-newlines-and-type-group"));
8
- const with_type_group_1 = __importDefault(require("./with-type-group"));
9
- module.exports = {
10
- parserOptions: {
11
- ecmaVersion: '2015',
12
- sourceType: 'module',
13
- },
14
- configs: {
15
- recommended: recommended_1.default,
16
- 'with-newlines': with_newlines_1.default,
17
- 'with-type-group': with_type_group_1.default,
18
- 'with-newlines-and-type-group': with_newlines_and_type_group_1.default,
19
- },
20
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const recommended_1 = __importDefault(require("./recommended"));
6
+ const with_newlines_1 = __importDefault(require("./with-newlines"));
7
+ const with_newlines_and_type_group_1 = __importDefault(require("./with-newlines-and-type-group"));
8
+ const with_type_group_1 = __importDefault(require("./with-type-group"));
9
+ module.exports = {
10
+ parserOptions: {
11
+ ecmaVersion: '2015',
12
+ sourceType: 'module',
13
+ },
14
+ configs: {
15
+ recommended: recommended_1.default,
16
+ 'with-newlines': with_newlines_1.default,
17
+ 'with-type-group': with_type_group_1.default,
18
+ 'with-newlines-and-type-group': with_newlines_and_type_group_1.default,
19
+ },
20
+ };
@@ -1,28 +1,28 @@
1
- "use strict";
2
- const config_1 = require("../../config");
3
- const LAYERS_REVERSED = [...config_1.layers].reverse();
4
- module.exports = {
5
- plugins: [
6
- 'import',
7
- ],
8
- rules: {
9
- 'import/order': [
10
- 2,
11
- {
12
- alphabetize: {
13
- order: 'asc',
14
- caseInsensitive: true,
15
- },
16
- 'newlines-between': 'never',
17
- pathGroups: LAYERS_REVERSED.map((layer) => ({
18
- pattern: `**/?(*)${layer}{,/**}`,
19
- group: 'internal',
20
- position: 'after',
21
- })),
22
- distinctGroup: false,
23
- pathGroupsExcludedImportTypes: ['builtin'],
24
- groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
25
- },
26
- ],
27
- },
28
- };
1
+ "use strict";
2
+ const config_1 = require("../../config");
3
+ const LAYERS_REVERSED = [...config_1.layers].reverse();
4
+ module.exports = {
5
+ plugins: [
6
+ 'import',
7
+ ],
8
+ rules: {
9
+ 'import/order': [
10
+ 2,
11
+ {
12
+ alphabetize: {
13
+ order: 'asc',
14
+ caseInsensitive: true,
15
+ },
16
+ 'newlines-between': 'never',
17
+ pathGroups: LAYERS_REVERSED.map((layer) => ({
18
+ pattern: `**/?(*)${layer}{,/**}`,
19
+ group: 'internal',
20
+ position: 'after',
21
+ })),
22
+ distinctGroup: false,
23
+ pathGroupsExcludedImportTypes: ['builtin'],
24
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
25
+ },
26
+ ],
27
+ },
28
+ };
@@ -1,28 +1,28 @@
1
- "use strict";
2
- const config_1 = require("../../config");
3
- const LAYERS_REVERSED = [...config_1.layers].reverse();
4
- module.exports = {
5
- plugins: [
6
- 'import',
7
- ],
8
- rules: {
9
- 'import/order': [
10
- 2,
11
- {
12
- alphabetize: {
13
- order: 'asc',
14
- caseInsensitive: true,
15
- },
16
- 'newlines-between': 'always',
17
- pathGroups: LAYERS_REVERSED.map((layer) => ({
18
- pattern: `**/?(*)${layer}{,/**}`,
19
- group: 'internal',
20
- position: 'after',
21
- })),
22
- distinctGroup: false,
23
- pathGroupsExcludedImportTypes: ['builtin', 'type'],
24
- groups: ['builtin', 'external', 'internal', 'type', 'parent', 'sibling', 'index'],
25
- },
26
- ],
27
- },
28
- };
1
+ "use strict";
2
+ const config_1 = require("../../config");
3
+ const LAYERS_REVERSED = [...config_1.layers].reverse();
4
+ module.exports = {
5
+ plugins: [
6
+ 'import',
7
+ ],
8
+ rules: {
9
+ 'import/order': [
10
+ 2,
11
+ {
12
+ alphabetize: {
13
+ order: 'asc',
14
+ caseInsensitive: true,
15
+ },
16
+ 'newlines-between': 'always',
17
+ pathGroups: LAYERS_REVERSED.map((layer) => ({
18
+ pattern: `**/?(*)${layer}{,/**}`,
19
+ group: 'internal',
20
+ position: 'after',
21
+ })),
22
+ distinctGroup: false,
23
+ pathGroupsExcludedImportTypes: ['builtin', 'type'],
24
+ groups: ['builtin', 'external', 'internal', 'type', 'parent', 'sibling', 'index'],
25
+ },
26
+ ],
27
+ },
28
+ };
@@ -1,28 +1,28 @@
1
- "use strict";
2
- const config_1 = require("../../config");
3
- const LAYERS_REVERSED = [...config_1.layers].reverse();
4
- module.exports = {
5
- plugins: [
6
- 'import',
7
- ],
8
- rules: {
9
- 'import/order': [
10
- 2,
11
- {
12
- alphabetize: {
13
- order: 'asc',
14
- caseInsensitive: true,
15
- },
16
- 'newlines-between': 'always',
17
- pathGroups: LAYERS_REVERSED.map((layer) => ({
18
- pattern: `**/?(*)${layer}{,/**}`,
19
- group: 'internal',
20
- position: 'after',
21
- })),
22
- distinctGroup: false,
23
- pathGroupsExcludedImportTypes: ['builtin'],
24
- groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
25
- },
26
- ],
27
- },
28
- };
1
+ "use strict";
2
+ const config_1 = require("../../config");
3
+ const LAYERS_REVERSED = [...config_1.layers].reverse();
4
+ module.exports = {
5
+ plugins: [
6
+ 'import',
7
+ ],
8
+ rules: {
9
+ 'import/order': [
10
+ 2,
11
+ {
12
+ alphabetize: {
13
+ order: 'asc',
14
+ caseInsensitive: true,
15
+ },
16
+ 'newlines-between': 'always',
17
+ pathGroups: LAYERS_REVERSED.map((layer) => ({
18
+ pattern: `**/?(*)${layer}{,/**}`,
19
+ group: 'internal',
20
+ position: 'after',
21
+ })),
22
+ distinctGroup: false,
23
+ pathGroupsExcludedImportTypes: ['builtin'],
24
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
25
+ },
26
+ ],
27
+ },
28
+ };
@@ -1,28 +1,28 @@
1
- "use strict";
2
- const config_1 = require("../../config");
3
- const LAYERS_REVERSED = [...config_1.layers].reverse();
4
- module.exports = {
5
- plugins: [
6
- 'import',
7
- ],
8
- rules: {
9
- 'import/order': [
10
- 2,
11
- {
12
- alphabetize: {
13
- order: 'asc',
14
- caseInsensitive: true,
15
- },
16
- 'newlines-between': 'never',
17
- pathGroups: LAYERS_REVERSED.map((layer) => ({
18
- pattern: `**/?(*)${layer}{,/**}`,
19
- group: 'internal',
20
- position: 'after',
21
- })),
22
- distinctGroup: false,
23
- pathGroupsExcludedImportTypes: ['builtin', 'type'],
24
- groups: ['builtin', 'external', 'internal', 'type', 'parent', 'sibling', 'index'],
25
- },
26
- ],
27
- },
28
- };
1
+ "use strict";
2
+ const config_1 = require("../../config");
3
+ const LAYERS_REVERSED = [...config_1.layers].reverse();
4
+ module.exports = {
5
+ plugins: [
6
+ 'import',
7
+ ],
8
+ rules: {
9
+ 'import/order': [
10
+ 2,
11
+ {
12
+ alphabetize: {
13
+ order: 'asc',
14
+ caseInsensitive: true,
15
+ },
16
+ 'newlines-between': 'never',
17
+ pathGroups: LAYERS_REVERSED.map((layer) => ({
18
+ pattern: `**/?(*)${layer}{,/**}`,
19
+ group: 'internal',
20
+ position: 'after',
21
+ })),
22
+ distinctGroup: false,
23
+ pathGroupsExcludedImportTypes: ['builtin', 'type'],
24
+ groups: ['builtin', 'external', 'internal', 'type', 'parent', 'sibling', 'index'],
25
+ },
26
+ ],
27
+ },
28
+ };
@@ -1,11 +1,11 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const path_1 = __importDefault(require("path"));
6
- module.exports = {
7
- extends: [
8
- path_1.default.resolve(__dirname, './rules'),
9
- path_1.default.resolve(__dirname, './import-order/recommended'),
10
- ],
11
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const path_1 = __importDefault(require("path"));
6
+ module.exports = {
7
+ extends: [
8
+ path_1.default.resolve(__dirname, './rules'),
9
+ path_1.default.resolve(__dirname, './import-order/recommended'),
10
+ ],
11
+ };
@@ -1,11 +1,11 @@
1
- "use strict";
2
- module.exports = {
3
- plugins: [
4
- '@conarti/feature-sliced',
5
- ],
6
- rules: {
7
- '@conarti/feature-sliced/layers-slices': 'error',
8
- '@conarti/feature-sliced/absolute-relative': 'error',
9
- '@conarti/feature-sliced/public-api': 'error',
10
- },
11
- };
1
+ "use strict";
2
+ module.exports = {
3
+ plugins: [
4
+ '@conarti/feature-sliced',
5
+ ],
6
+ rules: {
7
+ '@conarti/feature-sliced/layers-slices': 'error',
8
+ '@conarti/feature-sliced/absolute-relative': 'error',
9
+ '@conarti/feature-sliced/public-api': 'error',
10
+ },
11
+ };
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const recommended_1 = __importDefault(require("./configs/recommended"));
6
- const rules_1 = __importDefault(require("./configs/rules"));
7
- const absolute_relative_1 = __importDefault(require("./rules/absolute-relative"));
8
- const layers_slices_1 = __importDefault(require("./rules/layers-slices"));
9
- const public_api_1 = __importDefault(require("./rules/public-api"));
10
- module.exports = {
11
- parserOptions: {
12
- ecmaVersion: '2015',
13
- sourceType: 'module',
14
- },
15
- rules: {
16
- 'absolute-relative': absolute_relative_1.default,
17
- 'layers-slices': layers_slices_1.default,
18
- 'public-api': public_api_1.default,
19
- },
20
- configs: {
21
- recommended: recommended_1.default,
22
- rules: rules_1.default,
23
- },
24
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const recommended_1 = __importDefault(require("./configs/recommended"));
6
+ const rules_1 = __importDefault(require("./configs/rules"));
7
+ const absolute_relative_1 = __importDefault(require("./rules/absolute-relative"));
8
+ const layers_slices_1 = __importDefault(require("./rules/layers-slices"));
9
+ const public_api_1 = __importDefault(require("./rules/public-api"));
10
+ module.exports = {
11
+ parserOptions: {
12
+ ecmaVersion: '2015',
13
+ sourceType: 'module',
14
+ },
15
+ rules: {
16
+ 'absolute-relative': absolute_relative_1.default,
17
+ 'layers-slices': layers_slices_1.default,
18
+ 'public-api': public_api_1.default,
19
+ },
20
+ configs: {
21
+ recommended: recommended_1.default,
22
+ rules: rules_1.default,
23
+ },
24
+ };
@@ -1,18 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractFeatureSlicedParts = void 0;
4
- const extract_layer_1 = require("./extract-layer");
5
- const extract_segment_1 = require("./extract-segment");
6
- const extract_slice_1 = require("./extract-slice");
7
- function extractFeatureSlicedParts(targetPath, cwd) {
8
- const layer = (0, extract_layer_1.extractLayer)(targetPath, cwd);
9
- const slice = (0, extract_slice_1.extractSlice)(targetPath);
10
- const [segment, segmentFiles] = (0, extract_segment_1.extractSegment)(targetPath);
11
- return {
12
- layer,
13
- slice,
14
- segment,
15
- segmentFiles,
16
- };
17
- }
18
- exports.extractFeatureSlicedParts = extractFeatureSlicedParts;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractFeatureSlicedParts = void 0;
4
+ const extract_layer_1 = require("./extract-layer");
5
+ const extract_segment_1 = require("./extract-segment");
6
+ const extract_slice_1 = require("./extract-slice");
7
+ function extractFeatureSlicedParts(targetPath, cwd) {
8
+ const layer = (0, extract_layer_1.extractLayer)(targetPath, cwd);
9
+ const slice = (0, extract_slice_1.extractSlice)(targetPath);
10
+ const [segment, segmentFiles] = (0, extract_segment_1.extractSegment)(targetPath);
11
+ return {
12
+ layer,
13
+ slice,
14
+ segment,
15
+ segmentFiles,
16
+ };
17
+ }
18
+ exports.extractFeatureSlicedParts = extractFeatureSlicedParts;
@@ -1,21 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractLayer = void 0;
4
- const config_1 = require("../../config");
5
- const shared_1 = require("../shared");
6
- function prepareToExtract(targetPath, cwd) {
7
- const lowerCasedTargetPath = targetPath.toLowerCase();
8
- if (cwd === undefined) {
9
- return lowerCasedTargetPath;
10
- }
11
- const lowerCasedCwd = cwd.toLowerCase();
12
- const pathWithoutCwd = lowerCasedTargetPath.replace(lowerCasedCwd, '');
13
- return pathWithoutCwd;
14
- }
15
- function extractLayer(targetPath, cwd) {
16
- const layersRegExpPattern = `(${config_1.layers.join('|')})(?![\\w\\.-])`;
17
- const layersRegExp = new RegExp(layersRegExpPattern, 'ig');
18
- const pathForExtract = prepareToExtract(targetPath, cwd);
19
- return (0, shared_1.getByRegExp)(pathForExtract, layersRegExp);
20
- }
21
- exports.extractLayer = extractLayer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractLayer = void 0;
4
+ const config_1 = require("../../config");
5
+ const shared_1 = require("../shared");
6
+ function prepareToExtract(targetPath, cwd) {
7
+ const lowerCasedTargetPath = targetPath.toLowerCase();
8
+ if (cwd === undefined) {
9
+ return lowerCasedTargetPath;
10
+ }
11
+ const lowerCasedCwd = cwd.toLowerCase();
12
+ const pathWithoutCwd = lowerCasedTargetPath.replace(lowerCasedCwd, '');
13
+ return pathWithoutCwd;
14
+ }
15
+ function extractLayer(targetPath, cwd) {
16
+ const layersRegExpPattern = `(${config_1.layers.join('|')})(?![\\w\\.-])`;
17
+ const layersRegExp = new RegExp(layersRegExpPattern, 'ig');
18
+ const pathForExtract = prepareToExtract(targetPath, cwd);
19
+ return (0, shared_1.getByRegExp)(pathForExtract, layersRegExp);
20
+ }
21
+ exports.extractLayer = extractLayer;
@@ -1,59 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractPathsInfo = void 0;
4
- const extract_feature_sliced_parts_1 = require("./extract-feature-sliced-parts");
5
- const extract_paths_1 = require("./extract-paths");
6
- const validate_extracted_feature_sliced_parts_1 = require("./validate-extracted-feature-sliced-parts");
7
- function compareFeatureSlicedParts(fsPartsToCompare) {
8
- const { target, currentFile, } = fsPartsToCompare;
9
- const hasUnknownLayers = target.validatedFeatureSlicedParts.hasNotLayer || currentFile.validatedFeatureSlicedParts.hasNotLayer;
10
- const isSameLayer = target.validatedFeatureSlicedParts.hasLayer
11
- && currentFile.validatedFeatureSlicedParts.hasLayer
12
- && target.fsdParts.layer === currentFile.fsdParts.layer;
13
- const isSameSlice = target.validatedFeatureSlicedParts.hasSlice && currentFile.validatedFeatureSlicedParts.hasSlice
14
- && target.fsdParts.slice === currentFile.fsdParts.slice;
15
- const isSameSegment = target.fsdParts.segment === currentFile.fsdParts.segment;
16
- const isSameLayerWithoutSlices = isSameLayer
17
- && !target.validatedFeatureSlicedParts.canLayerContainSlices
18
- && !currentFile.validatedFeatureSlicedParts.canLayerContainSlices;
19
- return {
20
- hasUnknownLayers,
21
- isSameLayer,
22
- isSameSlice,
23
- isSameSegment,
24
- isSameLayerWithoutSlices,
25
- };
26
- }
27
- function extractPathsInfo(node, context) {
28
- const { targetPath, normalizedTargetPath, normalizedCurrentFilePath, absoluteTargetPath, normalizedCwd, } = (0, extract_paths_1.extractPaths)(node, context);
29
- const fsdPartsOfTarget = (0, extract_feature_sliced_parts_1.extractFeatureSlicedParts)(absoluteTargetPath, normalizedCwd);
30
- const fsdPartsOfCurrentFile = (0, extract_feature_sliced_parts_1.extractFeatureSlicedParts)(normalizedCurrentFilePath, normalizedCwd);
31
- const validatedFeatureSlicedPartsOfTarget = (0, validate_extracted_feature_sliced_parts_1.validateExtractedFeatureSlicedParts)(fsdPartsOfTarget);
32
- const validatedFeatureSlicedPartsOfCurrentFile = (0, validate_extracted_feature_sliced_parts_1.validateExtractedFeatureSlicedParts)(fsdPartsOfCurrentFile);
33
- const { hasUnknownLayers, isSameLayer, isSameSlice, isSameSegment, isSameLayerWithoutSlices, } = compareFeatureSlicedParts({
34
- target: {
35
- validatedFeatureSlicedParts: validatedFeatureSlicedPartsOfTarget,
36
- fsdParts: fsdPartsOfTarget,
37
- },
38
- currentFile: {
39
- validatedFeatureSlicedParts: validatedFeatureSlicedPartsOfCurrentFile,
40
- fsdParts: fsdPartsOfCurrentFile,
41
- },
42
- });
43
- return {
44
- targetPath,
45
- normalizedTargetPath,
46
- normalizedCurrentFilePath,
47
- absoluteTargetPath,
48
- fsdPartsOfTarget,
49
- fsdPartsOfCurrentFile,
50
- isSameLayer,
51
- isSameSlice,
52
- isSameSegment,
53
- isSameLayerWithoutSlices,
54
- hasUnknownLayers,
55
- validatedFeatureSlicedPartsOfTarget,
56
- validatedFeatureSlicedPartsOfCurrentFile,
57
- };
58
- }
59
- exports.extractPathsInfo = extractPathsInfo;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractPathsInfo = void 0;
4
+ const rule_1 = require("../rule");
5
+ const extract_feature_sliced_parts_1 = require("./extract-feature-sliced-parts");
6
+ const validate_extracted_feature_sliced_parts_1 = require("./validate-extracted-feature-sliced-parts");
7
+ function compareFeatureSlicedParts(fsPartsToCompare) {
8
+ const { target, currentFile, } = fsPartsToCompare;
9
+ const hasUnknownLayers = target.validatedFeatureSlicedParts.hasNotLayer || currentFile.validatedFeatureSlicedParts.hasNotLayer;
10
+ const isSameLayer = target.validatedFeatureSlicedParts.hasLayer
11
+ && currentFile.validatedFeatureSlicedParts.hasLayer
12
+ && target.fsdParts.layer === currentFile.fsdParts.layer;
13
+ const isSameSlice = target.validatedFeatureSlicedParts.hasSlice && currentFile.validatedFeatureSlicedParts.hasSlice
14
+ && target.fsdParts.slice === currentFile.fsdParts.slice;
15
+ const isSameSegment = target.fsdParts.segment === currentFile.fsdParts.segment;
16
+ const isSameLayerWithoutSlices = isSameLayer
17
+ && !target.validatedFeatureSlicedParts.canLayerContainSlices
18
+ && !currentFile.validatedFeatureSlicedParts.canLayerContainSlices;
19
+ return {
20
+ hasUnknownLayers,
21
+ isSameLayer,
22
+ isSameSlice,
23
+ isSameSegment,
24
+ isSameLayerWithoutSlices,
25
+ };
26
+ }
27
+ function extractPathsInfo(node, context) {
28
+ const { targetPath, normalizedTargetPath, normalizedCurrentFilePath, absoluteTargetPath, normalizedCwd, } = (0, rule_1.extractPaths)(node, context);
29
+ const fsdPartsOfTarget = (0, extract_feature_sliced_parts_1.extractFeatureSlicedParts)(absoluteTargetPath, normalizedCwd);
30
+ const fsdPartsOfCurrentFile = (0, extract_feature_sliced_parts_1.extractFeatureSlicedParts)(normalizedCurrentFilePath, normalizedCwd);
31
+ const validatedFeatureSlicedPartsOfTarget = (0, validate_extracted_feature_sliced_parts_1.validateExtractedFeatureSlicedParts)(fsdPartsOfTarget);
32
+ const validatedFeatureSlicedPartsOfCurrentFile = (0, validate_extracted_feature_sliced_parts_1.validateExtractedFeatureSlicedParts)(fsdPartsOfCurrentFile);
33
+ const { hasUnknownLayers, isSameLayer, isSameSlice, isSameSegment, isSameLayerWithoutSlices, } = compareFeatureSlicedParts({
34
+ target: {
35
+ validatedFeatureSlicedParts: validatedFeatureSlicedPartsOfTarget,
36
+ fsdParts: fsdPartsOfTarget,
37
+ },
38
+ currentFile: {
39
+ validatedFeatureSlicedParts: validatedFeatureSlicedPartsOfCurrentFile,
40
+ fsdParts: fsdPartsOfCurrentFile,
41
+ },
42
+ });
43
+ return {
44
+ targetPath,
45
+ normalizedTargetPath,
46
+ normalizedCurrentFilePath,
47
+ absoluteTargetPath,
48
+ fsdPartsOfTarget,
49
+ fsdPartsOfCurrentFile,
50
+ isSameLayer,
51
+ isSameSlice,
52
+ isSameSegment,
53
+ isSameLayerWithoutSlices,
54
+ hasUnknownLayers,
55
+ validatedFeatureSlicedPartsOfTarget,
56
+ validatedFeatureSlicedPartsOfCurrentFile,
57
+ };
58
+ }
59
+ exports.extractPathsInfo = extractPathsInfo;