@conarti/eslint-plugin-feature-sliced 1.0.5 → 2.0.0-rc.2

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/README.md +43 -38
  2. package/dist/index.cjs +1004 -0
  3. package/dist/index.d.cts +61 -0
  4. package/dist/index.d.ts +61 -0
  5. package/dist/index.js +978 -21
  6. package/package.json +39 -40
  7. package/dist/config.js +0 -27
  8. package/dist/configs/import-order/index.js +0 -20
  9. package/dist/configs/import-order/recommended.js +0 -28
  10. package/dist/configs/import-order/with-newlines-and-type-group.js +0 -28
  11. package/dist/configs/import-order/with-newlines.js +0 -28
  12. package/dist/configs/import-order/with-type-group.js +0 -28
  13. package/dist/configs/recommended.js +0 -11
  14. package/dist/configs/rules.js +0 -11
  15. package/dist/lib/feature-sliced/extract-feature-sliced-parts.js +0 -18
  16. package/dist/lib/feature-sliced/extract-layer.js +0 -21
  17. package/dist/lib/feature-sliced/extract-paths-info.js +0 -59
  18. package/dist/lib/feature-sliced/extract-segment.js +0 -18
  19. package/dist/lib/feature-sliced/extract-slice.js +0 -10
  20. package/dist/lib/feature-sliced/index.js +0 -10
  21. package/dist/lib/feature-sliced/layers.js +0 -16
  22. package/dist/lib/feature-sliced/validate-extracted-feature-sliced-parts.js +0 -29
  23. package/dist/lib/path/convert-to-absolute.js +0 -18
  24. package/dist/lib/path/index.js +0 -9
  25. package/dist/lib/path/is-path-relative.js +0 -7
  26. package/dist/lib/path/join-path.js +0 -12
  27. package/dist/lib/path/normalize-path.js +0 -19
  28. package/dist/lib/rule/create-rule.js +0 -7
  29. package/dist/lib/rule/extract-current-file-path.js +0 -11
  30. package/dist/lib/rule/extract-cwd.js +0 -13
  31. package/dist/lib/rule/extract-node-path.js +0 -13
  32. package/dist/lib/rule/extract-paths.js +0 -21
  33. package/dist/lib/rule/extract-rule-options.js +0 -7
  34. package/dist/lib/rule/get-source-range-without-quotes.js +0 -7
  35. package/dist/lib/rule/has-path.js +0 -11
  36. package/dist/lib/rule/index.js +0 -27
  37. package/dist/lib/rule/is-ignored-current-file.js +0 -12
  38. package/dist/lib/rule/is-ignored-target.js +0 -12
  39. package/dist/lib/rule/is-ignored.js +0 -12
  40. package/dist/lib/rule/is-node-type.js +0 -16
  41. package/dist/lib/rule/models.js +0 -2
  42. package/dist/lib/shared/get-by-reg-exp.js +0 -12
  43. package/dist/lib/shared/index.js +0 -11
  44. package/dist/lib/shared/is-null.js +0 -7
  45. package/dist/lib/shared/is-object.js +0 -7
  46. package/dist/lib/shared/is-undefined.js +0 -7
  47. package/dist/rules/absolute-relative/config.js +0 -2
  48. package/dist/rules/absolute-relative/index.js +0 -51
  49. package/dist/rules/absolute-relative/model/errors.js +0 -17
  50. package/dist/rules/absolute-relative/model/index.js +0 -5
  51. package/dist/rules/absolute-relative/model/should-be-absolute.js +0 -16
  52. package/dist/rules/absolute-relative/model/should-be-relative.js +0 -21
  53. package/dist/rules/absolute-relative/model/validate-and-report.js +0 -24
  54. package/dist/rules/layers-slices/config.js +0 -2
  55. package/dist/rules/layers-slices/index.js +0 -55
  56. package/dist/rules/layers-slices/model/errors.js +0 -22
  57. package/dist/rules/layers-slices/model/index.js +0 -5
  58. package/dist/rules/layers-slices/model/is-not-suitable-for-validation.js +0 -17
  59. package/dist/rules/layers-slices/model/specifiers/extract-import-specifiers.js +0 -8
  60. package/dist/rules/layers-slices/model/specifiers/has-errors-at-all-specifiers.js +0 -9
  61. package/dist/rules/layers-slices/model/specifiers/index.js +0 -7
  62. package/dist/rules/layers-slices/model/specifiers/validate-specifiers.js +0 -8
  63. package/dist/rules/layers-slices/model/validate-and-report.js +0 -46
  64. package/dist/rules/layers-slices/model/validate-node/index.js +0 -16
  65. package/dist/rules/layers-slices/model/validate-node/valid-by-layer-order.js +0 -10
  66. package/dist/rules/layers-slices/model/validate-node/valid-by-type-import.js +0 -9
  67. package/dist/rules/public-api/config.js +0 -2
  68. package/dist/rules/public-api/index.js +0 -65
  69. package/dist/rules/public-api/model/convert-to-public-api.js +0 -24
  70. package/dist/rules/public-api/model/errors.js +0 -34
  71. package/dist/rules/public-api/model/index.js +0 -5
  72. package/dist/rules/public-api/model/is-index-file.js +0 -7
  73. package/dist/rules/public-api/model/is-layer-public-api.js +0 -23
  74. package/dist/rules/public-api/model/is-segments-public-api.js +0 -11
  75. package/dist/rules/public-api/model/is-slice-public-api.js +0 -7
  76. package/dist/rules/public-api/model/should-be-from-public-api.js +0 -21
  77. package/dist/rules/public-api/model/validate-and-report-program.js +0 -15
  78. package/dist/rules/public-api/model/validate-and-report.js +0 -18
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@conarti/eslint-plugin-feature-sliced",
3
- "version": "1.0.5",
3
+ "type": "module",
4
+ "version": "2.0.0-rc.2",
4
5
  "description": "Feature-sliced design methodology plugin",
