pasika 0.10.43 → 0.10.45
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 +118 -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, literal-union aliases, or inline literal-union property types."
|
|
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,28 @@ 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
|
+
});
|
|
5217
|
+
},
|
|
5218
|
+
TSPropertySignature(node) {
|
|
5219
|
+
const typeAnnotation = node.typeAnnotation?.typeAnnotation;
|
|
5220
|
+
if (!isEnumLiteralUnion(typeAnnotation)) return;
|
|
5221
|
+
context.report({
|
|
5222
|
+
node,
|
|
5223
|
+
message: "A property whose type is a union made only of string or number literals must use a TypeScript enum. See docs/next-codebase-guide/rules/constants-rule.md"
|
|
5224
|
+
});
|
|
5196
5225
|
}
|
|
5197
5226
|
};
|
|
5198
5227
|
}
|
|
5199
5228
|
};
|
|
5200
5229
|
|
|
5201
5230
|
// eslint/rules/pure-function-extract.ts
|
|
5202
|
-
import
|
|
5231
|
+
import path41 from "path";
|
|
5203
5232
|
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
5204
5233
|
"GET",
|
|
5205
5234
|
"POST",
|
|
@@ -5243,12 +5272,12 @@ var pureFunctionExtractRule = {
|
|
|
5243
5272
|
},
|
|
5244
5273
|
create(context) {
|
|
5245
5274
|
const filename = context.filename;
|
|
5246
|
-
const isRouteFile =
|
|
5275
|
+
const isRouteFile = path41.basename(filename) === "route.ts";
|
|
5247
5276
|
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
5248
5277
|
const sourceRoot = sourceRootOf(context);
|
|
5249
|
-
const relative =
|
|
5278
|
+
const relative = path41.relative(sourceRoot, filename);
|
|
5250
5279
|
if (relative.startsWith("..")) return {};
|
|
5251
|
-
const segments = relative.split(
|
|
5280
|
+
const segments = relative.split(path41.sep);
|
|
5252
5281
|
const folders = segments.slice(0, -1);
|
|
5253
5282
|
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
5254
5283
|
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
@@ -5437,7 +5466,7 @@ var repeatedStructureRule = {
|
|
|
5437
5466
|
};
|
|
5438
5467
|
|
|
5439
5468
|
// eslint/rules/root-support-placement.ts
|
|
5440
|
-
import
|
|
5469
|
+
import path42 from "path";
|
|
5441
5470
|
function isSupportFolder(value) {
|
|
5442
5471
|
return value === "utils" || value === "types" || value === "schemas" || value === "constants";
|
|
5443
5472
|
}
|
|
@@ -5470,7 +5499,7 @@ var rootSupportPlacementRule = {
|
|
|
5470
5499
|
},
|
|
5471
5500
|
create(context) {
|
|
5472
5501
|
const sourceRoot = sourceRootOf(context);
|
|
5473
|
-
const file =
|
|
5502
|
+
const file = path42.resolve(context.filename);
|
|
5474
5503
|
const segments = segmentsOf(file, sourceRoot);
|
|
5475
5504
|
const folderSegments = folderSegmentsOf(file, sourceRoot);
|
|
5476
5505
|
const supportFolder = folderSegments[folderSegments.length - 1];
|
|
@@ -5510,9 +5539,9 @@ var rootSupportPlacementRule = {
|
|
|
5510
5539
|
};
|
|
5511
5540
|
|
|
5512
5541
|
// eslint/rules/route-handler-shape.ts
|
|
5513
|
-
import
|
|
5542
|
+
import path43 from "path";
|
|
5514
5543
|
import ts7 from "typescript";
|
|
5515
|
-
var
|
|
5544
|
+
var HTTP_METHODS2 = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
5516
5545
|
var REQUIRED_BOUNDARY = "withResponse";
|
|
5517
5546
|
function isFunctionLike(node) {
|
|
5518
5547
|
return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression";
|
|
@@ -5595,7 +5624,7 @@ var routeHandlerShapeRule = {
|
|
|
5595
5624
|
}
|
|
5596
5625
|
},
|
|
5597
5626
|
create(context) {
|
|
5598
|
-
if (
|
|
5627
|
+
if (path43.basename(context.filename) !== "route.ts") return {};
|
|
5599
5628
|
const sourceText = context.sourceCode.text;
|
|
5600
5629
|
function reportUnwrapped(node, name) {
|
|
5601
5630
|
context.report({
|
|
@@ -5639,14 +5668,14 @@ var routeHandlerShapeRule = {
|
|
|
5639
5668
|
FunctionDeclaration(node) {
|
|
5640
5669
|
const exported = node.parent?.type === "ExportNamedDeclaration";
|
|
5641
5670
|
const name = node.id?.name;
|
|
5642
|
-
if (!exported || !name || !
|
|
5671
|
+
if (!exported || !name || !HTTP_METHODS2.has(name) || !node.body) return;
|
|
5643
5672
|
reportUnwrapped(node, name);
|
|
5644
5673
|
},
|
|
5645
5674
|
VariableDeclarator(node) {
|
|
5646
5675
|
if (node.id.type !== "Identifier") return;
|
|
5647
5676
|
const name = node.id.name;
|
|
5648
5677
|
const exported = node.parent.parent?.type === "ExportNamedDeclaration";
|
|
5649
|
-
if (!exported || !
|
|
5678
|
+
if (!exported || !HTTP_METHODS2.has(name) || !node.init) return;
|
|
5650
5679
|
checkExport(node, name, node.init);
|
|
5651
5680
|
}
|
|
5652
5681
|
};
|
|
@@ -5654,7 +5683,7 @@ var routeHandlerShapeRule = {
|
|
|
5654
5683
|
};
|
|
5655
5684
|
|
|
5656
5685
|
// eslint/rules/schema-casing.ts
|
|
5657
|
-
import
|
|
5686
|
+
import path44 from "path";
|
|
5658
5687
|
function isCamelCase(name) {
|
|
5659
5688
|
return /^[a-z][a-zA-Z0-9]*$/.test(name);
|
|
5660
5689
|
}
|
|
@@ -5682,9 +5711,9 @@ var schemaCasingRule = {
|
|
|
5682
5711
|
}
|
|
5683
5712
|
},
|
|
5684
5713
|
create(context) {
|
|
5685
|
-
const filename =
|
|
5714
|
+
const filename = path44.resolve(context.filename);
|
|
5686
5715
|
const sourceRoot = sourceRootOf(context);
|
|
5687
|
-
if (!filename.startsWith(sourceRoot +
|
|
5716
|
+
if (!filename.startsWith(sourceRoot + path44.sep)) return {};
|
|
5688
5717
|
let zodLocalName;
|
|
5689
5718
|
return {
|
|
5690
5719
|
ImportDeclaration(node) {
|
|
@@ -5716,7 +5745,7 @@ var schemaCasingRule = {
|
|
|
5716
5745
|
};
|
|
5717
5746
|
|
|
5718
5747
|
// eslint/rules/sole-state-owner.ts
|
|
5719
|
-
import
|
|
5748
|
+
import path45 from "path";
|
|
5720
5749
|
import ts8 from "typescript";
|
|
5721
5750
|
function findStateHooks(node) {
|
|
5722
5751
|
const hooks = [];
|
|
@@ -5796,7 +5825,7 @@ var soleStateOwnerRule = {
|
|
|
5796
5825
|
}
|
|
5797
5826
|
},
|
|
5798
5827
|
create(context) {
|
|
5799
|
-
const filename =
|
|
5828
|
+
const filename = path45.resolve(context.filename);
|
|
5800
5829
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
5801
5830
|
const text = context.sourceCode.text;
|
|
5802
5831
|
const components = parseComponentInfo(text, filename);
|
|
@@ -5875,7 +5904,7 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
5875
5904
|
}
|
|
5876
5905
|
|
|
5877
5906
|
// eslint/rules/source-under-src.ts
|
|
5878
|
-
import
|
|
5907
|
+
import path46 from "path";
|
|
5879
5908
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
5880
5909
|
".agents",
|
|
5881
5910
|
".cache",
|
|
@@ -5916,14 +5945,14 @@ var sourceUnderSrcRule = {
|
|
|
5916
5945
|
}
|
|
5917
5946
|
},
|
|
5918
5947
|
create(context) {
|
|
5919
|
-
const filename =
|
|
5948
|
+
const filename = path46.resolve(context.filename);
|
|
5920
5949
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
5921
|
-
const relative =
|
|
5950
|
+
const relative = path46.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
5922
5951
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
5923
5952
|
const topLevel = relative.split("/")[0] ?? "";
|
|
5924
5953
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
5925
5954
|
if (!relative.includes("/")) {
|
|
5926
|
-
const basename =
|
|
5955
|
+
const basename = path46.basename(filename);
|
|
5927
5956
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
5928
5957
|
}
|
|
5929
5958
|
return {
|
|
@@ -5939,7 +5968,7 @@ var sourceUnderSrcRule = {
|
|
|
5939
5968
|
};
|
|
5940
5969
|
|
|
5941
5970
|
// eslint/rules/stay-flat.ts
|
|
5942
|
-
import
|
|
5971
|
+
import path47 from "path";
|
|
5943
5972
|
var stayFlatRule = {
|
|
5944
5973
|
meta: {
|
|
5945
5974
|
schema: [],
|
|
@@ -5950,7 +5979,7 @@ var stayFlatRule = {
|
|
|
5950
5979
|
},
|
|
5951
5980
|
create(context) {
|
|
5952
5981
|
const sourceRoot = sourceRootOf(context);
|
|
5953
|
-
const file =
|
|
5982
|
+
const file = path47.resolve(context.filename);
|
|
5954
5983
|
const segments = segmentsOf(file, sourceRoot);
|
|
5955
5984
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
5956
5985
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -5990,7 +6019,7 @@ var stayFlatRule = {
|
|
|
5990
6019
|
};
|
|
5991
6020
|
|
|
5992
6021
|
// eslint/rules/support-file-placement.ts
|
|
5993
|
-
import
|
|
6022
|
+
import path48 from "path";
|
|
5994
6023
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
5995
6024
|
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
5996
6025
|
["constants", "constant"],
|
|
@@ -6015,7 +6044,7 @@ var supportFilePlacementRule = {
|
|
|
6015
6044
|
},
|
|
6016
6045
|
create(context) {
|
|
6017
6046
|
const sourceRoot = sourceRootOf(context);
|
|
6018
|
-
const supportFile =
|
|
6047
|
+
const supportFile = path48.resolve(context.filename);
|
|
6019
6048
|
const currentFolder = folderSegmentsOf(supportFile, sourceRoot);
|
|
6020
6049
|
const supportFolder = currentFolder[currentFolder.length - 1];
|
|
6021
6050
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS.has(supportFolder)) return {};
|
|
@@ -6069,7 +6098,7 @@ var supportFilePlacementRule = {
|
|
|
6069
6098
|
|
|
6070
6099
|
// eslint/rules/support-folder-shape.ts
|
|
6071
6100
|
import fs5 from "fs";
|
|
6072
|
-
import
|
|
6101
|
+
import path49 from "path";
|
|
6073
6102
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
6074
6103
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
6075
6104
|
var supportFolderShapeRule = {
|
|
@@ -6081,12 +6110,12 @@ var supportFolderShapeRule = {
|
|
|
6081
6110
|
}
|
|
6082
6111
|
},
|
|
6083
6112
|
create(context) {
|
|
6084
|
-
const filename =
|
|
6085
|
-
const baseName =
|
|
6113
|
+
const filename = path49.resolve(context.filename);
|
|
6114
|
+
const baseName = path49.basename(filename);
|
|
6086
6115
|
if (!INDEX_NAMES.has(baseName)) return {};
|
|
6087
|
-
const folder =
|
|
6116
|
+
const folder = path49.basename(path49.dirname(filename));
|
|
6088
6117
|
if (!SUPPORT_FOLDERS3.has(folder)) return {};
|
|
6089
|
-
const directory =
|
|
6118
|
+
const directory = path49.dirname(filename);
|
|
6090
6119
|
let entries;
|
|
6091
6120
|
try {
|
|
6092
6121
|
entries = fs5.readdirSync(directory);
|
|
@@ -6103,7 +6132,7 @@ var supportFolderShapeRule = {
|
|
|
6103
6132
|
const exportPattern = /export\s+(?:\{[^}]*\}|\*[^;]*)\s+from\s+["'](?<specifier>\.[^"']+)["']/g;
|
|
6104
6133
|
for (const match of source.matchAll(exportPattern)) {
|
|
6105
6134
|
const specifier = match.groups?.specifier;
|
|
6106
|
-
if (specifier) exportedFiles.add(
|
|
6135
|
+
if (specifier) exportedFiles.add(path49.basename(specifier));
|
|
6107
6136
|
}
|
|
6108
6137
|
const hasAnyReExport = exportedFiles.size > 0;
|
|
6109
6138
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
@@ -6275,11 +6304,11 @@ var baseLayerPairRule = {
|
|
|
6275
6304
|
|
|
6276
6305
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
6277
6306
|
import { statSync as statSync4 } from "fs";
|
|
6278
|
-
import
|
|
6307
|
+
import path52 from "path";
|
|
6279
6308
|
|
|
6280
6309
|
// eslint/rules/tailwind/source-files.ts
|
|
6281
6310
|
import { readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
|
|
6282
|
-
import
|
|
6311
|
+
import path50 from "path";
|
|
6283
6312
|
var CSS_EXTENSIONS = [".css"];
|
|
6284
6313
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
6285
6314
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS3, ...CSS_EXTENSIONS];
|
|
@@ -6292,7 +6321,7 @@ function findFiles(dir, extensions) {
|
|
|
6292
6321
|
}
|
|
6293
6322
|
return entries.flatMap((entry) => {
|
|
6294
6323
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
6295
|
-
const entryPath =
|
|
6324
|
+
const entryPath = path50.join(dir, entry);
|
|
6296
6325
|
let stats;
|
|
6297
6326
|
try {
|
|
6298
6327
|
stats = statSync3(entryPath);
|
|
@@ -6300,7 +6329,7 @@ function findFiles(dir, extensions) {
|
|
|
6300
6329
|
return [];
|
|
6301
6330
|
}
|
|
6302
6331
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
6303
|
-
return extensions.includes(
|
|
6332
|
+
return extensions.includes(path50.extname(entry)) ? [entryPath] : [];
|
|
6304
6333
|
});
|
|
6305
6334
|
}
|
|
6306
6335
|
function cachedTextReader() {
|
|
@@ -6323,7 +6352,7 @@ function escapeRegExp(text) {
|
|
|
6323
6352
|
}
|
|
6324
6353
|
|
|
6325
6354
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
6326
|
-
import
|
|
6355
|
+
import path51 from "path";
|
|
6327
6356
|
function registersTailwind(text) {
|
|
6328
6357
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
6329
6358
|
}
|
|
@@ -6337,25 +6366,25 @@ function moduleImports(text, fileName) {
|
|
|
6337
6366
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
6338
6367
|
}
|
|
6339
6368
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
6340
|
-
if (spec.startsWith("/")) return
|
|
6341
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
6342
|
-
if (spec.startsWith("@/")) return
|
|
6369
|
+
if (spec.startsWith("/")) return path51.resolve(spec);
|
|
6370
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path51.resolve(path51.dirname(fromFile), spec);
|
|
6371
|
+
if (spec.startsWith("@/")) return path51.resolve(sourceRoot, spec.slice(2));
|
|
6343
6372
|
return void 0;
|
|
6344
6373
|
}
|
|
6345
6374
|
function buildStylesheetGraph(options) {
|
|
6346
6375
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
6347
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
6376
|
+
const cssSet = new Set(cssFiles.map((file) => path51.normalize(file)));
|
|
6348
6377
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
6349
6378
|
const reachable = /* @__PURE__ */ new Set();
|
|
6350
6379
|
const queue = [...globals];
|
|
6351
|
-
for (const global of globals) reachable.add(
|
|
6380
|
+
for (const global of globals) reachable.add(path51.normalize(global));
|
|
6352
6381
|
while (queue.length > 0) {
|
|
6353
6382
|
const from = queue.shift();
|
|
6354
6383
|
if (!from) continue;
|
|
6355
6384
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
6356
6385
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
6357
6386
|
if (!target) continue;
|
|
6358
|
-
const normalized =
|
|
6387
|
+
const normalized = path51.normalize(target);
|
|
6359
6388
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
6360
6389
|
reachable.add(normalized);
|
|
6361
6390
|
queue.push(normalized);
|
|
@@ -6367,7 +6396,7 @@ function buildStylesheetGraph(options) {
|
|
|
6367
6396
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
6368
6397
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
6369
6398
|
if (!target) continue;
|
|
6370
|
-
const normalized =
|
|
6399
|
+
const normalized = path51.normalize(target);
|
|
6371
6400
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
6372
6401
|
}
|
|
6373
6402
|
}
|
|
@@ -6375,8 +6404,8 @@ function buildStylesheetGraph(options) {
|
|
|
6375
6404
|
}
|
|
6376
6405
|
|
|
6377
6406
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
6378
|
-
var APP_STYLES_DIR =
|
|
6379
|
-
var GLOBAL_STYLESHEET_PATH =
|
|
6407
|
+
var APP_STYLES_DIR = path52.join("app", "styles");
|
|
6408
|
+
var GLOBAL_STYLESHEET_PATH = path52.join(APP_STYLES_DIR, "globals.css");
|
|
6380
6409
|
var cssEntryPointRule = {
|
|
6381
6410
|
meta: {
|
|
6382
6411
|
schema: [],
|
|
@@ -6402,8 +6431,8 @@ var cssEntryPointRule = {
|
|
|
6402
6431
|
return {
|
|
6403
6432
|
"StyleSheet:exit"(node) {
|
|
6404
6433
|
if (globals.length === 0) return;
|
|
6405
|
-
const current =
|
|
6406
|
-
const relative =
|
|
6434
|
+
const current = path52.normalize(path52.resolve(context.filename));
|
|
6435
|
+
const relative = path52.relative(sourceRoot, current);
|
|
6407
6436
|
if (globals.includes(current)) {
|
|
6408
6437
|
if (globals.length > 1) {
|
|
6409
6438
|
context.report({
|
|
@@ -6419,7 +6448,7 @@ var cssEntryPointRule = {
|
|
|
6419
6448
|
});
|
|
6420
6449
|
return;
|
|
6421
6450
|
}
|
|
6422
|
-
const basename =
|
|
6451
|
+
const basename = path52.basename(current);
|
|
6423
6452
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
6424
6453
|
if (importCount !== 1) {
|
|
6425
6454
|
context.report({
|
|
@@ -6429,7 +6458,7 @@ var cssEntryPointRule = {
|
|
|
6429
6458
|
}
|
|
6430
6459
|
return;
|
|
6431
6460
|
}
|
|
6432
|
-
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${
|
|
6461
|
+
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${path52.sep}`);
|
|
6433
6462
|
if (!isInAppStyles) {
|
|
6434
6463
|
context.report({
|
|
6435
6464
|
node,
|
|
@@ -6918,7 +6947,7 @@ var tailwindRules = {
|
|
|
6918
6947
|
};
|
|
6919
6948
|
|
|
6920
6949
|
// eslint/rules/type-extraction.ts
|
|
6921
|
-
import
|
|
6950
|
+
import path53 from "path";
|
|
6922
6951
|
var typeExtractionRule = {
|
|
6923
6952
|
meta: {
|
|
6924
6953
|
schema: [],
|
|
@@ -6929,7 +6958,7 @@ var typeExtractionRule = {
|
|
|
6929
6958
|
},
|
|
6930
6959
|
create(context) {
|
|
6931
6960
|
const sourceRoot = sourceRootOf(context);
|
|
6932
|
-
const file =
|
|
6961
|
+
const file = path53.resolve(context.filename);
|
|
6933
6962
|
const segments = segmentsOf(file, sourceRoot);
|
|
6934
6963
|
if (segments.length === 0) return {};
|
|
6935
6964
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -7064,7 +7093,7 @@ var uiStateRule = {
|
|
|
7064
7093
|
// eslint/rules/unknown-utility.ts
|
|
7065
7094
|
import { existsSync as existsSync6, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
|
|
7066
7095
|
import { createRequire } from "module";
|
|
7067
|
-
import
|
|
7096
|
+
import path54 from "path";
|
|
7068
7097
|
var PREFIX_NAMESPACES = {
|
|
7069
7098
|
bg: ["color"],
|
|
7070
7099
|
text: ["color", "text"],
|
|
@@ -7304,7 +7333,7 @@ function stylesheetFiles(dir) {
|
|
|
7304
7333
|
}
|
|
7305
7334
|
return entries.flatMap((entry) => {
|
|
7306
7335
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
7307
|
-
const entryPath =
|
|
7336
|
+
const entryPath = path54.join(dir, entry);
|
|
7308
7337
|
let stats;
|
|
7309
7338
|
try {
|
|
7310
7339
|
stats = statSync6(entryPath);
|
|
@@ -7312,7 +7341,7 @@ function stylesheetFiles(dir) {
|
|
|
7312
7341
|
return [];
|
|
7313
7342
|
}
|
|
7314
7343
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
7315
|
-
return
|
|
7344
|
+
return path54.extname(entry) === ".css" ? [entryPath] : [];
|
|
7316
7345
|
});
|
|
7317
7346
|
}
|
|
7318
7347
|
function packageNameOf(specifier) {
|
|
@@ -7323,10 +7352,10 @@ function packageNameOf(specifier) {
|
|
|
7323
7352
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
7324
7353
|
const packageName = packageNameOf(specifier);
|
|
7325
7354
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
7326
|
-
let directory =
|
|
7327
|
-
while (directory !==
|
|
7328
|
-
const packageRoot =
|
|
7329
|
-
const manifestPath =
|
|
7355
|
+
let directory = path54.dirname(fromFile);
|
|
7356
|
+
while (directory !== path54.dirname(directory)) {
|
|
7357
|
+
const packageRoot = path54.join(directory, "node_modules", packageName);
|
|
7358
|
+
const manifestPath = path54.join(packageRoot, "package.json");
|
|
7330
7359
|
if (existsSync6(manifestPath)) {
|
|
7331
7360
|
try {
|
|
7332
7361
|
const manifest = readFileSync10(manifestPath, "utf8");
|
|
@@ -7334,13 +7363,13 @@ function resolvePackageStylesheet(fromFile, specifier) {
|
|
|
7334
7363
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
7335
7364
|
const target = stylesheet ?? main;
|
|
7336
7365
|
if (!target) return void 0;
|
|
7337
|
-
const resolved =
|
|
7366
|
+
const resolved = path54.resolve(packageRoot, target);
|
|
7338
7367
|
return existsSync6(resolved) ? resolved : void 0;
|
|
7339
7368
|
} catch {
|
|
7340
7369
|
return void 0;
|
|
7341
7370
|
}
|
|
7342
7371
|
}
|
|
7343
|
-
directory =
|
|
7372
|
+
directory = path54.dirname(directory);
|
|
7344
7373
|
}
|
|
7345
7374
|
return void 0;
|
|
7346
7375
|
}
|
|
@@ -7591,7 +7620,7 @@ var unknownUtilityRule = {
|
|
|
7591
7620
|
};
|
|
7592
7621
|
|
|
7593
7622
|
// eslint/rules/util-file-name.ts
|
|
7594
|
-
import
|
|
7623
|
+
import path55 from "path";
|
|
7595
7624
|
function toKebabCase2(value) {
|
|
7596
7625
|
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
7626
|
}
|
|
@@ -7604,7 +7633,7 @@ var utilFileNameRule = {
|
|
|
7604
7633
|
}
|
|
7605
7634
|
},
|
|
7606
7635
|
create(context) {
|
|
7607
|
-
const filename =
|
|
7636
|
+
const filename = path55.resolve(context.filename);
|
|
7608
7637
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
7609
7638
|
if (!segments.includes("utils")) return {};
|
|
7610
7639
|
let module;
|
|
@@ -7618,13 +7647,13 @@ var utilFileNameRule = {
|
|
|
7618
7647
|
const functionName = functions[0]?.name;
|
|
7619
7648
|
if (!functionName) return {};
|
|
7620
7649
|
const expected = toKebabCase2(functionName);
|
|
7621
|
-
const actual =
|
|
7650
|
+
const actual = path55.basename(filename, path55.extname(filename));
|
|
7622
7651
|
if (!expected || actual === expected) return {};
|
|
7623
7652
|
return {
|
|
7624
7653
|
Program(node) {
|
|
7625
7654
|
context.report({
|
|
7626
7655
|
node,
|
|
7627
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
7656
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path55.extname(filename).slice(1)}.`
|
|
7628
7657
|
});
|
|
7629
7658
|
}
|
|
7630
7659
|
};
|
|
@@ -7632,7 +7661,7 @@ var utilFileNameRule = {
|
|
|
7632
7661
|
};
|
|
7633
7662
|
|
|
7634
7663
|
// eslint/rules/value-extraction.ts
|
|
7635
|
-
import
|
|
7664
|
+
import path56 from "path";
|
|
7636
7665
|
var valueExtractionRule = {
|
|
7637
7666
|
meta: {
|
|
7638
7667
|
schema: [],
|
|
@@ -7643,7 +7672,7 @@ var valueExtractionRule = {
|
|
|
7643
7672
|
},
|
|
7644
7673
|
create(context) {
|
|
7645
7674
|
const sourceRoot = sourceRootOf(context);
|
|
7646
|
-
const file =
|
|
7675
|
+
const file = path56.resolve(context.filename);
|
|
7647
7676
|
const segments = segmentsOf(file, sourceRoot);
|
|
7648
7677
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
7649
7678
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -7665,7 +7694,7 @@ var valueExtractionRule = {
|
|
|
7665
7694
|
|
|
7666
7695
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
7667
7696
|
import { existsSync as existsSync7, readFileSync as readFileSync11 } from "fs";
|
|
7668
|
-
import
|
|
7697
|
+
import path57 from "path";
|
|
7669
7698
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
7670
7699
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
7671
7700
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -7698,8 +7727,8 @@ var trackedDocsRule = {
|
|
|
7698
7727
|
if (!context.filename.endsWith("package.json")) return;
|
|
7699
7728
|
const root = node.body;
|
|
7700
7729
|
if (root.type !== "Object") return;
|
|
7701
|
-
const projectRoot =
|
|
7702
|
-
const configPath =
|
|
7730
|
+
const projectRoot = path57.dirname(path57.resolve(context.filename));
|
|
7731
|
+
const configPath = path57.join(projectRoot, "vulyk.config.ts");
|
|
7703
7732
|
if (!existsSync7(configPath)) {
|
|
7704
7733
|
context.report({
|
|
7705
7734
|
node,
|
|
@@ -7724,7 +7753,7 @@ var trackedDocsRule = {
|
|
|
7724
7753
|
});
|
|
7725
7754
|
}
|
|
7726
7755
|
}
|
|
7727
|
-
const agentsPath =
|
|
7756
|
+
const agentsPath = path57.join(projectRoot, "AGENTS.md");
|
|
7728
7757
|
if (!existsSync7(agentsPath)) {
|
|
7729
7758
|
context.report({
|
|
7730
7759
|
node,
|
|
@@ -7824,7 +7853,7 @@ var withResponseHelperRule = {
|
|
|
7824
7853
|
|
|
7825
7854
|
// eslint/rules/zirka-baseline.ts
|
|
7826
7855
|
import fs6 from "fs";
|
|
7827
|
-
import
|
|
7856
|
+
import path58 from "path";
|
|
7828
7857
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
7829
7858
|
var PRETTIER_CONFIGS = [
|
|
7830
7859
|
"prettier.config.mjs",
|
|
@@ -7843,10 +7872,10 @@ var zirkaBaselineRule = {
|
|
|
7843
7872
|
}
|
|
7844
7873
|
},
|
|
7845
7874
|
create(context) {
|
|
7846
|
-
const filename =
|
|
7847
|
-
const basename =
|
|
7875
|
+
const filename = path58.resolve(context.filename);
|
|
7876
|
+
const basename = path58.basename(filename);
|
|
7848
7877
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
7849
|
-
const projectRoot =
|
|
7878
|
+
const projectRoot = path58.dirname(filename);
|
|
7850
7879
|
const report3 = (message) => {
|
|
7851
7880
|
context.report({
|
|
7852
7881
|
node: context.sourceCode.ast,
|
|
@@ -7861,7 +7890,7 @@ var zirkaBaselineRule = {
|
|
|
7861
7890
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
7862
7891
|
);
|
|
7863
7892
|
}
|
|
7864
|
-
const tsconfigPath =
|
|
7893
|
+
const tsconfigPath = path58.join(projectRoot, "tsconfig.json");
|
|
7865
7894
|
if (!fs6.existsSync(tsconfigPath)) {
|
|
7866
7895
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
7867
7896
|
} else {
|
|
@@ -7879,13 +7908,13 @@ var zirkaBaselineRule = {
|
|
|
7879
7908
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
7880
7909
|
}
|
|
7881
7910
|
}
|
|
7882
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs6.existsSync(
|
|
7911
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs6.existsSync(path58.join(projectRoot, name)));
|
|
7883
7912
|
if (!prettierConfigFile) {
|
|
7884
7913
|
report3(
|
|
7885
7914
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
7886
7915
|
);
|
|
7887
7916
|
} else {
|
|
7888
|
-
const content = fs6.readFileSync(
|
|
7917
|
+
const content = fs6.readFileSync(path58.join(projectRoot, prettierConfigFile), "utf8");
|
|
7889
7918
|
if (!content.includes("zirka")) {
|
|
7890
7919
|
report3(
|
|
7891
7920
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|