@conarti/eslint-plugin-feature-sliced 1.0.3
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 +477 -0
- package/README.md +142 -0
- package/dist/config.js +27 -0
- package/dist/configs/import-order/index.js +20 -0
- package/dist/configs/import-order/recommended.js +28 -0
- package/dist/configs/import-order/with-newlines-and-type-group.js +28 -0
- package/dist/configs/import-order/with-newlines.js +28 -0
- package/dist/configs/import-order/with-type-group.js +28 -0
- package/dist/configs/recommended.js +11 -0
- package/dist/configs/rules.js +11 -0
- package/dist/index.js +24 -0
- package/dist/lib/fsd-lib/extract-feature-sliced-parts.js +18 -0
- package/dist/lib/fsd-lib/extract-layer.js +21 -0
- package/dist/lib/fsd-lib/extract-paths-info.js +59 -0
- package/dist/lib/fsd-lib/extract-paths.js +19 -0
- package/dist/lib/fsd-lib/extract-segment.js +18 -0
- package/dist/lib/fsd-lib/extract-slice.js +10 -0
- package/dist/lib/fsd-lib/index.js +10 -0
- package/dist/lib/fsd-lib/layers.js +16 -0
- package/dist/lib/fsd-lib/validate-extracted-feature-sliced-parts.js +29 -0
- package/dist/lib/path-lib/convert-to-absolute.js +18 -0
- package/dist/lib/path-lib/index.js +9 -0
- package/dist/lib/path-lib/is-path-relative.js +7 -0
- package/dist/lib/path-lib/join-path.js +12 -0
- package/dist/lib/path-lib/normalize-path.js +19 -0
- package/dist/lib/rule-lib/can-validate.js +11 -0
- package/dist/lib/rule-lib/create-rule.js +7 -0
- package/dist/lib/rule-lib/extract-current-file-path.js +11 -0
- package/dist/lib/rule-lib/extract-cwd.js +13 -0
- package/dist/lib/rule-lib/extract-node-path.js +13 -0
- package/dist/lib/rule-lib/extract-rule-options.js +7 -0
- package/dist/lib/rule-lib/get-source-range-without-quotes.js +7 -0
- package/dist/lib/rule-lib/index.js +23 -0
- package/dist/lib/rule-lib/is-ignored-current-file.js +12 -0
- package/dist/lib/rule-lib/is-ignored.js +12 -0
- package/dist/lib/rule-lib/is-node-type.js +17 -0
- package/dist/lib/rule-lib/models.js +2 -0
- package/dist/lib/shared/get-by-reg-exp.js +12 -0
- package/dist/lib/shared/index.js +11 -0
- package/dist/lib/shared/is-null.js +7 -0
- package/dist/lib/shared/is-object.js +7 -0
- package/dist/lib/shared/is-undefined.js +7 -0
- package/dist/rules/absolute-relative/config.js +2 -0
- package/dist/rules/absolute-relative/index.js +52 -0
- package/dist/rules/absolute-relative/model/errors-lib.js +17 -0
- package/dist/rules/absolute-relative/model/index.js +5 -0
- package/dist/rules/absolute-relative/model/should-be-absolute.js +16 -0
- package/dist/rules/absolute-relative/model/should-be-relative.js +21 -0
- package/dist/rules/absolute-relative/model/validate-and-report.js +24 -0
- package/dist/rules/layers-slices/config.js +2 -0
- package/dist/rules/layers-slices/index.js +56 -0
- package/dist/rules/layers-slices/model/can-import-layer.js +22 -0
- package/dist/rules/layers-slices/model/errors-lib.js +14 -0
- package/dist/rules/layers-slices/model/index.js +5 -0
- package/dist/rules/layers-slices/model/validate-and-report.js +22 -0
- package/dist/rules/public-api/config.js +2 -0
- package/dist/rules/public-api/index.js +65 -0
- package/dist/rules/public-api/model/convert-to-public-api.js +24 -0
- package/dist/rules/public-api/model/errors-lib.js +34 -0
- package/dist/rules/public-api/model/index.js +5 -0
- package/dist/rules/public-api/model/is-index-file.js +7 -0
- package/dist/rules/public-api/model/is-layer-public-api.js +23 -0
- package/dist/rules/public-api/model/is-segments-public-api.js +11 -0
- package/dist/rules/public-api/model/is-slice-public-api.js +7 -0
- package/dist/rules/public-api/model/should-be-from-public-api.js +21 -0
- package/dist/rules/public-api/model/validate-and-report-program.js +15 -0
- package/dist/rules/public-api/model/validate-and-report.js +18 -0
- package/package.json +86 -0
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractPaths = void 0;
|
|
4
|
+
const path_lib_1 = require("../path-lib");
|
|
5
|
+
const rule_lib_1 = require("../rule-lib");
|
|
6
|
+
function extractPaths(node, context) {
|
|
7
|
+
const normalizedCurrentFilePath = (0, rule_lib_1.extractCurrentFilePath)(context);
|
|
8
|
+
const { targetPath, normalizedTargetPath, } = (0, rule_lib_1.extractNodePath)(node);
|
|
9
|
+
const absoluteTargetPath = (0, path_lib_1.convertToAbsolute)(normalizedCurrentFilePath, normalizedTargetPath);
|
|
10
|
+
const cwd = (0, rule_lib_1.extractCwd)(context);
|
|
11
|
+
return {
|
|
12
|
+
targetPath,
|
|
13
|
+
normalizedTargetPath,
|
|
14
|
+
normalizedCurrentFilePath,
|
|
15
|
+
absoluteTargetPath,
|
|
16
|
+
normalizedCwd: cwd,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.extractPaths = extractPaths;
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
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'), true);
|
|
9
|
+
}
|
|
10
|
+
exports.extractSlice = extractSlice;
|
|
@@ -0,0 +1,10 @@
|
|
|
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; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
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;
|
|
@@ -0,0 +1,29 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canValidate = void 0;
|
|
4
|
+
const shared_1 = require("../shared");
|
|
5
|
+
function canValidate(node) {
|
|
6
|
+
if ((0, shared_1.isObject)(node) && 'source' in node) {
|
|
7
|
+
return node.source !== null;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
exports.canValidate = canValidate;
|
|
@@ -0,0 +1,7 @@
|
|
|
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());
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractCurrentFilePath = void 0;
|
|
4
|
+
const path_lib_1 = require("../path-lib");
|
|
5
|
+
function extractCurrentFilePath(context) {
|
|
6
|
+
const currentFilePath = context.getPhysicalFilename
|
|
7
|
+
? context.getPhysicalFilename()
|
|
8
|
+
: context.getFilename();
|
|
9
|
+
return (0, path_lib_1.normalizePath)(currentFilePath);
|
|
10
|
+
}
|
|
11
|
+
exports.extractCurrentFilePath = extractCurrentFilePath;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractCwd = void 0;
|
|
4
|
+
const path_lib_1 = require("../path-lib");
|
|
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_lib_1.normalizePath)(cwd);
|
|
12
|
+
}
|
|
13
|
+
exports.extractCwd = extractCwd;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractNodePath = void 0;
|
|
4
|
+
const path_lib_1 = require("../path-lib");
|
|
5
|
+
function extractNodePath(node) {
|
|
6
|
+
const targetPath = node.source.value;
|
|
7
|
+
const normalizedTargetPath = (0, path_lib_1.normalizePath)(targetPath);
|
|
8
|
+
return {
|
|
9
|
+
targetPath,
|
|
10
|
+
normalizedTargetPath,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
exports.extractNodePath = extractNodePath;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSourceRangeWithoutQuotes = void 0;
|
|
4
|
+
function getSourceRangeWithoutQuotes([rangeStart, rangeEnd]) {
|
|
5
|
+
return [rangeStart + 1, rangeEnd - 1];
|
|
6
|
+
}
|
|
7
|
+
exports.getSourceRangeWithoutQuotes = getSourceRangeWithoutQuotes;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isIgnoredCurrentFile = exports.extractCwd = exports.extractCurrentFilePath = exports.extractNodePath = exports.isNodeType = exports.createRule = exports.isIgnored = exports.getSourceRangeWithoutQuotes = exports.canValidate = exports.extractRuleOptions = void 0;
|
|
4
|
+
var extract_rule_options_1 = require("./extract-rule-options");
|
|
5
|
+
Object.defineProperty(exports, "extractRuleOptions", { enumerable: true, get: function () { return extract_rule_options_1.extractRuleOptions; } });
|
|
6
|
+
var can_validate_1 = require("./can-validate");
|
|
7
|
+
Object.defineProperty(exports, "canValidate", { enumerable: true, get: function () { return can_validate_1.canValidate; } });
|
|
8
|
+
var get_source_range_without_quotes_1 = require("./get-source-range-without-quotes");
|
|
9
|
+
Object.defineProperty(exports, "getSourceRangeWithoutQuotes", { enumerable: true, get: function () { return get_source_range_without_quotes_1.getSourceRangeWithoutQuotes; } });
|
|
10
|
+
var is_ignored_1 = require("./is-ignored");
|
|
11
|
+
Object.defineProperty(exports, "isIgnored", { enumerable: true, get: function () { return is_ignored_1.isIgnored; } });
|
|
12
|
+
var create_rule_1 = require("./create-rule");
|
|
13
|
+
Object.defineProperty(exports, "createRule", { enumerable: true, get: function () { return create_rule_1.createRule; } });
|
|
14
|
+
var is_node_type_1 = require("./is-node-type");
|
|
15
|
+
Object.defineProperty(exports, "isNodeType", { enumerable: true, get: function () { return is_node_type_1.isNodeType; } });
|
|
16
|
+
var extract_node_path_1 = require("./extract-node-path");
|
|
17
|
+
Object.defineProperty(exports, "extractNodePath", { enumerable: true, get: function () { return extract_node_path_1.extractNodePath; } });
|
|
18
|
+
var extract_current_file_path_1 = require("./extract-current-file-path");
|
|
19
|
+
Object.defineProperty(exports, "extractCurrentFilePath", { enumerable: true, get: function () { return extract_current_file_path_1.extractCurrentFilePath; } });
|
|
20
|
+
var extract_cwd_1 = require("./extract-cwd");
|
|
21
|
+
Object.defineProperty(exports, "extractCwd", { enumerable: true, get: function () { return extract_cwd_1.extractCwd; } });
|
|
22
|
+
var is_ignored_current_file_1 = require("./is-ignored-current-file");
|
|
23
|
+
Object.defineProperty(exports, "isIgnoredCurrentFile", { enumerable: true, get: function () { return is_ignored_current_file_1.isIgnoredCurrentFile; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isIgnoredCurrentFile = void 0;
|
|
4
|
+
const extract_current_file_path_1 = require("./extract-current-file-path");
|
|
5
|
+
const extract_rule_options_1 = require("./extract-rule-options");
|
|
6
|
+
const is_ignored_1 = require("./is-ignored");
|
|
7
|
+
function isIgnoredCurrentFile(context, optionsWithDefault) {
|
|
8
|
+
const ruleOptions = (0, extract_rule_options_1.extractRuleOptions)(optionsWithDefault);
|
|
9
|
+
const normalizedCurrentFilePath = (0, extract_current_file_path_1.extractCurrentFilePath)(context);
|
|
10
|
+
return (0, is_ignored_1.isIgnored)(normalizedCurrentFilePath, ruleOptions.ignoreInFilesPatterns);
|
|
11
|
+
}
|
|
12
|
+
exports.isIgnoredCurrentFile = isIgnoredCurrentFile;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.isIgnored = void 0;
|
|
7
|
+
const picomatch_1 = __importDefault(require("picomatch"));
|
|
8
|
+
function isIgnored(path, patterns) {
|
|
9
|
+
const match = (0, picomatch_1.default)(patterns);
|
|
10
|
+
return match(path);
|
|
11
|
+
}
|
|
12
|
+
exports.isIgnored = isIgnored;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNodeType = void 0;
|
|
4
|
+
const types_1 = require("@typescript-eslint/types");
|
|
5
|
+
function isNodeType(node) {
|
|
6
|
+
const isImport = node.type === types_1.AST_NODE_TYPES.ImportDeclaration;
|
|
7
|
+
const isExport = node.type === types_1.AST_NODE_TYPES.ExportAllDeclaration
|
|
8
|
+
|| node.type === types_1.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
9
|
+
if (isImport) {
|
|
10
|
+
return node.importKind === 'type';
|
|
11
|
+
}
|
|
12
|
+
if (isExport) {
|
|
13
|
+
return node.exportKind === 'type';
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
exports.isNodeType = isNodeType;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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; } });
|