6
+ "author": "Aleksandr Belous <abelous2009@gmail.com>",
7
+ "license": "ISC",
5
8
  "repository": "https://github.com/conarti/eslint-plugin-fsd.git",
6
9
  "keywords": [
7
10
  "eslint",
@@ -12,21 +15,29 @@
12
15
  "feature-driven",
13
16
  "feature-based"
14
17
  ],
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
15
26
  "files": [
16
- "dist",
17
- "CHANGELOG.md"
27
+ "CHANGELOG.md",
28
+ "dist"
18
29
  ],
19
- "author": "conarti",
20
- "main": "./dist/index.js",
21
- "exports": {
22
- ".": "./dist/index.js",
23
- "./import-order": "./dist/configs/import-order/index.js"
30
+ "engines": {
31
+ "node": ">= 18.0.0"
24
32
  },
25
33
  "scripts": {
26
34
  "clean": "rimraf ./dist",
27
- "build": "npm run clean && tsc -p tsconfig.build.json",
28
- "lint": "npm-run-all \"lint:*\"",
29
- "lint:js": "eslint .",
35
+ "build": "tsup --format esm,cjs --clean --dts",
36
+ "stub": "tsup --format esm",
37
+ "dev": "npx @eslint/config-inspector --config eslint.config.ts",
38
+ "watch": "tsup --format esm,cjs --watch",
39
+ "typecheck": "tsc --noEmit",
40
+ "lint": "eslint .",
30
41
  "test": "vitest",
31
42
  "test:ui": "vitest --ui --api 9527",
32
43
  "test:run": "vitest run",
@@ -41,47 +52,35 @@
41
52
  "docs:build": "vitepress build docs",
42
53
  "docs:preview": "vitepress preview docs"
43
54
  },
55
+ "peerDependencies": {
56
+ "eslint": ">=9"
57
+ },
58
+ "dependencies": {
59
+ "@typescript-eslint/utils": "^8.8.0",
60
+ "eslint-flat-config-utils": "^0.4.0",
61
+ "eslint-plugin-import-x": "^4.3.1",
62
+ "picomatch": "^2.3.1"
63
+ },
44
64
  "devDependencies": {
45
- "@total-typescript/ts-reset": "^0.4.2",
46
- "@tsconfig/node14": "^14.1.0",
47
- "@types/eslint": "^8.44.0",
65
+ "@antfu/eslint-config": "^3.7.3",
66
+ "@total-typescript/ts-reset": "^0.6.1",
67
+ "@types/eslint": "^9.6.1",
48
68
  "@types/node": "^20.4.2",
49
69
  "@types/picomatch": "^2.3.0",
50
- "@typescript-eslint/eslint-plugin": "^6.1.0",
51
- "@typescript-eslint/parser": "^6.1.0",
52
- "@typescript-eslint/utils": "^6.1.0",
70
+ "@typescript-eslint/parser": "^8.8.0",
53
71
  "@vitest/coverage-v8": "^0.33.0",
54
72
  "@vitest/ui": "^0.33.0",
55
73
  "conventional-changelog-cli": "^2.2.2",
56
- "eslint": "^8.45.0",
57
- "eslint-config-airbnb-base": "^15.0.0",
58
- "eslint-import-resolver-typescript": "^3.5.5",
59
- "eslint-plugin-eslint-plugin": "^5.1.1",
60
- "eslint-plugin-filenames-simple": "^0.8.0",
61
- "eslint-plugin-import": "^2.27.5",
62
- "eslint-plugin-modules-newlines": "^0.0.7",
63
- "eslint-plugin-node": "^11.1.0",
64
- "eslint-plugin-unused-imports": "^3.0.0",
65
- "eslint-plugin-vitest": "^0.2.6",
74
+ "eslint": "^9.11.1",
75
+ "eslint-plugin-vitest": "^0.5.4",
66
76
  "execa": "5.1.1",
67
- "npm-run-all": "^4.1.5",
68
77
  "picocolors": "^1.0.0",
69
78
  "prompts": "^2.4.2",
70
79
  "rimraf": "^5.0.1",
71
80
  "semver": "^7.5.4",
72
- "typescript": "^4.9.5",
81
+ "tsup": "^8.3.0",
82
+ "typescript": "^5.6.2",
73
83
  "vitepress": "^1.0.0-alpha.64",
74
84
  "vitest": "^0.33.0"
75
- },
76
- "engines": {
77
- "node": "^14.17.0 || ^16.0.0 || >= 18.0.0"
78
- },
79
- "peerDependencies": {
80
- "eslint": ">=7",
81
- "eslint-plugin-import": ">=2.26"
82
- },
83
- "license": "ISC",
84
- "dependencies": {
85
- "picomatch": "^2.3.1"
86
85
  }
87
86
  }
