pasika 0.10.73 → 0.10.75
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 +639 -169
- 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;
|
|
5122
5456
|
context.report({
|
|
5123
5457
|
node,
|
|
5124
|
-
message: bindingAliasMessage(binding.name,
|
|
5458
|
+
message: bindingAliasMessage(binding.name, propertyName5)
|
|
5125
5459
|
});
|
|
5126
5460
|
return;
|
|
5127
5461
|
}
|
|
5128
|
-
if (node.parent.type !== "ObjectExpression"
|
|
5129
|
-
if (node
|
|
5130
|
-
|
|
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") {
|
|
5495
|
+
context.report({
|
|
5496
|
+
node,
|
|
5497
|
+
message: unknownContractOwnershipMessage(propertyName5, sourcePropertyName)
|
|
5498
|
+
});
|
|
5499
|
+
return;
|
|
5500
|
+
}
|
|
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,24 +6074,80 @@ 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) {
|
|
5724
6093
|
return source.type === "Identifier" || source.type === "ThisExpression";
|
|
5725
6094
|
}
|
|
6095
|
+
function isStableObjectSource(source) {
|
|
6096
|
+
if (source.type === "Identifier" || source.type === "ThisExpression") return true;
|
|
6097
|
+
if (source.type !== "MemberExpression") return false;
|
|
6098
|
+
if (source.computed || source.optional || source.property.type !== "Identifier") return false;
|
|
6099
|
+
return isStableObjectSource(source.object);
|
|
6100
|
+
}
|
|
6101
|
+
function objectUsage(scope, sourceText) {
|
|
6102
|
+
let usage = scope.objects.get(sourceText);
|
|
6103
|
+
if (!usage) {
|
|
6104
|
+
usage = { propertyNames: /* @__PURE__ */ new Set(), directMembers: /* @__PURE__ */ new Map() };
|
|
6105
|
+
scope.objects.set(sourceText, usage);
|
|
6106
|
+
}
|
|
6107
|
+
return usage;
|
|
6108
|
+
}
|
|
6109
|
+
function memberIsRead(context, member) {
|
|
6110
|
+
const parent = context.sourceCode.getAncestors(member).at(-1);
|
|
6111
|
+
if (!parent) return true;
|
|
6112
|
+
if (parent.type === "AssignmentExpression" && parent.left === member) return false;
|
|
6113
|
+
if (parent.type === "UpdateExpression" && parent.argument === member) return false;
|
|
6114
|
+
if (parent.type === "UnaryExpression" && parent.operator === "delete" && parent.argument === member) return false;
|
|
6115
|
+
if ((parent.type === "ForInStatement" || parent.type === "ForOfStatement") && parent.left === member) return false;
|
|
6116
|
+
if ((parent.type === "CallExpression" || parent.type === "NewExpression") && parent.callee === member) return false;
|
|
6117
|
+
if (parent.type === "TaggedTemplateExpression" && parent.tag === member) return false;
|
|
6118
|
+
return true;
|
|
6119
|
+
}
|
|
6120
|
+
function memberIsDirectVariableInitializer(context, member) {
|
|
6121
|
+
const parent = context.sourceCode.getAncestors(member).at(-1);
|
|
6122
|
+
return parent?.type === "VariableDeclarator" && parent.init === member;
|
|
6123
|
+
}
|
|
6124
|
+
function recordMemberUsage(context, scope, member) {
|
|
6125
|
+
if (!scope || member.computed || member.optional || member.property.type !== "Identifier") return;
|
|
6126
|
+
if (!isStableObjectSource(member.object) || !memberIsRead(context, member)) return;
|
|
6127
|
+
const sourceText = context.sourceCode.getText(member.object);
|
|
6128
|
+
const usage = objectUsage(scope, sourceText);
|
|
6129
|
+
const propertyName5 = member.property.name;
|
|
6130
|
+
usage.propertyNames.add(propertyName5);
|
|
6131
|
+
if (!memberIsDirectVariableInitializer(context, member) && !usage.directMembers.has(propertyName5)) {
|
|
6132
|
+
usage.directMembers.set(propertyName5, member);
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
function recordDestructuringUsage(context, scope, declaration) {
|
|
6136
|
+
if (!scope) return;
|
|
6137
|
+
for (const declarator of declaration.declarations) {
|
|
6138
|
+
if (declarator.id.type !== "ObjectPattern" || !declarator.init || !isStableObjectSource(declarator.init)) continue;
|
|
6139
|
+
const sourceText = context.sourceCode.getText(declarator.init);
|
|
6140
|
+
const usage = objectUsage(scope, sourceText);
|
|
6141
|
+
for (const property of declarator.id.properties) {
|
|
6142
|
+
if (property.type !== "Property" || property.computed || property.key.type !== "Identifier") continue;
|
|
6143
|
+
usage.propertyNames.add(property.key.name);
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
}
|
|
6147
|
+
function scopeUsageMessage(sourceText, propertyNames) {
|
|
6148
|
+
const names = [...propertyNames].map((name) => `"${name}"`).join(", ");
|
|
6149
|
+
return `${names} are read from "${sourceText}" in the same block. Destructure them together in one declaration. ${DOC5}`;
|
|
6150
|
+
}
|
|
5726
6151
|
function whitespaceKeepsStatementsAdjacent(text) {
|
|
5727
6152
|
if (text.trim() !== "") return false;
|
|
5728
6153
|
return (text.match(/\n/gu) ?? []).length <= 1;
|
|
@@ -5799,13 +6224,13 @@ function groupedDestructuringSelections(context, first) {
|
|
|
5799
6224
|
if (!previous || nextNode?.type !== "VariableDeclaration" || nextNode.kind !== first.declaration.kind) break;
|
|
5800
6225
|
const next = destructuringSelection(context, nextNode);
|
|
5801
6226
|
if (next?.sourceText !== first.sourceText) break;
|
|
5802
|
-
if (next.propertyNames.some((
|
|
6227
|
+
if (next.propertyNames.some((propertyName5) => seenProperties.has(propertyName5))) break;
|
|
5803
6228
|
const [, previousEnd] = context.sourceCode.getRange(previous);
|
|
5804
6229
|
const [nextStart] = context.sourceCode.getRange(nextNode);
|
|
5805
6230
|
const gap = context.sourceCode.text.slice(previousEnd, nextStart);
|
|
5806
6231
|
if (!whitespaceKeepsStatementsAdjacent(gap)) break;
|
|
5807
6232
|
group.push(next);
|
|
5808
|
-
for (const
|
|
6233
|
+
for (const propertyName5 of next.propertyNames) seenProperties.add(propertyName5);
|
|
5809
6234
|
}
|
|
5810
6235
|
return group;
|
|
5811
6236
|
}
|
|
@@ -5833,13 +6258,45 @@ var preferObjectDestructuringRule = {
|
|
|
5833
6258
|
type: "problem",
|
|
5834
6259
|
fixable: "code",
|
|
5835
6260
|
docs: {
|
|
5836
|
-
description: "Require
|
|
6261
|
+
description: "Require related object-property reads to use one object destructuring declaration."
|
|
5837
6262
|
}
|
|
5838
6263
|
},
|
|
5839
6264
|
create(context) {
|
|
5840
6265
|
const grouped = /* @__PURE__ */ new Set();
|
|
6266
|
+
const usageScopes = [];
|
|
6267
|
+
const currentUsageScope = () => usageScopes.at(-1);
|
|
6268
|
+
const enterUsageScope = () => {
|
|
6269
|
+
usageScopes.push({ objects: /* @__PURE__ */ new Map() });
|
|
6270
|
+
};
|
|
6271
|
+
const exitUsageScope = () => {
|
|
6272
|
+
const scope = usageScopes.pop();
|
|
6273
|
+
if (!scope) return;
|
|
6274
|
+
for (const [sourceText, usage] of scope.objects) {
|
|
6275
|
+
if (usage.propertyNames.size < 2 || usage.directMembers.size === 0) continue;
|
|
6276
|
+
const firstDirectMember = usage.directMembers.values().next().value;
|
|
6277
|
+
if (!firstDirectMember) continue;
|
|
6278
|
+
context.report({
|
|
6279
|
+
node: firstDirectMember,
|
|
6280
|
+
message: scopeUsageMessage(sourceText, usage.propertyNames)
|
|
6281
|
+
});
|
|
6282
|
+
}
|
|
6283
|
+
};
|
|
5841
6284
|
return {
|
|
6285
|
+
Program: enterUsageScope,
|
|
6286
|
+
"Program:exit": exitUsageScope,
|
|
6287
|
+
BlockStatement: enterUsageScope,
|
|
6288
|
+
"BlockStatement:exit": exitUsageScope,
|
|
6289
|
+
FunctionDeclaration: enterUsageScope,
|
|
6290
|
+
"FunctionDeclaration:exit": exitUsageScope,
|
|
6291
|
+
FunctionExpression: enterUsageScope,
|
|
6292
|
+
"FunctionExpression:exit": exitUsageScope,
|
|
6293
|
+
ArrowFunctionExpression: enterUsageScope,
|
|
6294
|
+
"ArrowFunctionExpression:exit": exitUsageScope,
|
|
6295
|
+
MemberExpression(node) {
|
|
6296
|
+
recordMemberUsage(context, currentUsageScope(), node);
|
|
6297
|
+
},
|
|
5842
6298
|
VariableDeclaration(node) {
|
|
6299
|
+
recordDestructuringUsage(context, currentUsageScope(), node);
|
|
5843
6300
|
if (grouped.has(node)) return;
|
|
5844
6301
|
const selection = destructuringSelection(context, node);
|
|
5845
6302
|
if (selection) {
|
|
@@ -5869,7 +6326,7 @@ var preferObjectDestructuringRule = {
|
|
|
5869
6326
|
if (bindings.length === 0) return;
|
|
5870
6327
|
const firstBinding = bindings[0];
|
|
5871
6328
|
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:
|
|
6329
|
+
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
6330
|
if (sameSourceBindings) {
|
|
5874
6331
|
context.report({
|
|
5875
6332
|
node,
|
|
@@ -5926,7 +6383,7 @@ var preferObjectDestructuringRule = {
|
|
|
5926
6383
|
};
|
|
5927
6384
|
|
|
5928
6385
|
// eslint/rules/pure-function-extract.ts
|
|
5929
|
-
import
|
|
6386
|
+
import path44 from "path";
|
|
5930
6387
|
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
5931
6388
|
"GET",
|
|
5932
6389
|
"POST",
|
|
@@ -5991,12 +6448,12 @@ var pureFunctionExtractRule = {
|
|
|
5991
6448
|
},
|
|
5992
6449
|
create(context) {
|
|
5993
6450
|
const filename = context.filename;
|
|
5994
|
-
const isRouteFile =
|
|
6451
|
+
const isRouteFile = path44.basename(filename) === "route.ts";
|
|
5995
6452
|
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
5996
6453
|
const sourceRoot = sourceRootOf(context);
|
|
5997
|
-
const relative =
|
|
6454
|
+
const relative = path44.relative(sourceRoot, filename);
|
|
5998
6455
|
if (relative.startsWith("..")) return {};
|
|
5999
|
-
const segments = relative.split(
|
|
6456
|
+
const segments = relative.split(path44.sep);
|
|
6000
6457
|
const folders = segments.slice(0, -1);
|
|
6001
6458
|
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
6002
6459
|
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
@@ -6056,16 +6513,16 @@ var pureFunctionExtractRule = {
|
|
|
6056
6513
|
};
|
|
6057
6514
|
|
|
6058
6515
|
// eslint/rules/repeated-numeric-value.ts
|
|
6059
|
-
import
|
|
6516
|
+
import path45 from "path";
|
|
6060
6517
|
var ignoredValues = /* @__PURE__ */ new Set([-1, 0, 1]);
|
|
6061
6518
|
function isNonProductionFile(file, sourceRoot) {
|
|
6062
|
-
const relative =
|
|
6063
|
-
const segments = relative.split(
|
|
6064
|
-
const basename =
|
|
6519
|
+
const relative = path45.relative(sourceRoot, file);
|
|
6520
|
+
const segments = relative.split(path45.sep);
|
|
6521
|
+
const basename = path45.basename(file);
|
|
6065
6522
|
return /\.(?:test|spec|mock)\.[^.]+$/.test(basename) || segments.some((segment) => segment === "__tests__" || segment === "__mocks__" || segment === "mocks");
|
|
6066
6523
|
}
|
|
6067
6524
|
function isCanonicalConstantFile(file, sourceRoot) {
|
|
6068
|
-
const segments =
|
|
6525
|
+
const segments = path45.relative(sourceRoot, file).split(path45.sep);
|
|
6069
6526
|
return segments.includes("constants") || segments[0] === "config";
|
|
6070
6527
|
}
|
|
6071
6528
|
function groupKey(literal) {
|
|
@@ -6081,7 +6538,7 @@ var repeatedNumericValueRule = {
|
|
|
6081
6538
|
},
|
|
6082
6539
|
create(context) {
|
|
6083
6540
|
const sourceRoot = sourceRootOf(context);
|
|
6084
|
-
const file =
|
|
6541
|
+
const file = path45.resolve(context.filename);
|
|
6085
6542
|
if (isNonProductionFile(file, sourceRoot) || isCanonicalConstantFile(file, sourceRoot)) return {};
|
|
6086
6543
|
const index = getProjectIndex(sourceRoot);
|
|
6087
6544
|
if (!index) return {};
|
|
@@ -6301,7 +6758,7 @@ var repeatedStructureRule = {
|
|
|
6301
6758
|
|
|
6302
6759
|
// eslint/rules/require-barrel-star-exports.ts
|
|
6303
6760
|
import fs5 from "fs";
|
|
6304
|
-
import
|
|
6761
|
+
import path46 from "path";
|
|
6305
6762
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
6306
6763
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
6307
6764
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
@@ -6309,9 +6766,9 @@ function resolveSiblingModule(indexFile, specifier) {
|
|
|
6309
6766
|
if (!specifier.startsWith("./")) return void 0;
|
|
6310
6767
|
const relative = specifier.slice(2);
|
|
6311
6768
|
if (!relative || relative.includes("/")) return void 0;
|
|
6312
|
-
const directory =
|
|
6313
|
-
const direct =
|
|
6314
|
-
const candidates =
|
|
6769
|
+
const directory = path46.dirname(indexFile);
|
|
6770
|
+
const direct = path46.resolve(directory, relative);
|
|
6771
|
+
const candidates = path46.extname(direct) ? [direct] : MODULE_EXTENSIONS3.map((extension) => `${direct}${extension}`);
|
|
6315
6772
|
return candidates.find((candidate) => fs5.existsSync(candidate) && fs5.statSync(candidate).isFile());
|
|
6316
6773
|
}
|
|
6317
6774
|
var requireBarrelStarExportsRule = {
|
|
@@ -6324,9 +6781,9 @@ var requireBarrelStarExportsRule = {
|
|
|
6324
6781
|
fixable: "code"
|
|
6325
6782
|
},
|
|
6326
6783
|
create(context) {
|
|
6327
|
-
const filename =
|
|
6328
|
-
if (!INDEX_NAMES.has(
|
|
6329
|
-
if (!SUPPORT_FOLDERS3.has(
|
|
6784
|
+
const filename = path46.resolve(context.filename);
|
|
6785
|
+
if (!INDEX_NAMES.has(path46.basename(filename))) return {};
|
|
6786
|
+
if (!SUPPORT_FOLDERS3.has(path46.basename(path46.dirname(filename)))) return {};
|
|
6330
6787
|
return {
|
|
6331
6788
|
ExportNamedDeclaration(node) {
|
|
6332
6789
|
const sourceNode = node.source;
|
|
@@ -6379,7 +6836,7 @@ var requireBarrelStarExportsRule = {
|
|
|
6379
6836
|
};
|
|
6380
6837
|
|
|
6381
6838
|
// eslint/rules/root-support-placement.ts
|
|
6382
|
-
import
|
|
6839
|
+
import path47 from "path";
|
|
6383
6840
|
function isSupportFolder(value) {
|
|
6384
6841
|
return value === "utils" || value === "types" || value === "schemas" || value === "constants";
|
|
6385
6842
|
}
|
|
@@ -6412,7 +6869,7 @@ var rootSupportPlacementRule = {
|
|
|
6412
6869
|
},
|
|
6413
6870
|
create(context) {
|
|
6414
6871
|
const sourceRoot = sourceRootOf(context);
|
|
6415
|
-
const file =
|
|
6872
|
+
const file = path47.resolve(context.filename);
|
|
6416
6873
|
const segments = segmentsOf(file, sourceRoot);
|
|
6417
6874
|
const folderSegments = folderSegmentsOf(file, sourceRoot);
|
|
6418
6875
|
const supportFolder = folderSegments[folderSegments.length - 1];
|
|
@@ -6452,8 +6909,8 @@ var rootSupportPlacementRule = {
|
|
|
6452
6909
|
};
|
|
6453
6910
|
|
|
6454
6911
|
// eslint/rules/route-handler-shape.ts
|
|
6455
|
-
import
|
|
6456
|
-
import
|
|
6912
|
+
import path48 from "path";
|
|
6913
|
+
import ts8 from "typescript";
|
|
6457
6914
|
var HTTP_METHODS2 = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
6458
6915
|
var REQUIRED_BOUNDARY = "withResponse";
|
|
6459
6916
|
function isFunctionLike(node) {
|
|
@@ -6471,33 +6928,33 @@ function findHandler(node) {
|
|
|
6471
6928
|
return void 0;
|
|
6472
6929
|
}
|
|
6473
6930
|
function isLoop(node) {
|
|
6474
|
-
return
|
|
6931
|
+
return ts8.isForStatement(node) || ts8.isForOfStatement(node) || ts8.isForInStatement(node) || ts8.isWhileStatement(node) || ts8.isDoStatement(node);
|
|
6475
6932
|
}
|
|
6476
6933
|
function isFunctionBoundary(node) {
|
|
6477
|
-
return
|
|
6934
|
+
return ts8.isFunctionExpression(node) || ts8.isArrowFunction(node) || ts8.isFunctionDeclaration(node);
|
|
6478
6935
|
}
|
|
6479
6936
|
function analyzeHandlerBody(body, sourceText) {
|
|
6480
6937
|
const start = body.range?.[0] ?? 0;
|
|
6481
6938
|
const end = body.range?.[1] ?? sourceText.length;
|
|
6482
|
-
const sourceFile =
|
|
6939
|
+
const sourceFile = ts8.createSourceFile(
|
|
6483
6940
|
"route.ts",
|
|
6484
6941
|
sourceText.slice(start, end),
|
|
6485
|
-
|
|
6942
|
+
ts8.ScriptTarget.Latest,
|
|
6486
6943
|
true,
|
|
6487
|
-
|
|
6944
|
+
ts8.ScriptKind.TS
|
|
6488
6945
|
);
|
|
6489
6946
|
const kinds = /* @__PURE__ */ new Set();
|
|
6490
6947
|
const calledNames = /* @__PURE__ */ new Set();
|
|
6491
6948
|
const visit = (node) => {
|
|
6492
|
-
if (
|
|
6949
|
+
if (ts8.isTryStatement(node)) kinds.add("try");
|
|
6493
6950
|
if (isLoop(node)) kinds.add("loop");
|
|
6494
|
-
if (
|
|
6495
|
-
if (
|
|
6951
|
+
if (ts8.isIfStatement(node)) kinds.add("if");
|
|
6952
|
+
if (ts8.isCallExpression(node) && ts8.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map") {
|
|
6496
6953
|
kinds.add("map");
|
|
6497
6954
|
}
|
|
6498
|
-
if (
|
|
6955
|
+
if (ts8.isCallExpression(node) && ts8.isIdentifier(node.expression)) calledNames.add(node.expression.text);
|
|
6499
6956
|
if (isFunctionBoundary(node)) return;
|
|
6500
|
-
|
|
6957
|
+
ts8.forEachChild(node, visit);
|
|
6501
6958
|
};
|
|
6502
6959
|
visit(sourceFile);
|
|
6503
6960
|
return { kinds, calledNames };
|
|
@@ -6537,7 +6994,7 @@ var routeHandlerShapeRule = {
|
|
|
6537
6994
|
}
|
|
6538
6995
|
},
|
|
6539
6996
|
create(context) {
|
|
6540
|
-
if (
|
|
6997
|
+
if (path48.basename(context.filename) !== "route.ts") return {};
|
|
6541
6998
|
const sourceText = context.sourceCode.text;
|
|
6542
6999
|
function reportUnwrapped(node, name) {
|
|
6543
7000
|
context.report({
|
|
@@ -6596,7 +7053,7 @@ var routeHandlerShapeRule = {
|
|
|
6596
7053
|
};
|
|
6597
7054
|
|
|
6598
7055
|
// eslint/rules/schema-casing.ts
|
|
6599
|
-
import
|
|
7056
|
+
import path49 from "path";
|
|
6600
7057
|
function isCamelCase(name) {
|
|
6601
7058
|
return /^[a-z][a-zA-Z0-9]*$/.test(name);
|
|
6602
7059
|
}
|
|
@@ -6624,9 +7081,9 @@ var schemaCasingRule = {
|
|
|
6624
7081
|
}
|
|
6625
7082
|
},
|
|
6626
7083
|
create(context) {
|
|
6627
|
-
const filename =
|
|
7084
|
+
const filename = path49.resolve(context.filename);
|
|
6628
7085
|
const sourceRoot = sourceRootOf(context);
|
|
6629
|
-
if (!filename.startsWith(sourceRoot +
|
|
7086
|
+
if (!filename.startsWith(sourceRoot + path49.sep)) return {};
|
|
6630
7087
|
let zodLocalName;
|
|
6631
7088
|
return {
|
|
6632
7089
|
ImportDeclaration(node) {
|
|
@@ -6658,39 +7115,39 @@ var schemaCasingRule = {
|
|
|
6658
7115
|
};
|
|
6659
7116
|
|
|
6660
7117
|
// eslint/rules/sole-state-owner.ts
|
|
6661
|
-
import
|
|
6662
|
-
import
|
|
7118
|
+
import path50 from "path";
|
|
7119
|
+
import ts9 from "typescript";
|
|
6663
7120
|
function findStateHooks(node) {
|
|
6664
7121
|
const hooks = [];
|
|
6665
7122
|
const visit = (child) => {
|
|
6666
|
-
if (
|
|
6667
|
-
if (
|
|
7123
|
+
if (ts9.isCallExpression(child) && ts9.isIdentifier(child.expression) && child.expression.text === "useState") {
|
|
7124
|
+
if (ts9.isVariableDeclaration(child.parent)) {
|
|
6668
7125
|
const { name } = child.parent;
|
|
6669
|
-
if (
|
|
7126
|
+
if (ts9.isArrayBindingPattern(name) && name.elements.length >= 2) {
|
|
6670
7127
|
const value = name.elements[0];
|
|
6671
7128
|
const updater = name.elements[1];
|
|
6672
|
-
if (value && updater &&
|
|
7129
|
+
if (value && updater && ts9.isBindingElement(value) && ts9.isBindingElement(updater)) {
|
|
6673
7130
|
const valueName = value.name;
|
|
6674
7131
|
const updaterName = updater.name;
|
|
6675
|
-
if (
|
|
7132
|
+
if (ts9.isIdentifier(valueName) && ts9.isIdentifier(updaterName)) {
|
|
6676
7133
|
hooks.push({ value: valueName.text, updater: updaterName.text });
|
|
6677
7134
|
}
|
|
6678
7135
|
}
|
|
6679
7136
|
}
|
|
6680
7137
|
}
|
|
6681
7138
|
}
|
|
6682
|
-
|
|
7139
|
+
ts9.forEachChild(child, visit);
|
|
6683
7140
|
};
|
|
6684
7141
|
visit(node);
|
|
6685
7142
|
return hooks;
|
|
6686
7143
|
}
|
|
6687
7144
|
function isHookUsage(node, hook) {
|
|
6688
|
-
if (
|
|
7145
|
+
if (ts9.isCallExpression(node) && ts9.isIdentifier(node.expression) && node.expression.text === hook.updater) {
|
|
6689
7146
|
return "updater";
|
|
6690
7147
|
}
|
|
6691
|
-
if (
|
|
7148
|
+
if (ts9.isIdentifier(node) && node.text === hook.value) {
|
|
6692
7149
|
const parent = node.parent;
|
|
6693
|
-
if (
|
|
7150
|
+
if (ts9.isBindingElement(parent) || ts9.isPropertyAccessExpression(parent) || ts9.isShorthandPropertyAssignment(parent)) {
|
|
6694
7151
|
return void 0;
|
|
6695
7152
|
}
|
|
6696
7153
|
return "value";
|
|
@@ -6700,16 +7157,16 @@ function isHookUsage(node, hook) {
|
|
|
6700
7157
|
function topLevelJsxChildren(initial) {
|
|
6701
7158
|
if (!initial) return void 0;
|
|
6702
7159
|
let expression = initial;
|
|
6703
|
-
while (
|
|
6704
|
-
if (
|
|
7160
|
+
while (ts9.isParenthesizedExpression(expression)) expression = expression.expression;
|
|
7161
|
+
if (ts9.isJsxFragment(expression)) {
|
|
6705
7162
|
const children = expression.children.filter(
|
|
6706
|
-
(c) => !
|
|
7163
|
+
(c) => !ts9.isJsxText(c) && !ts9.isJsxSpreadAttribute(c)
|
|
6707
7164
|
);
|
|
6708
7165
|
return { root: expression, children };
|
|
6709
7166
|
}
|
|
6710
|
-
if (
|
|
7167
|
+
if (ts9.isJsxElement(expression)) {
|
|
6711
7168
|
const children = expression.children.filter(
|
|
6712
|
-
(c) => !
|
|
7169
|
+
(c) => !ts9.isJsxText(c) && !ts9.isJsxSpreadAttribute(c)
|
|
6713
7170
|
);
|
|
6714
7171
|
return { root: expression, children };
|
|
6715
7172
|
}
|
|
@@ -6723,8 +7180,8 @@ function collectUsesIn(child, hook) {
|
|
|
6723
7180
|
positions.push(node);
|
|
6724
7181
|
count += 1;
|
|
6725
7182
|
}
|
|
6726
|
-
if (
|
|
6727
|
-
|
|
7183
|
+
if (ts9.isFunctionDeclaration(node) || ts9.isClassDeclaration(node)) return;
|
|
7184
|
+
ts9.forEachChild(node, visit);
|
|
6728
7185
|
};
|
|
6729
7186
|
visit(child);
|
|
6730
7187
|
return { positions, count };
|
|
@@ -6738,7 +7195,7 @@ var soleStateOwnerRule = {
|
|
|
6738
7195
|
}
|
|
6739
7196
|
},
|
|
6740
7197
|
create(context) {
|
|
6741
|
-
const filename =
|
|
7198
|
+
const filename = path50.resolve(context.filename);
|
|
6742
7199
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
6743
7200
|
const text = context.sourceCode.text;
|
|
6744
7201
|
const components = parseComponentInfo(text, filename);
|
|
@@ -6763,18 +7220,18 @@ var soleStateOwnerRule = {
|
|
|
6763
7220
|
}
|
|
6764
7221
|
};
|
|
6765
7222
|
function analyzeSoleOwner(declaration, hook) {
|
|
6766
|
-
const body =
|
|
6767
|
-
if (!body || !
|
|
7223
|
+
const body = ts9.isFunctionDeclaration(declaration) ? declaration.body : void 0;
|
|
7224
|
+
if (!body || !ts9.isBlock(body)) return void 0;
|
|
6768
7225
|
const returns = [];
|
|
6769
7226
|
const visit = (node) => {
|
|
6770
|
-
if (node !== body && (
|
|
6771
|
-
if (
|
|
6772
|
-
|
|
7227
|
+
if (node !== body && (ts9.isFunctionLike(node) || ts9.isClassLike(node))) return;
|
|
7228
|
+
if (ts9.isReturnStatement(node)) returns.push(node);
|
|
7229
|
+
ts9.forEachChild(node, visit);
|
|
6773
7230
|
};
|
|
6774
7231
|
visit(body);
|
|
6775
7232
|
if (returns.length !== 1) return void 0;
|
|
6776
7233
|
const single = returns[0];
|
|
6777
|
-
if (!single?.expression || !
|
|
7234
|
+
if (!single?.expression || !ts9.isExpression(single.expression)) return void 0;
|
|
6778
7235
|
const returnExpression = single.expression;
|
|
6779
7236
|
const root = topLevelJsxChildren(returnExpression);
|
|
6780
7237
|
if (!root || root.children.length === 0) return void 0;
|
|
@@ -6797,11 +7254,11 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
6797
7254
|
let outside = false;
|
|
6798
7255
|
const visit = (node) => {
|
|
6799
7256
|
if (outside) return;
|
|
6800
|
-
if (node !== declaration && (
|
|
7257
|
+
if (node !== declaration && (ts9.isFunctionDeclaration(node) || ts9.isClassDeclaration(node))) return;
|
|
6801
7258
|
if (isHookUsage(node, hook)) {
|
|
6802
7259
|
let current = node;
|
|
6803
7260
|
let isInJsxChild = false;
|
|
6804
|
-
while (!
|
|
7261
|
+
while (!ts9.isSourceFile(current)) {
|
|
6805
7262
|
if (children.includes(current)) {
|
|
6806
7263
|
isInJsxChild = true;
|
|
6807
7264
|
break;
|
|
@@ -6810,14 +7267,14 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
6810
7267
|
}
|
|
6811
7268
|
if (!isInJsxChild) outside = true;
|
|
6812
7269
|
}
|
|
6813
|
-
|
|
7270
|
+
ts9.forEachChild(node, visit);
|
|
6814
7271
|
};
|
|
6815
7272
|
visit(declaration);
|
|
6816
7273
|
return outside;
|
|
6817
7274
|
}
|
|
6818
7275
|
|
|
6819
7276
|
// eslint/rules/source-under-src.ts
|
|
6820
|
-
import
|
|
7277
|
+
import path51 from "path";
|
|
6821
7278
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
6822
7279
|
".agents",
|
|
6823
7280
|
".cache",
|
|
@@ -6858,14 +7315,14 @@ var sourceUnderSrcRule = {
|
|
|
6858
7315
|
}
|
|
6859
7316
|
},
|
|
6860
7317
|
create(context) {
|
|
6861
|
-
const filename =
|
|
7318
|
+
const filename = path51.resolve(context.filename);
|
|
6862
7319
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
6863
|
-
const relative =
|
|
7320
|
+
const relative = path51.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
6864
7321
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
6865
7322
|
const topLevel = relative.split("/")[0] ?? "";
|
|
6866
7323
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
6867
7324
|
if (!relative.includes("/")) {
|
|
6868
|
-
const basename =
|
|
7325
|
+
const basename = path51.basename(filename);
|
|
6869
7326
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
6870
7327
|
}
|
|
6871
7328
|
return {
|
|
@@ -6881,7 +7338,7 @@ var sourceUnderSrcRule = {
|
|
|
6881
7338
|
};
|
|
6882
7339
|
|
|
6883
7340
|
// eslint/rules/stay-flat.ts
|
|
6884
|
-
import
|
|
7341
|
+
import path52 from "path";
|
|
6885
7342
|
var stayFlatRule = {
|
|
6886
7343
|
meta: {
|
|
6887
7344
|
schema: [],
|
|
@@ -6892,7 +7349,7 @@ var stayFlatRule = {
|
|
|
6892
7349
|
},
|
|
6893
7350
|
create(context) {
|
|
6894
7351
|
const sourceRoot = sourceRootOf(context);
|
|
6895
|
-
const file =
|
|
7352
|
+
const file = path52.resolve(context.filename);
|
|
6896
7353
|
const segments = segmentsOf(file, sourceRoot);
|
|
6897
7354
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
6898
7355
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -6932,7 +7389,7 @@ var stayFlatRule = {
|
|
|
6932
7389
|
};
|
|
6933
7390
|
|
|
6934
7391
|
// eslint/rules/support-file-placement.ts
|
|
6935
|
-
import
|
|
7392
|
+
import path53 from "path";
|
|
6936
7393
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
6937
7394
|
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
6938
7395
|
["constants", "constant"],
|
|
@@ -6957,7 +7414,7 @@ var supportFilePlacementRule = {
|
|
|
6957
7414
|
},
|
|
6958
7415
|
create(context) {
|
|
6959
7416
|
const sourceRoot = sourceRootOf(context);
|
|
6960
|
-
const supportFile =
|
|
7417
|
+
const supportFile = path53.resolve(context.filename);
|
|
6961
7418
|
const currentFolder = folderSegmentsOf(supportFile, sourceRoot);
|
|
6962
7419
|
const supportFolder = currentFolder[currentFolder.length - 1];
|
|
6963
7420
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS.has(supportFolder)) return {};
|
|
@@ -7011,7 +7468,7 @@ var supportFilePlacementRule = {
|
|
|
7011
7468
|
|
|
7012
7469
|
// eslint/rules/support-folder-shape.ts
|
|
7013
7470
|
import fs6 from "fs";
|
|
7014
|
-
import
|
|
7471
|
+
import path54 from "path";
|
|
7015
7472
|
var SUPPORT_FOLDERS4 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
7016
7473
|
var INDEX_NAMES2 = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
7017
7474
|
var supportFolderShapeRule = {
|
|
@@ -7023,12 +7480,12 @@ var supportFolderShapeRule = {
|
|
|
7023
7480
|
}
|
|
7024
7481
|
},
|
|
7025
7482
|
create(context) {
|
|
7026
|
-
const filename =
|
|
7027
|
-
const baseName =
|
|
7483
|
+
const filename = path54.resolve(context.filename);
|
|
7484
|
+
const baseName = path54.basename(filename);
|
|
7028
7485
|
if (!INDEX_NAMES2.has(baseName)) return {};
|
|
7029
|
-
const folder =
|
|
7486
|
+
const folder = path54.basename(path54.dirname(filename));
|
|
7030
7487
|
if (!SUPPORT_FOLDERS4.has(folder)) return {};
|
|
7031
|
-
const directory =
|
|
7488
|
+
const directory = path54.dirname(filename);
|
|
7032
7489
|
let entries;
|
|
7033
7490
|
try {
|
|
7034
7491
|
entries = fs6.readdirSync(directory);
|
|
@@ -7046,7 +7503,7 @@ var supportFolderShapeRule = {
|
|
|
7046
7503
|
for (const match of source.matchAll(exportPattern)) {
|
|
7047
7504
|
hasAnyReExport = true;
|
|
7048
7505
|
const specifier = match.groups?.specifier;
|
|
7049
|
-
if (specifier?.startsWith(".")) exportedFiles.add(
|
|
7506
|
+
if (specifier?.startsWith(".")) exportedFiles.add(path54.basename(specifier));
|
|
7050
7507
|
}
|
|
7051
7508
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
7052
7509
|
if (siblingModules.length === 0) {
|
|
@@ -7225,11 +7682,11 @@ var baseLayerPairRule = {
|
|
|
7225
7682
|
|
|
7226
7683
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
7227
7684
|
import { statSync as statSync4 } from "fs";
|
|
7228
|
-
import
|
|
7685
|
+
import path57 from "path";
|
|
7229
7686
|
|
|
7230
7687
|
// eslint/rules/tailwind/source-files.ts
|
|
7231
7688
|
import { readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
|
|
7232
|
-
import
|
|
7689
|
+
import path55 from "path";
|
|
7233
7690
|
var CSS_EXTENSIONS = [".css"];
|
|
7234
7691
|
var MODULE_EXTENSIONS4 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
7235
7692
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS4, ...CSS_EXTENSIONS];
|
|
@@ -7242,7 +7699,7 @@ function findFiles(dir, extensions) {
|
|
|
7242
7699
|
}
|
|
7243
7700
|
return entries.flatMap((entry) => {
|
|
7244
7701
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
7245
|
-
const entryPath =
|
|
7702
|
+
const entryPath = path55.join(dir, entry);
|
|
7246
7703
|
let stats;
|
|
7247
7704
|
try {
|
|
7248
7705
|
stats = statSync3(entryPath);
|
|
@@ -7250,7 +7707,7 @@ function findFiles(dir, extensions) {
|
|
|
7250
7707
|
return [];
|
|
7251
7708
|
}
|
|
7252
7709
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
7253
|
-
return extensions.includes(
|
|
7710
|
+
return extensions.includes(path55.extname(entry)) ? [entryPath] : [];
|
|
7254
7711
|
});
|
|
7255
7712
|
}
|
|
7256
7713
|
function cachedTextReader() {
|
|
@@ -7273,7 +7730,7 @@ function escapeRegExp(text) {
|
|
|
7273
7730
|
}
|
|
7274
7731
|
|
|
7275
7732
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
7276
|
-
import
|
|
7733
|
+
import path56 from "path";
|
|
7277
7734
|
function registersTailwind(text) {
|
|
7278
7735
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
7279
7736
|
}
|
|
@@ -7287,25 +7744,25 @@ function moduleImports(text, fileName) {
|
|
|
7287
7744
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
7288
7745
|
}
|
|
7289
7746
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
7290
|
-
if (spec.startsWith("/")) return
|
|
7291
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
7292
|
-
if (spec.startsWith("@/")) return
|
|
7747
|
+
if (spec.startsWith("/")) return path56.resolve(spec);
|
|
7748
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path56.resolve(path56.dirname(fromFile), spec);
|
|
7749
|
+
if (spec.startsWith("@/")) return path56.resolve(sourceRoot, spec.slice(2));
|
|
7293
7750
|
return void 0;
|
|
7294
7751
|
}
|
|
7295
7752
|
function buildStylesheetGraph(options) {
|
|
7296
7753
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
7297
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
7754
|
+
const cssSet = new Set(cssFiles.map((file) => path56.normalize(file)));
|
|
7298
7755
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
7299
7756
|
const reachable = /* @__PURE__ */ new Set();
|
|
7300
7757
|
const queue = [...globals];
|
|
7301
|
-
for (const global of globals) reachable.add(
|
|
7758
|
+
for (const global of globals) reachable.add(path56.normalize(global));
|
|
7302
7759
|
while (queue.length > 0) {
|
|
7303
7760
|
const from = queue.shift();
|
|
7304
7761
|
if (!from) continue;
|
|
7305
7762
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
7306
7763
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
7307
7764
|
if (!target) continue;
|
|
7308
|
-
const normalized =
|
|
7765
|
+
const normalized = path56.normalize(target);
|
|
7309
7766
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
7310
7767
|
reachable.add(normalized);
|
|
7311
7768
|
queue.push(normalized);
|
|
@@ -7317,7 +7774,7 @@ function buildStylesheetGraph(options) {
|
|
|
7317
7774
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
7318
7775
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
7319
7776
|
if (!target) continue;
|
|
7320
|
-
const normalized =
|
|
7777
|
+
const normalized = path56.normalize(target);
|
|
7321
7778
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
7322
7779
|
}
|
|
7323
7780
|
}
|
|
@@ -7325,8 +7782,8 @@ function buildStylesheetGraph(options) {
|
|
|
7325
7782
|
}
|
|
7326
7783
|
|
|
7327
7784
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
7328
|
-
var APP_STYLES_DIR =
|
|
7329
|
-
var GLOBAL_STYLESHEET_PATH =
|
|
7785
|
+
var APP_STYLES_DIR = path57.join("app", "styles");
|
|
7786
|
+
var GLOBAL_STYLESHEET_PATH = path57.join(APP_STYLES_DIR, "globals.css");
|
|
7330
7787
|
var cssEntryPointRule = {
|
|
7331
7788
|
meta: {
|
|
7332
7789
|
schema: [],
|
|
@@ -7352,8 +7809,8 @@ var cssEntryPointRule = {
|
|
|
7352
7809
|
return {
|
|
7353
7810
|
"StyleSheet:exit"(node) {
|
|
7354
7811
|
if (globals.length === 0) return;
|
|
7355
|
-
const current =
|
|
7356
|
-
const relative =
|
|
7812
|
+
const current = path57.normalize(path57.resolve(context.filename));
|
|
7813
|
+
const relative = path57.relative(sourceRoot, current);
|
|
7357
7814
|
if (globals.includes(current)) {
|
|
7358
7815
|
if (globals.length > 1) {
|
|
7359
7816
|
context.report({
|
|
@@ -7369,7 +7826,7 @@ var cssEntryPointRule = {
|
|
|
7369
7826
|
});
|
|
7370
7827
|
return;
|
|
7371
7828
|
}
|
|
7372
|
-
const basename =
|
|
7829
|
+
const basename = path57.basename(current);
|
|
7373
7830
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
7374
7831
|
if (importCount !== 1) {
|
|
7375
7832
|
context.report({
|
|
@@ -7379,7 +7836,7 @@ var cssEntryPointRule = {
|
|
|
7379
7836
|
}
|
|
7380
7837
|
return;
|
|
7381
7838
|
}
|
|
7382
|
-
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${
|
|
7839
|
+
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${path57.sep}`);
|
|
7383
7840
|
if (!isInAppStyles) {
|
|
7384
7841
|
context.report({
|
|
7385
7842
|
node,
|
|
@@ -7868,7 +8325,7 @@ var tailwindRules = {
|
|
|
7868
8325
|
};
|
|
7869
8326
|
|
|
7870
8327
|
// eslint/rules/type-extraction.ts
|
|
7871
|
-
import
|
|
8328
|
+
import path58 from "path";
|
|
7872
8329
|
var typeExtractionRule = {
|
|
7873
8330
|
meta: {
|
|
7874
8331
|
schema: [],
|
|
@@ -7879,7 +8336,7 @@ var typeExtractionRule = {
|
|
|
7879
8336
|
},
|
|
7880
8337
|
create(context) {
|
|
7881
8338
|
const sourceRoot = sourceRootOf(context);
|
|
7882
|
-
const file =
|
|
8339
|
+
const file = path58.resolve(context.filename);
|
|
7883
8340
|
const segments = segmentsOf(file, sourceRoot);
|
|
7884
8341
|
if (segments.length === 0) return {};
|
|
7885
8342
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -8020,7 +8477,7 @@ var uiStateRule = {
|
|
|
8020
8477
|
// eslint/rules/unknown-utility.ts
|
|
8021
8478
|
import { existsSync as existsSync6, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
|
|
8022
8479
|
import { createRequire } from "module";
|
|
8023
|
-
import
|
|
8480
|
+
import path59 from "path";
|
|
8024
8481
|
var PREFIX_NAMESPACES = {
|
|
8025
8482
|
bg: ["color"],
|
|
8026
8483
|
text: ["color", "text"],
|
|
@@ -8260,7 +8717,7 @@ function stylesheetFiles(dir) {
|
|
|
8260
8717
|
}
|
|
8261
8718
|
return entries.flatMap((entry) => {
|
|
8262
8719
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
8263
|
-
const entryPath =
|
|
8720
|
+
const entryPath = path59.join(dir, entry);
|
|
8264
8721
|
let stats;
|
|
8265
8722
|
try {
|
|
8266
8723
|
stats = statSync6(entryPath);
|
|
@@ -8268,7 +8725,7 @@ function stylesheetFiles(dir) {
|
|
|
8268
8725
|
return [];
|
|
8269
8726
|
}
|
|
8270
8727
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
8271
|
-
return
|
|
8728
|
+
return path59.extname(entry) === ".css" ? [entryPath] : [];
|
|
8272
8729
|
});
|
|
8273
8730
|
}
|
|
8274
8731
|
function packageNameOf(specifier) {
|
|
@@ -8279,10 +8736,10 @@ function packageNameOf(specifier) {
|
|
|
8279
8736
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
8280
8737
|
const packageName = packageNameOf(specifier);
|
|
8281
8738
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
8282
|
-
let directory =
|
|
8283
|
-
while (directory !==
|
|
8284
|
-
const packageRoot =
|
|
8285
|
-
const manifestPath =
|
|
8739
|
+
let directory = path59.dirname(fromFile);
|
|
8740
|
+
while (directory !== path59.dirname(directory)) {
|
|
8741
|
+
const packageRoot = path59.join(directory, "node_modules", packageName);
|
|
8742
|
+
const manifestPath = path59.join(packageRoot, "package.json");
|
|
8286
8743
|
if (existsSync6(manifestPath)) {
|
|
8287
8744
|
try {
|
|
8288
8745
|
const manifest = readFileSync10(manifestPath, "utf8");
|
|
@@ -8290,13 +8747,13 @@ function resolvePackageStylesheet(fromFile, specifier) {
|
|
|
8290
8747
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
8291
8748
|
const target = stylesheet ?? main;
|
|
8292
8749
|
if (!target) return void 0;
|
|
8293
|
-
const resolved =
|
|
8750
|
+
const resolved = path59.resolve(packageRoot, target);
|
|
8294
8751
|
return existsSync6(resolved) ? resolved : void 0;
|
|
8295
8752
|
} catch {
|
|
8296
8753
|
return void 0;
|
|
8297
8754
|
}
|
|
8298
8755
|
}
|
|
8299
|
-
directory =
|
|
8756
|
+
directory = path59.dirname(directory);
|
|
8300
8757
|
}
|
|
8301
8758
|
return void 0;
|
|
8302
8759
|
}
|
|
@@ -8547,7 +9004,7 @@ var unknownUtilityRule = {
|
|
|
8547
9004
|
};
|
|
8548
9005
|
|
|
8549
9006
|
// eslint/rules/util-file-name.ts
|
|
8550
|
-
import
|
|
9007
|
+
import path60 from "path";
|
|
8551
9008
|
function toKebabCase2(value) {
|
|
8552
9009
|
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
9010
|
}
|
|
@@ -8560,7 +9017,7 @@ var utilFileNameRule = {
|
|
|
8560
9017
|
}
|
|
8561
9018
|
},
|
|
8562
9019
|
create(context) {
|
|
8563
|
-
const filename =
|
|
9020
|
+
const filename = path60.resolve(context.filename);
|
|
8564
9021
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
8565
9022
|
if (!segments.includes("utils")) return {};
|
|
8566
9023
|
let module;
|
|
@@ -8574,13 +9031,13 @@ var utilFileNameRule = {
|
|
|
8574
9031
|
const functionName = functions[0]?.name;
|
|
8575
9032
|
if (!functionName) return {};
|
|
8576
9033
|
const expected = toKebabCase2(functionName);
|
|
8577
|
-
const actual =
|
|
9034
|
+
const actual = path60.basename(filename, path60.extname(filename));
|
|
8578
9035
|
if (!expected || actual === expected) return {};
|
|
8579
9036
|
return {
|
|
8580
9037
|
Program(node) {
|
|
8581
9038
|
context.report({
|
|
8582
9039
|
node,
|
|
8583
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
9040
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path60.extname(filename).slice(1)}.`
|
|
8584
9041
|
});
|
|
8585
9042
|
}
|
|
8586
9043
|
};
|
|
@@ -8588,7 +9045,7 @@ var utilFileNameRule = {
|
|
|
8588
9045
|
};
|
|
8589
9046
|
|
|
8590
9047
|
// eslint/rules/value-extraction.ts
|
|
8591
|
-
import
|
|
9048
|
+
import path61 from "path";
|
|
8592
9049
|
var valueExtractionRule = {
|
|
8593
9050
|
meta: {
|
|
8594
9051
|
schema: [],
|
|
@@ -8599,7 +9056,7 @@ var valueExtractionRule = {
|
|
|
8599
9056
|
},
|
|
8600
9057
|
create(context) {
|
|
8601
9058
|
const sourceRoot = sourceRootOf(context);
|
|
8602
|
-
const file =
|
|
9059
|
+
const file = path61.resolve(context.filename);
|
|
8603
9060
|
const segments = segmentsOf(file, sourceRoot);
|
|
8604
9061
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
8605
9062
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -8621,7 +9078,7 @@ var valueExtractionRule = {
|
|
|
8621
9078
|
|
|
8622
9079
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
8623
9080
|
import { existsSync as existsSync7, readFileSync as readFileSync11 } from "fs";
|
|
8624
|
-
import
|
|
9081
|
+
import path62 from "path";
|
|
8625
9082
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
8626
9083
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
8627
9084
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -8654,8 +9111,8 @@ var trackedDocsRule = {
|
|
|
8654
9111
|
if (!context.filename.endsWith("package.json")) return;
|
|
8655
9112
|
const root = node.body;
|
|
8656
9113
|
if (root.type !== "Object") return;
|
|
8657
|
-
const projectRoot =
|
|
8658
|
-
const configPath =
|
|
9114
|
+
const projectRoot = path62.dirname(path62.resolve(context.filename));
|
|
9115
|
+
const configPath = path62.join(projectRoot, "vulyk.config.ts");
|
|
8659
9116
|
if (!existsSync7(configPath)) {
|
|
8660
9117
|
context.report({
|
|
8661
9118
|
node,
|
|
@@ -8680,7 +9137,7 @@ var trackedDocsRule = {
|
|
|
8680
9137
|
});
|
|
8681
9138
|
}
|
|
8682
9139
|
}
|
|
8683
|
-
const agentsPath =
|
|
9140
|
+
const agentsPath = path62.join(projectRoot, "AGENTS.md");
|
|
8684
9141
|
if (!existsSync7(agentsPath)) {
|
|
8685
9142
|
context.report({
|
|
8686
9143
|
node,
|
|
@@ -8780,7 +9237,7 @@ var withResponseHelperRule = {
|
|
|
8780
9237
|
|
|
8781
9238
|
// eslint/rules/zirka-baseline.ts
|
|
8782
9239
|
import fs7 from "fs";
|
|
8783
|
-
import
|
|
9240
|
+
import path63 from "path";
|
|
8784
9241
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
8785
9242
|
var PRETTIER_CONFIGS = [
|
|
8786
9243
|
"prettier.config.mjs",
|
|
@@ -8799,10 +9256,10 @@ var zirkaBaselineRule = {
|
|
|
8799
9256
|
}
|
|
8800
9257
|
},
|
|
8801
9258
|
create(context) {
|
|
8802
|
-
const filename =
|
|
8803
|
-
const basename =
|
|
9259
|
+
const filename = path63.resolve(context.filename);
|
|
9260
|
+
const basename = path63.basename(filename);
|
|
8804
9261
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
8805
|
-
const projectRoot =
|
|
9262
|
+
const projectRoot = path63.dirname(filename);
|
|
8806
9263
|
const report3 = (message) => {
|
|
8807
9264
|
context.report({
|
|
8808
9265
|
node: context.sourceCode.ast,
|
|
@@ -8817,7 +9274,7 @@ var zirkaBaselineRule = {
|
|
|
8817
9274
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
8818
9275
|
);
|
|
8819
9276
|
}
|
|
8820
|
-
const tsconfigPath =
|
|
9277
|
+
const tsconfigPath = path63.join(projectRoot, "tsconfig.json");
|
|
8821
9278
|
if (!fs7.existsSync(tsconfigPath)) {
|
|
8822
9279
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
8823
9280
|
} else {
|
|
@@ -8835,13 +9292,13 @@ var zirkaBaselineRule = {
|
|
|
8835
9292
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
8836
9293
|
}
|
|
8837
9294
|
}
|
|
8838
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(
|
|
9295
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(path63.join(projectRoot, name)));
|
|
8839
9296
|
if (!prettierConfigFile) {
|
|
8840
9297
|
report3(
|
|
8841
9298
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
8842
9299
|
);
|
|
8843
9300
|
} else {
|
|
8844
|
-
const content = fs7.readFileSync(
|
|
9301
|
+
const content = fs7.readFileSync(path63.join(projectRoot, prettierConfigFile), "utf8");
|
|
8845
9302
|
if (!content.includes("zirka")) {
|
|
8846
9303
|
report3(
|
|
8847
9304
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|
|
@@ -9146,6 +9603,18 @@ var pasikaNextjsAppConfig = {
|
|
|
9146
9603
|
},
|
|
9147
9604
|
rules: Object.fromEntries(pasikaNextjsAppRuleIds.map((id) => [id, "error"]))
|
|
9148
9605
|
};
|
|
9606
|
+
var pasikaTypedProjectServiceConfig = {
|
|
9607
|
+
files: ["src/**/*.{cts,mts,ts,tsx}"],
|
|
9608
|
+
languageOptions: {
|
|
9609
|
+
parser: tsParser,
|
|
9610
|
+
parserOptions: {
|
|
9611
|
+
ecmaVersion: "latest",
|
|
9612
|
+
sourceType: "module",
|
|
9613
|
+
ecmaFeatures: { jsx: true },
|
|
9614
|
+
projectService: true
|
|
9615
|
+
}
|
|
9616
|
+
}
|
|
9617
|
+
};
|
|
9149
9618
|
var tailwindStructureRules = {
|
|
9150
9619
|
files: ["src/app/styles/globals.css"],
|
|
9151
9620
|
plugins: {
|
|
@@ -9215,6 +9684,7 @@ var pasikaNextjsApp = pasikaNextjsAppWithDiagnostic([
|
|
|
9215
9684
|
...pasikaApp,
|
|
9216
9685
|
pasikaNextjsAppPackageJsonConfig,
|
|
9217
9686
|
pasikaNextjsAppConfig,
|
|
9687
|
+
pasikaTypedProjectServiceConfig,
|
|
9218
9688
|
tailwindStructureRules,
|
|
9219
9689
|
tailwindImportGraph
|
|
9220
9690
|
]);
|