pasika 0.5.9 → 0.5.10
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/dist/eslint/pasika/index.js +126 -95
- package/package.json +1 -1
|
@@ -2218,6 +2218,7 @@ var jsxHygieneRule = {
|
|
|
2218
2218
|
};
|
|
2219
2219
|
|
|
2220
2220
|
// eslint/rules/interactive-component.ts
|
|
2221
|
+
import path20 from "path";
|
|
2221
2222
|
var INTERACTIVE_TAGS = /* @__PURE__ */ new Set([
|
|
2222
2223
|
"a",
|
|
2223
2224
|
"button",
|
|
@@ -2230,6 +2231,28 @@ var INTERACTIVE_TAGS = /* @__PURE__ */ new Set([
|
|
|
2230
2231
|
"textarea",
|
|
2231
2232
|
"video"
|
|
2232
2233
|
]);
|
|
2234
|
+
var NEXT_ROUTING_FILES3 = /* @__PURE__ */ new Set([
|
|
2235
|
+
"default",
|
|
2236
|
+
"error",
|
|
2237
|
+
"global-error",
|
|
2238
|
+
"instrumentation",
|
|
2239
|
+
"layout",
|
|
2240
|
+
"loading",
|
|
2241
|
+
"middleware",
|
|
2242
|
+
"not-found",
|
|
2243
|
+
"page",
|
|
2244
|
+
"route",
|
|
2245
|
+
"template",
|
|
2246
|
+
// File conventions Next.js requires to keep their exact names in src/app/
|
|
2247
|
+
"apple-icon",
|
|
2248
|
+
"icon",
|
|
2249
|
+
"manifest",
|
|
2250
|
+
"opengraph-image",
|
|
2251
|
+
"robots",
|
|
2252
|
+
"sitemap",
|
|
2253
|
+
"twitter-image"
|
|
2254
|
+
]);
|
|
2255
|
+
var INTERACTIVE_ATTRIBUTES = /* @__PURE__ */ new Set(["onClick", "onChange", "onSubmit", "href", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "htmlFor"]);
|
|
2233
2256
|
function tagName(node) {
|
|
2234
2257
|
const name = node.openingElement?.name;
|
|
2235
2258
|
if (name?.type !== "JSXIdentifier") return void 0;
|
|
@@ -2237,7 +2260,12 @@ function tagName(node) {
|
|
|
2237
2260
|
}
|
|
2238
2261
|
function isInteractive(node) {
|
|
2239
2262
|
const name = tagName(node);
|
|
2240
|
-
|
|
2263
|
+
if (name === void 0 || !INTERACTIVE_TAGS.has(name)) return false;
|
|
2264
|
+
const attributes = node.openingElement?.attributes;
|
|
2265
|
+
if (!attributes) return false;
|
|
2266
|
+
return attributes.some(
|
|
2267
|
+
(attribute) => attribute.type === "JSXAttribute" && typeof attribute.name === "object" && "name" in attribute.name && typeof attribute.name.name === "string" && INTERACTIVE_ATTRIBUTES.has(attribute.name.name)
|
|
2268
|
+
);
|
|
2241
2269
|
}
|
|
2242
2270
|
function isComponentElement(node) {
|
|
2243
2271
|
const name = tagName(node);
|
|
@@ -2258,6 +2286,9 @@ var interactiveComponentRule = {
|
|
|
2258
2286
|
},
|
|
2259
2287
|
create(context) {
|
|
2260
2288
|
if (!context.filename.endsWith(".tsx") && !context.filename.endsWith(".jsx")) return {};
|
|
2289
|
+
const filename = path20.resolve(context.filename);
|
|
2290
|
+
const base = path20.basename(filename, path20.extname(filename));
|
|
2291
|
+
if (NEXT_ROUTING_FILES3.has(base)) return {};
|
|
2261
2292
|
return {
|
|
2262
2293
|
JSXElement(node) {
|
|
2263
2294
|
if (!isInteractive(node)) return;
|
|
@@ -2501,12 +2532,12 @@ var cvaBooleanVariantsRule = {
|
|
|
2501
2532
|
};
|
|
2502
2533
|
|
|
2503
2534
|
// eslint/rules/cross-feature-import.ts
|
|
2504
|
-
import
|
|
2535
|
+
import path21 from "path";
|
|
2505
2536
|
var FEATURES_SEGMENT = "features";
|
|
2506
2537
|
function featureNameOf(resolvedPath, sourceRoot) {
|
|
2507
|
-
const relative =
|
|
2538
|
+
const relative = path21.relative(sourceRoot, resolvedPath);
|
|
2508
2539
|
if (relative.startsWith("..")) return void 0;
|
|
2509
|
-
const segments = relative.split(
|
|
2540
|
+
const segments = relative.split(path21.sep);
|
|
2510
2541
|
if (segments[0] !== FEATURES_SEGMENT || segments.length < 2) return void 0;
|
|
2511
2542
|
return segments[1];
|
|
2512
2543
|
}
|
|
@@ -2522,9 +2553,9 @@ var crossFeatureImportRule = {
|
|
|
2522
2553
|
const filename = context.filename;
|
|
2523
2554
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
2524
2555
|
const sourceRoot = sourceRootOf(context);
|
|
2525
|
-
const fileRelative =
|
|
2556
|
+
const fileRelative = path21.relative(sourceRoot, filename);
|
|
2526
2557
|
if (fileRelative.startsWith("..")) return {};
|
|
2527
|
-
const fileSegments = fileRelative.split(
|
|
2558
|
+
const fileSegments = fileRelative.split(path21.sep);
|
|
2528
2559
|
const isInCompositions = fileSegments[0] === "compositions";
|
|
2529
2560
|
const isInApp = fileSegments[0] === "app";
|
|
2530
2561
|
const isConfig = fileSegments[0] === "config";
|
|
@@ -2538,9 +2569,9 @@ var crossFeatureImportRule = {
|
|
|
2538
2569
|
if (typeof source.value !== "string") return;
|
|
2539
2570
|
let resolved;
|
|
2540
2571
|
if (source.value.startsWith("@/")) {
|
|
2541
|
-
resolved =
|
|
2572
|
+
resolved = path21.resolve(sourceRoot, source.value.slice(2));
|
|
2542
2573
|
} else if (source.value.startsWith(".")) {
|
|
2543
|
-
resolved =
|
|
2574
|
+
resolved = path21.resolve(path21.dirname(filename), source.value);
|
|
2544
2575
|
}
|
|
2545
2576
|
if (!resolved) return;
|
|
2546
2577
|
const feature = featureNameOf(resolved, sourceRoot);
|
|
@@ -2559,7 +2590,7 @@ var crossFeatureImportRule = {
|
|
|
2559
2590
|
};
|
|
2560
2591
|
|
|
2561
2592
|
// eslint/rules/pure-function-extract.ts
|
|
2562
|
-
import
|
|
2593
|
+
import path22 from "path";
|
|
2563
2594
|
function isComponentLikeName(name) {
|
|
2564
2595
|
return /^[A-Z]/.test(name);
|
|
2565
2596
|
}
|
|
@@ -2588,9 +2619,9 @@ var pureFunctionExtractRule = {
|
|
|
2588
2619
|
const filename = context.filename;
|
|
2589
2620
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
2590
2621
|
const sourceRoot = sourceRootOf(context);
|
|
2591
|
-
const relative =
|
|
2622
|
+
const relative = path22.relative(sourceRoot, filename);
|
|
2592
2623
|
if (relative.startsWith("..")) return {};
|
|
2593
|
-
const segments = relative.split(
|
|
2624
|
+
const segments = relative.split(path22.sep);
|
|
2594
2625
|
if (segments[0] === "utils") return {};
|
|
2595
2626
|
if (segments[0] === "app") return {};
|
|
2596
2627
|
const supportFolders = /* @__PURE__ */ new Set(["hooks", "types", "schemas", "constants", "utils"]);
|
|
@@ -2630,7 +2661,7 @@ var pureFunctionExtractRule = {
|
|
|
2630
2661
|
};
|
|
2631
2662
|
|
|
2632
2663
|
// eslint/rules/hook-complexity.ts
|
|
2633
|
-
import
|
|
2664
|
+
import path23 from "path";
|
|
2634
2665
|
import ts4 from "typescript";
|
|
2635
2666
|
var REACT_HOOKS = /* @__PURE__ */ new Set([
|
|
2636
2667
|
"useState",
|
|
@@ -2683,9 +2714,9 @@ var hookComplexityRule = {
|
|
|
2683
2714
|
create(context) {
|
|
2684
2715
|
const filename = context.filename;
|
|
2685
2716
|
const sourceRoot = sourceRootOf(context);
|
|
2686
|
-
const relative =
|
|
2717
|
+
const relative = path23.relative(sourceRoot, filename);
|
|
2687
2718
|
if (relative.startsWith("..")) return {};
|
|
2688
|
-
const segments = relative.split(
|
|
2719
|
+
const segments = relative.split(path23.sep);
|
|
2689
2720
|
const sourceText = context.sourceCode.text;
|
|
2690
2721
|
function checkHook(node, name, body, exported) {
|
|
2691
2722
|
if (!exported) return;
|
|
@@ -2727,9 +2758,9 @@ var hookComplexityRule = {
|
|
|
2727
2758
|
};
|
|
2728
2759
|
|
|
2729
2760
|
// eslint/rules/locale-dotted-path.ts
|
|
2730
|
-
import
|
|
2761
|
+
import path24 from "path";
|
|
2731
2762
|
function isInLocalesDir(filename) {
|
|
2732
|
-
const segments =
|
|
2763
|
+
const segments = path24.resolve(filename).split(path24.sep);
|
|
2733
2764
|
const srcIdx = segments.lastIndexOf("src");
|
|
2734
2765
|
return srcIdx !== -1 && segments[srcIdx + 1] === "locales";
|
|
2735
2766
|
}
|
|
@@ -2778,9 +2809,9 @@ var localeDottedPathRule = {
|
|
|
2778
2809
|
};
|
|
2779
2810
|
|
|
2780
2811
|
// eslint/rules/locales-location.ts
|
|
2781
|
-
import
|
|
2812
|
+
import path25 from "path";
|
|
2782
2813
|
function isLocalesFile(filename) {
|
|
2783
|
-
const segments =
|
|
2814
|
+
const segments = path25.resolve(filename).split(path25.sep);
|
|
2784
2815
|
const srcIdx = segments.lastIndexOf("src");
|
|
2785
2816
|
return srcIdx !== -1 && segments[srcIdx + 1] === "locales";
|
|
2786
2817
|
}
|
|
@@ -2799,7 +2830,7 @@ var localesLocationRule = {
|
|
|
2799
2830
|
create(context) {
|
|
2800
2831
|
if (isLocalesFile(context.filename)) return {};
|
|
2801
2832
|
const filename = context.filename;
|
|
2802
|
-
const segments =
|
|
2833
|
+
const segments = path25.resolve(filename).split(path25.sep);
|
|
2803
2834
|
const srcIdx = segments.lastIndexOf("src");
|
|
2804
2835
|
if (srcIdx === -1) return {};
|
|
2805
2836
|
const folder = segments[srcIdx + 1];
|
|
@@ -2821,7 +2852,7 @@ var localesLocationRule = {
|
|
|
2821
2852
|
};
|
|
2822
2853
|
|
|
2823
2854
|
// eslint/rules/hook-extraction.ts
|
|
2824
|
-
import
|
|
2855
|
+
import path26 from "path";
|
|
2825
2856
|
var hookExtractionRule = {
|
|
2826
2857
|
meta: {
|
|
2827
2858
|
schema: [],
|
|
@@ -2832,7 +2863,7 @@ var hookExtractionRule = {
|
|
|
2832
2863
|
},
|
|
2833
2864
|
create(context) {
|
|
2834
2865
|
const sourceRoot = sourceRootOf(context);
|
|
2835
|
-
const file =
|
|
2866
|
+
const file = path26.resolve(context.filename);
|
|
2836
2867
|
const segments = segmentsOf(file, sourceRoot);
|
|
2837
2868
|
if (segments.length === 0) return {};
|
|
2838
2869
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -2858,7 +2889,7 @@ var hookExtractionRule = {
|
|
|
2858
2889
|
};
|
|
2859
2890
|
|
|
2860
2891
|
// eslint/rules/value-extraction.ts
|
|
2861
|
-
import
|
|
2892
|
+
import path27 from "path";
|
|
2862
2893
|
var valueExtractionRule = {
|
|
2863
2894
|
meta: {
|
|
2864
2895
|
schema: [],
|
|
@@ -2869,7 +2900,7 @@ var valueExtractionRule = {
|
|
|
2869
2900
|
},
|
|
2870
2901
|
create(context) {
|
|
2871
2902
|
const sourceRoot = sourceRootOf(context);
|
|
2872
|
-
const file =
|
|
2903
|
+
const file = path27.resolve(context.filename);
|
|
2873
2904
|
const segments = segmentsOf(file, sourceRoot);
|
|
2874
2905
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
2875
2906
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -2890,7 +2921,7 @@ var valueExtractionRule = {
|
|
|
2890
2921
|
};
|
|
2891
2922
|
|
|
2892
2923
|
// eslint/rules/config-extraction.ts
|
|
2893
|
-
import
|
|
2924
|
+
import path28 from "path";
|
|
2894
2925
|
var configExtractionRule = {
|
|
2895
2926
|
meta: {
|
|
2896
2927
|
schema: [],
|
|
@@ -2901,7 +2932,7 @@ var configExtractionRule = {
|
|
|
2901
2932
|
},
|
|
2902
2933
|
create(context) {
|
|
2903
2934
|
const sourceRoot = sourceRootOf(context);
|
|
2904
|
-
const file =
|
|
2935
|
+
const file = path28.resolve(context.filename);
|
|
2905
2936
|
const segments = segmentsOf(file, sourceRoot);
|
|
2906
2937
|
if (segments.length < 3 || segments[0] !== "config") return {};
|
|
2907
2938
|
if (SUPPORT_FOLDERS2.has(segments[2] ?? "")) return {};
|
|
@@ -2939,7 +2970,7 @@ var configExtractionRule = {
|
|
|
2939
2970
|
};
|
|
2940
2971
|
|
|
2941
2972
|
// eslint/rules/component-nesting.ts
|
|
2942
|
-
import
|
|
2973
|
+
import path29 from "path";
|
|
2943
2974
|
var componentNestingRule = {
|
|
2944
2975
|
meta: {
|
|
2945
2976
|
schema: [],
|
|
@@ -2950,7 +2981,7 @@ var componentNestingRule = {
|
|
|
2950
2981
|
},
|
|
2951
2982
|
create(context) {
|
|
2952
2983
|
const sourceRoot = sourceRootOf(context);
|
|
2953
|
-
const file =
|
|
2984
|
+
const file = path29.resolve(context.filename);
|
|
2954
2985
|
const segments = segmentsOf(file, sourceRoot);
|
|
2955
2986
|
if (segments.length !== 4 || segments[0] !== "features") return {};
|
|
2956
2987
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -2983,7 +3014,7 @@ var componentNestingRule = {
|
|
|
2983
3014
|
};
|
|
2984
3015
|
|
|
2985
3016
|
// eslint/rules/stay-flat.ts
|
|
2986
|
-
import
|
|
3017
|
+
import path30 from "path";
|
|
2987
3018
|
var stayFlatRule = {
|
|
2988
3019
|
meta: {
|
|
2989
3020
|
schema: [],
|
|
@@ -2994,7 +3025,7 @@ var stayFlatRule = {
|
|
|
2994
3025
|
},
|
|
2995
3026
|
create(context) {
|
|
2996
3027
|
const sourceRoot = sourceRootOf(context);
|
|
2997
|
-
const file =
|
|
3028
|
+
const file = path30.resolve(context.filename);
|
|
2998
3029
|
const segments = segmentsOf(file, sourceRoot);
|
|
2999
3030
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
3000
3031
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -3034,7 +3065,7 @@ var stayFlatRule = {
|
|
|
3034
3065
|
};
|
|
3035
3066
|
|
|
3036
3067
|
// eslint/rules/type-extraction.ts
|
|
3037
|
-
import
|
|
3068
|
+
import path31 from "path";
|
|
3038
3069
|
var typeExtractionRule = {
|
|
3039
3070
|
meta: {
|
|
3040
3071
|
schema: [],
|
|
@@ -3045,7 +3076,7 @@ var typeExtractionRule = {
|
|
|
3045
3076
|
},
|
|
3046
3077
|
create(context) {
|
|
3047
3078
|
const sourceRoot = sourceRootOf(context);
|
|
3048
|
-
const file =
|
|
3079
|
+
const file = path31.resolve(context.filename);
|
|
3049
3080
|
const segments = segmentsOf(file, sourceRoot);
|
|
3050
3081
|
if (segments.length === 0) return {};
|
|
3051
3082
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -3091,7 +3122,7 @@ var typeExtractionRule = {
|
|
|
3091
3122
|
};
|
|
3092
3123
|
|
|
3093
3124
|
// eslint/rules/locale-placement.ts
|
|
3094
|
-
import
|
|
3125
|
+
import path32 from "path";
|
|
3095
3126
|
import { readFileSync as readFileSync3 } from "fs";
|
|
3096
3127
|
import ts5 from "typescript";
|
|
3097
3128
|
var LOCALE_ACCESS = /\blocales\.(?<key>[A-Za-z_$][\w$]*)/g;
|
|
@@ -3139,7 +3170,7 @@ var localePlacementRule = {
|
|
|
3139
3170
|
},
|
|
3140
3171
|
create(context) {
|
|
3141
3172
|
const sourceRoot = sourceRootOf(context);
|
|
3142
|
-
const file =
|
|
3173
|
+
const file = path32.resolve(context.filename);
|
|
3143
3174
|
const segments = segmentsOf(file, sourceRoot);
|
|
3144
3175
|
if (segments.length === 0) return {};
|
|
3145
3176
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -3217,7 +3248,7 @@ var localePlacementRule = {
|
|
|
3217
3248
|
};
|
|
3218
3249
|
|
|
3219
3250
|
// eslint/rules/sole-state-owner.ts
|
|
3220
|
-
import
|
|
3251
|
+
import path33 from "path";
|
|
3221
3252
|
import ts6 from "typescript";
|
|
3222
3253
|
function findStateHooks(node) {
|
|
3223
3254
|
const hooks = [];
|
|
@@ -3297,7 +3328,7 @@ var soleStateOwnerRule = {
|
|
|
3297
3328
|
}
|
|
3298
3329
|
},
|
|
3299
3330
|
create(context) {
|
|
3300
|
-
const filename =
|
|
3331
|
+
const filename = path33.resolve(context.filename);
|
|
3301
3332
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
3302
3333
|
const text = context.sourceCode.text;
|
|
3303
3334
|
const components = parseComponentInfo(text, filename);
|
|
@@ -3376,7 +3407,7 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
3376
3407
|
}
|
|
3377
3408
|
|
|
3378
3409
|
// eslint/rules/locale-key-shape.ts
|
|
3379
|
-
import
|
|
3410
|
+
import path34 from "path";
|
|
3380
3411
|
var MAX_KEY_LENGTH = 30;
|
|
3381
3412
|
var ROLE_POSTFIXES = /* @__PURE__ */ new Set([
|
|
3382
3413
|
"Button",
|
|
@@ -3426,7 +3457,7 @@ var ROLE_POSTFIXES = /* @__PURE__ */ new Set([
|
|
|
3426
3457
|
var CAMEL_CASE = /^[a-z][a-zA-Z0-9]*$/;
|
|
3427
3458
|
var ENGLISH = /^[A-Za-z0-9_]*$/;
|
|
3428
3459
|
function isLocalesFile2(filename) {
|
|
3429
|
-
const segments =
|
|
3460
|
+
const segments = path34.resolve(filename).split(path34.sep);
|
|
3430
3461
|
const srcIdx = segments.lastIndexOf("src");
|
|
3431
3462
|
return srcIdx !== -1 && segments[srcIdx + 1] === "locales";
|
|
3432
3463
|
}
|
|
@@ -3497,7 +3528,7 @@ var localeKeyShapeRule = {
|
|
|
3497
3528
|
};
|
|
3498
3529
|
|
|
3499
3530
|
// eslint/rules/shared-style-dedup.ts
|
|
3500
|
-
import
|
|
3531
|
+
import path35 from "path";
|
|
3501
3532
|
import { readFileSync as readFileSync4, statSync as statSync3 } from "fs";
|
|
3502
3533
|
var CLASS_NAME = /className="(?<classes>[^"]+)"/g;
|
|
3503
3534
|
var comboCache;
|
|
@@ -3539,7 +3570,7 @@ var sharedStyleDedupRule = {
|
|
|
3539
3570
|
},
|
|
3540
3571
|
create(context) {
|
|
3541
3572
|
const sourceRoot = sourceRootOf(context);
|
|
3542
|
-
const file =
|
|
3573
|
+
const file = path35.resolve(context.filename);
|
|
3543
3574
|
const segments = segmentsOf(file, sourceRoot);
|
|
3544
3575
|
if (segments.length === 0) return {};
|
|
3545
3576
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -3743,7 +3774,7 @@ var zodSchemaValidationRule = {
|
|
|
3743
3774
|
};
|
|
3744
3775
|
|
|
3745
3776
|
// eslint/rules/source-under-src.ts
|
|
3746
|
-
import
|
|
3777
|
+
import path36 from "path";
|
|
3747
3778
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
3748
3779
|
".agents",
|
|
3749
3780
|
".cache",
|
|
@@ -3784,14 +3815,14 @@ var sourceUnderSrcRule = {
|
|
|
3784
3815
|
}
|
|
3785
3816
|
},
|
|
3786
3817
|
create(context) {
|
|
3787
|
-
const filename =
|
|
3818
|
+
const filename = path36.resolve(context.filename);
|
|
3788
3819
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
3789
|
-
const relative =
|
|
3820
|
+
const relative = path36.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
3790
3821
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
3791
3822
|
const topLevel = relative.split("/")[0] ?? "";
|
|
3792
3823
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
3793
3824
|
if (!relative.includes("/")) {
|
|
3794
|
-
const basename =
|
|
3825
|
+
const basename = path36.basename(filename);
|
|
3795
3826
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
3796
3827
|
}
|
|
3797
3828
|
return {
|
|
@@ -3808,7 +3839,7 @@ var sourceUnderSrcRule = {
|
|
|
3808
3839
|
|
|
3809
3840
|
// eslint/rules/zirka-baseline.ts
|
|
3810
3841
|
import fs5 from "fs";
|
|
3811
|
-
import
|
|
3842
|
+
import path37 from "path";
|
|
3812
3843
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
3813
3844
|
var PRETTIER_CONFIGS = [
|
|
3814
3845
|
"prettier.config.mjs",
|
|
@@ -3827,10 +3858,10 @@ var zirkaBaselineRule = {
|
|
|
3827
3858
|
}
|
|
3828
3859
|
},
|
|
3829
3860
|
create(context) {
|
|
3830
|
-
const filename =
|
|
3831
|
-
const basename =
|
|
3861
|
+
const filename = path37.resolve(context.filename);
|
|
3862
|
+
const basename = path37.basename(filename);
|
|
3832
3863
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
3833
|
-
const projectRoot =
|
|
3864
|
+
const projectRoot = path37.dirname(filename);
|
|
3834
3865
|
const report3 = (message) => {
|
|
3835
3866
|
context.report({
|
|
3836
3867
|
node: context.sourceCode.ast,
|
|
@@ -3845,7 +3876,7 @@ var zirkaBaselineRule = {
|
|
|
3845
3876
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
3846
3877
|
);
|
|
3847
3878
|
}
|
|
3848
|
-
const tsconfigPath =
|
|
3879
|
+
const tsconfigPath = path37.join(projectRoot, "tsconfig.json");
|
|
3849
3880
|
if (!fs5.existsSync(tsconfigPath)) {
|
|
3850
3881
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
3851
3882
|
} else {
|
|
@@ -3863,13 +3894,13 @@ var zirkaBaselineRule = {
|
|
|
3863
3894
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
3864
3895
|
}
|
|
3865
3896
|
}
|
|
3866
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs5.existsSync(
|
|
3897
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs5.existsSync(path37.join(projectRoot, name)));
|
|
3867
3898
|
if (!prettierConfigFile) {
|
|
3868
3899
|
report3(
|
|
3869
3900
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
3870
3901
|
);
|
|
3871
3902
|
} else {
|
|
3872
|
-
const content = fs5.readFileSync(
|
|
3903
|
+
const content = fs5.readFileSync(path37.join(projectRoot, prettierConfigFile), "utf8");
|
|
3873
3904
|
if (!content.includes("zirka")) {
|
|
3874
3905
|
report3(
|
|
3875
3906
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|
|
@@ -3939,7 +3970,7 @@ var docKindSuffixRule = {
|
|
|
3939
3970
|
};
|
|
3940
3971
|
|
|
3941
3972
|
// eslint/rules/documentation/title-matches-file-name.ts
|
|
3942
|
-
import
|
|
3973
|
+
import path38 from "path";
|
|
3943
3974
|
function toExpectedFileName(title) {
|
|
3944
3975
|
return `${title.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "")}.md`;
|
|
3945
3976
|
}
|
|
@@ -3959,7 +3990,7 @@ var titleMatchesFileNameRule = {
|
|
|
3959
3990
|
if (!filename.endsWith(".md")) return;
|
|
3960
3991
|
const title = getTextContent(node).trim();
|
|
3961
3992
|
const expectedFileName = toExpectedFileName(title);
|
|
3962
|
-
const actualFileName =
|
|
3993
|
+
const actualFileName = path38.basename(filename);
|
|
3963
3994
|
if (!title) {
|
|
3964
3995
|
context.report({
|
|
3965
3996
|
node,
|
|
@@ -4366,7 +4397,7 @@ var referenceBlockHeadingsRule = {
|
|
|
4366
4397
|
};
|
|
4367
4398
|
|
|
4368
4399
|
// eslint/rules/documentation/support-document-placement.ts
|
|
4369
|
-
import
|
|
4400
|
+
import path39 from "path";
|
|
4370
4401
|
var supportDocumentPlacementRule = {
|
|
4371
4402
|
meta: {
|
|
4372
4403
|
type: "problem",
|
|
@@ -4380,7 +4411,7 @@ var supportDocumentPlacementRule = {
|
|
|
4380
4411
|
root(node) {
|
|
4381
4412
|
const filename = getFilename(context);
|
|
4382
4413
|
if (!filename.endsWith(".md")) return;
|
|
4383
|
-
const parentFolder =
|
|
4414
|
+
const parentFolder = path39.basename(path39.dirname(filename));
|
|
4384
4415
|
if (filename.endsWith("-rule.md") && parentFolder !== "rules") {
|
|
4385
4416
|
context.report({
|
|
4386
4417
|
node,
|
|
@@ -4423,11 +4454,11 @@ var noTemplatePromptRule = {
|
|
|
4423
4454
|
};
|
|
4424
4455
|
|
|
4425
4456
|
// eslint/rules/documentation/guide-folder-entry-point.ts
|
|
4426
|
-
import
|
|
4457
|
+
import path41 from "path";
|
|
4427
4458
|
|
|
4428
4459
|
// eslint/rules/documentation/project-index.ts
|
|
4429
4460
|
import { readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync4 } from "fs";
|
|
4430
|
-
import
|
|
4461
|
+
import path40 from "path";
|
|
4431
4462
|
var KIND_BY_SUFFIX = [
|
|
4432
4463
|
["-rule.md", "rule"],
|
|
4433
4464
|
["-guide.md", "guide"],
|
|
@@ -4436,7 +4467,7 @@ var KIND_BY_SUFFIX = [
|
|
|
4436
4467
|
];
|
|
4437
4468
|
function listMarkdownFiles(dir) {
|
|
4438
4469
|
return readdirSync3(dir).flatMap((entry) => {
|
|
4439
|
-
const entryPath =
|
|
4470
|
+
const entryPath = path40.join(dir, entry);
|
|
4440
4471
|
if (statSync4(entryPath).isDirectory()) {
|
|
4441
4472
|
return entry.startsWith("_") ? [] : listMarkdownFiles(entryPath);
|
|
4442
4473
|
}
|
|
@@ -4454,11 +4485,11 @@ function getProjectDocs(docsRoot) {
|
|
|
4454
4485
|
if (cached) return cached;
|
|
4455
4486
|
const files = listMarkdownFiles(docsRoot);
|
|
4456
4487
|
const docs = files.sort((a, b) => a.localeCompare(b)).map((filePath) => {
|
|
4457
|
-
const fileName =
|
|
4488
|
+
const fileName = path40.basename(filePath);
|
|
4458
4489
|
const kind = KIND_BY_SUFFIX.find(([suffix]) => fileName.endsWith(suffix))?.[1];
|
|
4459
4490
|
return {
|
|
4460
4491
|
filePath,
|
|
4461
|
-
doc:
|
|
4492
|
+
doc: path40.relative(docsRoot, filePath).split(path40.sep).join("/"),
|
|
4462
4493
|
fileName,
|
|
4463
4494
|
kind,
|
|
4464
4495
|
title: extractTitle(filePath)
|
|
@@ -4468,12 +4499,12 @@ function getProjectDocs(docsRoot) {
|
|
|
4468
4499
|
return docs;
|
|
4469
4500
|
}
|
|
4470
4501
|
function findDocsRoot(filePath) {
|
|
4471
|
-
let dir =
|
|
4502
|
+
let dir = path40.dirname(filePath);
|
|
4472
4503
|
for (; ; ) {
|
|
4473
|
-
if (
|
|
4504
|
+
if (path40.basename(dir) === "docs" && statSync4(dir).isDirectory()) {
|
|
4474
4505
|
return dir;
|
|
4475
4506
|
}
|
|
4476
|
-
const parent =
|
|
4507
|
+
const parent = path40.dirname(dir);
|
|
4477
4508
|
if (parent === dir) return void 0;
|
|
4478
4509
|
dir = parent;
|
|
4479
4510
|
}
|
|
@@ -4497,13 +4528,13 @@ var guideFolderEntryPointRule = {
|
|
|
4497
4528
|
if (!docsRoot) return;
|
|
4498
4529
|
const docs = getProjectDocs(docsRoot);
|
|
4499
4530
|
const guideFolders = new Set(
|
|
4500
|
-
docs.filter((doc) => ["rules", "references"].includes(
|
|
4531
|
+
docs.filter((doc) => ["rules", "references"].includes(path41.basename(path41.dirname(doc.filePath)))).map((doc) => path41.dirname(path41.dirname(doc.filePath))).filter((folder) => path41.resolve(folder) !== path41.resolve(docsRoot))
|
|
4501
4532
|
);
|
|
4502
|
-
const currentDir =
|
|
4533
|
+
const currentDir = path41.dirname(filename);
|
|
4503
4534
|
if (guideFolders.has(currentDir)) {
|
|
4504
|
-
const expectedEntryPoint = `${
|
|
4535
|
+
const expectedEntryPoint = `${path41.basename(currentDir)}.md`;
|
|
4505
4536
|
const hasEntryPoint = docs.some(
|
|
4506
|
-
(doc) => doc.kind === "guide" &&
|
|
4537
|
+
(doc) => doc.kind === "guide" && path41.dirname(doc.filePath) === currentDir && doc.fileName === expectedEntryPoint
|
|
4507
4538
|
);
|
|
4508
4539
|
if (!hasEntryPoint) {
|
|
4509
4540
|
context.report({
|
|
@@ -4728,7 +4759,7 @@ var noNestedHowToRule = {
|
|
|
4728
4759
|
|
|
4729
4760
|
// eslint/rules/documentation/glossary-term-linking.ts
|
|
4730
4761
|
import { readFileSync as readFileSync6 } from "fs";
|
|
4731
|
-
import
|
|
4762
|
+
import path42 from "path";
|
|
4732
4763
|
function extractGlossaryTerms(filePath) {
|
|
4733
4764
|
const content = readFileSync6(filePath, "utf8");
|
|
4734
4765
|
const terms = [];
|
|
@@ -4782,9 +4813,9 @@ var glossaryTermLinkingRule = {
|
|
|
4782
4813
|
const docsRoot = findDocsRoot(filename);
|
|
4783
4814
|
if (!docsRoot) return;
|
|
4784
4815
|
const docs = getProjectDocs(docsRoot);
|
|
4785
|
-
const guideDir =
|
|
4816
|
+
const guideDir = path42.dirname(filename);
|
|
4786
4817
|
const guideReferences = docs.filter(
|
|
4787
|
-
(doc) => doc.kind === "reference" &&
|
|
4818
|
+
(doc) => doc.kind === "reference" && path42.dirname(doc.filePath) === guideDir
|
|
4788
4819
|
);
|
|
4789
4820
|
if (guideReferences.length === 0) return;
|
|
4790
4821
|
const glossaryTerms = [];
|
|
@@ -4809,7 +4840,7 @@ var glossaryTermLinkingRule = {
|
|
|
4809
4840
|
|
|
4810
4841
|
// eslint/rules/documentation/guide-mentions-documents.ts
|
|
4811
4842
|
import { existsSync } from "fs";
|
|
4812
|
-
import
|
|
4843
|
+
import path43 from "path";
|
|
4813
4844
|
function visitSteps3(node, check) {
|
|
4814
4845
|
if (node.type === "list" && node.ordered) {
|
|
4815
4846
|
for (const child of node.children) check(child);
|
|
@@ -4842,12 +4873,12 @@ var guideMentionsDocumentsRule = {
|
|
|
4842
4873
|
if (!filename.endsWith("-guide.md")) return;
|
|
4843
4874
|
const docsRoot = findDocsRoot(filename);
|
|
4844
4875
|
if (!docsRoot) return;
|
|
4845
|
-
const guideDir =
|
|
4846
|
-
if (
|
|
4876
|
+
const guideDir = path43.dirname(filename);
|
|
4877
|
+
if (path43.basename(filename, ".md") !== path43.basename(guideDir)) return;
|
|
4847
4878
|
const docs = getProjectDocs(docsRoot);
|
|
4848
4879
|
const owned = docs.filter((doc) => {
|
|
4849
|
-
const parent =
|
|
4850
|
-
return parent ===
|
|
4880
|
+
const parent = path43.dirname(doc.filePath);
|
|
4881
|
+
return parent === path43.join(guideDir, "rules") || parent === path43.join(guideDir, "references");
|
|
4851
4882
|
});
|
|
4852
4883
|
const allLinks = [];
|
|
4853
4884
|
collectMarkdownLinks(node, allLinks);
|
|
@@ -4874,7 +4905,7 @@ var guideMentionsDocumentsRule = {
|
|
|
4874
4905
|
for (const link of allLinks) {
|
|
4875
4906
|
const target = linkTarget(link.url);
|
|
4876
4907
|
if (!target.endsWith(".md")) continue;
|
|
4877
|
-
const resolved =
|
|
4908
|
+
const resolved = path43.normalize(path43.join(guideDir, target));
|
|
4878
4909
|
if (!existsSync(resolved)) {
|
|
4879
4910
|
context.report({
|
|
4880
4911
|
node: link,
|
|
@@ -5326,11 +5357,11 @@ var themeVariableNamespaceRule = {
|
|
|
5326
5357
|
|
|
5327
5358
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
5328
5359
|
import { statSync as statSync6 } from "fs";
|
|
5329
|
-
import
|
|
5360
|
+
import path46 from "path";
|
|
5330
5361
|
|
|
5331
5362
|
// eslint/rules/tailwind/source-files.ts
|
|
5332
5363
|
import { readdirSync as readdirSync4, readFileSync as readFileSync7, statSync as statSync5 } from "fs";
|
|
5333
|
-
import
|
|
5364
|
+
import path44 from "path";
|
|
5334
5365
|
var CSS_EXTENSIONS = [".css"];
|
|
5335
5366
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
5336
5367
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS3, ...CSS_EXTENSIONS];
|
|
@@ -5343,7 +5374,7 @@ function findFiles(dir, extensions) {
|
|
|
5343
5374
|
}
|
|
5344
5375
|
return entries.flatMap((entry) => {
|
|
5345
5376
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
5346
|
-
const entryPath =
|
|
5377
|
+
const entryPath = path44.join(dir, entry);
|
|
5347
5378
|
let stats;
|
|
5348
5379
|
try {
|
|
5349
5380
|
stats = statSync5(entryPath);
|
|
@@ -5351,7 +5382,7 @@ function findFiles(dir, extensions) {
|
|
|
5351
5382
|
return [];
|
|
5352
5383
|
}
|
|
5353
5384
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
5354
|
-
return extensions.includes(
|
|
5385
|
+
return extensions.includes(path44.extname(entry)) ? [entryPath] : [];
|
|
5355
5386
|
});
|
|
5356
5387
|
}
|
|
5357
5388
|
function cachedTextReader() {
|
|
@@ -5374,7 +5405,7 @@ function escapeRegExp(text) {
|
|
|
5374
5405
|
}
|
|
5375
5406
|
|
|
5376
5407
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
5377
|
-
import
|
|
5408
|
+
import path45 from "path";
|
|
5378
5409
|
function registersTailwind(text) {
|
|
5379
5410
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
5380
5411
|
}
|
|
@@ -5388,25 +5419,25 @@ function moduleImports(text, fileName) {
|
|
|
5388
5419
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
5389
5420
|
}
|
|
5390
5421
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
5391
|
-
if (spec.startsWith("/")) return
|
|
5392
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
5393
|
-
if (spec.startsWith("@/")) return
|
|
5422
|
+
if (spec.startsWith("/")) return path45.resolve(spec);
|
|
5423
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path45.resolve(path45.dirname(fromFile), spec);
|
|
5424
|
+
if (spec.startsWith("@/")) return path45.resolve(sourceRoot, spec.slice(2));
|
|
5394
5425
|
return void 0;
|
|
5395
5426
|
}
|
|
5396
5427
|
function buildStylesheetGraph(options) {
|
|
5397
5428
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
5398
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
5429
|
+
const cssSet = new Set(cssFiles.map((file) => path45.normalize(file)));
|
|
5399
5430
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
5400
5431
|
const reachable = /* @__PURE__ */ new Set();
|
|
5401
5432
|
const queue = [...globals];
|
|
5402
|
-
for (const global of globals) reachable.add(
|
|
5433
|
+
for (const global of globals) reachable.add(path45.normalize(global));
|
|
5403
5434
|
while (queue.length > 0) {
|
|
5404
5435
|
const from = queue.shift();
|
|
5405
5436
|
if (!from) continue;
|
|
5406
5437
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
5407
5438
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
5408
5439
|
if (!target) continue;
|
|
5409
|
-
const normalized =
|
|
5440
|
+
const normalized = path45.normalize(target);
|
|
5410
5441
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
5411
5442
|
reachable.add(normalized);
|
|
5412
5443
|
queue.push(normalized);
|
|
@@ -5418,7 +5449,7 @@ function buildStylesheetGraph(options) {
|
|
|
5418
5449
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
5419
5450
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
5420
5451
|
if (!target) continue;
|
|
5421
|
-
const normalized =
|
|
5452
|
+
const normalized = path45.normalize(target);
|
|
5422
5453
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
5423
5454
|
}
|
|
5424
5455
|
}
|
|
@@ -5451,7 +5482,7 @@ var cssEntryPointRule = {
|
|
|
5451
5482
|
return {
|
|
5452
5483
|
"StyleSheet:exit"(node) {
|
|
5453
5484
|
if (globals.length === 0) return;
|
|
5454
|
-
const current =
|
|
5485
|
+
const current = path46.normalize(path46.resolve(context.filename));
|
|
5455
5486
|
if (globals.includes(current)) {
|
|
5456
5487
|
if (globals.length > 1) {
|
|
5457
5488
|
context.report({
|
|
@@ -5460,7 +5491,7 @@ var cssEntryPointRule = {
|
|
|
5460
5491
|
});
|
|
5461
5492
|
return;
|
|
5462
5493
|
}
|
|
5463
|
-
const basename =
|
|
5494
|
+
const basename = path46.basename(current);
|
|
5464
5495
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
5465
5496
|
if (importCount !== 1) {
|
|
5466
5497
|
context.report({
|
|
@@ -5729,7 +5760,7 @@ var nextjsPackageJsonRules = {
|
|
|
5729
5760
|
|
|
5730
5761
|
// eslint/rules/husky/husky-hook.ts
|
|
5731
5762
|
import { existsSync as existsSync2, readFileSync as readFileSync8 } from "fs";
|
|
5732
|
-
import
|
|
5763
|
+
import path47 from "path";
|
|
5733
5764
|
function memberName4(member) {
|
|
5734
5765
|
return member.name.type === "String" ? member.name.value : member.name.name;
|
|
5735
5766
|
}
|
|
@@ -5748,7 +5779,7 @@ var huskyHookRule = {
|
|
|
5748
5779
|
if (root.type !== "Object") return;
|
|
5749
5780
|
const scriptName = context.filename;
|
|
5750
5781
|
if (!scriptName.endsWith("package.json")) return;
|
|
5751
|
-
const hookPath =
|
|
5782
|
+
const hookPath = path47.join(context.cwd, ".husky", "pre-commit");
|
|
5752
5783
|
if (!existsSync2(hookPath)) {
|
|
5753
5784
|
context.report({
|
|
5754
5785
|
node,
|
|
@@ -5788,7 +5819,7 @@ var huskyRules = {
|
|
|
5788
5819
|
|
|
5789
5820
|
// eslint/rules/vulyk/vulyk-docs.ts
|
|
5790
5821
|
import { existsSync as existsSync3, readFileSync as readFileSync9 } from "fs";
|
|
5791
|
-
import
|
|
5822
|
+
import path48 from "path";
|
|
5792
5823
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
5793
5824
|
var BASE_REQUIRED_DOCS = [
|
|
5794
5825
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -5821,8 +5852,8 @@ var vulykDocsRule = {
|
|
|
5821
5852
|
if (!context.filename.endsWith("package.json")) return;
|
|
5822
5853
|
const root = node.body;
|
|
5823
5854
|
if (root.type !== "Object") return;
|
|
5824
|
-
const projectRoot =
|
|
5825
|
-
const configPath =
|
|
5855
|
+
const projectRoot = path48.dirname(path48.resolve(context.filename));
|
|
5856
|
+
const configPath = path48.join(projectRoot, "vulyk.config.ts");
|
|
5826
5857
|
if (!existsSync3(configPath)) {
|
|
5827
5858
|
context.report({
|
|
5828
5859
|
node,
|
|
@@ -5847,7 +5878,7 @@ var vulykDocsRule = {
|
|
|
5847
5878
|
});
|
|
5848
5879
|
}
|
|
5849
5880
|
}
|
|
5850
|
-
const agentsPath =
|
|
5881
|
+
const agentsPath = path48.join(projectRoot, "AGENTS.md");
|
|
5851
5882
|
if (!existsSync3(agentsPath)) {
|
|
5852
5883
|
context.report({
|
|
5853
5884
|
node,
|