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