@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,18 +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;
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 +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'));
9
- }
10
- exports.extractSlice = extractSlice;
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 +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; } });
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 +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;
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 +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;
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 +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;
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 +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; } });
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 +1,7 @@
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
+ "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 +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;
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 +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;
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 +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());
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 +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;
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 +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;
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 +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;
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;
@@ -0,0 +1,21 @@
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;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractRuleOptions = void 0;
4
- function extractRuleOptions(optionsWithDefault) {
5
- return optionsWithDefault[0];
6
- }
7
- exports.extractRuleOptions = extractRuleOptions;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractRuleOptions = void 0;
4
+ function extractRuleOptions(optionsWithDefault) {
5
+ return optionsWithDefault[0];
6
+ }
7
+ exports.extractRuleOptions = extractRuleOptions;
@@ -1,7 +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;
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;
@@ -1,11 +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;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasPath = void 0;
4
+ const shared_1 = require("../shared");
5
+ function hasPath(node) {
6
+ if ((0, shared_1.isObject)(node) && 'source' in node) {
7
+ return node.source !== null;
8
+ }
9
+ return false;
10
+ }
11
+ exports.hasPath = hasPath;
@@ -1,23 +1,27 @@
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; } });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractPaths = exports.isIgnoredTarget = exports.isIgnoredCurrentFile = exports.extractCwd = exports.extractCurrentFilePath = exports.extractNodePath = exports.isNodeType = exports.createRule = exports.isIgnored = exports.getSourceRangeWithoutQuotes = exports.hasPath = 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 has_path_1 = require("./has-path");
7
+ Object.defineProperty(exports, "hasPath", { enumerable: true, get: function () { return has_path_1.hasPath; } });
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; } });
24
+ var is_ignored_target_1 = require("./is-ignored-target");
25
+ Object.defineProperty(exports, "isIgnoredTarget", { enumerable: true, get: function () { return is_ignored_target_1.isIgnoredTarget; } });
26
+ var extract_paths_1 = require("./extract-paths");
27
+ Object.defineProperty(exports, "extractPaths", { enumerable: true, get: function () { return extract_paths_1.extractPaths; } });
@@ -1,12 +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;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isIgnoredTarget = void 0;
4
+ const extract_node_path_1 = require("./extract-node-path");
5
+ const extract_rule_options_1 = require("./extract-rule-options");
6
+ const is_ignored_1 = require("./is-ignored");
7
+ function isIgnoredTarget(node, optionsWithDefault) {
8
+ const { targetPath } = (0, extract_node_path_1.extractNodePath)(node);
9
+ const userDefinedRuleOptions = (0, extract_rule_options_1.extractRuleOptions)(optionsWithDefault);
10
+ return (0, is_ignored_1.isIgnored)(targetPath, userDefinedRuleOptions.ignorePatterns);
11
+ }
12
+ exports.isIgnoredTarget = isIgnoredTarget;
@@ -1,12 +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;
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,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNodeType = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ function isNodeType(node) {
6
+ const isImport = utils_1.ASTUtils.isNodeOfTypes([utils_1.AST_NODE_TYPES.ImportSpecifier, utils_1.AST_NODE_TYPES.ImportDeclaration])(node);
7
+ const isExport = utils_1.ASTUtils.isNodeOfTypes([utils_1.AST_NODE_TYPES.ExportAllDeclaration, utils_1.AST_NODE_TYPES.ExportNamedDeclaration])(node);
8
+ if (isImport) {
9
+ return node.importKind === 'type';
10
+ }
11
+ if (isExport) {
12
+ return node.exportKind === 'type';
13
+ }
14
+ return false;
15
+ }
16
+ exports.isNodeType = isNodeType;