package/dist/config.js DELETED
@@ -1,27 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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,18 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractSegment = void 0;
4
- const config_1 = require("../../config");
5
- const layersUnion = config_1.layersWithSlices.join('|');
6
- const segmentsUnion = config_1.segments.join('|');
7
- const fsdPartsRegExp = new RegExp(`(?<=(?<layer>${layersUnion}))\\/(?<slice>([\\w-]*\\/)+?)(?<segment>(${segmentsUnion})(\\.\\w+)?)(\\/(?<segmentFiles>.*))?`);
8
- function extractSegment(targetPath) {
9
- const fsdParts = targetPath.match(fsdPartsRegExp);
10
- if (fsdParts === null) {
11
- return [null, null];
12
- }
13
- const { segment = null, segmentFiles = null, } = fsdParts.groups || {};
14
- const fileExtensionRegExp = /\.[^/.]+$/;
15
- const segmentWithoutFileExtension = segment?.replace(fileExtensionRegExp, '') || null;
16
- return [segmentWithoutFileExtension, segmentFiles];
17
- }
18
- exports.extractSegment = extractSegment;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractSlice = void 0;
4
- const config_1 = require("../../config");
5
- const shared_1 = require("../shared");
6
- function extractSlice(targetPath) {
7
- const targetPathWithoutCurrentFileName = targetPath.replace(/\/\w+\.\w+$/, '');
8
- return (0, shared_1.getByRegExp)(targetPathWithoutCurrentFileName, new RegExp(`(?<=(${config_1.layersWithSlices.join('|')})\\/)(\\w|-)+`, 'ig'));
9
- }
10
- exports.extractSlice = extractSlice;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractLayer = exports.isLayer = exports.getLayerWeight = exports.extractPathsInfo = void 0;
4
- var extract_paths_info_1 = require("./extract-paths-info");
5
- Object.defineProperty(exports, "extractPathsInfo", { enumerable: true, get: function () { return extract_paths_info_1.extractPathsInfo; } });
6
- var layers_1 = require("./layers");
7
- Object.defineProperty(exports, "getLayerWeight", { enumerable: true, get: function () { return layers_1.getLayerWeight; } });
8
- Object.defineProperty(exports, "isLayer", { enumerable: true, get: function () { return layers_1.isLayer; } });
9
- var extract_layer_1 = require("./extract-layer");
10
- Object.defineProperty(exports, "extractLayer", { enumerable: true, get: function () { return extract_layer_1.extractLayer; } });
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canLayerContainSlices = exports.getLayerWeight = exports.isLayer = void 0;
4
- const config_1 = require("../../config");
5
- function isLayer(layer) {
6
- return config_1.layers.some((fsdLayer) => fsdLayer === layer);
7
- }
8
- exports.isLayer = isLayer;
9
- function getLayerWeight(layer) {
10
- return config_1.layers.indexOf(layer);
11
- }
12
- exports.getLayerWeight = getLayerWeight;
13
- function canLayerContainSlices(layer) {
14
- return !config_1.layersWithoutSlices.includes(layer);
15
- }
16
- exports.canLayerContainSlices = canLayerContainSlices;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateExtractedFeatureSlicedParts = void 0;
4
- const shared_1 = require("../shared");
5
- const layers_1 = require("./layers");
6
- function validateExtractedFeatureSlicedParts(extractedFeatureSlicedParts) {
7
- const { layer, slice, segment, segmentFiles, } = extractedFeatureSlicedParts;
8
- const hasLayer = (0, layers_1.isLayer)(layer);
9
- const hasNotLayer = !hasLayer;
10
- const hasSlice = !(0, shared_1.isNull)(slice);
11
- const hasNotSlice = !hasSlice;
12
- const hasSegment = !(0, shared_1.isNull)(segment);
13
- const hasNotSegment = !hasSegment;
14
- const hasSegmentFiles = !(0, shared_1.isNull)(segmentFiles);
15
- const hasNotSegmentFiles = !hasSegmentFiles;
16
- const canContainSlices = hasLayer && (0, layers_1.canLayerContainSlices)(layer);
17
- return {
18
- hasLayer,
19
- hasNotLayer,
20
- hasSlice,
21
- hasNotSlice,
22
- hasSegment,
23
- hasNotSegment,
24
- hasSegmentFiles,
25
- hasNotSegmentFiles,
26
- canLayerContainSlices: canContainSlices,
27
- };
28
- }
29
- exports.validateExtractedFeatureSlicedParts = validateExtractedFeatureSlicedParts;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToAbsolute = void 0;
4
- const is_path_relative_1 = require("./is-path-relative");
5
- const join_path_1 = require("./join-path");
6
- function convertToAbsolute(base, target) {
7
- if (target === '') {
8
- return base;
9
- }
10
- if (base === '') {
11
- return target;
12
- }
13
- if (!(0, is_path_relative_1.isPathRelative)(target)) {
14
- return target;
15
- }
16
- return (0, join_path_1.joinPath)(base, `../${target}`);
17
- }
18
- exports.convertToAbsolute = convertToAbsolute;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPathRelative = exports.convertToAbsolute = exports.normalizePath = void 0;
4
- var normalize_path_1 = require("./normalize-path");
5
- Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return normalize_path_1.normalizePath; } });
6
- var convert_to_absolute_1 = require("./convert-to-absolute");
7
- Object.defineProperty(exports, "convertToAbsolute", { enumerable: true, get: function () { return convert_to_absolute_1.convertToAbsolute; } });
8
- var is_path_relative_1 = require("./is-path-relative");
9
- Object.defineProperty(exports, "isPathRelative", { enumerable: true, get: function () { return is_path_relative_1.isPathRelative; } });
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPathRelative = void 0;
4
- function isPathRelative(path) {
5
- return path.startsWith('.');
6
- }
7
- exports.isPathRelative = isPathRelative;
@@ -1,12 +0,0 @@
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.joinPath = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const normalize_path_1 = require("./normalize-path");
9
- function joinPath(from, to) {
10
- return (0, normalize_path_1.normalizePath)(path_1.default.join((0, normalize_path_1.normalizePath)(from), (0, normalize_path_1.normalizePath)(to)));
11
- }
12
- exports.joinPath = joinPath;
@@ -1,19 +0,0 @@
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.normalizePath = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const config_1 = require("../../config");
9
- function normalizePath(targetPath) {
10
- const winSepRegExp = /\\/g;
11
- const withNormalizedSeparators = path_1.default
12
- .normalize(targetPath)
13
- .replace(winSepRegExp, config_1.pathSeparator);
14
- if (targetPath.startsWith('./')) {
15
- return `./${withNormalizedSeparators}`;
16
- }
17
- return withNormalizedSeparators;
18
- }
19
- exports.normalizePath = normalizePath;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRule = void 0;
4
- const url_1 = require("url");
5
- const utils_1 = require("@typescript-eslint/utils");
6
- const config_1 = require("../../config");
7
- exports.createRule = utils_1.ESLintUtils.RuleCreator((name) => new url_1.URL(name, config_1.RULE_DOCS_URL).toString());
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractCurrentFilePath = void 0;
4
- const path_1 = require("../path");
5
- function extractCurrentFilePath(context) {
6
- const currentFilePath = context.getPhysicalFilename
7
- ? context.getPhysicalFilename()
8
- : context.getFilename();
9
- return (0, path_1.normalizePath)(currentFilePath);
10
- }
11
- exports.extractCurrentFilePath = extractCurrentFilePath;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractCwd = void 0;
4
- const path_1 = require("../path");
5
- const shared_1 = require("../shared");
6
- function extractCwd(context) {
7
- const cwd = context.getCwd?.();
8
- if ((0, shared_1.isUndefined)(cwd)) {
9
- return undefined;
10
- }
11
- return (0, path_1.normalizePath)(cwd);
12
- }
13
- exports.extractCwd = extractCwd;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractNodePath = void 0;
4
- const path_1 = require("../path");
5
- function extractNodePath(node) {
6
- const targetPath = node.source.value;
7
- const normalizedTargetPath = (0, path_1.normalizePath)(targetPath);
8
- return {
9
- targetPath,
10
- normalizedTargetPath,
11
- };
12
- }
13
- exports.extractNodePath = extractNodePath;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractPaths = void 0;
4
- const path_1 = require("../path");
5
- const extract_current_file_path_1 = require("./extract-current-file-path");
6
- const extract_cwd_1 = require("./extract-cwd");
7
- const extract_node_path_1 = require("./extract-node-path");
8
- function extractPaths(node, context) {
9
- const normalizedCurrentFilePath = (0, extract_current_file_path_1.extractCurrentFilePath)(context);
10
- const { targetPath, normalizedTargetPath, } = (0, extract_node_path_1.extractNodePath)(node);
11
- const absoluteTargetPath = (0, path_1.convertToAbsolute)(normalizedCurrentFilePath, normalizedTargetPath);
12
- const cwd = (0, extract_cwd_1.extractCwd)(context);
13
- return {
14
- targetPath,
15
- normalizedTargetPath,
16
- normalizedCurrentFilePath,
17
- absoluteTargetPath,
18
- normalizedCwd: cwd,
19
- };
20
- }
21
- exports.extractPaths = extractPaths;