pasika 0.10.73 → 0.10.74
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 +550 -168
- package/package.json +1 -1
|
@@ -38,8 +38,8 @@ function memberPropertyName(node) {
|
|
|
38
38
|
}
|
|
39
39
|
return void 0;
|
|
40
40
|
}
|
|
41
|
-
function importedContractMember(expression,
|
|
42
|
-
if (expression?.type !== "MemberExpression" || memberPropertyName(expression) !==
|
|
41
|
+
function importedContractMember(expression, propertyName5, imports) {
|
|
42
|
+
if (expression?.type !== "MemberExpression" || memberPropertyName(expression) !== propertyName5 || expression.object.type !== "Identifier" || !imports.has(expression.object.name)) {
|
|
43
43
|
return void 0;
|
|
44
44
|
}
|
|
45
45
|
return expression.object.name;
|
|
@@ -5023,10 +5023,309 @@ var noMixedConcernsRule = {
|
|
|
5023
5023
|
};
|
|
5024
5024
|
|
|
5025
5025
|
// eslint/rules/no-redundant-alias.ts
|
|
5026
|
+
import path40 from "path";
|
|
5027
|
+
|
|
5028
|
+
// eslint/rules/contract-ownership.ts
|
|
5026
5029
|
import path39 from "path";
|
|
5030
|
+
import ts7 from "typescript";
|
|
5031
|
+
function isTsProgram(value) {
|
|
5032
|
+
return typeof value === "object" && value !== null && "getTypeChecker" in value && typeof value.getTypeChecker === "function" && "getSourceFiles" in value && typeof value.getSourceFiles === "function";
|
|
5033
|
+
}
|
|
5034
|
+
function isEstreeTsNodeMap(value) {
|
|
5035
|
+
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function";
|
|
5036
|
+
}
|
|
5037
|
+
function typedParserServices(value) {
|
|
5038
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
5039
|
+
if (!("program" in value && "esTreeNodeToTSNodeMap" in value)) return void 0;
|
|
5040
|
+
if (!isTsProgram(value.program) || !isEstreeTsNodeMap(value.esTreeNodeToTSNodeMap)) return void 0;
|
|
5041
|
+
return { program: value.program, esTreeNodeToTSNodeMap: value.esTreeNodeToTSNodeMap };
|
|
5042
|
+
}
|
|
5043
|
+
var ownershipIndexCache = /* @__PURE__ */ new WeakMap();
|
|
5044
|
+
function normalizePath(value) {
|
|
5045
|
+
return value.replaceAll("\\", "/").toLowerCase();
|
|
5046
|
+
}
|
|
5047
|
+
function isWithin(root, file) {
|
|
5048
|
+
const relative = path39.relative(root, file);
|
|
5049
|
+
return relative === "" || !relative.startsWith("..") && !path39.isAbsolute(relative);
|
|
5050
|
+
}
|
|
5051
|
+
function mergeOwnership(values) {
|
|
5052
|
+
if (values.length === 0 || values.includes("unknown")) return "unknown";
|
|
5053
|
+
const known = new Set(values);
|
|
5054
|
+
if (known.size === 1) return [...known][0] ?? "unknown";
|
|
5055
|
+
return "unknown";
|
|
5056
|
+
}
|
|
5057
|
+
function endpointOwnership(pathValue) {
|
|
5058
|
+
if (pathValue === void 0) return "unknown";
|
|
5059
|
+
if (/^https?:\/\//u.test(pathValue)) return "third-party";
|
|
5060
|
+
if (pathValue.startsWith("/")) return "first-party";
|
|
5061
|
+
return "unknown";
|
|
5062
|
+
}
|
|
5063
|
+
function resolvedSymbol(checker, symbol) {
|
|
5064
|
+
return symbol.flags === ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
5065
|
+
}
|
|
5066
|
+
function propertyName3(node) {
|
|
5067
|
+
if (!node) return void 0;
|
|
5068
|
+
if (ts7.isIdentifier(node) || ts7.isStringLiteral(node) || ts7.isNumericLiteral(node)) return node.text;
|
|
5069
|
+
return void 0;
|
|
5070
|
+
}
|
|
5071
|
+
var ContractOwnershipIndex = class {
|
|
5072
|
+
constructor(program, cwd) {
|
|
5073
|
+
this.program = program;
|
|
5074
|
+
this.cwd = cwd;
|
|
5075
|
+
this.checker = program.getTypeChecker();
|
|
5076
|
+
this.indexApiContracts();
|
|
5077
|
+
}
|
|
5078
|
+
program;
|
|
5079
|
+
cwd;
|
|
5080
|
+
checker;
|
|
5081
|
+
schemaNodeOwnership = /* @__PURE__ */ new Map();
|
|
5082
|
+
sourceMember(node) {
|
|
5083
|
+
const symbol = this.checker.getSymbolAtLocation(node) ?? this.memberNameSymbol(node);
|
|
5084
|
+
const declarations = this.symbolDeclarations(symbol);
|
|
5085
|
+
if (this.isZodSchemaValue(node)) {
|
|
5086
|
+
const typeDeclarations2 = this.typeDeclarations(this.checker.getTypeAtLocation(node));
|
|
5087
|
+
const ownership = this.declarationsOwnership(declarations.length > 0 ? declarations : typeDeclarations2);
|
|
5088
|
+
return { kind: "non-contract", ownership };
|
|
5089
|
+
}
|
|
5090
|
+
if (declarations.length > 0) return this.endpointFromDeclarations(declarations);
|
|
5091
|
+
let object;
|
|
5092
|
+
if (ts7.isPropertyAccessExpression(node) || ts7.isElementAccessExpression(node)) object = node.expression;
|
|
5093
|
+
if (!object) return { kind: "missing", ownership: "unknown" };
|
|
5094
|
+
const type = this.checker.getTypeAtLocation(object);
|
|
5095
|
+
const typeDeclarations = this.typeDeclarations(type);
|
|
5096
|
+
if (typeDeclarations.length === 0) return { kind: "missing", ownership: "unknown" };
|
|
5097
|
+
return this.endpointFromDeclarations(typeDeclarations);
|
|
5098
|
+
}
|
|
5099
|
+
targetProperty(node, name) {
|
|
5100
|
+
if (!ts7.isPropertyAssignment(node) && !ts7.isShorthandPropertyAssignment(node)) {
|
|
5101
|
+
return { kind: "missing", ownership: "unknown" };
|
|
5102
|
+
}
|
|
5103
|
+
const object = node.parent;
|
|
5104
|
+
if (!ts7.isObjectLiteralExpression(object)) return { kind: "missing", ownership: "unknown" };
|
|
5105
|
+
const contextualType = this.checker.getContextualType(object);
|
|
5106
|
+
if (!contextualType) return { kind: "missing", ownership: "unknown" };
|
|
5107
|
+
const declarations = this.propertyDeclarations(contextualType, name);
|
|
5108
|
+
if (declarations.length === 0) return { kind: "missing", ownership: "unknown" };
|
|
5109
|
+
return this.endpointFromDeclarations(declarations);
|
|
5110
|
+
}
|
|
5111
|
+
memberNameSymbol(node) {
|
|
5112
|
+
if (ts7.isPropertyAccessExpression(node)) return this.checker.getSymbolAtLocation(node.name);
|
|
5113
|
+
if (ts7.isElementAccessExpression(node)) return this.checker.getSymbolAtLocation(node.argumentExpression);
|
|
5114
|
+
return void 0;
|
|
5115
|
+
}
|
|
5116
|
+
propertyDeclarations(type, name) {
|
|
5117
|
+
const types = type.isUnionOrIntersection() ? type.types : [type];
|
|
5118
|
+
const declarations = [];
|
|
5119
|
+
for (const item of types) {
|
|
5120
|
+
const symbol = this.checker.getPropertyOfType(item, name);
|
|
5121
|
+
if (symbol?.declarations) declarations.push(...symbol.declarations);
|
|
5122
|
+
}
|
|
5123
|
+
return declarations;
|
|
5124
|
+
}
|
|
5125
|
+
symbolDeclarations(symbol) {
|
|
5126
|
+
if (!symbol) return [];
|
|
5127
|
+
return [...resolvedSymbol(this.checker, symbol).declarations ?? []];
|
|
5128
|
+
}
|
|
5129
|
+
typeDeclarations(type) {
|
|
5130
|
+
const declarations = [...type.aliasSymbol?.declarations ?? [], ...type.getSymbol()?.declarations ?? []];
|
|
5131
|
+
if (type.isUnionOrIntersection()) {
|
|
5132
|
+
for (const item of type.types) {
|
|
5133
|
+
declarations.push(...item.aliasSymbol?.declarations ?? [], ...item.getSymbol()?.declarations ?? []);
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5136
|
+
return declarations;
|
|
5137
|
+
}
|
|
5138
|
+
endpointFromDeclarations(declarations) {
|
|
5139
|
+
const ownership = this.declarationsOwnership(declarations);
|
|
5140
|
+
if (declarations.some((declaration) => this.isDataContractField(declaration))) {
|
|
5141
|
+
return { kind: "data-contract", ownership };
|
|
5142
|
+
}
|
|
5143
|
+
if (declarations.some((declaration) => ts7.isPropertySignature(declaration) || ts7.isPropertyDeclaration(declaration))) {
|
|
5144
|
+
return { kind: "typed-local", ownership };
|
|
5145
|
+
}
|
|
5146
|
+
return { kind: "non-contract", ownership };
|
|
5147
|
+
}
|
|
5148
|
+
isDataContractField(declaration) {
|
|
5149
|
+
if (this.isZodSchemaField(declaration)) return true;
|
|
5150
|
+
if (!ts7.isPropertySignature(declaration) && !ts7.isPropertyDeclaration(declaration)) return false;
|
|
5151
|
+
const fileName = normalizePath(declaration.getSourceFile().fileName);
|
|
5152
|
+
return /(?:^|\/)database(?:[-.]generated)?\.ts$/u.test(fileName);
|
|
5153
|
+
}
|
|
5154
|
+
isZodSchemaValue(node) {
|
|
5155
|
+
const type = this.checker.getTypeAtLocation(node);
|
|
5156
|
+
return this.checker.getPropertyOfType(type, "_zod") !== void 0 && this.checker.getPropertyOfType(type, "parse") !== void 0 && this.checker.getPropertyOfType(type, "safeParse") !== void 0;
|
|
5157
|
+
}
|
|
5158
|
+
isZodSchemaField(declaration) {
|
|
5159
|
+
if (!ts7.isPropertyAssignment(declaration)) return false;
|
|
5160
|
+
let current = declaration.parent;
|
|
5161
|
+
while (!ts7.isSourceFile(current)) {
|
|
5162
|
+
if (ts7.isVariableDeclaration(current) && ts7.isIdentifier(current.name) && current.name.text.endsWith("Schema")) {
|
|
5163
|
+
return true;
|
|
5164
|
+
}
|
|
5165
|
+
current = current.parent;
|
|
5166
|
+
}
|
|
5167
|
+
return false;
|
|
5168
|
+
}
|
|
5169
|
+
declarationsOwnership(declarations) {
|
|
5170
|
+
if (declarations.length === 0) return "unknown";
|
|
5171
|
+
return mergeOwnership(declarations.map((declaration) => this.declarationOwnership(declaration)));
|
|
5172
|
+
}
|
|
5173
|
+
declarationOwnership(declaration) {
|
|
5174
|
+
const schemaOwnership = this.schemaOwnership(declaration);
|
|
5175
|
+
if (schemaOwnership !== void 0) return schemaOwnership;
|
|
5176
|
+
const fileName = declaration.getSourceFile().fileName;
|
|
5177
|
+
const normalized = normalizePath(fileName);
|
|
5178
|
+
if (/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u.test(normalized)) return "platform";
|
|
5179
|
+
if (normalized.includes("/node_modules/")) return "third-party";
|
|
5180
|
+
if (isWithin(this.cwd, path39.resolve(fileName))) return "first-party";
|
|
5181
|
+
return "unknown";
|
|
5182
|
+
}
|
|
5183
|
+
schemaOwnership(declaration) {
|
|
5184
|
+
let current = declaration;
|
|
5185
|
+
while (!ts7.isSourceFile(current)) {
|
|
5186
|
+
const ownership = this.schemaNodeOwnership.get(current);
|
|
5187
|
+
if (ownership !== void 0) return ownership;
|
|
5188
|
+
current = current.parent;
|
|
5189
|
+
}
|
|
5190
|
+
return void 0;
|
|
5191
|
+
}
|
|
5192
|
+
indexApiContracts() {
|
|
5193
|
+
for (const sourceFile of this.program.getSourceFiles()) {
|
|
5194
|
+
if (sourceFile.isDeclarationFile || !isWithin(this.cwd, path39.resolve(sourceFile.fileName))) continue;
|
|
5195
|
+
const visit = (node) => {
|
|
5196
|
+
if (ts7.isCallExpression(node) && this.isDefineApiContractCall(node)) this.indexApiContractCall(node);
|
|
5197
|
+
ts7.forEachChild(node, visit);
|
|
5198
|
+
};
|
|
5199
|
+
visit(sourceFile);
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
isDefineApiContractCall(node) {
|
|
5203
|
+
if (ts7.isIdentifier(node.expression)) return node.expression.text === "defineApiContract";
|
|
5204
|
+
return ts7.isPropertyAccessExpression(node.expression) && node.expression.name.text === "defineApiContract";
|
|
5205
|
+
}
|
|
5206
|
+
indexApiContractCall(node) {
|
|
5207
|
+
const argument = node.arguments[0];
|
|
5208
|
+
if (!argument || !ts7.isObjectLiteralExpression(argument)) return;
|
|
5209
|
+
let pathExpression;
|
|
5210
|
+
const schemaExpressions = [];
|
|
5211
|
+
for (const property of argument.properties) {
|
|
5212
|
+
if (ts7.isPropertyAssignment(property)) {
|
|
5213
|
+
const name = propertyName3(property.name);
|
|
5214
|
+
if (name === "path") pathExpression = property.initializer;
|
|
5215
|
+
if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.initializer);
|
|
5216
|
+
continue;
|
|
5217
|
+
}
|
|
5218
|
+
if (ts7.isShorthandPropertyAssignment(property)) {
|
|
5219
|
+
const name = property.name.text;
|
|
5220
|
+
if (name === "path") pathExpression = property.name;
|
|
5221
|
+
if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.name);
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5224
|
+
const ownership = endpointOwnership(this.staticString(pathExpression, /* @__PURE__ */ new Set()));
|
|
5225
|
+
if (ownership === "first-party") return;
|
|
5226
|
+
for (const expression of schemaExpressions) {
|
|
5227
|
+
this.markSchemaExpression(expression, ownership, /* @__PURE__ */ new Set());
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
staticString(node, seen) {
|
|
5231
|
+
if (!node) return void 0;
|
|
5232
|
+
if (ts7.isStringLiteralLike(node)) return node.text;
|
|
5233
|
+
if (ts7.isIdentifier(node)) {
|
|
5234
|
+
const symbol = this.checker.getSymbolAtLocation(node);
|
|
5235
|
+
if (!symbol || seen.has(symbol)) return void 0;
|
|
5236
|
+
seen.add(symbol);
|
|
5237
|
+
for (const declaration of resolvedSymbol(this.checker, symbol).declarations ?? []) {
|
|
5238
|
+
if (ts7.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
5239
|
+
const value = this.staticString(declaration.initializer, seen);
|
|
5240
|
+
if (value !== void 0) return value;
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5244
|
+
return void 0;
|
|
5245
|
+
}
|
|
5246
|
+
markSchemaExpression(node, ownership, seen) {
|
|
5247
|
+
this.setSchemaOwnership(node, ownership);
|
|
5248
|
+
const symbol = this.schemaReferenceSymbol(node);
|
|
5249
|
+
if (symbol && !seen.has(symbol)) {
|
|
5250
|
+
seen.add(symbol);
|
|
5251
|
+
const resolved = resolvedSymbol(this.checker, symbol);
|
|
5252
|
+
for (const declaration of resolved.declarations ?? []) {
|
|
5253
|
+
this.followSchemaDeclaration(declaration, ownership, seen);
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
ts7.forEachChild(node, (child) => {
|
|
5257
|
+
this.markSchemaExpression(child, ownership, seen);
|
|
5258
|
+
});
|
|
5259
|
+
}
|
|
5260
|
+
schemaReferenceSymbol(node) {
|
|
5261
|
+
if (ts7.isIdentifier(node)) {
|
|
5262
|
+
if (!node.text.endsWith("Schema")) return void 0;
|
|
5263
|
+
return this.checker.getSymbolAtLocation(node);
|
|
5264
|
+
}
|
|
5265
|
+
if (ts7.isPropertyAccessExpression(node)) {
|
|
5266
|
+
if (!node.name.text.endsWith("Schema")) return void 0;
|
|
5267
|
+
return this.checker.getSymbolAtLocation(node.name);
|
|
5268
|
+
}
|
|
5269
|
+
if (ts7.isElementAccessExpression(node) && ts7.isStringLiteralLike(node.argumentExpression)) {
|
|
5270
|
+
if (!node.argumentExpression.text.endsWith("Schema")) return void 0;
|
|
5271
|
+
return this.checker.getSymbolAtLocation(node.argumentExpression);
|
|
5272
|
+
}
|
|
5273
|
+
return void 0;
|
|
5274
|
+
}
|
|
5275
|
+
followSchemaDeclaration(declaration, ownership, seen) {
|
|
5276
|
+
this.setSchemaOwnership(declaration, ownership);
|
|
5277
|
+
if (ts7.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
5278
|
+
this.markSchemaExpression(declaration.initializer, ownership, seen);
|
|
5279
|
+
return;
|
|
5280
|
+
}
|
|
5281
|
+
if (ts7.isPropertyAssignment(declaration)) {
|
|
5282
|
+
this.markSchemaExpression(declaration.initializer, ownership, seen);
|
|
5283
|
+
return;
|
|
5284
|
+
}
|
|
5285
|
+
if (ts7.isShorthandPropertyAssignment(declaration)) {
|
|
5286
|
+
const valueSymbol = this.checker.getShorthandAssignmentValueSymbol(declaration);
|
|
5287
|
+
if (!valueSymbol || seen.has(valueSymbol)) return;
|
|
5288
|
+
seen.add(valueSymbol);
|
|
5289
|
+
for (const valueDeclaration of valueSymbol.declarations ?? []) {
|
|
5290
|
+
this.followSchemaDeclaration(valueDeclaration, ownership, seen);
|
|
5291
|
+
}
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
setSchemaOwnership(node, ownership) {
|
|
5295
|
+
const previous = this.schemaNodeOwnership.get(node);
|
|
5296
|
+
if (previous === void 0) {
|
|
5297
|
+
this.schemaNodeOwnership.set(node, ownership);
|
|
5298
|
+
return;
|
|
5299
|
+
}
|
|
5300
|
+
if (previous !== ownership) this.schemaNodeOwnership.set(node, "unknown");
|
|
5301
|
+
}
|
|
5302
|
+
};
|
|
5303
|
+
function contractOwnershipResolver(context) {
|
|
5304
|
+
const services = typedParserServices(context.sourceCode.parserServices);
|
|
5305
|
+
if (!services) return void 0;
|
|
5306
|
+
const { program, esTreeNodeToTSNodeMap: nodeMap } = services;
|
|
5307
|
+
let index = ownershipIndexCache.get(program);
|
|
5308
|
+
if (!index) {
|
|
5309
|
+
index = new ContractOwnershipIndex(program, context.cwd);
|
|
5310
|
+
ownershipIndexCache.set(program, index);
|
|
5311
|
+
}
|
|
5312
|
+
return {
|
|
5313
|
+
sourceMember(node) {
|
|
5314
|
+
const tsNode = nodeMap.get(node);
|
|
5315
|
+
return tsNode ? index.sourceMember(tsNode) : { kind: "missing", ownership: "unknown" };
|
|
5316
|
+
},
|
|
5317
|
+
targetProperty(node, name) {
|
|
5318
|
+
const tsNode = nodeMap.get(node);
|
|
5319
|
+
return tsNode ? index.targetProperty(tsNode, name) : { kind: "missing", ownership: "unknown" };
|
|
5320
|
+
}
|
|
5321
|
+
};
|
|
5322
|
+
}
|
|
5323
|
+
|
|
5324
|
+
// eslint/rules/no-redundant-alias.ts
|
|
5027
5325
|
var DOC4 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
5028
5326
|
var VALUE_SENTINELS = /* @__PURE__ */ new Set(["undefined", "NaN", "Infinity"]);
|
|
5029
5327
|
var HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
5328
|
+
var FRAMEWORK_MAPPING_KEYS = /* @__PURE__ */ new Set(["default", "apiRoutePath"]);
|
|
5030
5329
|
var PRIMITIVE_TYPE_NAMES = {
|
|
5031
5330
|
TSBigIntKeyword: "bigint",
|
|
5032
5331
|
TSBooleanKeyword: "boolean",
|
|
@@ -5061,9 +5360,43 @@ function aliasMessage(alias, source) {
|
|
|
5061
5360
|
function bindingAliasMessage(alias, source) {
|
|
5062
5361
|
return `"${alias}" renames "${source}" while creating a binding. Keep the original name and map it only at the object boundary. ${DOC4}`;
|
|
5063
5362
|
}
|
|
5064
|
-
function objectPropertyMessage(
|
|
5065
|
-
if (source ===
|
|
5066
|
-
return `"${
|
|
5363
|
+
function objectPropertyMessage(propertyName5, source) {
|
|
5364
|
+
if (source === propertyName5) return `Use property shorthand for "${propertyName5}". ${DOC4}`;
|
|
5365
|
+
return `"${propertyName5}" maps the local "${source}". Keep the local name or map directly from its source object instead. ${DOC4}`;
|
|
5366
|
+
}
|
|
5367
|
+
function normalizePropertyName(name) {
|
|
5368
|
+
return name.replace(/[-_\s]/g, "").toLowerCase();
|
|
5369
|
+
}
|
|
5370
|
+
function memberPropertyName2(node) {
|
|
5371
|
+
if (node.type !== "MemberExpression") return void 0;
|
|
5372
|
+
if (!node.computed && node.property.type === "Identifier") return node.property.name;
|
|
5373
|
+
if (node.computed && node.property.type === "Literal" && typeof node.property.value === "string") {
|
|
5374
|
+
return node.property.value;
|
|
5375
|
+
}
|
|
5376
|
+
return void 0;
|
|
5377
|
+
}
|
|
5378
|
+
function isNamedMemberValue(propertyName5) {
|
|
5379
|
+
return /^[A-Z]/.test(propertyName5);
|
|
5380
|
+
}
|
|
5381
|
+
function isQualifiedSourceField(propertyName5, sourceMember, sourcePropertyName) {
|
|
5382
|
+
if (sourceMember.type !== "MemberExpression" || sourceMember.object.type !== "Identifier") return false;
|
|
5383
|
+
return normalizePropertyName(propertyName5) === normalizePropertyName(`${sourceMember.object.name}${sourcePropertyName}`);
|
|
5384
|
+
}
|
|
5385
|
+
function isInsideSchemaDeclaration(node) {
|
|
5386
|
+
let current = node;
|
|
5387
|
+
while (current.type !== "Program") {
|
|
5388
|
+
if (current.type === "VariableDeclarator" && current.id.type === "Identifier" && current.id.name.endsWith("Schema")) {
|
|
5389
|
+
return true;
|
|
5390
|
+
}
|
|
5391
|
+
current = current.parent;
|
|
5392
|
+
}
|
|
5393
|
+
return false;
|
|
5394
|
+
}
|
|
5395
|
+
function semanticMappingMessage(propertyName5, sourcePropertyName) {
|
|
5396
|
+
return `"${propertyName5}" maps from "${sourcePropertyName}" between first-party contracts. Use one canonical field name across the contracts. ${DOC4}`;
|
|
5397
|
+
}
|
|
5398
|
+
function unknownContractOwnershipMessage(propertyName5, sourcePropertyName) {
|
|
5399
|
+
return `Cannot determine contract ownership for mapping "${propertyName5}" from "${sourcePropertyName}". Define or propagate a concrete contract, make the boundary schema explicit, or connect a mirrored external schema to its defineApiContract. ${DOC4}`;
|
|
5067
5400
|
}
|
|
5068
5401
|
var noRedundantAliasRule = {
|
|
5069
5402
|
meta: {
|
|
@@ -5071,10 +5404,11 @@ var noRedundantAliasRule = {
|
|
|
5071
5404
|
type: "problem",
|
|
5072
5405
|
fixable: "code",
|
|
5073
5406
|
docs: {
|
|
5074
|
-
description: "Disallow
|
|
5407
|
+
description: "Disallow redundant aliases and inconsistent object-to-object mappings."
|
|
5075
5408
|
}
|
|
5076
5409
|
},
|
|
5077
5410
|
create(context) {
|
|
5411
|
+
const ownershipResolver = contractOwnershipResolver(context);
|
|
5078
5412
|
return {
|
|
5079
5413
|
VariableDeclarator(node) {
|
|
5080
5414
|
if (node.id.type !== "Identifier" || !node.init) return;
|
|
@@ -5082,7 +5416,7 @@ var noRedundantAliasRule = {
|
|
|
5082
5416
|
if (declaration.type !== "VariableDeclaration" || declaration.kind !== "const") return;
|
|
5083
5417
|
if (node.init.type === "Identifier") {
|
|
5084
5418
|
const exported = declaration.parent.type === "ExportNamedDeclaration";
|
|
5085
|
-
const frameworkRouteAlias =
|
|
5419
|
+
const frameworkRouteAlias = path40.basename(context.filename) === "route.ts" && exported && HTTP_METHODS.has(node.id.name);
|
|
5086
5420
|
if (frameworkRouteAlias || VALUE_SENTINELS.has(node.init.name)) return;
|
|
5087
5421
|
context.report({
|
|
5088
5422
|
node,
|
|
@@ -5091,14 +5425,14 @@ var noRedundantAliasRule = {
|
|
|
5091
5425
|
return;
|
|
5092
5426
|
}
|
|
5093
5427
|
if (node.init.type !== "MemberExpression") return;
|
|
5094
|
-
let
|
|
5428
|
+
let propertyName5;
|
|
5095
5429
|
if (!node.init.computed && node.init.property.type === "Identifier") {
|
|
5096
|
-
|
|
5430
|
+
propertyName5 = node.init.property.name;
|
|
5097
5431
|
}
|
|
5098
5432
|
if (node.init.computed && node.init.property.type === "Literal" && typeof node.init.property.value === "string") {
|
|
5099
|
-
|
|
5433
|
+
propertyName5 = node.init.property.value;
|
|
5100
5434
|
}
|
|
5101
|
-
if (
|
|
5435
|
+
if (propertyName5 === void 0 || propertyName5 === node.id.name) return;
|
|
5102
5436
|
context.report({
|
|
5103
5437
|
node,
|
|
5104
5438
|
message: bindingAliasMessage(node.id.name, context.sourceCode.getText(node.init))
|
|
@@ -5106,34 +5440,69 @@ var noRedundantAliasRule = {
|
|
|
5106
5440
|
},
|
|
5107
5441
|
Property(node) {
|
|
5108
5442
|
if (node.computed) return;
|
|
5109
|
-
let
|
|
5110
|
-
if (node.key.type === "Identifier")
|
|
5443
|
+
let propertyName5;
|
|
5444
|
+
if (node.key.type === "Identifier") propertyName5 = node.key.name;
|
|
5111
5445
|
if (node.key.type === "Literal" && typeof node.key.value === "string") {
|
|
5112
|
-
|
|
5446
|
+
propertyName5 = node.key.value;
|
|
5113
5447
|
}
|
|
5114
|
-
if (
|
|
5448
|
+
if (propertyName5 === void 0) return;
|
|
5115
5449
|
if (node.parent.type === "ObjectPattern") {
|
|
5116
5450
|
let binding;
|
|
5117
5451
|
if (node.value.type === "Identifier") binding = node.value;
|
|
5118
5452
|
if (node.value.type === "AssignmentPattern" && node.value.left.type === "Identifier") {
|
|
5119
5453
|
binding = node.value.left;
|
|
5120
5454
|
}
|
|
5121
|
-
if (!binding || binding.name ===
|
|
5455
|
+
if (!binding || binding.name === propertyName5) return;
|
|
5456
|
+
context.report({
|
|
5457
|
+
node,
|
|
5458
|
+
message: bindingAliasMessage(binding.name, propertyName5)
|
|
5459
|
+
});
|
|
5460
|
+
return;
|
|
5461
|
+
}
|
|
5462
|
+
if (node.parent.type !== "ObjectExpression") return;
|
|
5463
|
+
if (isInsideSchemaDeclaration(node)) return;
|
|
5464
|
+
if (node.value.type === "Identifier") {
|
|
5465
|
+
if (node.shorthand) return;
|
|
5466
|
+
const source = node.value.name;
|
|
5467
|
+
context.report({
|
|
5468
|
+
node,
|
|
5469
|
+
message: objectPropertyMessage(propertyName5, source),
|
|
5470
|
+
fix(fixer) {
|
|
5471
|
+
return propertyName5 === source ? fixer.replaceText(node, propertyName5) : null;
|
|
5472
|
+
}
|
|
5473
|
+
});
|
|
5474
|
+
return;
|
|
5475
|
+
}
|
|
5476
|
+
if (node.value.type !== "MemberExpression") return;
|
|
5477
|
+
const sourcePropertyName = memberPropertyName2(node.value);
|
|
5478
|
+
if (sourcePropertyName === void 0) return;
|
|
5479
|
+
if (normalizePropertyName(propertyName5) === normalizePropertyName(sourcePropertyName)) return;
|
|
5480
|
+
if (FRAMEWORK_MAPPING_KEYS.has(propertyName5) || isNamedMemberValue(sourcePropertyName)) return;
|
|
5481
|
+
if (isQualifiedSourceField(propertyName5, node.value, sourcePropertyName)) return;
|
|
5482
|
+
if (!ownershipResolver) return;
|
|
5483
|
+
const sourceResolution = ownershipResolver.sourceMember(node.value);
|
|
5484
|
+
const targetResolution = ownershipResolver.targetProperty(node, propertyName5);
|
|
5485
|
+
if (sourceResolution.kind === "non-contract" || targetResolution.kind === "non-contract") return;
|
|
5486
|
+
if ((sourceResolution.ownership === "third-party" || sourceResolution.ownership === "platform") && targetResolution.kind !== "missing") {
|
|
5487
|
+
return;
|
|
5488
|
+
}
|
|
5489
|
+
if ((targetResolution.ownership === "third-party" || targetResolution.ownership === "platform") && sourceResolution.kind !== "missing") {
|
|
5490
|
+
return;
|
|
5491
|
+
}
|
|
5492
|
+
const hasDataContract = sourceResolution.kind === "data-contract" || targetResolution.kind === "data-contract";
|
|
5493
|
+
if (!hasDataContract) return;
|
|
5494
|
+
if (sourceResolution.kind === "missing" || targetResolution.kind === "missing" || sourceResolution.ownership === "unknown" || targetResolution.ownership === "unknown") {
|
|
5122
5495
|
context.report({
|
|
5123
5496
|
node,
|
|
5124
|
-
message:
|
|
5497
|
+
message: unknownContractOwnershipMessage(propertyName5, sourcePropertyName)
|
|
5125
5498
|
});
|
|
5126
5499
|
return;
|
|
5127
5500
|
}
|
|
5128
|
-
if (
|
|
5129
|
-
if (
|
|
5130
|
-
const source = node.value.name;
|
|
5501
|
+
if (sourceResolution.kind !== "data-contract") return;
|
|
5502
|
+
if (sourceResolution.ownership !== "first-party" || targetResolution.ownership !== "first-party") return;
|
|
5131
5503
|
context.report({
|
|
5132
5504
|
node,
|
|
5133
|
-
message:
|
|
5134
|
-
fix(fixer) {
|
|
5135
|
-
return propertyName4 === source ? fixer.replaceText(node, propertyName4) : null;
|
|
5136
|
-
}
|
|
5505
|
+
message: semanticMappingMessage(propertyName5, sourcePropertyName)
|
|
5137
5506
|
});
|
|
5138
5507
|
},
|
|
5139
5508
|
TSTypeAliasDeclaration(node) {
|
|
@@ -5160,7 +5529,7 @@ var noRedundantAliasRule = {
|
|
|
5160
5529
|
const source = specifier.local.name;
|
|
5161
5530
|
const alias = specifier.exported.name;
|
|
5162
5531
|
if (source === alias) continue;
|
|
5163
|
-
const frameworkRouteAlias =
|
|
5532
|
+
const frameworkRouteAlias = path40.basename(context.filename) === "route.ts" && HTTP_METHODS.has(alias);
|
|
5164
5533
|
if (frameworkRouteAlias) continue;
|
|
5165
5534
|
context.report({
|
|
5166
5535
|
node: specifier,
|
|
@@ -5185,7 +5554,7 @@ var noRedundantAliasRule = {
|
|
|
5185
5554
|
};
|
|
5186
5555
|
|
|
5187
5556
|
// eslint/rules/no-util-barrel.ts
|
|
5188
|
-
import
|
|
5557
|
+
import path41 from "path";
|
|
5189
5558
|
var noUtilBarrelRule = {
|
|
5190
5559
|
meta: {
|
|
5191
5560
|
schema: [],
|
|
@@ -5195,7 +5564,7 @@ var noUtilBarrelRule = {
|
|
|
5195
5564
|
}
|
|
5196
5565
|
},
|
|
5197
5566
|
create(context) {
|
|
5198
|
-
const filename =
|
|
5567
|
+
const filename = path41.resolve(context.filename);
|
|
5199
5568
|
const sourceRoot = sourceRootOf3(context, filename);
|
|
5200
5569
|
return {
|
|
5201
5570
|
Program(node) {
|
|
@@ -5204,7 +5573,7 @@ var noUtilBarrelRule = {
|
|
|
5204
5573
|
if (!target) continue;
|
|
5205
5574
|
const segments = target.replace(/\\/g, "/").split("/");
|
|
5206
5575
|
const utilsIndex = segments.lastIndexOf("utils");
|
|
5207
|
-
if (utilsIndex < 0 || !
|
|
5576
|
+
if (utilsIndex < 0 || !path41.basename(target).startsWith("index.")) continue;
|
|
5208
5577
|
context.report({
|
|
5209
5578
|
node,
|
|
5210
5579
|
message: `Import utilities directly instead of through "${specifier}". See docs/next-codebase-guide/rules/utilities-rule.md`
|
|
@@ -5224,10 +5593,10 @@ function importSpecifiers2(source) {
|
|
|
5224
5593
|
return specifiers;
|
|
5225
5594
|
}
|
|
5226
5595
|
function sourceRootOf3(context, filename) {
|
|
5227
|
-
const marker = `${
|
|
5596
|
+
const marker = `${path41.sep}src${path41.sep}`;
|
|
5228
5597
|
const srcIndex = filename.lastIndexOf(marker);
|
|
5229
5598
|
if (srcIndex >= 0) return filename.slice(0, srcIndex + marker.length - 1);
|
|
5230
|
-
return
|
|
5599
|
+
return path41.resolve(context.cwd ?? process.cwd(), "src");
|
|
5231
5600
|
}
|
|
5232
5601
|
|
|
5233
5602
|
// eslint/rules/package-json/exact-version.ts
|
|
@@ -5446,7 +5815,7 @@ var nextjsStackRule = {
|
|
|
5446
5815
|
|
|
5447
5816
|
// eslint/rules/package-json/vitest-coverage.ts
|
|
5448
5817
|
import { existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
|
|
5449
|
-
import
|
|
5818
|
+
import path42 from "path";
|
|
5450
5819
|
function memberName5(member) {
|
|
5451
5820
|
return member.name.type === "String" ? member.name.value : member.name.name;
|
|
5452
5821
|
}
|
|
@@ -5516,7 +5885,7 @@ var vitestCoverageRule = {
|
|
|
5516
5885
|
message: 'package.json must declare a "test:unit:coverage" script that runs Vitest with coverage.'
|
|
5517
5886
|
});
|
|
5518
5887
|
}
|
|
5519
|
-
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync5(
|
|
5888
|
+
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync5(path42.join(context.cwd, name)));
|
|
5520
5889
|
if (!configName) {
|
|
5521
5890
|
context.report({
|
|
5522
5891
|
node,
|
|
@@ -5524,7 +5893,7 @@ var vitestCoverageRule = {
|
|
|
5524
5893
|
});
|
|
5525
5894
|
return;
|
|
5526
5895
|
}
|
|
5527
|
-
const content = readFileSync8(
|
|
5896
|
+
const content = readFileSync8(path42.join(context.cwd, configName), "utf8");
|
|
5528
5897
|
for (const metric of THRESHOLD_METRICS) {
|
|
5529
5898
|
if (!new RegExp(`\\b${metric}\\s*:\\s*[1-9]\\d*`).test(content)) {
|
|
5530
5899
|
context.report({ node, message: `${configName} must set a coverage threshold above zero for ${metric}.` });
|
|
@@ -5570,7 +5939,7 @@ var nextjsPackageJsonRules = {
|
|
|
5570
5939
|
};
|
|
5571
5940
|
|
|
5572
5941
|
// eslint/rules/prefer-enum.ts
|
|
5573
|
-
import
|
|
5942
|
+
import path43 from "path";
|
|
5574
5943
|
function isConstAssertion(node) {
|
|
5575
5944
|
const typeAnnotation = node.typeAnnotation;
|
|
5576
5945
|
return typeAnnotation?.type === "TSTypeReference" && typeAnnotation.typeName?.type === "Identifier" && typeAnnotation.typeName.name === "const";
|
|
@@ -5592,7 +5961,7 @@ function isZodCall(node, method) {
|
|
|
5592
5961
|
const { callee } = node;
|
|
5593
5962
|
return callee?.type === "MemberExpression" && !callee.computed && callee.object.type === "Identifier" && callee.object.name === "z" && callee.property.type === "Identifier" && callee.property.name === method;
|
|
5594
5963
|
}
|
|
5595
|
-
function
|
|
5964
|
+
function propertyName4(property) {
|
|
5596
5965
|
if (property.computed) return void 0;
|
|
5597
5966
|
if (property.key.type === "Identifier") return property.key.name;
|
|
5598
5967
|
if (property.key.type === "Literal" && typeof property.key.value === "string") return property.key.value;
|
|
@@ -5603,7 +5972,7 @@ function rawZodDiscriminantLiteral(schemaCall, discriminator) {
|
|
|
5603
5972
|
const shape = schemaCall.arguments[0];
|
|
5604
5973
|
if (shape?.type !== "ObjectExpression") return void 0;
|
|
5605
5974
|
for (const property of shape.properties) {
|
|
5606
|
-
if (property.type !== "Property" ||
|
|
5975
|
+
if (property.type !== "Property" || propertyName4(property) !== discriminator) continue;
|
|
5607
5976
|
if (property.value.type !== "CallExpression" || !isZodCall(property.value, "literal")) return void 0;
|
|
5608
5977
|
const literal = property.value.arguments[0];
|
|
5609
5978
|
if (literal?.type === "Literal" && (typeof literal.value === "string" || typeof literal.value === "number")) {
|
|
@@ -5622,9 +5991,9 @@ var preferEnumRule = {
|
|
|
5622
5991
|
}
|
|
5623
5992
|
},
|
|
5624
5993
|
create(context) {
|
|
5625
|
-
const filename =
|
|
5994
|
+
const filename = path43.resolve(context.filename);
|
|
5626
5995
|
const sourceRoot = sourceRootOf(context);
|
|
5627
|
-
if (!filename.startsWith(sourceRoot +
|
|
5996
|
+
if (!filename.startsWith(sourceRoot + path43.sep)) return {};
|
|
5628
5997
|
const objectSchemas = /* @__PURE__ */ new Map();
|
|
5629
5998
|
const discriminatedUnions = [];
|
|
5630
5999
|
const reportedDiscriminants = /* @__PURE__ */ new Set();
|
|
@@ -5705,19 +6074,19 @@ function directPropertyBinding(context, declarator) {
|
|
|
5705
6074
|
const member = declarator.init;
|
|
5706
6075
|
if (member.computed || member.optional || member.property.type !== "Identifier") return void 0;
|
|
5707
6076
|
if (context.sourceCode.getCommentsInside(declarator).length > 0) return void 0;
|
|
5708
|
-
const
|
|
6077
|
+
const propertyName5 = member.property.name;
|
|
5709
6078
|
const localName = declarator.id.name;
|
|
5710
|
-
if (
|
|
6079
|
+
if (propertyName5 !== localName) return void 0;
|
|
5711
6080
|
const source = member.object;
|
|
5712
6081
|
const sourceText = context.sourceCode.getText(source);
|
|
5713
6082
|
return {
|
|
5714
6083
|
declarator,
|
|
5715
6084
|
member,
|
|
5716
|
-
propertyName:
|
|
6085
|
+
propertyName: propertyName5,
|
|
5717
6086
|
localName,
|
|
5718
6087
|
source,
|
|
5719
6088
|
sourceText,
|
|
5720
|
-
bindingText:
|
|
6089
|
+
bindingText: propertyName5
|
|
5721
6090
|
};
|
|
5722
6091
|
}
|
|
5723
6092
|
function canGroupSource(source) {
|
|
@@ -5799,13 +6168,13 @@ function groupedDestructuringSelections(context, first) {
|
|
|
5799
6168
|
if (!previous || nextNode?.type !== "VariableDeclaration" || nextNode.kind !== first.declaration.kind) break;
|
|
5800
6169
|
const next = destructuringSelection(context, nextNode);
|
|
5801
6170
|
if (next?.sourceText !== first.sourceText) break;
|
|
5802
|
-
if (next.propertyNames.some((
|
|
6171
|
+
if (next.propertyNames.some((propertyName5) => seenProperties.has(propertyName5))) break;
|
|
5803
6172
|
const [, previousEnd] = context.sourceCode.getRange(previous);
|
|
5804
6173
|
const [nextStart] = context.sourceCode.getRange(nextNode);
|
|
5805
6174
|
const gap = context.sourceCode.text.slice(previousEnd, nextStart);
|
|
5806
6175
|
if (!whitespaceKeepsStatementsAdjacent(gap)) break;
|
|
5807
6176
|
group.push(next);
|
|
5808
|
-
for (const
|
|
6177
|
+
for (const propertyName5 of next.propertyNames) seenProperties.add(propertyName5);
|
|
5809
6178
|
}
|
|
5810
6179
|
return group;
|
|
5811
6180
|
}
|
|
@@ -5869,7 +6238,7 @@ var preferObjectDestructuringRule = {
|
|
|
5869
6238
|
if (bindings.length === 0) return;
|
|
5870
6239
|
const firstBinding = bindings[0];
|
|
5871
6240
|
if (!firstBinding) return;
|
|
5872
|
-
const sameSourceBindings = bindings.length > 1 && bindings.length === node.declarations.length && bindings.every(({ sourceText }) => sourceText === firstBinding.sourceText) && new Set(bindings.map(({ propertyName:
|
|
6241
|
+
const sameSourceBindings = bindings.length > 1 && bindings.length === node.declarations.length && bindings.every(({ sourceText }) => sourceText === firstBinding.sourceText) && new Set(bindings.map(({ propertyName: propertyName5 }) => propertyName5)).size === bindings.length;
|
|
5873
6242
|
if (sameSourceBindings) {
|
|
5874
6243
|
context.report({
|
|
5875
6244
|
node,
|
|
@@ -5926,7 +6295,7 @@ var preferObjectDestructuringRule = {
|
|
|
5926
6295
|
};
|
|
5927
6296
|
|
|
5928
6297
|
// eslint/rules/pure-function-extract.ts
|
|
5929
|
-
import
|
|
6298
|
+
import path44 from "path";
|
|
5930
6299
|
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
5931
6300
|
"GET",
|
|
5932
6301
|
"POST",
|
|
@@ -5991,12 +6360,12 @@ var pureFunctionExtractRule = {
|
|
|
5991
6360
|
},
|
|
5992
6361
|
create(context) {
|
|
5993
6362
|
const filename = context.filename;
|
|
5994
|
-
const isRouteFile =
|
|
6363
|
+
const isRouteFile = path44.basename(filename) === "route.ts";
|
|
5995
6364
|
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
5996
6365
|
const sourceRoot = sourceRootOf(context);
|
|
5997
|
-
const relative =
|
|
6366
|
+
const relative = path44.relative(sourceRoot, filename);
|
|
5998
6367
|
if (relative.startsWith("..")) return {};
|
|
5999
|
-
const segments = relative.split(
|
|
6368
|
+
const segments = relative.split(path44.sep);
|
|
6000
6369
|
const folders = segments.slice(0, -1);
|
|
6001
6370
|
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
6002
6371
|
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
@@ -6056,16 +6425,16 @@ var pureFunctionExtractRule = {
|
|
|
6056
6425
|
};
|
|
6057
6426
|
|
|
6058
6427
|
// eslint/rules/repeated-numeric-value.ts
|
|
6059
|
-
import
|
|
6428
|
+
import path45 from "path";
|
|
6060
6429
|
var ignoredValues = /* @__PURE__ */ new Set([-1, 0, 1]);
|
|
6061
6430
|
function isNonProductionFile(file, sourceRoot) {
|
|
6062
|
-
const relative =
|
|
6063
|
-
const segments = relative.split(
|
|
6064
|
-
const basename =
|
|
6431
|
+
const relative = path45.relative(sourceRoot, file);
|
|
6432
|
+
const segments = relative.split(path45.sep);
|
|
6433
|
+
const basename = path45.basename(file);
|
|
6065
6434
|
return /\.(?:test|spec|mock)\.[^.]+$/.test(basename) || segments.some((segment) => segment === "__tests__" || segment === "__mocks__" || segment === "mocks");
|
|
6066
6435
|
}
|
|
6067
6436
|
function isCanonicalConstantFile(file, sourceRoot) {
|
|
6068
|
-
const segments =
|
|
6437
|
+
const segments = path45.relative(sourceRoot, file).split(path45.sep);
|
|
6069
6438
|
return segments.includes("constants") || segments[0] === "config";
|
|
6070
6439
|
}
|
|
6071
6440
|
function groupKey(literal) {
|
|
@@ -6081,7 +6450,7 @@ var repeatedNumericValueRule = {
|
|
|
6081
6450
|
},
|
|
6082
6451
|
create(context) {
|
|
6083
6452
|
const sourceRoot = sourceRootOf(context);
|
|
6084
|
-
const file =
|
|
6453
|
+
const file = path45.resolve(context.filename);
|
|
6085
6454
|
if (isNonProductionFile(file, sourceRoot) || isCanonicalConstantFile(file, sourceRoot)) return {};
|
|
6086
6455
|
const index = getProjectIndex(sourceRoot);
|
|
6087
6456
|
if (!index) return {};
|
|
@@ -6301,7 +6670,7 @@ var repeatedStructureRule = {
|
|
|
6301
6670
|
|
|
6302
6671
|
// eslint/rules/require-barrel-star-exports.ts
|
|
6303
6672
|
import fs5 from "fs";
|
|
6304
|
-
import
|
|
6673
|
+
import path46 from "path";
|
|
6305
6674
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
6306
6675
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
6307
6676
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
@@ -6309,9 +6678,9 @@ function resolveSiblingModule(indexFile, specifier) {
|
|
|
6309
6678
|
if (!specifier.startsWith("./")) return void 0;
|
|
6310
6679
|
const relative = specifier.slice(2);
|
|
6311
6680
|
if (!relative || relative.includes("/")) return void 0;
|
|
6312
|
-
const directory =
|
|
6313
|
-
const direct =
|
|
6314
|
-
const candidates =
|
|
6681
|
+
const directory = path46.dirname(indexFile);
|
|
6682
|
+
const direct = path46.resolve(directory, relative);
|
|
6683
|
+
const candidates = path46.extname(direct) ? [direct] : MODULE_EXTENSIONS3.map((extension) => `${direct}${extension}`);
|
|
6315
6684
|
return candidates.find((candidate) => fs5.existsSync(candidate) && fs5.statSync(candidate).isFile());
|
|
6316
6685
|
}
|
|
6317
6686
|
var requireBarrelStarExportsRule = {
|
|
@@ -6324,9 +6693,9 @@ var requireBarrelStarExportsRule = {
|
|
|
6324
6693
|
fixable: "code"
|
|
6325
6694
|
},
|
|
6326
6695
|
create(context) {
|
|
6327
|
-
const filename =
|
|
6328
|
-
if (!INDEX_NAMES.has(
|
|
6329
|
-
if (!SUPPORT_FOLDERS3.has(
|
|
6696
|
+
const filename = path46.resolve(context.filename);
|
|
6697
|
+
if (!INDEX_NAMES.has(path46.basename(filename))) return {};
|
|
6698
|
+
if (!SUPPORT_FOLDERS3.has(path46.basename(path46.dirname(filename)))) return {};
|
|
6330
6699
|
return {
|
|
6331
6700
|
ExportNamedDeclaration(node) {
|
|
6332
6701
|
const sourceNode = node.source;
|
|
@@ -6379,7 +6748,7 @@ var requireBarrelStarExportsRule = {
|
|
|
6379
6748
|
};
|
|
6380
6749
|
|
|
6381
6750
|
// eslint/rules/root-support-placement.ts
|
|
6382
|
-
import
|
|
6751
|
+
import path47 from "path";
|
|
6383
6752
|
function isSupportFolder(value) {
|
|
6384
6753
|
return value === "utils" || value === "types" || value === "schemas" || value === "constants";
|
|
6385
6754
|
}
|
|
@@ -6412,7 +6781,7 @@ var rootSupportPlacementRule = {
|
|
|
6412
6781
|
},
|
|
6413
6782
|
create(context) {
|
|
6414
6783
|
const sourceRoot = sourceRootOf(context);
|
|
6415
|
-
const file =
|
|
6784
|
+
const file = path47.resolve(context.filename);
|
|
6416
6785
|
const segments = segmentsOf(file, sourceRoot);
|
|
6417
6786
|
const folderSegments = folderSegmentsOf(file, sourceRoot);
|
|
6418
6787
|
const supportFolder = folderSegments[folderSegments.length - 1];
|
|
@@ -6452,8 +6821,8 @@ var rootSupportPlacementRule = {
|
|
|
6452
6821
|
};
|
|
6453
6822
|
|
|
6454
6823
|
// eslint/rules/route-handler-shape.ts
|
|
6455
|
-
import
|
|
6456
|
-
import
|
|
6824
|
+
import path48 from "path";
|
|
6825
|
+
import ts8 from "typescript";
|
|
6457
6826
|
var HTTP_METHODS2 = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
6458
6827
|
var REQUIRED_BOUNDARY = "withResponse";
|
|
6459
6828
|
function isFunctionLike(node) {
|
|
@@ -6471,33 +6840,33 @@ function findHandler(node) {
|
|
|
6471
6840
|
return void 0;
|
|
6472
6841
|
}
|
|
6473
6842
|
function isLoop(node) {
|
|
6474
|
-
return
|
|
6843
|
+
return ts8.isForStatement(node) || ts8.isForOfStatement(node) || ts8.isForInStatement(node) || ts8.isWhileStatement(node) || ts8.isDoStatement(node);
|
|
6475
6844
|
}
|
|
6476
6845
|
function isFunctionBoundary(node) {
|
|
6477
|
-
return
|
|
6846
|
+
return ts8.isFunctionExpression(node) || ts8.isArrowFunction(node) || ts8.isFunctionDeclaration(node);
|
|
6478
6847
|
}
|
|
6479
6848
|
function analyzeHandlerBody(body, sourceText) {
|
|
6480
6849
|
const start = body.range?.[0] ?? 0;
|
|
6481
6850
|
const end = body.range?.[1] ?? sourceText.length;
|
|
6482
|
-
const sourceFile =
|
|
6851
|
+
const sourceFile = ts8.createSourceFile(
|
|
6483
6852
|
"route.ts",
|
|
6484
6853
|
sourceText.slice(start, end),
|
|
6485
|
-
|
|
6854
|
+
ts8.ScriptTarget.Latest,
|
|
6486
6855
|
true,
|
|
6487
|
-
|
|
6856
|
+
ts8.ScriptKind.TS
|
|
6488
6857
|
);
|
|
6489
6858
|
const kinds = /* @__PURE__ */ new Set();
|
|
6490
6859
|
const calledNames = /* @__PURE__ */ new Set();
|
|
6491
6860
|
const visit = (node) => {
|
|
6492
|
-
if (
|
|
6861
|
+
if (ts8.isTryStatement(node)) kinds.add("try");
|
|
6493
6862
|
if (isLoop(node)) kinds.add("loop");
|
|
6494
|
-
if (
|
|
6495
|
-
if (
|
|
6863
|
+
if (ts8.isIfStatement(node)) kinds.add("if");
|
|
6864
|
+
if (ts8.isCallExpression(node) && ts8.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map") {
|
|
6496
6865
|
kinds.add("map");
|
|
6497
6866
|
}
|
|
6498
|
-
if (
|
|
6867
|
+
if (ts8.isCallExpression(node) && ts8.isIdentifier(node.expression)) calledNames.add(node.expression.text);
|
|
6499
6868
|
if (isFunctionBoundary(node)) return;
|
|
6500
|
-
|
|
6869
|
+
ts8.forEachChild(node, visit);
|
|
6501
6870
|
};
|
|
6502
6871
|
visit(sourceFile);
|
|
6503
6872
|
return { kinds, calledNames };
|
|
@@ -6537,7 +6906,7 @@ var routeHandlerShapeRule = {
|
|
|
6537
6906
|
}
|
|
6538
6907
|
},
|
|
6539
6908
|
create(context) {
|
|
6540
|
-
if (
|
|
6909
|
+
if (path48.basename(context.filename) !== "route.ts") return {};
|
|
6541
6910
|
const sourceText = context.sourceCode.text;
|
|
6542
6911
|
function reportUnwrapped(node, name) {
|
|
6543
6912
|
context.report({
|
|
@@ -6596,7 +6965,7 @@ var routeHandlerShapeRule = {
|
|
|
6596
6965
|
};
|
|
6597
6966
|
|
|
6598
6967
|
// eslint/rules/schema-casing.ts
|
|
6599
|
-
import
|
|
6968
|
+
import path49 from "path";
|
|
6600
6969
|
function isCamelCase(name) {
|
|
6601
6970
|
return /^[a-z][a-zA-Z0-9]*$/.test(name);
|
|
6602
6971
|
}
|
|
@@ -6624,9 +6993,9 @@ var schemaCasingRule = {
|
|
|
6624
6993
|
}
|
|
6625
6994
|
},
|
|
6626
6995
|
create(context) {
|
|
6627
|
-
const filename =
|
|
6996
|
+
const filename = path49.resolve(context.filename);
|
|
6628
6997
|
const sourceRoot = sourceRootOf(context);
|
|
6629
|
-
if (!filename.startsWith(sourceRoot +
|
|
6998
|
+
if (!filename.startsWith(sourceRoot + path49.sep)) return {};
|
|
6630
6999
|
let zodLocalName;
|
|
6631
7000
|
return {
|
|
6632
7001
|
ImportDeclaration(node) {
|
|
@@ -6658,39 +7027,39 @@ var schemaCasingRule = {
|
|
|
6658
7027
|
};
|
|
6659
7028
|
|
|
6660
7029
|
// eslint/rules/sole-state-owner.ts
|
|
6661
|
-
import
|
|
6662
|
-
import
|
|
7030
|
+
import path50 from "path";
|
|
7031
|
+
import ts9 from "typescript";
|
|
6663
7032
|
function findStateHooks(node) {
|
|
6664
7033
|
const hooks = [];
|
|
6665
7034
|
const visit = (child) => {
|
|
6666
|
-
if (
|
|
6667
|
-
if (
|
|
7035
|
+
if (ts9.isCallExpression(child) && ts9.isIdentifier(child.expression) && child.expression.text === "useState") {
|
|
7036
|
+
if (ts9.isVariableDeclaration(child.parent)) {
|
|
6668
7037
|
const { name } = child.parent;
|
|
6669
|
-
if (
|
|
7038
|
+
if (ts9.isArrayBindingPattern(name) && name.elements.length >= 2) {
|
|
6670
7039
|
const value = name.elements[0];
|
|
6671
7040
|
const updater = name.elements[1];
|
|
6672
|
-
if (value && updater &&
|
|
7041
|
+
if (value && updater && ts9.isBindingElement(value) && ts9.isBindingElement(updater)) {
|
|
6673
7042
|
const valueName = value.name;
|
|
6674
7043
|
const updaterName = updater.name;
|
|
6675
|
-
if (
|
|
7044
|
+
if (ts9.isIdentifier(valueName) && ts9.isIdentifier(updaterName)) {
|
|
6676
7045
|
hooks.push({ value: valueName.text, updater: updaterName.text });
|
|
6677
7046
|
}
|
|
6678
7047
|
}
|
|
6679
7048
|
}
|
|
6680
7049
|
}
|
|
6681
7050
|
}
|
|
6682
|
-
|
|
7051
|
+
ts9.forEachChild(child, visit);
|
|
6683
7052
|
};
|
|
6684
7053
|
visit(node);
|
|
6685
7054
|
return hooks;
|
|
6686
7055
|
}
|
|
6687
7056
|
function isHookUsage(node, hook) {
|
|
6688
|
-
if (
|
|
7057
|
+
if (ts9.isCallExpression(node) && ts9.isIdentifier(node.expression) && node.expression.text === hook.updater) {
|
|
6689
7058
|
return "updater";
|
|
6690
7059
|
}
|
|
6691
|
-
if (
|
|
7060
|
+
if (ts9.isIdentifier(node) && node.text === hook.value) {
|
|
6692
7061
|
const parent = node.parent;
|
|
6693
|
-
if (
|
|
7062
|
+
if (ts9.isBindingElement(parent) || ts9.isPropertyAccessExpression(parent) || ts9.isShorthandPropertyAssignment(parent)) {
|
|
6694
7063
|
return void 0;
|
|
6695
7064
|
}
|
|
6696
7065
|
return "value";
|
|
@@ -6700,16 +7069,16 @@ function isHookUsage(node, hook) {
|
|
|
6700
7069
|
function topLevelJsxChildren(initial) {
|
|
6701
7070
|
if (!initial) return void 0;
|
|
6702
7071
|
let expression = initial;
|
|
6703
|
-
while (
|
|
6704
|
-
if (
|
|
7072
|
+
while (ts9.isParenthesizedExpression(expression)) expression = expression.expression;
|
|
7073
|
+
if (ts9.isJsxFragment(expression)) {
|
|
6705
7074
|
const children = expression.children.filter(
|
|
6706
|
-
(c) => !
|
|
7075
|
+
(c) => !ts9.isJsxText(c) && !ts9.isJsxSpreadAttribute(c)
|
|
6707
7076
|
);
|
|
6708
7077
|
return { root: expression, children };
|
|
6709
7078
|
}
|
|
6710
|
-
if (
|
|
7079
|
+
if (ts9.isJsxElement(expression)) {
|
|
6711
7080
|
const children = expression.children.filter(
|
|
6712
|
-
(c) => !
|
|
7081
|
+
(c) => !ts9.isJsxText(c) && !ts9.isJsxSpreadAttribute(c)
|
|
6713
7082
|
);
|
|
6714
7083
|
return { root: expression, children };
|
|
6715
7084
|
}
|
|
@@ -6723,8 +7092,8 @@ function collectUsesIn(child, hook) {
|
|
|
6723
7092
|
positions.push(node);
|
|
6724
7093
|
count += 1;
|
|
6725
7094
|
}
|
|
6726
|
-
if (
|
|
6727
|
-
|
|
7095
|
+
if (ts9.isFunctionDeclaration(node) || ts9.isClassDeclaration(node)) return;
|
|
7096
|
+
ts9.forEachChild(node, visit);
|
|
6728
7097
|
};
|
|
6729
7098
|
visit(child);
|
|
6730
7099
|
return { positions, count };
|
|
@@ -6738,7 +7107,7 @@ var soleStateOwnerRule = {
|
|
|
6738
7107
|
}
|
|
6739
7108
|
},
|
|
6740
7109
|
create(context) {
|
|
6741
|
-
const filename =
|
|
7110
|
+
const filename = path50.resolve(context.filename);
|
|
6742
7111
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
6743
7112
|
const text = context.sourceCode.text;
|
|
6744
7113
|
const components = parseComponentInfo(text, filename);
|
|
@@ -6763,18 +7132,18 @@ var soleStateOwnerRule = {
|
|
|
6763
7132
|
}
|
|
6764
7133
|
};
|
|
6765
7134
|
function analyzeSoleOwner(declaration, hook) {
|
|
6766
|
-
const body =
|
|
6767
|
-
if (!body || !
|
|
7135
|
+
const body = ts9.isFunctionDeclaration(declaration) ? declaration.body : void 0;
|
|
7136
|
+
if (!body || !ts9.isBlock(body)) return void 0;
|
|
6768
7137
|
const returns = [];
|
|
6769
7138
|
const visit = (node) => {
|
|
6770
|
-
if (node !== body && (
|
|
6771
|
-
if (
|
|
6772
|
-
|
|
7139
|
+
if (node !== body && (ts9.isFunctionLike(node) || ts9.isClassLike(node))) return;
|
|
7140
|
+
if (ts9.isReturnStatement(node)) returns.push(node);
|
|
7141
|
+
ts9.forEachChild(node, visit);
|
|
6773
7142
|
};
|
|
6774
7143
|
visit(body);
|
|
6775
7144
|
if (returns.length !== 1) return void 0;
|
|
6776
7145
|
const single = returns[0];
|
|
6777
|
-
if (!single?.expression || !
|
|
7146
|
+
if (!single?.expression || !ts9.isExpression(single.expression)) return void 0;
|
|
6778
7147
|
const returnExpression = single.expression;
|
|
6779
7148
|
const root = topLevelJsxChildren(returnExpression);
|
|
6780
7149
|
if (!root || root.children.length === 0) return void 0;
|
|
@@ -6797,11 +7166,11 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
6797
7166
|
let outside = false;
|
|
6798
7167
|
const visit = (node) => {
|
|
6799
7168
|
if (outside) return;
|
|
6800
|
-
if (node !== declaration && (
|
|
7169
|
+
if (node !== declaration && (ts9.isFunctionDeclaration(node) || ts9.isClassDeclaration(node))) return;
|
|
6801
7170
|
if (isHookUsage(node, hook)) {
|
|
6802
7171
|
let current = node;
|
|
6803
7172
|
let isInJsxChild = false;
|
|
6804
|
-
while (!
|
|
7173
|
+
while (!ts9.isSourceFile(current)) {
|
|
6805
7174
|
if (children.includes(current)) {
|
|
6806
7175
|
isInJsxChild = true;
|
|
6807
7176
|
break;
|
|
@@ -6810,14 +7179,14 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
6810
7179
|
}
|
|
6811
7180
|
if (!isInJsxChild) outside = true;
|
|
6812
7181
|
}
|
|
6813
|
-
|
|
7182
|
+
ts9.forEachChild(node, visit);
|
|
6814
7183
|
};
|
|
6815
7184
|
visit(declaration);
|
|
6816
7185
|
return outside;
|
|
6817
7186
|
}
|
|
6818
7187
|
|
|
6819
7188
|
// eslint/rules/source-under-src.ts
|
|
6820
|
-
import
|
|
7189
|
+
import path51 from "path";
|
|
6821
7190
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
6822
7191
|
".agents",
|
|
6823
7192
|
".cache",
|
|
@@ -6858,14 +7227,14 @@ var sourceUnderSrcRule = {
|
|
|
6858
7227
|
}
|
|
6859
7228
|
},
|
|
6860
7229
|
create(context) {
|
|
6861
|
-
const filename =
|
|
7230
|
+
const filename = path51.resolve(context.filename);
|
|
6862
7231
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
6863
|
-
const relative =
|
|
7232
|
+
const relative = path51.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
6864
7233
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
6865
7234
|
const topLevel = relative.split("/")[0] ?? "";
|
|
6866
7235
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
6867
7236
|
if (!relative.includes("/")) {
|
|
6868
|
-
const basename =
|
|
7237
|
+
const basename = path51.basename(filename);
|
|
6869
7238
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
6870
7239
|
}
|
|
6871
7240
|
return {
|
|
@@ -6881,7 +7250,7 @@ var sourceUnderSrcRule = {
|
|
|
6881
7250
|
};
|
|
6882
7251
|
|
|
6883
7252
|
// eslint/rules/stay-flat.ts
|
|
6884
|
-
import
|
|
7253
|
+
import path52 from "path";
|
|
6885
7254
|
var stayFlatRule = {
|
|
6886
7255
|
meta: {
|
|
6887
7256
|
schema: [],
|
|
@@ -6892,7 +7261,7 @@ var stayFlatRule = {
|
|
|
6892
7261
|
},
|
|
6893
7262
|
create(context) {
|
|
6894
7263
|
const sourceRoot = sourceRootOf(context);
|
|
6895
|
-
const file =
|
|
7264
|
+
const file = path52.resolve(context.filename);
|
|
6896
7265
|
const segments = segmentsOf(file, sourceRoot);
|
|
6897
7266
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
6898
7267
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -6932,7 +7301,7 @@ var stayFlatRule = {
|
|
|
6932
7301
|
};
|
|
6933
7302
|
|
|
6934
7303
|
// eslint/rules/support-file-placement.ts
|
|
6935
|
-
import
|
|
7304
|
+
import path53 from "path";
|
|
6936
7305
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
6937
7306
|
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
6938
7307
|
["constants", "constant"],
|
|
@@ -6957,7 +7326,7 @@ var supportFilePlacementRule = {
|
|
|
6957
7326
|
},
|
|
6958
7327
|
create(context) {
|
|
6959
7328
|
const sourceRoot = sourceRootOf(context);
|
|
6960
|
-
const supportFile =
|
|
7329
|
+
const supportFile = path53.resolve(context.filename);
|
|
6961
7330
|
const currentFolder = folderSegmentsOf(supportFile, sourceRoot);
|
|
6962
7331
|
const supportFolder = currentFolder[currentFolder.length - 1];
|
|
6963
7332
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS.has(supportFolder)) return {};
|
|
@@ -7011,7 +7380,7 @@ var supportFilePlacementRule = {
|
|
|
7011
7380
|
|
|
7012
7381
|
// eslint/rules/support-folder-shape.ts
|
|
7013
7382
|
import fs6 from "fs";
|
|
7014
|
-
import
|
|
7383
|
+
import path54 from "path";
|
|
7015
7384
|
var SUPPORT_FOLDERS4 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
7016
7385
|
var INDEX_NAMES2 = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
7017
7386
|
var supportFolderShapeRule = {
|
|
@@ -7023,12 +7392,12 @@ var supportFolderShapeRule = {
|
|
|
7023
7392
|
}
|
|
7024
7393
|
},
|
|
7025
7394
|
create(context) {
|
|
7026
|
-
const filename =
|
|
7027
|
-
const baseName =
|
|
7395
|
+
const filename = path54.resolve(context.filename);
|
|
7396
|
+
const baseName = path54.basename(filename);
|
|
7028
7397
|
if (!INDEX_NAMES2.has(baseName)) return {};
|
|
7029
|
-
const folder =
|
|
7398
|
+
const folder = path54.basename(path54.dirname(filename));
|
|
7030
7399
|
if (!SUPPORT_FOLDERS4.has(folder)) return {};
|
|
7031
|
-
const directory =
|
|
7400
|
+
const directory = path54.dirname(filename);
|
|
7032
7401
|
let entries;
|
|
7033
7402
|
try {
|
|
7034
7403
|
entries = fs6.readdirSync(directory);
|
|
@@ -7046,7 +7415,7 @@ var supportFolderShapeRule = {
|
|
|
7046
7415
|
for (const match of source.matchAll(exportPattern)) {
|
|
7047
7416
|
hasAnyReExport = true;
|
|
7048
7417
|
const specifier = match.groups?.specifier;
|
|
7049
|
-
if (specifier?.startsWith(".")) exportedFiles.add(
|
|
7418
|
+
if (specifier?.startsWith(".")) exportedFiles.add(path54.basename(specifier));
|
|
7050
7419
|
}
|
|
7051
7420
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
7052
7421
|
if (siblingModules.length === 0) {
|
|
@@ -7225,11 +7594,11 @@ var baseLayerPairRule = {
|
|
|
7225
7594
|
|
|
7226
7595
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
7227
7596
|
import { statSync as statSync4 } from "fs";
|
|
7228
|
-
import
|
|
7597
|
+
import path57 from "path";
|
|
7229
7598
|
|
|
7230
7599
|
// eslint/rules/tailwind/source-files.ts
|
|
7231
7600
|
import { readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
|
|
7232
|
-
import
|
|
7601
|
+
import path55 from "path";
|
|
7233
7602
|
var CSS_EXTENSIONS = [".css"];
|
|
7234
7603
|
var MODULE_EXTENSIONS4 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
7235
7604
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS4, ...CSS_EXTENSIONS];
|
|
@@ -7242,7 +7611,7 @@ function findFiles(dir, extensions) {
|
|
|
7242
7611
|
}
|
|
7243
7612
|
return entries.flatMap((entry) => {
|
|
7244
7613
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
7245
|
-
const entryPath =
|
|
7614
|
+
const entryPath = path55.join(dir, entry);
|
|
7246
7615
|
let stats;
|
|
7247
7616
|
try {
|
|
7248
7617
|
stats = statSync3(entryPath);
|
|
@@ -7250,7 +7619,7 @@ function findFiles(dir, extensions) {
|
|
|
7250
7619
|
return [];
|
|
7251
7620
|
}
|
|
7252
7621
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
7253
|
-
return extensions.includes(
|
|
7622
|
+
return extensions.includes(path55.extname(entry)) ? [entryPath] : [];
|
|
7254
7623
|
});
|
|
7255
7624
|
}
|
|
7256
7625
|
function cachedTextReader() {
|
|
@@ -7273,7 +7642,7 @@ function escapeRegExp(text) {
|
|
|
7273
7642
|
}
|
|
7274
7643
|
|
|
7275
7644
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
7276
|
-
import
|
|
7645
|
+
import path56 from "path";
|
|
7277
7646
|
function registersTailwind(text) {
|
|
7278
7647
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
7279
7648
|
}
|
|
@@ -7287,25 +7656,25 @@ function moduleImports(text, fileName) {
|
|
|
7287
7656
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
7288
7657
|
}
|
|
7289
7658
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
7290
|
-
if (spec.startsWith("/")) return
|
|
7291
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
7292
|
-
if (spec.startsWith("@/")) return
|
|
7659
|
+
if (spec.startsWith("/")) return path56.resolve(spec);
|
|
7660
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path56.resolve(path56.dirname(fromFile), spec);
|
|
7661
|
+
if (spec.startsWith("@/")) return path56.resolve(sourceRoot, spec.slice(2));
|
|
7293
7662
|
return void 0;
|
|
7294
7663
|
}
|
|
7295
7664
|
function buildStylesheetGraph(options) {
|
|
7296
7665
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
7297
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
7666
|
+
const cssSet = new Set(cssFiles.map((file) => path56.normalize(file)));
|
|
7298
7667
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
7299
7668
|
const reachable = /* @__PURE__ */ new Set();
|
|
7300
7669
|
const queue = [...globals];
|
|
7301
|
-
for (const global of globals) reachable.add(
|
|
7670
|
+
for (const global of globals) reachable.add(path56.normalize(global));
|
|
7302
7671
|
while (queue.length > 0) {
|
|
7303
7672
|
const from = queue.shift();
|
|
7304
7673
|
if (!from) continue;
|
|
7305
7674
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
7306
7675
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
7307
7676
|
if (!target) continue;
|
|
7308
|
-
const normalized =
|
|
7677
|
+
const normalized = path56.normalize(target);
|
|
7309
7678
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
7310
7679
|
reachable.add(normalized);
|
|
7311
7680
|
queue.push(normalized);
|
|
@@ -7317,7 +7686,7 @@ function buildStylesheetGraph(options) {
|
|
|
7317
7686
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
7318
7687
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
7319
7688
|
if (!target) continue;
|
|
7320
|
-
const normalized =
|
|
7689
|
+
const normalized = path56.normalize(target);
|
|
7321
7690
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
7322
7691
|
}
|
|
7323
7692
|
}
|
|
@@ -7325,8 +7694,8 @@ function buildStylesheetGraph(options) {
|
|
|
7325
7694
|
}
|
|
7326
7695
|
|
|
7327
7696
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
7328
|
-
var APP_STYLES_DIR =
|
|
7329
|
-
var GLOBAL_STYLESHEET_PATH =
|
|
7697
|
+
var APP_STYLES_DIR = path57.join("app", "styles");
|
|
7698
|
+
var GLOBAL_STYLESHEET_PATH = path57.join(APP_STYLES_DIR, "globals.css");
|
|
7330
7699
|
var cssEntryPointRule = {
|
|
7331
7700
|
meta: {
|
|
7332
7701
|
schema: [],
|
|
@@ -7352,8 +7721,8 @@ var cssEntryPointRule = {
|
|
|
7352
7721
|
return {
|
|
7353
7722
|
"StyleSheet:exit"(node) {
|
|
7354
7723
|
if (globals.length === 0) return;
|
|
7355
|
-
const current =
|
|
7356
|
-
const relative =
|
|
7724
|
+
const current = path57.normalize(path57.resolve(context.filename));
|
|
7725
|
+
const relative = path57.relative(sourceRoot, current);
|
|
7357
7726
|
if (globals.includes(current)) {
|
|
7358
7727
|
if (globals.length > 1) {
|
|
7359
7728
|
context.report({
|
|
@@ -7369,7 +7738,7 @@ var cssEntryPointRule = {
|
|
|
7369
7738
|
});
|
|
7370
7739
|
return;
|
|
7371
7740
|
}
|
|
7372
|
-
const basename =
|
|
7741
|
+
const basename = path57.basename(current);
|
|
7373
7742
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
7374
7743
|
if (importCount !== 1) {
|
|
7375
7744
|
context.report({
|
|
@@ -7379,7 +7748,7 @@ var cssEntryPointRule = {
|
|
|
7379
7748
|
}
|
|
7380
7749
|
return;
|
|
7381
7750
|
}
|
|
7382
|
-
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${
|
|
7751
|
+
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${path57.sep}`);
|
|
7383
7752
|
if (!isInAppStyles) {
|
|
7384
7753
|
context.report({
|
|
7385
7754
|
node,
|
|
@@ -7868,7 +8237,7 @@ var tailwindRules = {
|
|
|
7868
8237
|
};
|
|
7869
8238
|
|
|
7870
8239
|
// eslint/rules/type-extraction.ts
|
|
7871
|
-
import
|
|
8240
|
+
import path58 from "path";
|
|
7872
8241
|
var typeExtractionRule = {
|
|
7873
8242
|
meta: {
|
|
7874
8243
|
schema: [],
|
|
@@ -7879,7 +8248,7 @@ var typeExtractionRule = {
|
|
|
7879
8248
|
},
|
|
7880
8249
|
create(context) {
|
|
7881
8250
|
const sourceRoot = sourceRootOf(context);
|
|
7882
|
-
const file =
|
|
8251
|
+
const file = path58.resolve(context.filename);
|
|
7883
8252
|
const segments = segmentsOf(file, sourceRoot);
|
|
7884
8253
|
if (segments.length === 0) return {};
|
|
7885
8254
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -8020,7 +8389,7 @@ var uiStateRule = {
|
|
|
8020
8389
|
// eslint/rules/unknown-utility.ts
|
|
8021
8390
|
import { existsSync as existsSync6, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
|
|
8022
8391
|
import { createRequire } from "module";
|
|
8023
|
-
import
|
|
8392
|
+
import path59 from "path";
|
|
8024
8393
|
var PREFIX_NAMESPACES = {
|
|
8025
8394
|
bg: ["color"],
|
|
8026
8395
|
text: ["color", "text"],
|
|
@@ -8260,7 +8629,7 @@ function stylesheetFiles(dir) {
|
|
|
8260
8629
|
}
|
|
8261
8630
|
return entries.flatMap((entry) => {
|
|
8262
8631
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
8263
|
-
const entryPath =
|
|
8632
|
+
const entryPath = path59.join(dir, entry);
|
|
8264
8633
|
let stats;
|
|
8265
8634
|
try {
|
|
8266
8635
|
stats = statSync6(entryPath);
|
|
@@ -8268,7 +8637,7 @@ function stylesheetFiles(dir) {
|
|
|
8268
8637
|
return [];
|
|
8269
8638
|
}
|
|
8270
8639
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
8271
|
-
return
|
|
8640
|
+
return path59.extname(entry) === ".css" ? [entryPath] : [];
|
|
8272
8641
|
});
|
|
8273
8642
|
}
|
|
8274
8643
|
function packageNameOf(specifier) {
|
|
@@ -8279,10 +8648,10 @@ function packageNameOf(specifier) {
|
|
|
8279
8648
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
8280
8649
|
const packageName = packageNameOf(specifier);
|
|
8281
8650
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
8282
|
-
let directory =
|
|
8283
|
-
while (directory !==
|
|
8284
|
-
const packageRoot =
|
|
8285
|
-
const manifestPath =
|
|
8651
|
+
let directory = path59.dirname(fromFile);
|
|
8652
|
+
while (directory !== path59.dirname(directory)) {
|
|
8653
|
+
const packageRoot = path59.join(directory, "node_modules", packageName);
|
|
8654
|
+
const manifestPath = path59.join(packageRoot, "package.json");
|
|
8286
8655
|
if (existsSync6(manifestPath)) {
|
|
8287
8656
|
try {
|
|
8288
8657
|
const manifest = readFileSync10(manifestPath, "utf8");
|
|
@@ -8290,13 +8659,13 @@ function resolvePackageStylesheet(fromFile, specifier) {
|
|
|
8290
8659
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
8291
8660
|
const target = stylesheet ?? main;
|
|
8292
8661
|
if (!target) return void 0;
|
|
8293
|
-
const resolved =
|
|
8662
|
+
const resolved = path59.resolve(packageRoot, target);
|
|
8294
8663
|
return existsSync6(resolved) ? resolved : void 0;
|
|
8295
8664
|
} catch {
|
|
8296
8665
|
return void 0;
|
|
8297
8666
|
}
|
|
8298
8667
|
}
|
|
8299
|
-
directory =
|
|
8668
|
+
directory = path59.dirname(directory);
|
|
8300
8669
|
}
|
|
8301
8670
|
return void 0;
|
|
8302
8671
|
}
|
|
@@ -8547,7 +8916,7 @@ var unknownUtilityRule = {
|
|
|
8547
8916
|
};
|
|
8548
8917
|
|
|
8549
8918
|
// eslint/rules/util-file-name.ts
|
|
8550
|
-
import
|
|
8919
|
+
import path60 from "path";
|
|
8551
8920
|
function toKebabCase2(value) {
|
|
8552
8921
|
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();
|
|
8553
8922
|
}
|
|
@@ -8560,7 +8929,7 @@ var utilFileNameRule = {
|
|
|
8560
8929
|
}
|
|
8561
8930
|
},
|
|
8562
8931
|
create(context) {
|
|
8563
|
-
const filename =
|
|
8932
|
+
const filename = path60.resolve(context.filename);
|
|
8564
8933
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
8565
8934
|
if (!segments.includes("utils")) return {};
|
|
8566
8935
|
let module;
|
|
@@ -8574,13 +8943,13 @@ var utilFileNameRule = {
|
|
|
8574
8943
|
const functionName = functions[0]?.name;
|
|
8575
8944
|
if (!functionName) return {};
|
|
8576
8945
|
const expected = toKebabCase2(functionName);
|
|
8577
|
-
const actual =
|
|
8946
|
+
const actual = path60.basename(filename, path60.extname(filename));
|
|
8578
8947
|
if (!expected || actual === expected) return {};
|
|
8579
8948
|
return {
|
|
8580
8949
|
Program(node) {
|
|
8581
8950
|
context.report({
|
|
8582
8951
|
node,
|
|
8583
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
8952
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path60.extname(filename).slice(1)}.`
|
|
8584
8953
|
});
|
|
8585
8954
|
}
|
|
8586
8955
|
};
|
|
@@ -8588,7 +8957,7 @@ var utilFileNameRule = {
|
|
|
8588
8957
|
};
|
|
8589
8958
|
|
|
8590
8959
|
// eslint/rules/value-extraction.ts
|
|
8591
|
-
import
|
|
8960
|
+
import path61 from "path";
|
|
8592
8961
|
var valueExtractionRule = {
|
|
8593
8962
|
meta: {
|
|
8594
8963
|
schema: [],
|
|
@@ -8599,7 +8968,7 @@ var valueExtractionRule = {
|
|
|
8599
8968
|
},
|
|
8600
8969
|
create(context) {
|
|
8601
8970
|
const sourceRoot = sourceRootOf(context);
|
|
8602
|
-
const file =
|
|
8971
|
+
const file = path61.resolve(context.filename);
|
|
8603
8972
|
const segments = segmentsOf(file, sourceRoot);
|
|
8604
8973
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
8605
8974
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -8621,7 +8990,7 @@ var valueExtractionRule = {
|
|
|
8621
8990
|
|
|
8622
8991
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
8623
8992
|
import { existsSync as existsSync7, readFileSync as readFileSync11 } from "fs";
|
|
8624
|
-
import
|
|
8993
|
+
import path62 from "path";
|
|
8625
8994
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
8626
8995
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
8627
8996
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -8654,8 +9023,8 @@ var trackedDocsRule = {
|
|
|
8654
9023
|
if (!context.filename.endsWith("package.json")) return;
|
|
8655
9024
|
const root = node.body;
|
|
8656
9025
|
if (root.type !== "Object") return;
|
|
8657
|
-
const projectRoot =
|
|
8658
|
-
const configPath =
|
|
9026
|
+
const projectRoot = path62.dirname(path62.resolve(context.filename));
|
|
9027
|
+
const configPath = path62.join(projectRoot, "vulyk.config.ts");
|
|
8659
9028
|
if (!existsSync7(configPath)) {
|
|
8660
9029
|
context.report({
|
|
8661
9030
|
node,
|
|
@@ -8680,7 +9049,7 @@ var trackedDocsRule = {
|
|
|
8680
9049
|
});
|
|
8681
9050
|
}
|
|
8682
9051
|
}
|
|
8683
|
-
const agentsPath =
|
|
9052
|
+
const agentsPath = path62.join(projectRoot, "AGENTS.md");
|
|
8684
9053
|
if (!existsSync7(agentsPath)) {
|
|
8685
9054
|
context.report({
|
|
8686
9055
|
node,
|
|
@@ -8780,7 +9149,7 @@ var withResponseHelperRule = {
|
|
|
8780
9149
|
|
|
8781
9150
|
// eslint/rules/zirka-baseline.ts
|
|
8782
9151
|
import fs7 from "fs";
|
|
8783
|
-
import
|
|
9152
|
+
import path63 from "path";
|
|
8784
9153
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
8785
9154
|
var PRETTIER_CONFIGS = [
|
|
8786
9155
|
"prettier.config.mjs",
|
|
@@ -8799,10 +9168,10 @@ var zirkaBaselineRule = {
|
|
|
8799
9168
|
}
|
|
8800
9169
|
},
|
|
8801
9170
|
create(context) {
|
|
8802
|
-
const filename =
|
|
8803
|
-
const basename =
|
|
9171
|
+
const filename = path63.resolve(context.filename);
|
|
9172
|
+
const basename = path63.basename(filename);
|
|
8804
9173
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
8805
|
-
const projectRoot =
|
|
9174
|
+
const projectRoot = path63.dirname(filename);
|
|
8806
9175
|
const report3 = (message) => {
|
|
8807
9176
|
context.report({
|
|
8808
9177
|
node: context.sourceCode.ast,
|
|
@@ -8817,7 +9186,7 @@ var zirkaBaselineRule = {
|
|
|
8817
9186
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
8818
9187
|
);
|
|
8819
9188
|
}
|
|
8820
|
-
const tsconfigPath =
|
|
9189
|
+
const tsconfigPath = path63.join(projectRoot, "tsconfig.json");
|
|
8821
9190
|
if (!fs7.existsSync(tsconfigPath)) {
|
|
8822
9191
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
8823
9192
|
} else {
|
|
@@ -8835,13 +9204,13 @@ var zirkaBaselineRule = {
|
|
|
8835
9204
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
8836
9205
|
}
|
|
8837
9206
|
}
|
|
8838
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(
|
|
9207
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(path63.join(projectRoot, name)));
|
|
8839
9208
|
if (!prettierConfigFile) {
|
|
8840
9209
|
report3(
|
|
8841
9210
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
8842
9211
|
);
|
|
8843
9212
|
} else {
|
|
8844
|
-
const content = fs7.readFileSync(
|
|
9213
|
+
const content = fs7.readFileSync(path63.join(projectRoot, prettierConfigFile), "utf8");
|
|
8845
9214
|
if (!content.includes("zirka")) {
|
|
8846
9215
|
report3(
|
|
8847
9216
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|
|
@@ -9146,6 +9515,18 @@ var pasikaNextjsAppConfig = {
|
|
|
9146
9515
|
},
|
|
9147
9516
|
rules: Object.fromEntries(pasikaNextjsAppRuleIds.map((id) => [id, "error"]))
|
|
9148
9517
|
};
|
|
9518
|
+
var pasikaTypedProjectServiceConfig = {
|
|
9519
|
+
files: ["src/**/*.{cts,mts,ts,tsx}"],
|
|
9520
|
+
languageOptions: {
|
|
9521
|
+
parser: tsParser,
|
|
9522
|
+
parserOptions: {
|
|
9523
|
+
ecmaVersion: "latest",
|
|
9524
|
+
sourceType: "module",
|
|
9525
|
+
ecmaFeatures: { jsx: true },
|
|
9526
|
+
projectService: true
|
|
9527
|
+
}
|
|
9528
|
+
}
|
|
9529
|
+
};
|
|
9149
9530
|
var tailwindStructureRules = {
|
|
9150
9531
|
files: ["src/app/styles/globals.css"],
|
|
9151
9532
|
plugins: {
|
|
@@ -9215,6 +9596,7 @@ var pasikaNextjsApp = pasikaNextjsAppWithDiagnostic([
|
|
|
9215
9596
|
...pasikaApp,
|
|
9216
9597
|
pasikaNextjsAppPackageJsonConfig,
|
|
9217
9598
|
pasikaNextjsAppConfig,
|
|
9599
|
+
pasikaTypedProjectServiceConfig,
|
|
9218
9600
|
tailwindStructureRules,
|
|
9219
9601
|
tailwindImportGraph
|
|
9220
9602
|
]);
|