pasika 0.10.43 → 0.10.44
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 +110 -89
- package/package.json +1 -1
|
@@ -4709,8 +4709,10 @@ var noMixedConcernsRule = {
|
|
|
4709
4709
|
};
|
|
4710
4710
|
|
|
4711
4711
|
// eslint/rules/no-redundant-alias.ts
|
|
4712
|
+
import path37 from "path";
|
|
4712
4713
|
var DOC3 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
4713
4714
|
var VALUE_SENTINELS = /* @__PURE__ */ new Set(["undefined", "NaN", "Infinity"]);
|
|
4715
|
+
var HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
4714
4716
|
function entityNameText(name) {
|
|
4715
4717
|
if (!name) return void 0;
|
|
4716
4718
|
if (name.type === "Identifier") return name.name;
|
|
@@ -4743,7 +4745,11 @@ var noRedundantAliasRule = {
|
|
|
4743
4745
|
return {
|
|
4744
4746
|
VariableDeclarator(node) {
|
|
4745
4747
|
if (node.id.type !== "Identifier" || node.init?.type !== "Identifier") return;
|
|
4746
|
-
|
|
4748
|
+
const declaration = node.parent;
|
|
4749
|
+
if (declaration.type !== "VariableDeclaration" || declaration.kind !== "const") return;
|
|
4750
|
+
const exported = declaration.parent.type === "ExportNamedDeclaration";
|
|
4751
|
+
const frameworkRouteAlias = path37.basename(context.filename) === "route.ts" && exported && HTTP_METHODS.has(node.id.name);
|
|
4752
|
+
if (frameworkRouteAlias || VALUE_SENTINELS.has(node.init.name)) return;
|
|
4747
4753
|
context.report({
|
|
4748
4754
|
node,
|
|
4749
4755
|
message: aliasMessage(node.id.name, node.init.name)
|
|
@@ -4776,7 +4782,7 @@ var noRedundantAliasRule = {
|
|
|
4776
4782
|
};
|
|
4777
4783
|
|
|
4778
4784
|
// eslint/rules/no-util-barrel.ts
|
|
4779
|
-
import
|
|
4785
|
+
import path38 from "path";
|
|
4780
4786
|
var noUtilBarrelRule = {
|
|
4781
4787
|
meta: {
|
|
4782
4788
|
schema: [],
|
|
@@ -4786,7 +4792,7 @@ var noUtilBarrelRule = {
|
|
|
4786
4792
|
}
|
|
4787
4793
|
},
|
|
4788
4794
|
create(context) {
|
|
4789
|
-
const filename =
|
|
4795
|
+
const filename = path38.resolve(context.filename);
|
|
4790
4796
|
const sourceRoot = sourceRootOf3(context, filename);
|
|
4791
4797
|
return {
|
|
4792
4798
|
Program(node) {
|
|
@@ -4795,7 +4801,7 @@ var noUtilBarrelRule = {
|
|
|
4795
4801
|
if (!target) continue;
|
|
4796
4802
|
const segments = target.replace(/\\/g, "/").split("/");
|
|
4797
4803
|
const utilsIndex = segments.lastIndexOf("utils");
|
|
4798
|
-
if (utilsIndex < 0 || !
|
|
4804
|
+
if (utilsIndex < 0 || !path38.basename(target).startsWith("index.")) continue;
|
|
4799
4805
|
context.report({
|
|
4800
4806
|
node,
|
|
4801
4807
|
message: `Import utilities directly instead of through "${specifier}". See docs/next-codebase-guide/rules/utilities-rule.md`
|
|
@@ -4815,10 +4821,10 @@ function importSpecifiers2(source) {
|
|
|
4815
4821
|
return specifiers;
|
|
4816
4822
|
}
|
|
4817
4823
|
function sourceRootOf3(context, filename) {
|
|
4818
|
-
const marker = `${
|
|
4824
|
+
const marker = `${path38.sep}src${path38.sep}`;
|
|
4819
4825
|
const srcIndex = filename.lastIndexOf(marker);
|
|
4820
4826
|
if (srcIndex >= 0) return filename.slice(0, srcIndex + marker.length - 1);
|
|
4821
|
-
return
|
|
4827
|
+
return path38.resolve(context.cwd ?? process.cwd(), "src");
|
|
4822
4828
|
}
|
|
4823
4829
|
|
|
4824
4830
|
// eslint/rules/package-json/exact-version.ts
|
|
@@ -5037,7 +5043,7 @@ var nextjsStackRule = {
|
|
|
5037
5043
|
|
|
5038
5044
|
// eslint/rules/package-json/vitest-coverage.ts
|
|
5039
5045
|
import { existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
|
|
5040
|
-
import
|
|
5046
|
+
import path39 from "path";
|
|
5041
5047
|
function memberName5(member) {
|
|
5042
5048
|
return member.name.type === "String" ? member.name.value : member.name.name;
|
|
5043
5049
|
}
|
|
@@ -5106,7 +5112,7 @@ var vitestCoverageRule = {
|
|
|
5106
5112
|
message: 'package.json must declare a "test:unit:coverage" script that runs Vitest with coverage.'
|
|
5107
5113
|
});
|
|
5108
5114
|
}
|
|
5109
|
-
const configName = VITEST_CONFIG_NAMES2.find((name) => existsSync5(
|
|
5115
|
+
const configName = VITEST_CONFIG_NAMES2.find((name) => existsSync5(path39.join(context.cwd, name)));
|
|
5110
5116
|
if (!configName) {
|
|
5111
5117
|
context.report({
|
|
5112
5118
|
node,
|
|
@@ -5114,7 +5120,7 @@ var vitestCoverageRule = {
|
|
|
5114
5120
|
});
|
|
5115
5121
|
return;
|
|
5116
5122
|
}
|
|
5117
|
-
const content = readFileSync8(
|
|
5123
|
+
const content = readFileSync8(path39.join(context.cwd, configName), "utf8");
|
|
5118
5124
|
for (const metric of THRESHOLD_METRICS) {
|
|
5119
5125
|
if (!new RegExp(`\\b${metric}\\s*:\\s*[1-9]\\d*`).test(content)) {
|
|
5120
5126
|
context.report({ node, message: `${configName} must set a coverage threshold above zero for ${metric}.` });
|
|
@@ -5160,7 +5166,7 @@ var nextjsPackageJsonRules = {
|
|
|
5160
5166
|
};
|
|
5161
5167
|
|
|
5162
5168
|
// eslint/rules/prefer-enum.ts
|
|
5163
|
-
import
|
|
5169
|
+
import path40 from "path";
|
|
5164
5170
|
function isConstAssertion(node) {
|
|
5165
5171
|
const typeAnnotation = node.typeAnnotation;
|
|
5166
5172
|
return typeAnnotation?.type === "TSTypeReference" && typeAnnotation.typeName?.type === "Identifier" && typeAnnotation.typeName.name === "const";
|
|
@@ -5170,18 +5176,26 @@ function isEnumConvertibleProperty(property) {
|
|
|
5170
5176
|
const { value } = property;
|
|
5171
5177
|
return value.type === "Literal" && (typeof value.value === "string" || typeof value.value === "number");
|
|
5172
5178
|
}
|
|
5179
|
+
function isEnumLiteralType(node) {
|
|
5180
|
+
if (node.type !== "TSLiteralType") return false;
|
|
5181
|
+
const value = node.literal?.value;
|
|
5182
|
+
return typeof value === "string" || typeof value === "number";
|
|
5183
|
+
}
|
|
5184
|
+
function isEnumLiteralUnion(node) {
|
|
5185
|
+
return node?.type === "TSUnionType" && (node.types?.length ?? 0) >= 2 && (node.types ?? []).every(isEnumLiteralType);
|
|
5186
|
+
}
|
|
5173
5187
|
var preferEnumRule = {
|
|
5174
5188
|
meta: {
|
|
5175
5189
|
schema: [],
|
|
5176
5190
|
type: "problem",
|
|
5177
5191
|
docs: {
|
|
5178
|
-
description: "Require
|
|
5192
|
+
description: "Require fixed sets of named string/number values to be TypeScript enums instead of `as const` objects or literal-union type aliases."
|
|
5179
5193
|
}
|
|
5180
5194
|
},
|
|
5181
5195
|
create(context) {
|
|
5182
|
-
const filename =
|
|
5196
|
+
const filename = path40.resolve(context.filename);
|
|
5183
5197
|
const sourceRoot = sourceRootOf(context);
|
|
5184
|
-
if (!filename.startsWith(sourceRoot +
|
|
5198
|
+
if (!filename.startsWith(sourceRoot + path40.sep)) return {};
|
|
5185
5199
|
return {
|
|
5186
5200
|
TSAsExpression(node) {
|
|
5187
5201
|
if (!isConstAssertion(node)) return;
|
|
@@ -5193,13 +5207,20 @@ var preferEnumRule = {
|
|
|
5193
5207
|
node,
|
|
5194
5208
|
message: "A fixed set of named values must be a TypeScript enum, not an object literal marked as const. See docs/next-codebase-guide/rules/constants-rule.md"
|
|
5195
5209
|
});
|
|
5210
|
+
},
|
|
5211
|
+
TSTypeAliasDeclaration(node) {
|
|
5212
|
+
if (node.typeParameters || !isEnumLiteralUnion(node.typeAnnotation)) return;
|
|
5213
|
+
context.report({
|
|
5214
|
+
node,
|
|
5215
|
+
message: "A named union made only of string or number literals must be a TypeScript enum. See docs/next-codebase-guide/rules/constants-rule.md"
|
|
5216
|
+
});
|
|
5196
5217
|
}
|
|
5197
5218
|
};
|
|
5198
5219
|
}
|
|
5199
5220
|
};
|
|
5200
5221
|
|
|
5201
5222
|
// eslint/rules/pure-function-extract.ts
|
|
5202
|
-
import
|
|
5223
|
+
import path41 from "path";
|
|
5203
5224
|
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
5204
5225
|
"GET",
|
|
5205
5226
|
"POST",
|
|
@@ -5243,12 +5264,12 @@ var pureFunctionExtractRule = {
|
|
|
5243
5264
|
},
|
|
5244
5265
|
create(context) {
|
|
5245
5266
|
const filename = context.filename;
|
|
5246
|
-
const isRouteFile =
|
|
5267
|
+
const isRouteFile = path41.basename(filename) === "route.ts";
|
|
5247
5268
|
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
5248
5269
|
const sourceRoot = sourceRootOf(context);
|
|
5249
|
-
const relative =
|
|
5270
|
+
const relative = path41.relative(sourceRoot, filename);
|
|
5250
5271
|
if (relative.startsWith("..")) return {};
|
|
5251
|
-
const segments = relative.split(
|
|
5272
|
+
const segments = relative.split(path41.sep);
|
|
5252
5273
|
const folders = segments.slice(0, -1);
|
|
5253
5274
|
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
5254
5275
|
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
@@ -5437,7 +5458,7 @@ var repeatedStructureRule = {
|
|
|
5437
5458
|
};
|
|
5438
5459
|
|
|
5439
5460
|
// eslint/rules/root-support-placement.ts
|
|
5440
|
-
import
|
|
5461
|
+
import path42 from "path";
|
|
5441
5462
|
function isSupportFolder(value) {
|
|
5442
5463
|
return value === "utils" || value === "types" || value === "schemas" || value === "constants";
|
|
5443
5464
|
}
|
|
@@ -5470,7 +5491,7 @@ var rootSupportPlacementRule = {
|
|
|
5470
5491
|
},
|
|
5471
5492
|
create(context) {
|
|
5472
5493
|
const sourceRoot = sourceRootOf(context);
|
|
5473
|
-
const file =
|
|
5494
|
+
const file = path42.resolve(context.filename);
|
|
5474
5495
|
const segments = segmentsOf(file, sourceRoot);
|
|
5475
5496
|
const folderSegments = folderSegmentsOf(file, sourceRoot);
|
|
5476
5497
|
const supportFolder = folderSegments[folderSegments.length - 1];
|
|
@@ -5510,9 +5531,9 @@ var rootSupportPlacementRule = {
|
|
|
5510
5531
|
};
|
|
5511
5532
|
|
|
5512
5533
|
// eslint/rules/route-handler-shape.ts
|
|
5513
|
-
import
|
|
5534
|
+
import path43 from "path";
|
|
5514
5535
|
import ts7 from "typescript";
|
|
5515
|
-
var
|
|
5536
|
+
var HTTP_METHODS2 = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
5516
5537
|
var REQUIRED_BOUNDARY = "withResponse";
|
|
5517
5538
|
function isFunctionLike(node) {
|
|
5518
5539
|
return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression";
|
|
@@ -5595,7 +5616,7 @@ var routeHandlerShapeRule = {
|
|
|
5595
5616
|
}
|
|
5596
5617
|
},
|
|
5597
5618
|
create(context) {
|
|
5598
|
-
if (
|
|
5619
|
+
if (path43.basename(context.filename) !== "route.ts") return {};
|
|
5599
5620
|
const sourceText = context.sourceCode.text;
|
|
5600
5621
|
function reportUnwrapped(node, name) {
|
|
5601
5622
|
context.report({
|
|
@@ -5639,14 +5660,14 @@ var routeHandlerShapeRule = {
|
|
|
5639
5660
|
FunctionDeclaration(node) {
|
|
5640
5661
|
const exported = node.parent?.type === "ExportNamedDeclaration";
|
|
5641
5662
|
const name = node.id?.name;
|
|
5642
|
-
if (!exported || !name || !
|
|
5663
|
+
if (!exported || !name || !HTTP_METHODS2.has(name) || !node.body) return;
|
|
5643
5664
|
reportUnwrapped(node, name);
|
|
5644
5665
|
},
|
|
5645
5666
|
VariableDeclarator(node) {
|
|
5646
5667
|
if (node.id.type !== "Identifier") return;
|
|
5647
5668
|
const name = node.id.name;
|
|
5648
5669
|
const exported = node.parent.parent?.type === "ExportNamedDeclaration";
|
|
5649
|
-
if (!exported || !
|
|
5670
|
+
if (!exported || !HTTP_METHODS2.has(name) || !node.init) return;
|
|
5650
5671
|
checkExport(node, name, node.init);
|
|
5651
5672
|
}
|
|
5652
5673
|
};
|
|
@@ -5654,7 +5675,7 @@ var routeHandlerShapeRule = {
|
|
|
5654
5675
|
};
|
|
5655
5676
|
|
|
5656
5677
|
// eslint/rules/schema-casing.ts
|
|
5657
|
-
import
|
|
5678
|
+
import path44 from "path";
|
|
5658
5679
|
function isCamelCase(name) {
|
|
5659
5680
|
return /^[a-z][a-zA-Z0-9]*$/.test(name);
|
|
5660
5681
|
}
|
|
@@ -5682,9 +5703,9 @@ var schemaCasingRule = {
|
|
|
5682
5703
|
}
|
|
5683
5704
|
},
|
|
5684
5705
|
create(context) {
|
|
5685
|
-
const filename =
|
|
5706
|
+
const filename = path44.resolve(context.filename);
|
|
5686
5707
|
const sourceRoot = sourceRootOf(context);
|
|
5687
|
-
if (!filename.startsWith(sourceRoot +
|
|
5708
|
+
if (!filename.startsWith(sourceRoot + path44.sep)) return {};
|
|
5688
5709
|
let zodLocalName;
|
|
5689
5710
|
return {
|
|
5690
5711
|
ImportDeclaration(node) {
|
|
@@ -5716,7 +5737,7 @@ var schemaCasingRule = {
|
|
|
5716
5737
|
};
|
|
5717
5738
|
|
|
5718
5739
|
// eslint/rules/sole-state-owner.ts
|
|
5719
|
-
import
|
|
5740
|
+
import path45 from "path";
|
|
5720
5741
|
import ts8 from "typescript";
|
|
5721
5742
|
function findStateHooks(node) {
|
|
5722
5743
|
const hooks = [];
|
|
@@ -5796,7 +5817,7 @@ var soleStateOwnerRule = {
|
|
|
5796
5817
|
}
|
|
5797
5818
|
},
|
|
5798
5819
|
create(context) {
|
|
5799
|
-
const filename =
|
|
5820
|
+
const filename = path45.resolve(context.filename);
|
|
5800
5821
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
5801
5822
|
const text = context.sourceCode.text;
|
|
5802
5823
|
const components = parseComponentInfo(text, filename);
|
|
@@ -5875,7 +5896,7 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
5875
5896
|
}
|
|
5876
5897
|
|
|
5877
5898
|
// eslint/rules/source-under-src.ts
|
|
5878
|
-
import
|
|
5899
|
+
import path46 from "path";
|
|
5879
5900
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
5880
5901
|
".agents",
|
|
5881
5902
|
".cache",
|
|
@@ -5916,14 +5937,14 @@ var sourceUnderSrcRule = {
|
|
|
5916
5937
|
}
|
|
5917
5938
|
},
|
|
5918
5939
|
create(context) {
|
|
5919
|
-
const filename =
|
|
5940
|
+
const filename = path46.resolve(context.filename);
|
|
5920
5941
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
5921
|
-
const relative =
|
|
5942
|
+
const relative = path46.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
5922
5943
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
5923
5944
|
const topLevel = relative.split("/")[0] ?? "";
|
|
5924
5945
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
5925
5946
|
if (!relative.includes("/")) {
|
|
5926
|
-
const basename =
|
|
5947
|
+
const basename = path46.basename(filename);
|
|
5927
5948
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
5928
5949
|
}
|
|
5929
5950
|
return {
|
|
@@ -5939,7 +5960,7 @@ var sourceUnderSrcRule = {
|
|
|
5939
5960
|
};
|
|
5940
5961
|
|
|
5941
5962
|
// eslint/rules/stay-flat.ts
|
|
5942
|
-
import
|
|
5963
|
+
import path47 from "path";
|
|
5943
5964
|
var stayFlatRule = {
|
|
5944
5965
|
meta: {
|
|
5945
5966
|
schema: [],
|
|
@@ -5950,7 +5971,7 @@ var stayFlatRule = {
|
|
|
5950
5971
|
},
|
|
5951
5972
|
create(context) {
|
|
5952
5973
|
const sourceRoot = sourceRootOf(context);
|
|
5953
|
-
const file =
|
|
5974
|
+
const file = path47.resolve(context.filename);
|
|
5954
5975
|
const segments = segmentsOf(file, sourceRoot);
|
|
5955
5976
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
5956
5977
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -5990,7 +6011,7 @@ var stayFlatRule = {
|
|
|
5990
6011
|
};
|
|
5991
6012
|
|
|
5992
6013
|
// eslint/rules/support-file-placement.ts
|
|
5993
|
-
import
|
|
6014
|
+
import path48 from "path";
|
|
5994
6015
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
5995
6016
|
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
5996
6017
|
["constants", "constant"],
|
|
@@ -6015,7 +6036,7 @@ var supportFilePlacementRule = {
|
|
|
6015
6036
|
},
|
|
6016
6037
|
create(context) {
|
|
6017
6038
|
const sourceRoot = sourceRootOf(context);
|
|
6018
|
-
const supportFile =
|
|
6039
|
+
const supportFile = path48.resolve(context.filename);
|
|
6019
6040
|
const currentFolder = folderSegmentsOf(supportFile, sourceRoot);
|
|
6020
6041
|
const supportFolder = currentFolder[currentFolder.length - 1];
|
|
6021
6042
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS.has(supportFolder)) return {};
|
|
@@ -6069,7 +6090,7 @@ var supportFilePlacementRule = {
|
|
|
6069
6090
|
|
|
6070
6091
|
// eslint/rules/support-folder-shape.ts
|
|
6071
6092
|
import fs5 from "fs";
|
|
6072
|
-
import
|
|
6093
|
+
import path49 from "path";
|
|
6073
6094
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
6074
6095
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
6075
6096
|
var supportFolderShapeRule = {
|
|
@@ -6081,12 +6102,12 @@ var supportFolderShapeRule = {
|
|
|
6081
6102
|
}
|
|
6082
6103
|
},
|
|
6083
6104
|
create(context) {
|
|
6084
|
-
const filename =
|
|
6085
|
-
const baseName =
|
|
6105
|
+
const filename = path49.resolve(context.filename);
|
|
6106
|
+
const baseName = path49.basename(filename);
|
|
6086
6107
|
if (!INDEX_NAMES.has(baseName)) return {};
|
|
6087
|
-
const folder =
|
|
6108
|
+
const folder = path49.basename(path49.dirname(filename));
|
|
6088
6109
|
if (!SUPPORT_FOLDERS3.has(folder)) return {};
|
|
6089
|
-
const directory =
|
|
6110
|
+
const directory = path49.dirname(filename);
|
|
6090
6111
|
let entries;
|
|
6091
6112
|
try {
|
|
6092
6113
|
entries = fs5.readdirSync(directory);
|
|
@@ -6103,7 +6124,7 @@ var supportFolderShapeRule = {
|
|
|
6103
6124
|
const exportPattern = /export\s+(?:\{[^}]*\}|\*[^;]*)\s+from\s+["'](?<specifier>\.[^"']+)["']/g;
|
|
6104
6125
|
for (const match of source.matchAll(exportPattern)) {
|
|
6105
6126
|
const specifier = match.groups?.specifier;
|
|
6106
|
-
if (specifier) exportedFiles.add(
|
|
6127
|
+
if (specifier) exportedFiles.add(path49.basename(specifier));
|
|
6107
6128
|
}
|
|
6108
6129
|
const hasAnyReExport = exportedFiles.size > 0;
|
|
6109
6130
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
@@ -6275,11 +6296,11 @@ var baseLayerPairRule = {
|
|
|
6275
6296
|
|
|
6276
6297
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
6277
6298
|
import { statSync as statSync4 } from "fs";
|
|
6278
|
-
import
|
|
6299
|
+
import path52 from "path";
|
|
6279
6300
|
|
|
6280
6301
|
// eslint/rules/tailwind/source-files.ts
|
|
6281
6302
|
import { readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
|
|
6282
|
-
import
|
|
6303
|
+
import path50 from "path";
|
|
6283
6304
|
var CSS_EXTENSIONS = [".css"];
|
|
6284
6305
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
6285
6306
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS3, ...CSS_EXTENSIONS];
|
|
@@ -6292,7 +6313,7 @@ function findFiles(dir, extensions) {
|
|
|
6292
6313
|
}
|
|
6293
6314
|
return entries.flatMap((entry) => {
|
|
6294
6315
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
6295
|
-
const entryPath =
|
|
6316
|
+
const entryPath = path50.join(dir, entry);
|
|
6296
6317
|
let stats;
|
|
6297
6318
|
try {
|
|
6298
6319
|
stats = statSync3(entryPath);
|
|
@@ -6300,7 +6321,7 @@ function findFiles(dir, extensions) {
|
|
|
6300
6321
|
return [];
|
|
6301
6322
|
}
|
|
6302
6323
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
6303
|
-
return extensions.includes(
|
|
6324
|
+
return extensions.includes(path50.extname(entry)) ? [entryPath] : [];
|
|
6304
6325
|
});
|
|
6305
6326
|
}
|
|
6306
6327
|
function cachedTextReader() {
|
|
@@ -6323,7 +6344,7 @@ function escapeRegExp(text) {
|
|
|
6323
6344
|
}
|
|
6324
6345
|
|
|
6325
6346
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
6326
|
-
import
|
|
6347
|
+
import path51 from "path";
|
|
6327
6348
|
function registersTailwind(text) {
|
|
6328
6349
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
6329
6350
|
}
|
|
@@ -6337,25 +6358,25 @@ function moduleImports(text, fileName) {
|
|
|
6337
6358
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
6338
6359
|
}
|
|
6339
6360
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
6340
|
-
if (spec.startsWith("/")) return
|
|
6341
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
6342
|
-
if (spec.startsWith("@/")) return
|
|
6361
|
+
if (spec.startsWith("/")) return path51.resolve(spec);
|
|
6362
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path51.resolve(path51.dirname(fromFile), spec);
|
|
6363
|
+
if (spec.startsWith("@/")) return path51.resolve(sourceRoot, spec.slice(2));
|
|
6343
6364
|
return void 0;
|
|
6344
6365
|
}
|
|
6345
6366
|
function buildStylesheetGraph(options) {
|
|
6346
6367
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
6347
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
6368
|
+
const cssSet = new Set(cssFiles.map((file) => path51.normalize(file)));
|
|
6348
6369
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
6349
6370
|
const reachable = /* @__PURE__ */ new Set();
|
|
6350
6371
|
const queue = [...globals];
|
|
6351
|
-
for (const global of globals) reachable.add(
|
|
6372
|
+
for (const global of globals) reachable.add(path51.normalize(global));
|
|
6352
6373
|
while (queue.length > 0) {
|
|
6353
6374
|
const from = queue.shift();
|
|
6354
6375
|
if (!from) continue;
|
|
6355
6376
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
6356
6377
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
6357
6378
|
if (!target) continue;
|
|
6358
|
-
const normalized =
|
|
6379
|
+
const normalized = path51.normalize(target);
|
|
6359
6380
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
6360
6381
|
reachable.add(normalized);
|
|
6361
6382
|
queue.push(normalized);
|
|
@@ -6367,7 +6388,7 @@ function buildStylesheetGraph(options) {
|
|
|
6367
6388
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
6368
6389
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
6369
6390
|
if (!target) continue;
|
|
6370
|
-
const normalized =
|
|
6391
|
+
const normalized = path51.normalize(target);
|
|
6371
6392
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
6372
6393
|
}
|
|
6373
6394
|
}
|
|
@@ -6375,8 +6396,8 @@ function buildStylesheetGraph(options) {
|
|
|
6375
6396
|
}
|
|
6376
6397
|
|
|
6377
6398
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
6378
|
-
var APP_STYLES_DIR =
|
|
6379
|
-
var GLOBAL_STYLESHEET_PATH =
|
|
6399
|
+
var APP_STYLES_DIR = path52.join("app", "styles");
|
|
6400
|
+
var GLOBAL_STYLESHEET_PATH = path52.join(APP_STYLES_DIR, "globals.css");
|
|
6380
6401
|
var cssEntryPointRule = {
|
|
6381
6402
|
meta: {
|
|
6382
6403
|
schema: [],
|
|
@@ -6402,8 +6423,8 @@ var cssEntryPointRule = {
|
|
|
6402
6423
|
return {
|
|
6403
6424
|
"StyleSheet:exit"(node) {
|
|
6404
6425
|
if (globals.length === 0) return;
|
|
6405
|
-
const current =
|
|
6406
|
-
const relative =
|
|
6426
|
+
const current = path52.normalize(path52.resolve(context.filename));
|
|
6427
|
+
const relative = path52.relative(sourceRoot, current);
|
|
6407
6428
|
if (globals.includes(current)) {
|
|
6408
6429
|
if (globals.length > 1) {
|
|
6409
6430
|
context.report({
|
|
@@ -6419,7 +6440,7 @@ var cssEntryPointRule = {
|
|
|
6419
6440
|
});
|
|
6420
6441
|
return;
|
|
6421
6442
|
}
|
|
6422
|
-
const basename =
|
|
6443
|
+
const basename = path52.basename(current);
|
|
6423
6444
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
6424
6445
|
if (importCount !== 1) {
|
|
6425
6446
|
context.report({
|
|
@@ -6429,7 +6450,7 @@ var cssEntryPointRule = {
|
|
|
6429
6450
|
}
|
|
6430
6451
|
return;
|
|
6431
6452
|
}
|
|
6432
|
-
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${
|
|
6453
|
+
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${path52.sep}`);
|
|
6433
6454
|
if (!isInAppStyles) {
|
|
6434
6455
|
context.report({
|
|
6435
6456
|
node,
|
|
@@ -6918,7 +6939,7 @@ var tailwindRules = {
|
|
|
6918
6939
|
};
|
|
6919
6940
|
|
|
6920
6941
|
// eslint/rules/type-extraction.ts
|
|
6921
|
-
import
|
|
6942
|
+
import path53 from "path";
|
|
6922
6943
|
var typeExtractionRule = {
|
|
6923
6944
|
meta: {
|
|
6924
6945
|
schema: [],
|
|
@@ -6929,7 +6950,7 @@ var typeExtractionRule = {
|
|
|
6929
6950
|
},
|
|
6930
6951
|
create(context) {
|
|
6931
6952
|
const sourceRoot = sourceRootOf(context);
|
|
6932
|
-
const file =
|
|
6953
|
+
const file = path53.resolve(context.filename);
|
|
6933
6954
|
const segments = segmentsOf(file, sourceRoot);
|
|
6934
6955
|
if (segments.length === 0) return {};
|
|
6935
6956
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -7064,7 +7085,7 @@ var uiStateRule = {
|
|
|
7064
7085
|
// eslint/rules/unknown-utility.ts
|
|
7065
7086
|
import { existsSync as existsSync6, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
|
|
7066
7087
|
import { createRequire } from "module";
|
|
7067
|
-
import
|
|
7088
|
+
import path54 from "path";
|
|
7068
7089
|
var PREFIX_NAMESPACES = {
|
|
7069
7090
|
bg: ["color"],
|
|
7070
7091
|
text: ["color", "text"],
|
|
@@ -7304,7 +7325,7 @@ function stylesheetFiles(dir) {
|
|
|
7304
7325
|
}
|
|
7305
7326
|
return entries.flatMap((entry) => {
|
|
7306
7327
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
7307
|
-
const entryPath =
|
|
7328
|
+
const entryPath = path54.join(dir, entry);
|
|
7308
7329
|
let stats;
|
|
7309
7330
|
try {
|
|
7310
7331
|
stats = statSync6(entryPath);
|
|
@@ -7312,7 +7333,7 @@ function stylesheetFiles(dir) {
|
|
|
7312
7333
|
return [];
|
|
7313
7334
|
}
|
|
7314
7335
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
7315
|
-
return
|
|
7336
|
+
return path54.extname(entry) === ".css" ? [entryPath] : [];
|
|
7316
7337
|
});
|
|
7317
7338
|
}
|
|
7318
7339
|
function packageNameOf(specifier) {
|
|
@@ -7323,10 +7344,10 @@ function packageNameOf(specifier) {
|
|
|
7323
7344
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
7324
7345
|
const packageName = packageNameOf(specifier);
|
|
7325
7346
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
7326
|
-
let directory =
|
|
7327
|
-
while (directory !==
|
|
7328
|
-
const packageRoot =
|
|
7329
|
-
const manifestPath =
|
|
7347
|
+
let directory = path54.dirname(fromFile);
|
|
7348
|
+
while (directory !== path54.dirname(directory)) {
|
|
7349
|
+
const packageRoot = path54.join(directory, "node_modules", packageName);
|
|
7350
|
+
const manifestPath = path54.join(packageRoot, "package.json");
|
|
7330
7351
|
if (existsSync6(manifestPath)) {
|
|
7331
7352
|
try {
|
|
7332
7353
|
const manifest = readFileSync10(manifestPath, "utf8");
|
|
@@ -7334,13 +7355,13 @@ function resolvePackageStylesheet(fromFile, specifier) {
|
|
|
7334
7355
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
7335
7356
|
const target = stylesheet ?? main;
|
|
7336
7357
|
if (!target) return void 0;
|
|
7337
|
-
const resolved =
|
|
7358
|
+
const resolved = path54.resolve(packageRoot, target);
|
|
7338
7359
|
return existsSync6(resolved) ? resolved : void 0;
|
|
7339
7360
|
} catch {
|
|
7340
7361
|
return void 0;
|
|
7341
7362
|
}
|
|
7342
7363
|
}
|
|
7343
|
-
directory =
|
|
7364
|
+
directory = path54.dirname(directory);
|
|
7344
7365
|
}
|
|
7345
7366
|
return void 0;
|
|
7346
7367
|
}
|
|
@@ -7591,7 +7612,7 @@ var unknownUtilityRule = {
|
|
|
7591
7612
|
};
|
|
7592
7613
|
|
|
7593
7614
|
// eslint/rules/util-file-name.ts
|
|
7594
|
-
import
|
|
7615
|
+
import path55 from "path";
|
|
7595
7616
|
function toKebabCase2(value) {
|
|
7596
7617
|
return value.replace(/(?<lower>[a-z0-9])(?<upper>[A-Z])/g, "$<lower>-$<upper>").replace(/(?<first>[A-Z])(?<rest>[A-Z][a-z])/g, "$<first>-$<rest>").toLowerCase();
|
|
7597
7618
|
}
|
|
@@ -7604,7 +7625,7 @@ var utilFileNameRule = {
|
|
|
7604
7625
|
}
|
|
7605
7626
|
},
|
|
7606
7627
|
create(context) {
|
|
7607
|
-
const filename =
|
|
7628
|
+
const filename = path55.resolve(context.filename);
|
|
7608
7629
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
7609
7630
|
if (!segments.includes("utils")) return {};
|
|
7610
7631
|
let module;
|
|
@@ -7618,13 +7639,13 @@ var utilFileNameRule = {
|
|
|
7618
7639
|
const functionName = functions[0]?.name;
|
|
7619
7640
|
if (!functionName) return {};
|
|
7620
7641
|
const expected = toKebabCase2(functionName);
|
|
7621
|
-
const actual =
|
|
7642
|
+
const actual = path55.basename(filename, path55.extname(filename));
|
|
7622
7643
|
if (!expected || actual === expected) return {};
|
|
7623
7644
|
return {
|
|
7624
7645
|
Program(node) {
|
|
7625
7646
|
context.report({
|
|
7626
7647
|
node,
|
|
7627
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
7648
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path55.extname(filename).slice(1)}.`
|
|
7628
7649
|
});
|
|
7629
7650
|
}
|
|
7630
7651
|
};
|
|
@@ -7632,7 +7653,7 @@ var utilFileNameRule = {
|
|
|
7632
7653
|
};
|
|
7633
7654
|
|
|
7634
7655
|
// eslint/rules/value-extraction.ts
|
|
7635
|
-
import
|
|
7656
|
+
import path56 from "path";
|
|
7636
7657
|
var valueExtractionRule = {
|
|
7637
7658
|
meta: {
|
|
7638
7659
|
schema: [],
|
|
@@ -7643,7 +7664,7 @@ var valueExtractionRule = {
|
|
|
7643
7664
|
},
|
|
7644
7665
|
create(context) {
|
|
7645
7666
|
const sourceRoot = sourceRootOf(context);
|
|
7646
|
-
const file =
|
|
7667
|
+
const file = path56.resolve(context.filename);
|
|
7647
7668
|
const segments = segmentsOf(file, sourceRoot);
|
|
7648
7669
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
7649
7670
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -7665,7 +7686,7 @@ var valueExtractionRule = {
|
|
|
7665
7686
|
|
|
7666
7687
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
7667
7688
|
import { existsSync as existsSync7, readFileSync as readFileSync11 } from "fs";
|
|
7668
|
-
import
|
|
7689
|
+
import path57 from "path";
|
|
7669
7690
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
7670
7691
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
7671
7692
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -7698,8 +7719,8 @@ var trackedDocsRule = {
|
|
|
7698
7719
|
if (!context.filename.endsWith("package.json")) return;
|
|
7699
7720
|
const root = node.body;
|
|
7700
7721
|
if (root.type !== "Object") return;
|
|
7701
|
-
const projectRoot =
|
|
7702
|
-
const configPath =
|
|
7722
|
+
const projectRoot = path57.dirname(path57.resolve(context.filename));
|
|
7723
|
+
const configPath = path57.join(projectRoot, "vulyk.config.ts");
|
|
7703
7724
|
if (!existsSync7(configPath)) {
|
|
7704
7725
|
context.report({
|
|
7705
7726
|
node,
|
|
@@ -7724,7 +7745,7 @@ var trackedDocsRule = {
|
|
|
7724
7745
|
});
|
|
7725
7746
|
}
|
|
7726
7747
|
}
|
|
7727
|
-
const agentsPath =
|
|
7748
|
+
const agentsPath = path57.join(projectRoot, "AGENTS.md");
|
|
7728
7749
|
if (!existsSync7(agentsPath)) {
|
|
7729
7750
|
context.report({
|
|
7730
7751
|
node,
|
|
@@ -7824,7 +7845,7 @@ var withResponseHelperRule = {
|
|
|
7824
7845
|
|
|
7825
7846
|
// eslint/rules/zirka-baseline.ts
|
|
7826
7847
|
import fs6 from "fs";
|
|
7827
|
-
import
|
|
7848
|
+
import path58 from "path";
|
|
7828
7849
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
7829
7850
|
var PRETTIER_CONFIGS = [
|
|
7830
7851
|
"prettier.config.mjs",
|
|
@@ -7843,10 +7864,10 @@ var zirkaBaselineRule = {
|
|
|
7843
7864
|
}
|
|
7844
7865
|
},
|
|
7845
7866
|
create(context) {
|
|
7846
|
-
const filename =
|
|
7847
|
-
const basename =
|
|
7867
|
+
const filename = path58.resolve(context.filename);
|
|
7868
|
+
const basename = path58.basename(filename);
|
|
7848
7869
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
7849
|
-
const projectRoot =
|
|
7870
|
+
const projectRoot = path58.dirname(filename);
|
|
7850
7871
|
const report3 = (message) => {
|
|
7851
7872
|
context.report({
|
|
7852
7873
|
node: context.sourceCode.ast,
|
|
@@ -7861,7 +7882,7 @@ var zirkaBaselineRule = {
|
|
|
7861
7882
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
7862
7883
|
);
|
|
7863
7884
|
}
|
|
7864
|
-
const tsconfigPath =
|
|
7885
|
+
const tsconfigPath = path58.join(projectRoot, "tsconfig.json");
|
|
7865
7886
|
if (!fs6.existsSync(tsconfigPath)) {
|
|
7866
7887
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
7867
7888
|
} else {
|
|
@@ -7879,13 +7900,13 @@ var zirkaBaselineRule = {
|
|
|
7879
7900
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
7880
7901
|
}
|
|
7881
7902
|
}
|
|
7882
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs6.existsSync(
|
|
7903
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs6.existsSync(path58.join(projectRoot, name)));
|
|
7883
7904
|
if (!prettierConfigFile) {
|
|
7884
7905
|
report3(
|
|
7885
7906
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
7886
7907
|
);
|
|
7887
7908
|
} else {
|
|
7888
|
-
const content = fs6.readFileSync(
|
|
7909
|
+
const content = fs6.readFileSync(path58.join(projectRoot, prettierConfigFile), "utf8");
|
|
7889
7910
|
if (!content.includes("zirka")) {
|
|
7890
7911
|
report3(
|
|
7891
7912
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|