pasika 0.10.97 → 0.10.99
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.d.ts +1 -0
- package/dist/eslint/pasika/index.js +525 -408
- package/package.json +1 -1
|
@@ -5100,6 +5100,308 @@ var noArbitraryTailwindRule = {
|
|
|
5100
5100
|
}
|
|
5101
5101
|
};
|
|
5102
5102
|
|
|
5103
|
+
// eslint/rules/no-inline-runtime-literal.ts
|
|
5104
|
+
import path40 from "path";
|
|
5105
|
+
|
|
5106
|
+
// eslint/project/semantic-literals.ts
|
|
5107
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
5108
|
+
import path39 from "path";
|
|
5109
|
+
import ts7 from "typescript";
|
|
5110
|
+
var excludedProperties = /* @__PURE__ */ new Set([
|
|
5111
|
+
"label",
|
|
5112
|
+
"title",
|
|
5113
|
+
"description",
|
|
5114
|
+
"message",
|
|
5115
|
+
"text",
|
|
5116
|
+
"placeholder",
|
|
5117
|
+
"className",
|
|
5118
|
+
"content",
|
|
5119
|
+
"alt",
|
|
5120
|
+
"src",
|
|
5121
|
+
"href",
|
|
5122
|
+
"url",
|
|
5123
|
+
"html",
|
|
5124
|
+
"ariaLabel",
|
|
5125
|
+
"testId"
|
|
5126
|
+
]);
|
|
5127
|
+
var semanticProperties = /* @__PURE__ */ new Set(["status", "phase", "event", "eventName", "action", "storageKey", "endpoint"]);
|
|
5128
|
+
var semanticVariableName = /route|path|key|status|event|timeout|delay|token|column|endpoint|limit|duration/i;
|
|
5129
|
+
var columnMethods = /* @__PURE__ */ new Set([
|
|
5130
|
+
"eq",
|
|
5131
|
+
"neq",
|
|
5132
|
+
"gt",
|
|
5133
|
+
"gte",
|
|
5134
|
+
"lt",
|
|
5135
|
+
"lte",
|
|
5136
|
+
"like",
|
|
5137
|
+
"ilike",
|
|
5138
|
+
"is",
|
|
5139
|
+
"in",
|
|
5140
|
+
"order",
|
|
5141
|
+
"filter",
|
|
5142
|
+
"not"
|
|
5143
|
+
]);
|
|
5144
|
+
var eventMethods = /* @__PURE__ */ new Set(["emit", "on", "off", "once", "addListener", "removeListener"]);
|
|
5145
|
+
var ignoredNumbers = /* @__PURE__ */ new Set([-1, 0, 1]);
|
|
5146
|
+
function isProductionSource(file, root) {
|
|
5147
|
+
const parts = path39.relative(root, file).split(path39.sep);
|
|
5148
|
+
return !(/\.(?:test|spec|mock)\.[^.]+$/.test(path39.basename(file)) || parts.some((part) => part === "__tests__" || part === "__mocks__" || part === "mocks"));
|
|
5149
|
+
}
|
|
5150
|
+
function featureOf(file, root) {
|
|
5151
|
+
const parts = path39.relative(root, file).split(path39.sep);
|
|
5152
|
+
if (parts[0] === "features" && parts[1]) return `feature:${parts[1]}`;
|
|
5153
|
+
return `layer:${parts[0] ?? "src"}`;
|
|
5154
|
+
}
|
|
5155
|
+
function nameOf(property) {
|
|
5156
|
+
if (ts7.isIdentifier(property) || ts7.isStringLiteral(property)) return property.text;
|
|
5157
|
+
return void 0;
|
|
5158
|
+
}
|
|
5159
|
+
function literalOf(node) {
|
|
5160
|
+
if (ts7.isStringLiteral(node)) return node.text;
|
|
5161
|
+
if (ts7.isNumericLiteral(node)) return Number(node.text.replaceAll("_", ""));
|
|
5162
|
+
if (ts7.isPrefixUnaryExpression(node) && node.operator === ts7.SyntaxKind.MinusToken && ts7.isNumericLiteral(node.operand)) {
|
|
5163
|
+
return -Number(node.operand.text.replaceAll("_", ""));
|
|
5164
|
+
}
|
|
5165
|
+
return void 0;
|
|
5166
|
+
}
|
|
5167
|
+
function isLiteralRoot(node) {
|
|
5168
|
+
if (ts7.isPrefixUnaryExpression(node)) return literalOf(node) !== void 0;
|
|
5169
|
+
return (ts7.isStringLiteral(node) || ts7.isNumericLiteral(node)) && !(ts7.isPrefixUnaryExpression(node.parent) && node.parent.operand === node);
|
|
5170
|
+
}
|
|
5171
|
+
function invocation(node) {
|
|
5172
|
+
if (ts7.isIdentifier(node.expression)) return { method: node.expression.text };
|
|
5173
|
+
if (ts7.isPropertyAccessExpression(node.expression)) {
|
|
5174
|
+
const receiver = node.expression.expression.getText();
|
|
5175
|
+
if (!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)?$/.test(receiver)) return void 0;
|
|
5176
|
+
return { method: node.expression.name.text, receiver };
|
|
5177
|
+
}
|
|
5178
|
+
return void 0;
|
|
5179
|
+
}
|
|
5180
|
+
function isPathname(node) {
|
|
5181
|
+
return ts7.isPropertyAccessExpression(node) && node.name.text === "pathname";
|
|
5182
|
+
}
|
|
5183
|
+
function contextFor(node, value, file, root) {
|
|
5184
|
+
if (typeof value === "number" && ignoredNumbers.has(value)) return void 0;
|
|
5185
|
+
if (typeof value === "string" && (value.length < 3 || /\s/.test(value))) return void 0;
|
|
5186
|
+
const parent = node.parent;
|
|
5187
|
+
const scope = featureOf(file, root);
|
|
5188
|
+
const isApiRoute = typeof value === "string" && value.startsWith("/api/") && !/[?&#\s]/.test(value);
|
|
5189
|
+
const route = () => ({ role: "api-route", family: "api-route" });
|
|
5190
|
+
if (ts7.isPropertyAssignment(parent) && parent.initializer === node) {
|
|
5191
|
+
const name = nameOf(parent.name);
|
|
5192
|
+
if (!name) return void 0;
|
|
5193
|
+
if (name === "path" && isApiRoute) return route();
|
|
5194
|
+
if (!semanticProperties.has(name)) return void 0;
|
|
5195
|
+
if (typeof value === "number") return void 0;
|
|
5196
|
+
if (isApiRoute && /route|path|endpoint/i.test(name)) return route();
|
|
5197
|
+
return { role: `property:${name}:${scope}`, family: `property:${name}` };
|
|
5198
|
+
}
|
|
5199
|
+
if (ts7.isVariableDeclaration(parent) && parent.initializer === node && ts7.isIdentifier(parent.name)) {
|
|
5200
|
+
if (typeof value === "number") return void 0;
|
|
5201
|
+
const name = parent.name.text;
|
|
5202
|
+
if (excludedProperties.has(name) || !semanticVariableName.test(name)) return void 0;
|
|
5203
|
+
if (isApiRoute && /route|path|endpoint/i.test(name)) return route();
|
|
5204
|
+
return { role: `variable:${name}:${scope}`, family: `variable:${name}` };
|
|
5205
|
+
}
|
|
5206
|
+
if (ts7.isCallExpression(parent)) {
|
|
5207
|
+
const position = parent.arguments.findIndex((argument) => argument === node);
|
|
5208
|
+
if (position < 0) return void 0;
|
|
5209
|
+
const call = invocation(parent);
|
|
5210
|
+
if (!call) return void 0;
|
|
5211
|
+
if (isApiRoute && position === 0 && (call.method === "fetch" || call.method === "zodFetch")) return route();
|
|
5212
|
+
if (typeof value === "number" && position === 1 && (call.method === "setTimeout" || call.method === "setInterval")) {
|
|
5213
|
+
return { role: `timer:${call.method}:${scope}`, family: "timer" };
|
|
5214
|
+
}
|
|
5215
|
+
if (typeof value === "string" && position === 0 && call.receiver && (call.receiver === "localStorage" || call.receiver === "sessionStorage") && ["getItem", "setItem", "removeItem"].includes(call.method)) {
|
|
5216
|
+
return { role: `storage:${call.receiver}`, family: "storage" };
|
|
5217
|
+
}
|
|
5218
|
+
if (typeof value === "string" && position === 0 && call.receiver && eventMethods.has(call.method) && /(?:event|bus|socket|emitter)/i.test(call.receiver)) {
|
|
5219
|
+
return { role: `event:${call.receiver}`, family: "event" };
|
|
5220
|
+
}
|
|
5221
|
+
if (typeof value === "string" && position === 0 && call.receiver && columnMethods.has(call.method) && value.length > 3 && /^[a-z][a-z0-9_]*$/.test(value)) {
|
|
5222
|
+
return { role: `column:${scope}`, family: "column" };
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
if (isApiRoute && ts7.isBinaryExpression(parent) && (parent.operatorToken.kind === ts7.SyntaxKind.EqualsEqualsEqualsToken || parent.operatorToken.kind === ts7.SyntaxKind.ExclamationEqualsEqualsToken) && (parent.left === node && isPathname(parent.right) || parent.right === node && isPathname(parent.left))) {
|
|
5226
|
+
return route();
|
|
5227
|
+
}
|
|
5228
|
+
if (isApiRoute && ts7.isCallExpression(parent) && parent.arguments[0] === node && ts7.isPropertyAccessExpression(parent.expression) && parent.expression.name.text === "startsWith" && isPathname(parent.expression.expression)) {
|
|
5229
|
+
return route();
|
|
5230
|
+
}
|
|
5231
|
+
return void 0;
|
|
5232
|
+
}
|
|
5233
|
+
function isExported2(node) {
|
|
5234
|
+
return ts7.canHaveModifiers(node) && (ts7.getModifiers(node) ?? []).some((modifier) => modifier.kind === ts7.SyntaxKind.ExportKeyword);
|
|
5235
|
+
}
|
|
5236
|
+
function parse(file, root, output) {
|
|
5237
|
+
if (!isProductionSource(file, root)) return;
|
|
5238
|
+
const source = ts7.createSourceFile(
|
|
5239
|
+
file,
|
|
5240
|
+
readFileSync8(file, "utf8"),
|
|
5241
|
+
ts7.ScriptTarget.Latest,
|
|
5242
|
+
true,
|
|
5243
|
+
file.endsWith(".tsx") || file.endsWith(".jsx") ? ts7.ScriptKind.TSX : ts7.ScriptKind.TS
|
|
5244
|
+
);
|
|
5245
|
+
const inConstants = path39.relative(root, file).split(path39.sep).includes("constants");
|
|
5246
|
+
for (const statement of source.statements) {
|
|
5247
|
+
if (inConstants && ts7.isEnumDeclaration(statement) && isExported2(statement)) {
|
|
5248
|
+
for (const member of statement.members) {
|
|
5249
|
+
const value = member.initializer && literalOf(member.initializer);
|
|
5250
|
+
const memberName9 = nameOf(member.name);
|
|
5251
|
+
if (value === void 0 || !memberName9) continue;
|
|
5252
|
+
output.canonicals.push({
|
|
5253
|
+
file,
|
|
5254
|
+
name: memberName9,
|
|
5255
|
+
owner: statement.name.text,
|
|
5256
|
+
kind: typeof value === "string" ? "string" : "number",
|
|
5257
|
+
value
|
|
5258
|
+
});
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
if (inConstants && ts7.isVariableStatement(statement) && isExported2(statement)) {
|
|
5262
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
5263
|
+
if (!ts7.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
5264
|
+
const value = literalOf(declaration.initializer);
|
|
5265
|
+
if (value === void 0) continue;
|
|
5266
|
+
output.canonicals.push({
|
|
5267
|
+
file,
|
|
5268
|
+
name: declaration.name.text,
|
|
5269
|
+
kind: typeof value === "string" ? "string" : "number",
|
|
5270
|
+
value
|
|
5271
|
+
});
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
const visit = (node) => {
|
|
5276
|
+
if (isLiteralRoot(node)) {
|
|
5277
|
+
const value = literalOf(node);
|
|
5278
|
+
if (value !== void 0) {
|
|
5279
|
+
const semantic = contextFor(node, value, file, root);
|
|
5280
|
+
if (semantic) {
|
|
5281
|
+
const declaration = node.parent;
|
|
5282
|
+
const isCanonicalDefinition = inConstants && (ts7.isVariableDeclaration(declaration) && ts7.isVariableStatement(declaration.parent.parent) && isExported2(declaration.parent.parent) || ts7.isEnumMember(declaration));
|
|
5283
|
+
if ((!inConstants || semantic.family === "api-route") && !isCanonicalDefinition) {
|
|
5284
|
+
const position = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
5285
|
+
output.uses.push({
|
|
5286
|
+
file,
|
|
5287
|
+
kind: typeof value === "string" ? "string" : "number",
|
|
5288
|
+
value,
|
|
5289
|
+
line: position.line + 1,
|
|
5290
|
+
column: position.character,
|
|
5291
|
+
...semantic
|
|
5292
|
+
});
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
}
|
|
5297
|
+
ts7.forEachChild(node, visit);
|
|
5298
|
+
};
|
|
5299
|
+
visit(source);
|
|
5300
|
+
}
|
|
5301
|
+
var cache3 = /* @__PURE__ */ new WeakMap();
|
|
5302
|
+
function getSemanticLiteralIndex(index) {
|
|
5303
|
+
const previous = cache3.get(index);
|
|
5304
|
+
if (previous) return previous;
|
|
5305
|
+
const result = { uses: [], canonicals: [] };
|
|
5306
|
+
for (const file of index.modules.keys()) {
|
|
5307
|
+
try {
|
|
5308
|
+
parse(file, index.sourceRoot, result);
|
|
5309
|
+
} catch {
|
|
5310
|
+
}
|
|
5311
|
+
}
|
|
5312
|
+
cache3.set(index, result);
|
|
5313
|
+
return result;
|
|
5314
|
+
}
|
|
5315
|
+
|
|
5316
|
+
// eslint/rules/no-inline-runtime-literal.ts
|
|
5317
|
+
var DOC4 = "See docs/next-codebase-guide/rules/constants-rule.md";
|
|
5318
|
+
var MESSAGE2 = `Every runtime string or numeric value must use a named constant or enum member, including single-use values. Only JSX className props permit inline values. ${DOC4}`;
|
|
5319
|
+
function isClassNameProp(node) {
|
|
5320
|
+
let current = node;
|
|
5321
|
+
while (current.parent) {
|
|
5322
|
+
current = current.parent;
|
|
5323
|
+
if (current.type === "JSXAttribute") {
|
|
5324
|
+
const { name } = current;
|
|
5325
|
+
return typeof name === "object" && name !== null && "name" in name && name.name === "className";
|
|
5326
|
+
}
|
|
5327
|
+
if (current.type === "Program") return false;
|
|
5328
|
+
}
|
|
5329
|
+
return false;
|
|
5330
|
+
}
|
|
5331
|
+
function containsInlineString(node) {
|
|
5332
|
+
if (typeof node !== "object" || node === null || !("type" in node)) return false;
|
|
5333
|
+
if (node.type === "TemplateLiteral") return true;
|
|
5334
|
+
if (node.type === "Literal") return "value" in node && typeof node.value === "string";
|
|
5335
|
+
if (node.type === "BinaryExpression") {
|
|
5336
|
+
return "left" in node && containsInlineString(node.left) || "right" in node && containsInlineString(node.right);
|
|
5337
|
+
}
|
|
5338
|
+
if (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression") {
|
|
5339
|
+
return "expression" in node && containsInlineString(node.expression);
|
|
5340
|
+
}
|
|
5341
|
+
return false;
|
|
5342
|
+
}
|
|
5343
|
+
function isNamedValue(node) {
|
|
5344
|
+
let current = node;
|
|
5345
|
+
while (current.parent) {
|
|
5346
|
+
const parent2 = current.parent;
|
|
5347
|
+
const isTypeWrapper = parent2.type === "TSAsExpression" || parent2.type === "TSSatisfiesExpression";
|
|
5348
|
+
const isSignedNumber = parent2.type === "UnaryExpression" && parent2.argument === current && (parent2.operator === "-" || parent2.operator === "+");
|
|
5349
|
+
const isArithmetic = parent2.type === "BinaryExpression" && typeof parent2.operator === "string" && ["+", "-", "*", "/", "%", "**", "<<", ">>", ">>>", "&", "|", "^"].includes(parent2.operator) && !containsInlineString(parent2.left) && !containsInlineString(parent2.right);
|
|
5350
|
+
if (!isTypeWrapper && !isSignedNumber && !isArithmetic) break;
|
|
5351
|
+
current = parent2;
|
|
5352
|
+
}
|
|
5353
|
+
const parent = current.parent;
|
|
5354
|
+
if (!parent) return false;
|
|
5355
|
+
if (parent.type === "TSEnumMember" && parent.initializer === current) return true;
|
|
5356
|
+
if (parent.type !== "VariableDeclarator" || parent.init !== current) return false;
|
|
5357
|
+
const id = parent.id;
|
|
5358
|
+
return parent.parent?.type === "VariableDeclaration" && parent.parent.kind === "const" && typeof id === "object" && id !== null && "type" in id && id.type === "Identifier";
|
|
5359
|
+
}
|
|
5360
|
+
function isSyntacticString(node) {
|
|
5361
|
+
const parent = node.parent;
|
|
5362
|
+
if (!parent) return false;
|
|
5363
|
+
if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression" || parent.type === "TSLiteralType" || parent.type === "TSExternalModuleReference") {
|
|
5364
|
+
return true;
|
|
5365
|
+
}
|
|
5366
|
+
if (parent.type === "ExpressionStatement" && typeof parent.directive === "string") return true;
|
|
5367
|
+
if ((parent.type === "Property" || parent.type === "MethodDefinition") && parent.key === node && parent.computed === false) {
|
|
5368
|
+
return true;
|
|
5369
|
+
}
|
|
5370
|
+
return false;
|
|
5371
|
+
}
|
|
5372
|
+
var noInlineRuntimeLiteralRule = {
|
|
5373
|
+
meta: {
|
|
5374
|
+
schema: [],
|
|
5375
|
+
type: "problem",
|
|
5376
|
+
docs: { description: "Require named runtime string and numeric values except inside JSX className props." }
|
|
5377
|
+
},
|
|
5378
|
+
create(context) {
|
|
5379
|
+
const root = sourceRootOf(context);
|
|
5380
|
+
const file = path40.resolve(context.filename);
|
|
5381
|
+
if (!file.startsWith(root + path40.sep) || !isProductionSource(file, root)) return {};
|
|
5382
|
+
return {
|
|
5383
|
+
Literal(node) {
|
|
5384
|
+
if (typeof node.value !== "string" && typeof node.value !== "number" && typeof node.value !== "bigint" && !("bigint" in node && typeof node.bigint === "string")) {
|
|
5385
|
+
return;
|
|
5386
|
+
}
|
|
5387
|
+
if (typeof node.value === "string" && isClassNameProp(node) || isNamedValue(node) || isSyntacticString(node)) {
|
|
5388
|
+
return;
|
|
5389
|
+
}
|
|
5390
|
+
context.report({ node, message: MESSAGE2 });
|
|
5391
|
+
},
|
|
5392
|
+
TemplateLiteral(node) {
|
|
5393
|
+
if (isClassNameProp(node) || isNamedValue(node)) return;
|
|
5394
|
+
if (node.quasis.every((quasi) => quasi.value.raw === "")) return;
|
|
5395
|
+
context.report({ node, message: MESSAGE2 });
|
|
5396
|
+
},
|
|
5397
|
+
JSXText(node) {
|
|
5398
|
+
if (!("value" in node) || typeof node.value !== "string" || node.value.trim().length === 0) return;
|
|
5399
|
+
context.report({ node, message: MESSAGE2 });
|
|
5400
|
+
}
|
|
5401
|
+
};
|
|
5402
|
+
}
|
|
5403
|
+
};
|
|
5404
|
+
|
|
5103
5405
|
// eslint/rules/no-literal-inline-style.ts
|
|
5104
5406
|
function isStaticValue(value) {
|
|
5105
5407
|
if (value.type === "Literal") {
|
|
@@ -5169,8 +5471,8 @@ var noLiteralInlineStyleRule = {
|
|
|
5169
5471
|
};
|
|
5170
5472
|
|
|
5171
5473
|
// eslint/rules/no-mixed-concerns.ts
|
|
5172
|
-
import { readFileSync as
|
|
5173
|
-
import
|
|
5474
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
5475
|
+
import path41 from "path";
|
|
5174
5476
|
var noMixedConcernsRule = {
|
|
5175
5477
|
meta: {
|
|
5176
5478
|
schema: [],
|
|
@@ -5194,7 +5496,7 @@ var noMixedConcernsRule = {
|
|
|
5194
5496
|
if (components.length > 1) return;
|
|
5195
5497
|
const componentName = components[0]?.name;
|
|
5196
5498
|
if (!componentName) return;
|
|
5197
|
-
const file =
|
|
5499
|
+
const file = path41.resolve(context.filename);
|
|
5198
5500
|
const sourceRoot = sourceRootOf(context);
|
|
5199
5501
|
const index = getProjectIndex(sourceRoot);
|
|
5200
5502
|
const componentConsumers = index?.symbolConsumers.get(symbolKey(file, componentName)) ?? /* @__PURE__ */ new Set();
|
|
@@ -5238,7 +5540,7 @@ var noMixedConcernsRule = {
|
|
|
5238
5540
|
continue;
|
|
5239
5541
|
}
|
|
5240
5542
|
const target = typeof statement.source?.value === "string" ? resolveSpecifier(file, statement.source.value, sourceRoot) : void 0;
|
|
5241
|
-
const forwardedComponents = target?.endsWith(".tsx") ? parseComponentInfo(
|
|
5543
|
+
const forwardedComponents = target?.endsWith(".tsx") ? parseComponentInfo(readFileSync9(target, "utf8"), target).map((component) => component.name) : [];
|
|
5242
5544
|
for (const specifier of statement.specifiers) {
|
|
5243
5545
|
if (/^type\b/.test(context.sourceCode.getText(specifier))) continue;
|
|
5244
5546
|
if (specifier.local.type !== "Identifier") continue;
|
|
@@ -5272,11 +5574,11 @@ var noMixedConcernsRule = {
|
|
|
5272
5574
|
};
|
|
5273
5575
|
|
|
5274
5576
|
// eslint/rules/no-redundant-alias.ts
|
|
5275
|
-
import
|
|
5577
|
+
import path43 from "path";
|
|
5276
5578
|
|
|
5277
5579
|
// eslint/rules/contract-ownership.ts
|
|
5278
|
-
import
|
|
5279
|
-
import
|
|
5580
|
+
import path42 from "path";
|
|
5581
|
+
import ts8 from "typescript";
|
|
5280
5582
|
function isTsProgram(value) {
|
|
5281
5583
|
return typeof value === "object" && value !== null && "getTypeChecker" in value && typeof value.getTypeChecker === "function" && "getSourceFiles" in value && typeof value.getSourceFiles === "function";
|
|
5282
5584
|
}
|
|
@@ -5294,8 +5596,8 @@ function normalizePath(value) {
|
|
|
5294
5596
|
return value.replaceAll("\\", "/").toLowerCase();
|
|
5295
5597
|
}
|
|
5296
5598
|
function isWithin2(root, file) {
|
|
5297
|
-
const relative =
|
|
5298
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
5599
|
+
const relative = path42.relative(root, file);
|
|
5600
|
+
return relative === "" || !relative.startsWith("..") && !path42.isAbsolute(relative);
|
|
5299
5601
|
}
|
|
5300
5602
|
function mergeOwnership(values) {
|
|
5301
5603
|
if (values.length === 0 || values.includes("unknown")) return "unknown";
|
|
@@ -5310,11 +5612,11 @@ function endpointOwnership(pathValue) {
|
|
|
5310
5612
|
return "unknown";
|
|
5311
5613
|
}
|
|
5312
5614
|
function resolvedSymbol(checker, symbol) {
|
|
5313
|
-
return symbol.flags ===
|
|
5615
|
+
return symbol.flags === ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
5314
5616
|
}
|
|
5315
5617
|
function propertyName3(node) {
|
|
5316
5618
|
if (!node) return void 0;
|
|
5317
|
-
if (
|
|
5619
|
+
if (ts8.isIdentifier(node) || ts8.isStringLiteral(node) || ts8.isNumericLiteral(node)) return node.text;
|
|
5318
5620
|
return void 0;
|
|
5319
5621
|
}
|
|
5320
5622
|
var ContractOwnershipIndex = class {
|
|
@@ -5338,7 +5640,7 @@ var ContractOwnershipIndex = class {
|
|
|
5338
5640
|
}
|
|
5339
5641
|
if (declarations.length > 0) return this.endpointFromDeclarations(declarations);
|
|
5340
5642
|
let object;
|
|
5341
|
-
if (
|
|
5643
|
+
if (ts8.isPropertyAccessExpression(node) || ts8.isElementAccessExpression(node)) object = node.expression;
|
|
5342
5644
|
if (!object) return { kind: "missing", ownership: "unknown" };
|
|
5343
5645
|
const type = this.checker.getTypeAtLocation(object);
|
|
5344
5646
|
const typeDeclarations = this.typeDeclarations(type);
|
|
@@ -5346,7 +5648,7 @@ var ContractOwnershipIndex = class {
|
|
|
5346
5648
|
return this.endpointFromDeclarations(typeDeclarations);
|
|
5347
5649
|
}
|
|
5348
5650
|
sourceBinding(node, name) {
|
|
5349
|
-
if (!
|
|
5651
|
+
if (!ts8.isVariableDeclaration(node) || !node.initializer) {
|
|
5350
5652
|
return { kind: "missing", ownership: "unknown" };
|
|
5351
5653
|
}
|
|
5352
5654
|
const sourceType = this.checker.getTypeAtLocation(node.initializer);
|
|
@@ -5355,11 +5657,11 @@ var ContractOwnershipIndex = class {
|
|
|
5355
5657
|
return this.endpointFromDeclarations(declarations);
|
|
5356
5658
|
}
|
|
5357
5659
|
targetProperty(node, name) {
|
|
5358
|
-
if (!
|
|
5660
|
+
if (!ts8.isPropertyAssignment(node) && !ts8.isShorthandPropertyAssignment(node)) {
|
|
5359
5661
|
return { kind: "missing", ownership: "unknown" };
|
|
5360
5662
|
}
|
|
5361
5663
|
const object = node.parent;
|
|
5362
|
-
if (!
|
|
5664
|
+
if (!ts8.isObjectLiteralExpression(object)) return { kind: "missing", ownership: "unknown" };
|
|
5363
5665
|
const contextualType = this.checker.getContextualType(object);
|
|
5364
5666
|
if (!contextualType) return { kind: "missing", ownership: "unknown" };
|
|
5365
5667
|
const declarations = this.propertyDeclarations(contextualType, name);
|
|
@@ -5367,8 +5669,8 @@ var ContractOwnershipIndex = class {
|
|
|
5367
5669
|
return this.endpointFromDeclarations(declarations);
|
|
5368
5670
|
}
|
|
5369
5671
|
memberNameSymbol(node) {
|
|
5370
|
-
if (
|
|
5371
|
-
if (
|
|
5672
|
+
if (ts8.isPropertyAccessExpression(node)) return this.checker.getSymbolAtLocation(node.name);
|
|
5673
|
+
if (ts8.isElementAccessExpression(node)) return this.checker.getSymbolAtLocation(node.argumentExpression);
|
|
5372
5674
|
return void 0;
|
|
5373
5675
|
}
|
|
5374
5676
|
propertyDeclarations(type, name) {
|
|
@@ -5398,14 +5700,14 @@ var ContractOwnershipIndex = class {
|
|
|
5398
5700
|
if (declarations.some((declaration) => this.isDataContractField(declaration))) {
|
|
5399
5701
|
return { kind: "data-contract", ownership };
|
|
5400
5702
|
}
|
|
5401
|
-
if (declarations.some((declaration) =>
|
|
5703
|
+
if (declarations.some((declaration) => ts8.isPropertySignature(declaration) || ts8.isPropertyDeclaration(declaration))) {
|
|
5402
5704
|
return { kind: "typed-local", ownership };
|
|
5403
5705
|
}
|
|
5404
5706
|
return { kind: "non-contract", ownership };
|
|
5405
5707
|
}
|
|
5406
5708
|
isDataContractField(declaration) {
|
|
5407
5709
|
if (this.isZodSchemaField(declaration)) return true;
|
|
5408
|
-
if (!
|
|
5710
|
+
if (!ts8.isPropertySignature(declaration) && !ts8.isPropertyDeclaration(declaration)) return false;
|
|
5409
5711
|
const fileName = normalizePath(declaration.getSourceFile().fileName);
|
|
5410
5712
|
return /(?:^|\/)database(?:[-.]generated)?\.ts$/u.test(fileName);
|
|
5411
5713
|
}
|
|
@@ -5414,10 +5716,10 @@ var ContractOwnershipIndex = class {
|
|
|
5414
5716
|
return this.checker.getPropertyOfType(type, "_zod") !== void 0 && this.checker.getPropertyOfType(type, "parse") !== void 0 && this.checker.getPropertyOfType(type, "safeParse") !== void 0;
|
|
5415
5717
|
}
|
|
5416
5718
|
isZodSchemaField(declaration) {
|
|
5417
|
-
if (!
|
|
5719
|
+
if (!ts8.isPropertyAssignment(declaration)) return false;
|
|
5418
5720
|
let current = declaration.parent;
|
|
5419
|
-
while (!
|
|
5420
|
-
if (
|
|
5721
|
+
while (!ts8.isSourceFile(current)) {
|
|
5722
|
+
if (ts8.isVariableDeclaration(current) && ts8.isIdentifier(current.name) && current.name.text.endsWith("Schema")) {
|
|
5421
5723
|
return true;
|
|
5422
5724
|
}
|
|
5423
5725
|
current = current.parent;
|
|
@@ -5435,12 +5737,12 @@ var ContractOwnershipIndex = class {
|
|
|
5435
5737
|
const normalized = normalizePath(fileName);
|
|
5436
5738
|
if (/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u.test(normalized)) return "platform";
|
|
5437
5739
|
if (normalized.includes("/node_modules/")) return "third-party";
|
|
5438
|
-
if (isWithin2(this.cwd,
|
|
5740
|
+
if (isWithin2(this.cwd, path42.resolve(fileName))) return "first-party";
|
|
5439
5741
|
return "unknown";
|
|
5440
5742
|
}
|
|
5441
5743
|
schemaOwnership(declaration) {
|
|
5442
5744
|
let current = declaration;
|
|
5443
|
-
while (!
|
|
5745
|
+
while (!ts8.isSourceFile(current)) {
|
|
5444
5746
|
const ownership = this.schemaNodeOwnership.get(current);
|
|
5445
5747
|
if (ownership !== void 0) return ownership;
|
|
5446
5748
|
current = current.parent;
|
|
@@ -5449,31 +5751,31 @@ var ContractOwnershipIndex = class {
|
|
|
5449
5751
|
}
|
|
5450
5752
|
indexApiContracts() {
|
|
5451
5753
|
for (const sourceFile of this.program.getSourceFiles()) {
|
|
5452
|
-
if (sourceFile.isDeclarationFile || !isWithin2(this.cwd,
|
|
5754
|
+
if (sourceFile.isDeclarationFile || !isWithin2(this.cwd, path42.resolve(sourceFile.fileName))) continue;
|
|
5453
5755
|
const visit = (node) => {
|
|
5454
|
-
if (
|
|
5455
|
-
|
|
5756
|
+
if (ts8.isCallExpression(node) && this.isDefineApiContractCall(node)) this.indexApiContractCall(node);
|
|
5757
|
+
ts8.forEachChild(node, visit);
|
|
5456
5758
|
};
|
|
5457
5759
|
visit(sourceFile);
|
|
5458
5760
|
}
|
|
5459
5761
|
}
|
|
5460
5762
|
isDefineApiContractCall(node) {
|
|
5461
|
-
if (
|
|
5462
|
-
return
|
|
5763
|
+
if (ts8.isIdentifier(node.expression)) return node.expression.text === "defineApiContract";
|
|
5764
|
+
return ts8.isPropertyAccessExpression(node.expression) && node.expression.name.text === "defineApiContract";
|
|
5463
5765
|
}
|
|
5464
5766
|
indexApiContractCall(node) {
|
|
5465
5767
|
const argument = node.arguments[0];
|
|
5466
|
-
if (!argument || !
|
|
5768
|
+
if (!argument || !ts8.isObjectLiteralExpression(argument)) return;
|
|
5467
5769
|
let pathExpression;
|
|
5468
5770
|
const schemaExpressions = [];
|
|
5469
5771
|
for (const property of argument.properties) {
|
|
5470
|
-
if (
|
|
5772
|
+
if (ts8.isPropertyAssignment(property)) {
|
|
5471
5773
|
const name = propertyName3(property.name);
|
|
5472
5774
|
if (name === "path") pathExpression = property.initializer;
|
|
5473
5775
|
if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.initializer);
|
|
5474
5776
|
continue;
|
|
5475
5777
|
}
|
|
5476
|
-
if (
|
|
5778
|
+
if (ts8.isShorthandPropertyAssignment(property)) {
|
|
5477
5779
|
const name = property.name.text;
|
|
5478
5780
|
if (name === "path") pathExpression = property.name;
|
|
5479
5781
|
if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.name);
|
|
@@ -5487,13 +5789,13 @@ var ContractOwnershipIndex = class {
|
|
|
5487
5789
|
}
|
|
5488
5790
|
staticString(node, seen) {
|
|
5489
5791
|
if (!node) return void 0;
|
|
5490
|
-
if (
|
|
5491
|
-
if (
|
|
5792
|
+
if (ts8.isStringLiteralLike(node)) return node.text;
|
|
5793
|
+
if (ts8.isIdentifier(node)) {
|
|
5492
5794
|
const symbol = this.checker.getSymbolAtLocation(node);
|
|
5493
5795
|
if (!symbol || seen.has(symbol)) return void 0;
|
|
5494
5796
|
seen.add(symbol);
|
|
5495
5797
|
for (const declaration of resolvedSymbol(this.checker, symbol).declarations ?? []) {
|
|
5496
|
-
if (
|
|
5798
|
+
if (ts8.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
5497
5799
|
const value = this.staticString(declaration.initializer, seen);
|
|
5498
5800
|
if (value !== void 0) return value;
|
|
5499
5801
|
}
|
|
@@ -5511,20 +5813,20 @@ var ContractOwnershipIndex = class {
|
|
|
5511
5813
|
this.followSchemaDeclaration(declaration, ownership, seen);
|
|
5512
5814
|
}
|
|
5513
5815
|
}
|
|
5514
|
-
|
|
5816
|
+
ts8.forEachChild(node, (child) => {
|
|
5515
5817
|
this.markSchemaExpression(child, ownership, seen);
|
|
5516
5818
|
});
|
|
5517
5819
|
}
|
|
5518
5820
|
schemaReferenceSymbol(node) {
|
|
5519
|
-
if (
|
|
5821
|
+
if (ts8.isIdentifier(node)) {
|
|
5520
5822
|
if (!node.text.endsWith("Schema")) return void 0;
|
|
5521
5823
|
return this.checker.getSymbolAtLocation(node);
|
|
5522
5824
|
}
|
|
5523
|
-
if (
|
|
5825
|
+
if (ts8.isPropertyAccessExpression(node)) {
|
|
5524
5826
|
if (!node.name.text.endsWith("Schema")) return void 0;
|
|
5525
5827
|
return this.checker.getSymbolAtLocation(node.name);
|
|
5526
5828
|
}
|
|
5527
|
-
if (
|
|
5829
|
+
if (ts8.isElementAccessExpression(node) && ts8.isStringLiteralLike(node.argumentExpression)) {
|
|
5528
5830
|
if (!node.argumentExpression.text.endsWith("Schema")) return void 0;
|
|
5529
5831
|
return this.checker.getSymbolAtLocation(node.argumentExpression);
|
|
5530
5832
|
}
|
|
@@ -5532,15 +5834,15 @@ var ContractOwnershipIndex = class {
|
|
|
5532
5834
|
}
|
|
5533
5835
|
followSchemaDeclaration(declaration, ownership, seen) {
|
|
5534
5836
|
this.setSchemaOwnership(declaration, ownership);
|
|
5535
|
-
if (
|
|
5837
|
+
if (ts8.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
5536
5838
|
this.markSchemaExpression(declaration.initializer, ownership, seen);
|
|
5537
5839
|
return;
|
|
5538
5840
|
}
|
|
5539
|
-
if (
|
|
5841
|
+
if (ts8.isPropertyAssignment(declaration)) {
|
|
5540
5842
|
this.markSchemaExpression(declaration.initializer, ownership, seen);
|
|
5541
5843
|
return;
|
|
5542
5844
|
}
|
|
5543
|
-
if (
|
|
5845
|
+
if (ts8.isShorthandPropertyAssignment(declaration)) {
|
|
5544
5846
|
const valueSymbol = this.checker.getShorthandAssignmentValueSymbol(declaration);
|
|
5545
5847
|
if (!valueSymbol || seen.has(valueSymbol)) return;
|
|
5546
5848
|
seen.add(valueSymbol);
|
|
@@ -5584,7 +5886,7 @@ function contractOwnershipResolver(context) {
|
|
|
5584
5886
|
}
|
|
5585
5887
|
|
|
5586
5888
|
// eslint/rules/no-redundant-alias.ts
|
|
5587
|
-
var
|
|
5889
|
+
var DOC5 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
5588
5890
|
var VALUE_SENTINELS = /* @__PURE__ */ new Set(["undefined", "NaN", "Infinity"]);
|
|
5589
5891
|
var HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
5590
5892
|
var FRAMEWORK_MAPPING_KEYS = /* @__PURE__ */ new Set(["default", "apiRoutePath"]);
|
|
@@ -5617,14 +5919,14 @@ function aliasedTypeName(annotation) {
|
|
|
5617
5919
|
function aliasMessage(alias, source) {
|
|
5618
5920
|
const aliasName = alias ?? "This declaration";
|
|
5619
5921
|
const sourceName = source ?? "the original symbol";
|
|
5620
|
-
return `"${aliasName}" only renames "${sourceName}". Use "${sourceName}" directly or rename the original symbol and its consumers. ${
|
|
5922
|
+
return `"${aliasName}" only renames "${sourceName}". Use "${sourceName}" directly or rename the original symbol and its consumers. ${DOC5}`;
|
|
5621
5923
|
}
|
|
5622
5924
|
function bindingAliasMessage(alias, source) {
|
|
5623
|
-
return `"${alias}" renames "${source}" while creating a binding. Keep the original name and map it only at the object boundary. ${
|
|
5925
|
+
return `"${alias}" renames "${source}" while creating a binding. Keep the original name and map it only at the object boundary. ${DOC5}`;
|
|
5624
5926
|
}
|
|
5625
5927
|
function objectPropertyMessage(propertyName5, source) {
|
|
5626
|
-
if (source === propertyName5) return `Use property shorthand for "${propertyName5}". ${
|
|
5627
|
-
return `"${propertyName5}" maps the local "${source}". Keep the local name or map directly from its source object instead. ${
|
|
5928
|
+
if (source === propertyName5) return `Use property shorthand for "${propertyName5}". ${DOC5}`;
|
|
5929
|
+
return `"${propertyName5}" maps the local "${source}". Keep the local name or map directly from its source object instead. ${DOC5}`;
|
|
5628
5930
|
}
|
|
5629
5931
|
function normalizePropertyName(name) {
|
|
5630
5932
|
return name.replace(/[-_\s]/g, "").toLowerCase();
|
|
@@ -5655,10 +5957,10 @@ function isInsideSchemaDeclaration(node) {
|
|
|
5655
5957
|
return false;
|
|
5656
5958
|
}
|
|
5657
5959
|
function semanticMappingMessage(propertyName5, sourcePropertyName) {
|
|
5658
|
-
return `"${propertyName5}" maps from "${sourcePropertyName}" between first-party contracts. Use one canonical field name across the contracts. ${
|
|
5960
|
+
return `"${propertyName5}" maps from "${sourcePropertyName}" between first-party contracts. Use one canonical field name across the contracts. ${DOC5}`;
|
|
5659
5961
|
}
|
|
5660
5962
|
function unknownContractOwnershipMessage(propertyName5, sourcePropertyName) {
|
|
5661
|
-
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. ${
|
|
5963
|
+
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. ${DOC5}`;
|
|
5662
5964
|
}
|
|
5663
5965
|
function destructuredBindingSource(context, identifier) {
|
|
5664
5966
|
const initialScope = context.sourceCode.getScope(identifier);
|
|
@@ -5720,7 +6022,7 @@ var noRedundantAliasRule = {
|
|
|
5720
6022
|
if (declaration.type !== "VariableDeclaration" || declaration.kind !== "const") return;
|
|
5721
6023
|
if (node.init.type === "Identifier") {
|
|
5722
6024
|
const exported = declaration.parent.type === "ExportNamedDeclaration";
|
|
5723
|
-
const frameworkRouteAlias =
|
|
6025
|
+
const frameworkRouteAlias = path43.basename(context.filename) === "route.ts" && exported && HTTP_METHODS.has(node.id.name);
|
|
5724
6026
|
if (frameworkRouteAlias || VALUE_SENTINELS.has(node.init.name)) return;
|
|
5725
6027
|
context.report({
|
|
5726
6028
|
node,
|
|
@@ -5838,7 +6140,7 @@ var noRedundantAliasRule = {
|
|
|
5838
6140
|
const source = specifier.local.name;
|
|
5839
6141
|
const alias = specifier.exported.name;
|
|
5840
6142
|
if (source === alias) continue;
|
|
5841
|
-
const frameworkRouteAlias =
|
|
6143
|
+
const frameworkRouteAlias = path43.basename(context.filename) === "route.ts" && HTTP_METHODS.has(alias);
|
|
5842
6144
|
if (frameworkRouteAlias) continue;
|
|
5843
6145
|
context.report({
|
|
5844
6146
|
node: specifier,
|
|
@@ -5863,7 +6165,7 @@ var noRedundantAliasRule = {
|
|
|
5863
6165
|
};
|
|
5864
6166
|
|
|
5865
6167
|
// eslint/rules/no-util-barrel.ts
|
|
5866
|
-
import
|
|
6168
|
+
import path44 from "path";
|
|
5867
6169
|
var noUtilBarrelRule = {
|
|
5868
6170
|
meta: {
|
|
5869
6171
|
schema: [],
|
|
@@ -5873,7 +6175,7 @@ var noUtilBarrelRule = {
|
|
|
5873
6175
|
}
|
|
5874
6176
|
},
|
|
5875
6177
|
create(context) {
|
|
5876
|
-
const filename =
|
|
6178
|
+
const filename = path44.resolve(context.filename);
|
|
5877
6179
|
const sourceRoot = sourceRootOf3(context, filename);
|
|
5878
6180
|
return {
|
|
5879
6181
|
Program(node) {
|
|
@@ -5882,7 +6184,7 @@ var noUtilBarrelRule = {
|
|
|
5882
6184
|
if (!target) continue;
|
|
5883
6185
|
const segments = target.replace(/\\/g, "/").split("/");
|
|
5884
6186
|
const utilsIndex = segments.lastIndexOf("utils");
|
|
5885
|
-
if (utilsIndex < 0 || !
|
|
6187
|
+
if (utilsIndex < 0 || !path44.basename(target).startsWith("index.")) continue;
|
|
5886
6188
|
context.report({
|
|
5887
6189
|
node,
|
|
5888
6190
|
message: `Import utilities directly instead of through "${specifier}". See docs/next-codebase-guide/rules/utilities-rule.md`
|
|
@@ -5902,10 +6204,10 @@ function importSpecifiers2(source) {
|
|
|
5902
6204
|
return specifiers;
|
|
5903
6205
|
}
|
|
5904
6206
|
function sourceRootOf3(context, filename) {
|
|
5905
|
-
const marker = `${
|
|
6207
|
+
const marker = `${path44.sep}src${path44.sep}`;
|
|
5906
6208
|
const srcIndex = filename.lastIndexOf(marker);
|
|
5907
6209
|
if (srcIndex >= 0) return filename.slice(0, srcIndex + marker.length - 1);
|
|
5908
|
-
return
|
|
6210
|
+
return path44.resolve(context.cwd ?? process.cwd(), "src");
|
|
5909
6211
|
}
|
|
5910
6212
|
|
|
5911
6213
|
// eslint/rules/package-json/exact-version.ts
|
|
@@ -6123,8 +6425,8 @@ var nextjsStackRule = {
|
|
|
6123
6425
|
};
|
|
6124
6426
|
|
|
6125
6427
|
// eslint/rules/package-json/vitest-coverage.ts
|
|
6126
|
-
import { existsSync as existsSync5, readFileSync as
|
|
6127
|
-
import
|
|
6428
|
+
import { existsSync as existsSync5, readFileSync as readFileSync10 } from "fs";
|
|
6429
|
+
import path45 from "path";
|
|
6128
6430
|
function memberName5(member) {
|
|
6129
6431
|
return member.name.type === "String" ? member.name.value : member.name.name;
|
|
6130
6432
|
}
|
|
@@ -6194,7 +6496,7 @@ var vitestCoverageRule = {
|
|
|
6194
6496
|
message: 'package.json must declare a "test:unit:coverage" script that runs Vitest with coverage.'
|
|
6195
6497
|
});
|
|
6196
6498
|
}
|
|
6197
|
-
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync5(
|
|
6499
|
+
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync5(path45.join(context.cwd, name)));
|
|
6198
6500
|
if (!configName) {
|
|
6199
6501
|
context.report({
|
|
6200
6502
|
node,
|
|
@@ -6202,7 +6504,7 @@ var vitestCoverageRule = {
|
|
|
6202
6504
|
});
|
|
6203
6505
|
return;
|
|
6204
6506
|
}
|
|
6205
|
-
const content =
|
|
6507
|
+
const content = readFileSync10(path45.join(context.cwd, configName), "utf8");
|
|
6206
6508
|
for (const metric of THRESHOLD_METRICS) {
|
|
6207
6509
|
if (!new RegExp(`\\b${metric}\\s*:\\s*[1-9]\\d*`).test(content)) {
|
|
6208
6510
|
context.report({ node, message: `${configName} must set a coverage threshold above zero for ${metric}.` });
|
|
@@ -6248,8 +6550,8 @@ var nextjsPackageJsonRules = {
|
|
|
6248
6550
|
};
|
|
6249
6551
|
|
|
6250
6552
|
// eslint/rules/prefer-enum.ts
|
|
6251
|
-
import
|
|
6252
|
-
import
|
|
6553
|
+
import path46 from "path";
|
|
6554
|
+
import ts9 from "typescript";
|
|
6253
6555
|
function isConstAssertion(node) {
|
|
6254
6556
|
const typeAnnotation = node.typeAnnotation;
|
|
6255
6557
|
return typeAnnotation?.type === "TSTypeReference" && typeAnnotation.typeName?.type === "Identifier" && typeAnnotation.typeName.name === "const";
|
|
@@ -6303,13 +6605,13 @@ function isLiteralTupleAssertion(node) {
|
|
|
6303
6605
|
return values.every((value) => value !== void 0) && new Set(values).size >= 2;
|
|
6304
6606
|
}
|
|
6305
6607
|
function isTsLiteralTupleDeclaration(declaration) {
|
|
6306
|
-
if (!
|
|
6608
|
+
if (!ts9.isVariableDeclaration(declaration) || !declaration.initializer) return false;
|
|
6307
6609
|
const init = declaration.initializer;
|
|
6308
|
-
if (!
|
|
6610
|
+
if (!ts9.isAsExpression(init) || !ts9.isTypeReferenceNode(init.type) || !ts9.isIdentifier(init.type.typeName) || init.type.typeName.text !== "const" || !ts9.isArrayLiteralExpression(init.expression) || init.expression.elements.length < 2) {
|
|
6309
6611
|
return false;
|
|
6310
6612
|
}
|
|
6311
6613
|
const values = init.expression.elements.map(
|
|
6312
|
-
(element) =>
|
|
6614
|
+
(element) => ts9.isStringLiteral(element) || ts9.isNumericLiteral(element) ? element.text : void 0
|
|
6313
6615
|
);
|
|
6314
6616
|
return values.every((value) => value !== void 0) && new Set(values).size >= 2;
|
|
6315
6617
|
}
|
|
@@ -6322,9 +6624,9 @@ var preferEnumRule = {
|
|
|
6322
6624
|
}
|
|
6323
6625
|
},
|
|
6324
6626
|
create(context) {
|
|
6325
|
-
const filename =
|
|
6627
|
+
const filename = path46.resolve(context.filename);
|
|
6326
6628
|
const sourceRoot = sourceRootOf(context);
|
|
6327
|
-
if (!filename.startsWith(sourceRoot +
|
|
6629
|
+
if (!filename.startsWith(sourceRoot + path46.sep)) return {};
|
|
6328
6630
|
const objectSchemas = /* @__PURE__ */ new Map();
|
|
6329
6631
|
const literalTuples = /* @__PURE__ */ new Set();
|
|
6330
6632
|
const enumTupleUses = [];
|
|
@@ -6338,7 +6640,7 @@ var preferEnumRule = {
|
|
|
6338
6640
|
const checker = services.program.getTypeChecker();
|
|
6339
6641
|
const symbol = checker.getSymbolAtLocation(tsNode);
|
|
6340
6642
|
if (!symbol) return false;
|
|
6341
|
-
const original = symbol.flags ===
|
|
6643
|
+
const original = symbol.flags === ts9.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
6342
6644
|
return (original.declarations ?? []).some(isTsLiteralTupleDeclaration);
|
|
6343
6645
|
}
|
|
6344
6646
|
return {
|
|
@@ -6433,8 +6735,8 @@ var preferEnumRule = {
|
|
|
6433
6735
|
};
|
|
6434
6736
|
|
|
6435
6737
|
// eslint/rules/prefer-object-destructuring.ts
|
|
6436
|
-
import
|
|
6437
|
-
var
|
|
6738
|
+
import ts10 from "typescript";
|
|
6739
|
+
var DOC6 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
6438
6740
|
function hasTypeAnnotation(identifier) {
|
|
6439
6741
|
return "typeAnnotation" in identifier && identifier.typeAnnotation !== void 0;
|
|
6440
6742
|
}
|
|
@@ -6526,8 +6828,8 @@ function enumValueResolver(context) {
|
|
|
6526
6828
|
const checker = services.program.getTypeChecker();
|
|
6527
6829
|
const { esTreeNodeToTSNodeMap: nodeMap } = services;
|
|
6528
6830
|
const isEnumSymbol = (symbol) => {
|
|
6529
|
-
const resolved = symbol.flags ===
|
|
6530
|
-
return (resolved.declarations ?? []).some((declaration) =>
|
|
6831
|
+
const resolved = symbol.flags === ts10.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
6832
|
+
return (resolved.declarations ?? []).some((declaration) => ts10.isEnumDeclaration(declaration));
|
|
6531
6833
|
};
|
|
6532
6834
|
return (node) => {
|
|
6533
6835
|
const tsNode = nodeMap.get(node);
|
|
@@ -6543,18 +6845,18 @@ function detachableCallResolver(context) {
|
|
|
6543
6845
|
if (!services) return () => false;
|
|
6544
6846
|
const checker = services.program.getTypeChecker();
|
|
6545
6847
|
const { esTreeNodeToTSNodeMap: nodeMap } = services;
|
|
6546
|
-
const isUnboundFunctionType = (type) =>
|
|
6848
|
+
const isUnboundFunctionType = (type) => ts10.isFunctionTypeNode(type) && !type.parameters.some((parameter) => ts10.isIdentifier(parameter.name) && parameter.name.text === "this");
|
|
6547
6849
|
return (member) => {
|
|
6548
6850
|
const node = nodeMap.get(member);
|
|
6549
|
-
if (!node || !
|
|
6851
|
+
if (!node || !ts10.isPropertyAccessExpression(node)) return false;
|
|
6550
6852
|
const symbol = checker.getSymbolAtLocation(node.name);
|
|
6551
6853
|
const declarations = symbol?.declarations;
|
|
6552
6854
|
if (!declarations?.length) return false;
|
|
6553
6855
|
return declarations.every((declaration) => {
|
|
6554
|
-
if (
|
|
6555
|
-
return declaration.type !== void 0 && isUnboundFunctionType(declaration.type) ||
|
|
6856
|
+
if (ts10.isPropertySignature(declaration) || ts10.isPropertyDeclaration(declaration)) {
|
|
6857
|
+
return declaration.type !== void 0 && isUnboundFunctionType(declaration.type) || ts10.isPropertyDeclaration(declaration) && declaration.initializer !== void 0 && ts10.isArrowFunction(declaration.initializer);
|
|
6556
6858
|
}
|
|
6557
|
-
if (
|
|
6859
|
+
if (ts10.isPropertyAssignment(declaration)) return ts10.isArrowFunction(declaration.initializer);
|
|
6558
6860
|
return false;
|
|
6559
6861
|
});
|
|
6560
6862
|
};
|
|
@@ -6625,7 +6927,7 @@ function recordDestructuringUsage(context, scope, declaration, isEnumValue) {
|
|
|
6625
6927
|
}
|
|
6626
6928
|
function scopeUsageMessage(sourceText, propertyNames) {
|
|
6627
6929
|
const names = [...propertyNames].map((name) => `"${name}"`).join(", ");
|
|
6628
|
-
return `${names} are read from "${sourceText}" in the same block. Destructure them together in one declaration. ${
|
|
6930
|
+
return `${names} are read from "${sourceText}" in the same block. Destructure them together in one declaration. ${DOC6}`;
|
|
6629
6931
|
}
|
|
6630
6932
|
function hasBinding(context, node, name) {
|
|
6631
6933
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -6743,19 +7045,19 @@ function declarationTerminator(context, declaration) {
|
|
|
6743
7045
|
return context.sourceCode.getText(declaration).trimEnd().endsWith(";") ? ";" : "";
|
|
6744
7046
|
}
|
|
6745
7047
|
function singlePropertyMessage(binding) {
|
|
6746
|
-
return `"${binding.propertyName}" is the only property bound from "${binding.sourceText}". Read "${binding.sourceText}.${binding.propertyName}" directly instead of creating a local binding. ${
|
|
7048
|
+
return `"${binding.propertyName}" is the only property bound from "${binding.sourceText}". Read "${binding.sourceText}.${binding.propertyName}" directly instead of creating a local binding. ${DOC6}`;
|
|
6747
7049
|
}
|
|
6748
7050
|
function groupMessage(bindings) {
|
|
6749
7051
|
const firstBinding = bindings[0];
|
|
6750
|
-
if (!firstBinding) return `Use one object destructuring declaration. ${
|
|
7052
|
+
if (!firstBinding) return `Use one object destructuring declaration. ${DOC6}`;
|
|
6751
7053
|
const names = bindings.map(({ localName }) => `"${localName}"`).join(", ");
|
|
6752
|
-
return `${names} are derived directly from properties of "${firstBinding.sourceText}". Use one object destructuring declaration. ${
|
|
7054
|
+
return `${names} are derived directly from properties of "${firstBinding.sourceText}". Use one object destructuring declaration. ${DOC6}`;
|
|
6753
7055
|
}
|
|
6754
7056
|
function repeatedDestructuringMessage(group) {
|
|
6755
7057
|
const first = group[0];
|
|
6756
|
-
if (!first) return `Combine repeated destructuring into one declaration. ${
|
|
7058
|
+
if (!first) return `Combine repeated destructuring into one declaration. ${DOC6}`;
|
|
6757
7059
|
const names = group.flatMap(({ localNames }) => localNames).map((name) => `"${name}"`).join(", ");
|
|
6758
|
-
return `${names} destructure the same source "${first.sourceText}" repeatedly. Combine them into one object destructuring declaration. ${
|
|
7060
|
+
return `${names} destructure the same source "${first.sourceText}" repeatedly. Combine them into one object destructuring declaration. ${DOC6}`;
|
|
6759
7061
|
}
|
|
6760
7062
|
var preferObjectDestructuringRule = {
|
|
6761
7063
|
meta: {
|
|
@@ -6873,7 +7175,7 @@ ${indentation}`;
|
|
|
6873
7175
|
const sourceText = context.sourceCode.getText(declarator.init);
|
|
6874
7176
|
context.report({
|
|
6875
7177
|
node: declarator.id,
|
|
6876
|
-
message: `"${sourceText}" is an enum. Keep enum member accesses qualified instead of destructuring it. ${
|
|
7178
|
+
message: `"${sourceText}" is an enum. Keep enum member accesses qualified instead of destructuring it. ${DOC6}`
|
|
6877
7179
|
});
|
|
6878
7180
|
}
|
|
6879
7181
|
recordDestructuringUsage(context, currentUsageScope(), node, isEnumValue);
|
|
@@ -6974,7 +7276,7 @@ ${indentation}`;
|
|
|
6974
7276
|
};
|
|
6975
7277
|
|
|
6976
7278
|
// eslint/rules/pure-function-extract.ts
|
|
6977
|
-
import
|
|
7279
|
+
import path47 from "path";
|
|
6978
7280
|
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
6979
7281
|
"GET",
|
|
6980
7282
|
"POST",
|
|
@@ -7039,12 +7341,12 @@ var pureFunctionExtractRule = {
|
|
|
7039
7341
|
},
|
|
7040
7342
|
create(context) {
|
|
7041
7343
|
const filename = context.filename;
|
|
7042
|
-
const isRouteFile =
|
|
7344
|
+
const isRouteFile = path47.basename(filename) === "route.ts";
|
|
7043
7345
|
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
7044
7346
|
const sourceRoot = sourceRootOf(context);
|
|
7045
|
-
const relative =
|
|
7347
|
+
const relative = path47.relative(sourceRoot, filename);
|
|
7046
7348
|
if (relative.startsWith("..")) return {};
|
|
7047
|
-
const segments = relative.split(
|
|
7349
|
+
const segments = relative.split(path47.sep);
|
|
7048
7350
|
const folders = segments.slice(0, -1);
|
|
7049
7351
|
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
7050
7352
|
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
@@ -7104,16 +7406,15 @@ var pureFunctionExtractRule = {
|
|
|
7104
7406
|
};
|
|
7105
7407
|
|
|
7106
7408
|
// eslint/rules/repeated-numeric-value.ts
|
|
7107
|
-
import
|
|
7108
|
-
var ignoredValues = /* @__PURE__ */ new Set([-1, 0, 1]);
|
|
7409
|
+
import path48 from "path";
|
|
7109
7410
|
function isNonProductionFile(file, sourceRoot) {
|
|
7110
|
-
const relative =
|
|
7111
|
-
const segments = relative.split(
|
|
7112
|
-
const basename =
|
|
7411
|
+
const relative = path48.relative(sourceRoot, file);
|
|
7412
|
+
const segments = relative.split(path48.sep);
|
|
7413
|
+
const basename = path48.basename(file);
|
|
7113
7414
|
return /\.(?:test|spec|mock)\.[^.]+$/.test(basename) || segments.some((segment) => segment === "__tests__" || segment === "__mocks__" || segment === "mocks");
|
|
7114
7415
|
}
|
|
7115
7416
|
function isCanonicalConstantFile(file, sourceRoot) {
|
|
7116
|
-
const segments =
|
|
7417
|
+
const segments = path48.relative(sourceRoot, file).split(path48.sep);
|
|
7117
7418
|
return segments.includes("constants") || segments[0] === "config";
|
|
7118
7419
|
}
|
|
7119
7420
|
function groupKey(literal) {
|
|
@@ -7129,7 +7430,7 @@ var repeatedNumericValueRule = {
|
|
|
7129
7430
|
},
|
|
7130
7431
|
create(context) {
|
|
7131
7432
|
const sourceRoot = sourceRootOf(context);
|
|
7132
|
-
const file =
|
|
7433
|
+
const file = path48.resolve(context.filename);
|
|
7133
7434
|
if (isNonProductionFile(file, sourceRoot) || isCanonicalConstantFile(file, sourceRoot)) return {};
|
|
7134
7435
|
const index = getProjectIndex(sourceRoot);
|
|
7135
7436
|
if (!index) return {};
|
|
@@ -7139,7 +7440,6 @@ var repeatedNumericValueRule = {
|
|
|
7139
7440
|
for (const [moduleFile, parsedModule] of index.modules) {
|
|
7140
7441
|
if (isNonProductionFile(moduleFile, sourceRoot)) continue;
|
|
7141
7442
|
for (const literal of parsedModule.namedNumericLiterals) {
|
|
7142
|
-
if (ignoredValues.has(literal.value)) continue;
|
|
7143
7443
|
const key = groupKey(literal);
|
|
7144
7444
|
const files = filesByGroup.get(key) ?? /* @__PURE__ */ new Set();
|
|
7145
7445
|
files.add(moduleFile);
|
|
@@ -7150,7 +7450,6 @@ var repeatedNumericValueRule = {
|
|
|
7150
7450
|
Program(node) {
|
|
7151
7451
|
const reported = /* @__PURE__ */ new Set();
|
|
7152
7452
|
for (const literal of currentModule.namedNumericLiterals) {
|
|
7153
|
-
if (ignoredValues.has(literal.value)) continue;
|
|
7154
7453
|
const key = groupKey(literal);
|
|
7155
7454
|
if (reported.has(key)) continue;
|
|
7156
7455
|
const files = filesByGroup.get(key);
|
|
@@ -7168,220 +7467,10 @@ var repeatedNumericValueRule = {
|
|
|
7168
7467
|
};
|
|
7169
7468
|
|
|
7170
7469
|
// eslint/rules/repeated-semantic-literal.ts
|
|
7171
|
-
import
|
|
7172
|
-
|
|
7173
|
-
// eslint/project/semantic-literals.ts
|
|
7174
|
-
import { readFileSync as readFileSync10 } from "fs";
|
|
7175
|
-
import path47 from "path";
|
|
7176
|
-
import ts10 from "typescript";
|
|
7177
|
-
var excludedProperties = /* @__PURE__ */ new Set([
|
|
7178
|
-
"label",
|
|
7179
|
-
"title",
|
|
7180
|
-
"description",
|
|
7181
|
-
"message",
|
|
7182
|
-
"text",
|
|
7183
|
-
"placeholder",
|
|
7184
|
-
"className",
|
|
7185
|
-
"content",
|
|
7186
|
-
"alt",
|
|
7187
|
-
"src",
|
|
7188
|
-
"href",
|
|
7189
|
-
"url",
|
|
7190
|
-
"html",
|
|
7191
|
-
"ariaLabel",
|
|
7192
|
-
"testId"
|
|
7193
|
-
]);
|
|
7194
|
-
var semanticProperties = /* @__PURE__ */ new Set(["status", "phase", "event", "eventName", "action", "storageKey", "endpoint"]);
|
|
7195
|
-
var semanticVariableName = /route|path|key|status|event|timeout|delay|token|column|endpoint|limit|duration/i;
|
|
7196
|
-
var columnMethods = /* @__PURE__ */ new Set([
|
|
7197
|
-
"eq",
|
|
7198
|
-
"neq",
|
|
7199
|
-
"gt",
|
|
7200
|
-
"gte",
|
|
7201
|
-
"lt",
|
|
7202
|
-
"lte",
|
|
7203
|
-
"like",
|
|
7204
|
-
"ilike",
|
|
7205
|
-
"is",
|
|
7206
|
-
"in",
|
|
7207
|
-
"order",
|
|
7208
|
-
"filter",
|
|
7209
|
-
"not"
|
|
7210
|
-
]);
|
|
7211
|
-
var eventMethods = /* @__PURE__ */ new Set(["emit", "on", "off", "once", "addListener", "removeListener"]);
|
|
7212
|
-
var ignoredNumbers = /* @__PURE__ */ new Set([-1, 0, 1]);
|
|
7213
|
-
function isProductionSource(file, root) {
|
|
7214
|
-
const parts = path47.relative(root, file).split(path47.sep);
|
|
7215
|
-
return !(/\.(?:test|spec|mock)\.[^.]+$/.test(path47.basename(file)) || parts.some((part) => part === "__tests__" || part === "__mocks__" || part === "mocks"));
|
|
7216
|
-
}
|
|
7217
|
-
function featureOf(file, root) {
|
|
7218
|
-
const parts = path47.relative(root, file).split(path47.sep);
|
|
7219
|
-
if (parts[0] === "features" && parts[1]) return `feature:${parts[1]}`;
|
|
7220
|
-
return `layer:${parts[0] ?? "src"}`;
|
|
7221
|
-
}
|
|
7222
|
-
function nameOf(property) {
|
|
7223
|
-
if (ts10.isIdentifier(property) || ts10.isStringLiteral(property)) return property.text;
|
|
7224
|
-
return void 0;
|
|
7225
|
-
}
|
|
7226
|
-
function literalOf(node) {
|
|
7227
|
-
if (ts10.isStringLiteral(node)) return node.text;
|
|
7228
|
-
if (ts10.isNumericLiteral(node)) return Number(node.text.replaceAll("_", ""));
|
|
7229
|
-
if (ts10.isPrefixUnaryExpression(node) && node.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(node.operand)) {
|
|
7230
|
-
return -Number(node.operand.text.replaceAll("_", ""));
|
|
7231
|
-
}
|
|
7232
|
-
return void 0;
|
|
7233
|
-
}
|
|
7234
|
-
function isLiteralRoot(node) {
|
|
7235
|
-
if (ts10.isPrefixUnaryExpression(node)) return literalOf(node) !== void 0;
|
|
7236
|
-
return (ts10.isStringLiteral(node) || ts10.isNumericLiteral(node)) && !(ts10.isPrefixUnaryExpression(node.parent) && node.parent.operand === node);
|
|
7237
|
-
}
|
|
7238
|
-
function invocation(node) {
|
|
7239
|
-
if (ts10.isIdentifier(node.expression)) return { method: node.expression.text };
|
|
7240
|
-
if (ts10.isPropertyAccessExpression(node.expression)) {
|
|
7241
|
-
const receiver = node.expression.expression.getText();
|
|
7242
|
-
if (!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)?$/.test(receiver)) return void 0;
|
|
7243
|
-
return { method: node.expression.name.text, receiver };
|
|
7244
|
-
}
|
|
7245
|
-
return void 0;
|
|
7246
|
-
}
|
|
7247
|
-
function isPathname(node) {
|
|
7248
|
-
return ts10.isPropertyAccessExpression(node) && node.name.text === "pathname";
|
|
7249
|
-
}
|
|
7250
|
-
function contextFor(node, value, file, root) {
|
|
7251
|
-
if (typeof value === "number" && ignoredNumbers.has(value)) return void 0;
|
|
7252
|
-
if (typeof value === "string" && (value.length < 3 || /\s/.test(value))) return void 0;
|
|
7253
|
-
const parent = node.parent;
|
|
7254
|
-
const scope = featureOf(file, root);
|
|
7255
|
-
const isApiRoute = typeof value === "string" && value.startsWith("/api/") && !/[?&#\s]/.test(value);
|
|
7256
|
-
const route = () => ({ role: "api-route", family: "api-route" });
|
|
7257
|
-
if (ts10.isPropertyAssignment(parent) && parent.initializer === node) {
|
|
7258
|
-
const name = nameOf(parent.name);
|
|
7259
|
-
if (!name) return void 0;
|
|
7260
|
-
if (name === "path" && isApiRoute) return route();
|
|
7261
|
-
if (!semanticProperties.has(name)) return void 0;
|
|
7262
|
-
if (typeof value === "number") return void 0;
|
|
7263
|
-
if (isApiRoute && /route|path|endpoint/i.test(name)) return route();
|
|
7264
|
-
return { role: `property:${name}:${scope}`, family: `property:${name}` };
|
|
7265
|
-
}
|
|
7266
|
-
if (ts10.isVariableDeclaration(parent) && parent.initializer === node && ts10.isIdentifier(parent.name)) {
|
|
7267
|
-
if (typeof value === "number") return void 0;
|
|
7268
|
-
const name = parent.name.text;
|
|
7269
|
-
if (excludedProperties.has(name) || !semanticVariableName.test(name)) return void 0;
|
|
7270
|
-
if (isApiRoute && /route|path|endpoint/i.test(name)) return route();
|
|
7271
|
-
return { role: `variable:${name}:${scope}`, family: `variable:${name}` };
|
|
7272
|
-
}
|
|
7273
|
-
if (ts10.isCallExpression(parent)) {
|
|
7274
|
-
const position = parent.arguments.findIndex((argument) => argument === node);
|
|
7275
|
-
if (position < 0) return void 0;
|
|
7276
|
-
const call = invocation(parent);
|
|
7277
|
-
if (!call) return void 0;
|
|
7278
|
-
if (isApiRoute && position === 0 && (call.method === "fetch" || call.method === "zodFetch")) return route();
|
|
7279
|
-
if (typeof value === "number" && position === 1 && (call.method === "setTimeout" || call.method === "setInterval")) {
|
|
7280
|
-
return { role: `timer:${call.method}:${scope}`, family: "timer" };
|
|
7281
|
-
}
|
|
7282
|
-
if (typeof value === "string" && position === 0 && call.receiver && (call.receiver === "localStorage" || call.receiver === "sessionStorage") && ["getItem", "setItem", "removeItem"].includes(call.method)) {
|
|
7283
|
-
return { role: `storage:${call.receiver}`, family: "storage" };
|
|
7284
|
-
}
|
|
7285
|
-
if (typeof value === "string" && position === 0 && call.receiver && eventMethods.has(call.method) && /(?:event|bus|socket|emitter)/i.test(call.receiver)) {
|
|
7286
|
-
return { role: `event:${call.receiver}`, family: "event" };
|
|
7287
|
-
}
|
|
7288
|
-
if (typeof value === "string" && position === 0 && call.receiver && columnMethods.has(call.method) && value.length > 3 && /^[a-z][a-z0-9_]*$/.test(value)) {
|
|
7289
|
-
return { role: `column:${scope}`, family: "column" };
|
|
7290
|
-
}
|
|
7291
|
-
}
|
|
7292
|
-
if (isApiRoute && ts10.isBinaryExpression(parent) && (parent.operatorToken.kind === ts10.SyntaxKind.EqualsEqualsEqualsToken || parent.operatorToken.kind === ts10.SyntaxKind.ExclamationEqualsEqualsToken) && (parent.left === node && isPathname(parent.right) || parent.right === node && isPathname(parent.left))) {
|
|
7293
|
-
return route();
|
|
7294
|
-
}
|
|
7295
|
-
if (isApiRoute && ts10.isCallExpression(parent) && parent.arguments[0] === node && ts10.isPropertyAccessExpression(parent.expression) && parent.expression.name.text === "startsWith" && isPathname(parent.expression.expression)) {
|
|
7296
|
-
return route();
|
|
7297
|
-
}
|
|
7298
|
-
return void 0;
|
|
7299
|
-
}
|
|
7300
|
-
function isExported2(node) {
|
|
7301
|
-
return ts10.canHaveModifiers(node) && (ts10.getModifiers(node) ?? []).some((modifier) => modifier.kind === ts10.SyntaxKind.ExportKeyword);
|
|
7302
|
-
}
|
|
7303
|
-
function parse(file, root, output) {
|
|
7304
|
-
if (!isProductionSource(file, root)) return;
|
|
7305
|
-
const source = ts10.createSourceFile(
|
|
7306
|
-
file,
|
|
7307
|
-
readFileSync10(file, "utf8"),
|
|
7308
|
-
ts10.ScriptTarget.Latest,
|
|
7309
|
-
true,
|
|
7310
|
-
file.endsWith(".tsx") || file.endsWith(".jsx") ? ts10.ScriptKind.TSX : ts10.ScriptKind.TS
|
|
7311
|
-
);
|
|
7312
|
-
const inConstants = path47.relative(root, file).split(path47.sep).includes("constants");
|
|
7313
|
-
for (const statement of source.statements) {
|
|
7314
|
-
if (inConstants && ts10.isEnumDeclaration(statement) && isExported2(statement)) {
|
|
7315
|
-
for (const member of statement.members) {
|
|
7316
|
-
const value = member.initializer && literalOf(member.initializer);
|
|
7317
|
-
const memberName9 = nameOf(member.name);
|
|
7318
|
-
if (value === void 0 || !memberName9) continue;
|
|
7319
|
-
output.canonicals.push({
|
|
7320
|
-
file,
|
|
7321
|
-
name: memberName9,
|
|
7322
|
-
owner: statement.name.text,
|
|
7323
|
-
kind: typeof value === "string" ? "string" : "number",
|
|
7324
|
-
value
|
|
7325
|
-
});
|
|
7326
|
-
}
|
|
7327
|
-
}
|
|
7328
|
-
if (inConstants && ts10.isVariableStatement(statement) && isExported2(statement)) {
|
|
7329
|
-
for (const declaration of statement.declarationList.declarations) {
|
|
7330
|
-
if (!ts10.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
7331
|
-
const value = literalOf(declaration.initializer);
|
|
7332
|
-
if (value === void 0) continue;
|
|
7333
|
-
output.canonicals.push({
|
|
7334
|
-
file,
|
|
7335
|
-
name: declaration.name.text,
|
|
7336
|
-
kind: typeof value === "string" ? "string" : "number",
|
|
7337
|
-
value
|
|
7338
|
-
});
|
|
7339
|
-
}
|
|
7340
|
-
}
|
|
7341
|
-
}
|
|
7342
|
-
const visit = (node) => {
|
|
7343
|
-
if (isLiteralRoot(node)) {
|
|
7344
|
-
const value = literalOf(node);
|
|
7345
|
-
if (value !== void 0) {
|
|
7346
|
-
const semantic = contextFor(node, value, file, root);
|
|
7347
|
-
if (semantic) {
|
|
7348
|
-
const declaration = node.parent;
|
|
7349
|
-
const isCanonicalDefinition = inConstants && (ts10.isVariableDeclaration(declaration) && ts10.isVariableStatement(declaration.parent.parent) && isExported2(declaration.parent.parent) || ts10.isEnumMember(declaration));
|
|
7350
|
-
if ((!inConstants || semantic.family === "api-route") && !isCanonicalDefinition) {
|
|
7351
|
-
const position = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
7352
|
-
output.uses.push({
|
|
7353
|
-
file,
|
|
7354
|
-
kind: typeof value === "string" ? "string" : "number",
|
|
7355
|
-
value,
|
|
7356
|
-
line: position.line + 1,
|
|
7357
|
-
column: position.character,
|
|
7358
|
-
...semantic
|
|
7359
|
-
});
|
|
7360
|
-
}
|
|
7361
|
-
}
|
|
7362
|
-
}
|
|
7363
|
-
}
|
|
7364
|
-
ts10.forEachChild(node, visit);
|
|
7365
|
-
};
|
|
7366
|
-
visit(source);
|
|
7367
|
-
}
|
|
7368
|
-
var cache3 = /* @__PURE__ */ new WeakMap();
|
|
7369
|
-
function getSemanticLiteralIndex(index) {
|
|
7370
|
-
const previous = cache3.get(index);
|
|
7371
|
-
if (previous) return previous;
|
|
7372
|
-
const result = { uses: [], canonicals: [] };
|
|
7373
|
-
for (const file of index.modules.keys()) {
|
|
7374
|
-
try {
|
|
7375
|
-
parse(file, index.sourceRoot, result);
|
|
7376
|
-
} catch {
|
|
7377
|
-
}
|
|
7378
|
-
}
|
|
7379
|
-
cache3.set(index, result);
|
|
7380
|
-
return result;
|
|
7381
|
-
}
|
|
7470
|
+
import path50 from "path";
|
|
7382
7471
|
|
|
7383
7472
|
// eslint/rules/imported-enum-literals.ts
|
|
7384
|
-
import
|
|
7473
|
+
import path49 from "path";
|
|
7385
7474
|
import ts11 from "typescript";
|
|
7386
7475
|
var columnMethods2 = /* @__PURE__ */ new Set([
|
|
7387
7476
|
"eq",
|
|
@@ -7403,8 +7492,8 @@ function memberName6(name) {
|
|
|
7403
7492
|
return void 0;
|
|
7404
7493
|
}
|
|
7405
7494
|
function isWithin3(root, file) {
|
|
7406
|
-
const relative =
|
|
7407
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
7495
|
+
const relative = path49.relative(root, file);
|
|
7496
|
+
return relative === "" || !relative.startsWith("..") && !path49.isAbsolute(relative);
|
|
7408
7497
|
}
|
|
7409
7498
|
function domainOf(name) {
|
|
7410
7499
|
if (name.endsWith("ColumnEnum")) return "column";
|
|
@@ -7424,7 +7513,7 @@ function importedEnums(file, checker, sourceRoot, importedNames) {
|
|
|
7424
7513
|
const resolved = symbol.flags === ts11.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
7425
7514
|
for (const declaration of resolved.declarations ?? []) {
|
|
7426
7515
|
if (!ts11.isEnumDeclaration(declaration)) continue;
|
|
7427
|
-
const declarationFile =
|
|
7516
|
+
const declarationFile = path49.resolve(declaration.getSourceFile().fileName);
|
|
7428
7517
|
if (!isWithin3(sourceRoot, declarationFile)) continue;
|
|
7429
7518
|
const domain = domainOf(declaration.name.text);
|
|
7430
7519
|
if (!domain) continue;
|
|
@@ -7464,7 +7553,7 @@ function domainForUse(node) {
|
|
|
7464
7553
|
return void 0;
|
|
7465
7554
|
}
|
|
7466
7555
|
function importedEnumLiteralUses(context, root) {
|
|
7467
|
-
const filename =
|
|
7556
|
+
const filename = path49.resolve(context.filename);
|
|
7468
7557
|
if (!isWithin3(root, filename)) return [];
|
|
7469
7558
|
const services = typedParserServices(context.sourceCode.parserServices);
|
|
7470
7559
|
if (!services) return [];
|
|
@@ -7504,7 +7593,8 @@ function importedEnumLiteralUses(context, root) {
|
|
|
7504
7593
|
}
|
|
7505
7594
|
|
|
7506
7595
|
// eslint/rules/repeated-semantic-literal.ts
|
|
7507
|
-
var
|
|
7596
|
+
var DOC7 = "See docs/next-codebase-guide/rules/constants-rule.md";
|
|
7597
|
+
var closedDomainFamilies = /* @__PURE__ */ new Set(["api-route", "event", "storage"]);
|
|
7508
7598
|
function canonicalMatches(use, canonical, sourceRoot) {
|
|
7509
7599
|
if (use.kind !== canonical.kind || use.value !== canonical.value) return false;
|
|
7510
7600
|
const name = canonical.owner ?? canonical.name;
|
|
@@ -7517,7 +7607,7 @@ function canonicalMatches(use, canonical, sourceRoot) {
|
|
|
7517
7607
|
const semanticName2 = use.family.split(":")[1];
|
|
7518
7608
|
if (!semanticName2 || !name.toLowerCase().includes(semanticName2.toLowerCase())) return false;
|
|
7519
7609
|
const location = featureOf(canonical.file, sourceRoot);
|
|
7520
|
-
return location === featureOf(use.file, sourceRoot) ||
|
|
7610
|
+
return location === featureOf(use.file, sourceRoot) || path50.relative(sourceRoot, canonical.file).split(path50.sep)[0] === "constants";
|
|
7521
7611
|
}
|
|
7522
7612
|
return false;
|
|
7523
7613
|
}
|
|
@@ -7531,14 +7621,14 @@ function messageFor(use, matches, duplicateRouteDomains, existingRouteEnum, root
|
|
|
7531
7621
|
const count = new Set(matches.map((match) => match.file)).size;
|
|
7532
7622
|
const kind = use.kind === "string" ? "string" : "numeric";
|
|
7533
7623
|
if (use.family === "api-route" && existingRouteEnum?.owner) {
|
|
7534
|
-
const location =
|
|
7535
|
-
return `The route ${formatValue(use)} repeats; add a member to existing ${existingRouteEnum.owner} in src/${location} and reuse it. ${
|
|
7624
|
+
const location = path50.relative(root, existingRouteEnum.file).replaceAll(path50.sep, "/");
|
|
7625
|
+
return `The route ${formatValue(use)} repeats; add a member to existing ${existingRouteEnum.owner} in src/${location} and reuse it. ${DOC7}`;
|
|
7536
7626
|
}
|
|
7537
7627
|
if (count === 1) {
|
|
7538
|
-
return `The ${kind} literal ${formatValue(use)} repeats in the same semantic role in this file. Extract a file-local const. ${
|
|
7628
|
+
return `The ${kind} literal ${formatValue(use)} repeats in the same semantic role in this file. Extract a file-local const. ${DOC7}`;
|
|
7539
7629
|
}
|
|
7540
7630
|
const placement = use.family === "api-route" && duplicateRouteDomains.has(use.role) ? "a shared enum for this closed route domain" : "one shared const";
|
|
7541
|
-
return `The ${kind} literal ${formatValue(use)} repeats in ${String(count)} production files for the same semantic role. Extract ${placement} at the consumers' CCF and import it. ${
|
|
7631
|
+
return `The ${kind} literal ${formatValue(use)} repeats in ${String(count)} production files for the same semantic role. Extract ${placement} at the consumers' CCF and import it. ${DOC7}`;
|
|
7542
7632
|
}
|
|
7543
7633
|
var repeatedSemanticLiteralRule = {
|
|
7544
7634
|
meta: {
|
|
@@ -7550,7 +7640,7 @@ var repeatedSemanticLiteralRule = {
|
|
|
7550
7640
|
},
|
|
7551
7641
|
create(context) {
|
|
7552
7642
|
const root = sourceRootOf(context);
|
|
7553
|
-
const file =
|
|
7643
|
+
const file = path50.resolve(context.filename);
|
|
7554
7644
|
if (!isProductionSource(file, root)) return {};
|
|
7555
7645
|
const project = getProjectIndex(root);
|
|
7556
7646
|
if (!project?.modules.has(file)) return {};
|
|
@@ -7577,6 +7667,13 @@ var repeatedSemanticLiteralRule = {
|
|
|
7577
7667
|
for (const [role, values] of routeValues) {
|
|
7578
7668
|
if (values.size >= 2) duplicatedApiRoutes.add(role);
|
|
7579
7669
|
}
|
|
7670
|
+
const closedDomains = /* @__PURE__ */ new Map();
|
|
7671
|
+
for (const use of index.uses) {
|
|
7672
|
+
if (use.kind !== "string" || !closedDomainFamilies.has(use.family)) continue;
|
|
7673
|
+
const values = closedDomains.get(use.role) ?? /* @__PURE__ */ new Set();
|
|
7674
|
+
values.add(String(use.value));
|
|
7675
|
+
closedDomains.set(use.role, values);
|
|
7676
|
+
}
|
|
7580
7677
|
const routeDomains = /* @__PURE__ */ new Map();
|
|
7581
7678
|
for (const canonical of index.canonicals) {
|
|
7582
7679
|
if (canonical.owner && /^ApiRoute(?:Enum)?$/.test(canonical.owner)) {
|
|
@@ -7588,11 +7685,11 @@ var repeatedSemanticLiteralRule = {
|
|
|
7588
7685
|
return {
|
|
7589
7686
|
Program(node) {
|
|
7590
7687
|
for (const use of imported) {
|
|
7591
|
-
const relative =
|
|
7688
|
+
const relative = path50.relative(root, use.sourceFile).replaceAll(path50.sep, "/");
|
|
7592
7689
|
context.report({
|
|
7593
7690
|
node,
|
|
7594
7691
|
loc: { line: use.line, column: use.column },
|
|
7595
|
-
message: `Reuse ${use.reference} from src/${relative} instead of raw ${JSON.stringify(use.value)}. ${
|
|
7692
|
+
message: `Reuse ${use.reference} from src/${relative} instead of raw ${JSON.stringify(use.value)}. ${DOC7}`
|
|
7596
7693
|
});
|
|
7597
7694
|
}
|
|
7598
7695
|
for (const use of current) {
|
|
@@ -7603,18 +7700,37 @@ var repeatedSemanticLiteralRule = {
|
|
|
7603
7700
|
if (candidates.length === 1) {
|
|
7604
7701
|
const canonical = candidates[0];
|
|
7605
7702
|
if (!canonical) continue;
|
|
7606
|
-
const relative =
|
|
7703
|
+
const relative = path50.relative(root, canonical.file).replaceAll(path50.sep, "/");
|
|
7607
7704
|
context.report({
|
|
7608
7705
|
node,
|
|
7609
7706
|
loc: { line: use.line, column: use.column },
|
|
7610
|
-
message: `Reuse ${canonicalName(canonical)} from src/${relative} instead of raw ${formatValue(use)}. ${
|
|
7707
|
+
message: `Reuse ${canonicalName(canonical)} from src/${relative} instead of raw ${formatValue(use)}. ${DOC7}`
|
|
7611
7708
|
});
|
|
7612
7709
|
continue;
|
|
7613
7710
|
}
|
|
7614
7711
|
if (candidates.length > 1) continue;
|
|
7615
7712
|
const key = `${use.kind}\0${String(use.value)}\0${use.role}`;
|
|
7616
7713
|
const peers = groups.get(key) ?? [];
|
|
7617
|
-
if (peers.length < 2)
|
|
7714
|
+
if (peers.length < 2) {
|
|
7715
|
+
if (use.family === "api-route" && existingRouteEnum?.owner) {
|
|
7716
|
+
const location = path50.relative(root, existingRouteEnum.file).replaceAll(path50.sep, "/");
|
|
7717
|
+
context.report({
|
|
7718
|
+
node,
|
|
7719
|
+
loc: { line: use.line, column: use.column },
|
|
7720
|
+
message: `The route ${formatValue(use)} belongs to existing ${existingRouteEnum.owner}; add a member in src/${location} and reuse it. ${DOC7}`
|
|
7721
|
+
});
|
|
7722
|
+
continue;
|
|
7723
|
+
}
|
|
7724
|
+
const domain = closedDomains.get(use.role);
|
|
7725
|
+
if (domain && domain.size >= 2) {
|
|
7726
|
+
context.report({
|
|
7727
|
+
node,
|
|
7728
|
+
loc: { line: use.line, column: use.column },
|
|
7729
|
+
message: `The string literal ${formatValue(use)} is one of ${String(domain.size)} values in a closed ${use.family} domain. Declare the domain in a shared enum at the consumers' CCF and reuse it. ${DOC7}`
|
|
7730
|
+
});
|
|
7731
|
+
}
|
|
7732
|
+
continue;
|
|
7733
|
+
}
|
|
7618
7734
|
if (use.kind === "number" && !use.family.startsWith("timer")) continue;
|
|
7619
7735
|
context.report({
|
|
7620
7736
|
node,
|
|
@@ -7809,7 +7925,7 @@ var repeatedStructureRule = {
|
|
|
7809
7925
|
|
|
7810
7926
|
// eslint/rules/require-barrel-star-exports.ts
|
|
7811
7927
|
import fs5 from "fs";
|
|
7812
|
-
import
|
|
7928
|
+
import path51 from "path";
|
|
7813
7929
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
7814
7930
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
7815
7931
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
@@ -7817,9 +7933,9 @@ function resolveSiblingModule(indexFile, specifier) {
|
|
|
7817
7933
|
if (!specifier.startsWith("./")) return void 0;
|
|
7818
7934
|
const relative = specifier.slice(2);
|
|
7819
7935
|
if (!relative || relative.includes("/")) return void 0;
|
|
7820
|
-
const directory =
|
|
7821
|
-
const direct =
|
|
7822
|
-
const candidates =
|
|
7936
|
+
const directory = path51.dirname(indexFile);
|
|
7937
|
+
const direct = path51.resolve(directory, relative);
|
|
7938
|
+
const candidates = path51.extname(direct) ? [direct] : MODULE_EXTENSIONS3.map((extension) => `${direct}${extension}`);
|
|
7823
7939
|
return candidates.find((candidate) => fs5.existsSync(candidate) && fs5.statSync(candidate).isFile());
|
|
7824
7940
|
}
|
|
7825
7941
|
var requireBarrelStarExportsRule = {
|
|
@@ -7832,9 +7948,9 @@ var requireBarrelStarExportsRule = {
|
|
|
7832
7948
|
fixable: "code"
|
|
7833
7949
|
},
|
|
7834
7950
|
create(context) {
|
|
7835
|
-
const filename =
|
|
7836
|
-
if (!INDEX_NAMES.has(
|
|
7837
|
-
if (!SUPPORT_FOLDERS3.has(
|
|
7951
|
+
const filename = path51.resolve(context.filename);
|
|
7952
|
+
if (!INDEX_NAMES.has(path51.basename(filename))) return {};
|
|
7953
|
+
if (!SUPPORT_FOLDERS3.has(path51.basename(path51.dirname(filename)))) return {};
|
|
7838
7954
|
return {
|
|
7839
7955
|
ExportNamedDeclaration(node) {
|
|
7840
7956
|
const sourceNode = node.source;
|
|
@@ -7887,7 +8003,7 @@ var requireBarrelStarExportsRule = {
|
|
|
7887
8003
|
};
|
|
7888
8004
|
|
|
7889
8005
|
// eslint/rules/root-support-placement.ts
|
|
7890
|
-
import
|
|
8006
|
+
import path52 from "path";
|
|
7891
8007
|
function isSupportFolder(value) {
|
|
7892
8008
|
return value === "utils" || value === "types" || value === "schemas" || value === "constants";
|
|
7893
8009
|
}
|
|
@@ -7920,7 +8036,7 @@ var rootSupportPlacementRule = {
|
|
|
7920
8036
|
},
|
|
7921
8037
|
create(context) {
|
|
7922
8038
|
const sourceRoot = sourceRootOf(context);
|
|
7923
|
-
const file =
|
|
8039
|
+
const file = path52.resolve(context.filename);
|
|
7924
8040
|
const segments = segmentsOf(file, sourceRoot);
|
|
7925
8041
|
const folderSegments = folderSegmentsOf(file, sourceRoot);
|
|
7926
8042
|
const supportFolder = folderSegments[folderSegments.length - 1];
|
|
@@ -7966,7 +8082,7 @@ var rootSupportPlacementRule = {
|
|
|
7966
8082
|
};
|
|
7967
8083
|
|
|
7968
8084
|
// eslint/rules/route-handler-shape.ts
|
|
7969
|
-
import
|
|
8085
|
+
import path53 from "path";
|
|
7970
8086
|
import ts12 from "typescript";
|
|
7971
8087
|
var HTTP_METHODS2 = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
7972
8088
|
var REQUIRED_BOUNDARY = "withResponse";
|
|
@@ -8051,7 +8167,7 @@ var routeHandlerShapeRule = {
|
|
|
8051
8167
|
}
|
|
8052
8168
|
},
|
|
8053
8169
|
create(context) {
|
|
8054
|
-
if (
|
|
8170
|
+
if (path53.basename(context.filename) !== "route.ts") return {};
|
|
8055
8171
|
const sourceText = context.sourceCode.text;
|
|
8056
8172
|
function reportUnwrapped(node, name) {
|
|
8057
8173
|
context.report({
|
|
@@ -8110,7 +8226,7 @@ var routeHandlerShapeRule = {
|
|
|
8110
8226
|
};
|
|
8111
8227
|
|
|
8112
8228
|
// eslint/rules/schema-casing.ts
|
|
8113
|
-
import
|
|
8229
|
+
import path54 from "path";
|
|
8114
8230
|
function isCamelCase(name) {
|
|
8115
8231
|
return /^[a-z][a-zA-Z0-9]*$/.test(name);
|
|
8116
8232
|
}
|
|
@@ -8138,9 +8254,9 @@ var schemaCasingRule = {
|
|
|
8138
8254
|
}
|
|
8139
8255
|
},
|
|
8140
8256
|
create(context) {
|
|
8141
|
-
const filename =
|
|
8257
|
+
const filename = path54.resolve(context.filename);
|
|
8142
8258
|
const sourceRoot = sourceRootOf(context);
|
|
8143
|
-
if (!filename.startsWith(sourceRoot +
|
|
8259
|
+
if (!filename.startsWith(sourceRoot + path54.sep)) return {};
|
|
8144
8260
|
let zodLocalName;
|
|
8145
8261
|
return {
|
|
8146
8262
|
ImportDeclaration(node) {
|
|
@@ -8172,7 +8288,7 @@ var schemaCasingRule = {
|
|
|
8172
8288
|
};
|
|
8173
8289
|
|
|
8174
8290
|
// eslint/rules/sole-state-owner.ts
|
|
8175
|
-
import
|
|
8291
|
+
import path55 from "path";
|
|
8176
8292
|
import ts13 from "typescript";
|
|
8177
8293
|
function findStateHooks(node) {
|
|
8178
8294
|
const hooks = [];
|
|
@@ -8252,7 +8368,7 @@ var soleStateOwnerRule = {
|
|
|
8252
8368
|
}
|
|
8253
8369
|
},
|
|
8254
8370
|
create(context) {
|
|
8255
|
-
const filename =
|
|
8371
|
+
const filename = path55.resolve(context.filename);
|
|
8256
8372
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
8257
8373
|
const text = context.sourceCode.text;
|
|
8258
8374
|
const components = parseComponentInfo(text, filename);
|
|
@@ -8331,7 +8447,7 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
8331
8447
|
}
|
|
8332
8448
|
|
|
8333
8449
|
// eslint/rules/source-under-src.ts
|
|
8334
|
-
import
|
|
8450
|
+
import path56 from "path";
|
|
8335
8451
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
8336
8452
|
".agents",
|
|
8337
8453
|
".cache",
|
|
@@ -8372,14 +8488,14 @@ var sourceUnderSrcRule = {
|
|
|
8372
8488
|
}
|
|
8373
8489
|
},
|
|
8374
8490
|
create(context) {
|
|
8375
|
-
const filename =
|
|
8491
|
+
const filename = path56.resolve(context.filename);
|
|
8376
8492
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
8377
|
-
const relative =
|
|
8493
|
+
const relative = path56.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
8378
8494
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
8379
8495
|
const topLevel = relative.split("/")[0] ?? "";
|
|
8380
8496
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
8381
8497
|
if (!relative.includes("/")) {
|
|
8382
|
-
const basename =
|
|
8498
|
+
const basename = path56.basename(filename);
|
|
8383
8499
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
8384
8500
|
}
|
|
8385
8501
|
return {
|
|
@@ -8395,7 +8511,7 @@ var sourceUnderSrcRule = {
|
|
|
8395
8511
|
};
|
|
8396
8512
|
|
|
8397
8513
|
// eslint/rules/stay-flat.ts
|
|
8398
|
-
import
|
|
8514
|
+
import path57 from "path";
|
|
8399
8515
|
var stayFlatRule = {
|
|
8400
8516
|
meta: {
|
|
8401
8517
|
schema: [],
|
|
@@ -8406,7 +8522,7 @@ var stayFlatRule = {
|
|
|
8406
8522
|
},
|
|
8407
8523
|
create(context) {
|
|
8408
8524
|
const sourceRoot = sourceRootOf(context);
|
|
8409
|
-
const file =
|
|
8525
|
+
const file = path57.resolve(context.filename);
|
|
8410
8526
|
const segments = segmentsOf(file, sourceRoot);
|
|
8411
8527
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
8412
8528
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -8446,7 +8562,7 @@ var stayFlatRule = {
|
|
|
8446
8562
|
};
|
|
8447
8563
|
|
|
8448
8564
|
// eslint/rules/support-file-placement.ts
|
|
8449
|
-
import
|
|
8565
|
+
import path58 from "path";
|
|
8450
8566
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
8451
8567
|
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
8452
8568
|
["constants", "constant"],
|
|
@@ -8471,7 +8587,7 @@ var supportFilePlacementRule = {
|
|
|
8471
8587
|
},
|
|
8472
8588
|
create(context) {
|
|
8473
8589
|
const sourceRoot = sourceRootOf(context);
|
|
8474
|
-
const supportFile =
|
|
8590
|
+
const supportFile = path58.resolve(context.filename);
|
|
8475
8591
|
const currentFolder = folderSegmentsOf(supportFile, sourceRoot);
|
|
8476
8592
|
const supportFolder = currentFolder[currentFolder.length - 1];
|
|
8477
8593
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS.has(supportFolder)) return {};
|
|
@@ -8525,7 +8641,7 @@ var supportFilePlacementRule = {
|
|
|
8525
8641
|
|
|
8526
8642
|
// eslint/rules/support-folder-shape.ts
|
|
8527
8643
|
import fs6 from "fs";
|
|
8528
|
-
import
|
|
8644
|
+
import path59 from "path";
|
|
8529
8645
|
var SUPPORT_FOLDERS4 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
8530
8646
|
var INDEX_NAMES2 = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
8531
8647
|
var supportFolderShapeRule = {
|
|
@@ -8537,12 +8653,12 @@ var supportFolderShapeRule = {
|
|
|
8537
8653
|
}
|
|
8538
8654
|
},
|
|
8539
8655
|
create(context) {
|
|
8540
|
-
const filename =
|
|
8541
|
-
const baseName =
|
|
8656
|
+
const filename = path59.resolve(context.filename);
|
|
8657
|
+
const baseName = path59.basename(filename);
|
|
8542
8658
|
if (!INDEX_NAMES2.has(baseName)) return {};
|
|
8543
|
-
const folder =
|
|
8659
|
+
const folder = path59.basename(path59.dirname(filename));
|
|
8544
8660
|
if (!SUPPORT_FOLDERS4.has(folder)) return {};
|
|
8545
|
-
const directory =
|
|
8661
|
+
const directory = path59.dirname(filename);
|
|
8546
8662
|
let entries;
|
|
8547
8663
|
try {
|
|
8548
8664
|
entries = fs6.readdirSync(directory);
|
|
@@ -8560,7 +8676,7 @@ var supportFolderShapeRule = {
|
|
|
8560
8676
|
for (const match of source.matchAll(exportPattern)) {
|
|
8561
8677
|
hasAnyReExport = true;
|
|
8562
8678
|
const specifier = match.groups?.specifier;
|
|
8563
|
-
if (specifier?.startsWith(".")) exportedFiles.add(
|
|
8679
|
+
if (specifier?.startsWith(".")) exportedFiles.add(path59.basename(specifier));
|
|
8564
8680
|
}
|
|
8565
8681
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
8566
8682
|
if (siblingModules.length === 0) {
|
|
@@ -8739,11 +8855,11 @@ var baseLayerPairRule = {
|
|
|
8739
8855
|
|
|
8740
8856
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
8741
8857
|
import { statSync as statSync4 } from "fs";
|
|
8742
|
-
import
|
|
8858
|
+
import path62 from "path";
|
|
8743
8859
|
|
|
8744
8860
|
// eslint/rules/tailwind/source-files.ts
|
|
8745
8861
|
import { readdirSync as readdirSync3, readFileSync as readFileSync11, statSync as statSync3 } from "fs";
|
|
8746
|
-
import
|
|
8862
|
+
import path60 from "path";
|
|
8747
8863
|
var CSS_EXTENSIONS = [".css"];
|
|
8748
8864
|
var MODULE_EXTENSIONS4 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
8749
8865
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS4, ...CSS_EXTENSIONS];
|
|
@@ -8756,7 +8872,7 @@ function findFiles(dir, extensions) {
|
|
|
8756
8872
|
}
|
|
8757
8873
|
return entries.flatMap((entry) => {
|
|
8758
8874
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
8759
|
-
const entryPath =
|
|
8875
|
+
const entryPath = path60.join(dir, entry);
|
|
8760
8876
|
let stats;
|
|
8761
8877
|
try {
|
|
8762
8878
|
stats = statSync3(entryPath);
|
|
@@ -8764,7 +8880,7 @@ function findFiles(dir, extensions) {
|
|
|
8764
8880
|
return [];
|
|
8765
8881
|
}
|
|
8766
8882
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
8767
|
-
return extensions.includes(
|
|
8883
|
+
return extensions.includes(path60.extname(entry)) ? [entryPath] : [];
|
|
8768
8884
|
});
|
|
8769
8885
|
}
|
|
8770
8886
|
function cachedTextReader() {
|
|
@@ -8787,7 +8903,7 @@ function escapeRegExp(text) {
|
|
|
8787
8903
|
}
|
|
8788
8904
|
|
|
8789
8905
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
8790
|
-
import
|
|
8906
|
+
import path61 from "path";
|
|
8791
8907
|
function registersTailwind(text) {
|
|
8792
8908
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
8793
8909
|
}
|
|
@@ -8801,25 +8917,25 @@ function moduleImports(text, fileName) {
|
|
|
8801
8917
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
8802
8918
|
}
|
|
8803
8919
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
8804
|
-
if (spec.startsWith("/")) return
|
|
8805
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
8806
|
-
if (spec.startsWith("@/")) return
|
|
8920
|
+
if (spec.startsWith("/")) return path61.resolve(spec);
|
|
8921
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path61.resolve(path61.dirname(fromFile), spec);
|
|
8922
|
+
if (spec.startsWith("@/")) return path61.resolve(sourceRoot, spec.slice(2));
|
|
8807
8923
|
return void 0;
|
|
8808
8924
|
}
|
|
8809
8925
|
function buildStylesheetGraph(options) {
|
|
8810
8926
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
8811
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
8927
|
+
const cssSet = new Set(cssFiles.map((file) => path61.normalize(file)));
|
|
8812
8928
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
8813
8929
|
const reachable = /* @__PURE__ */ new Set();
|
|
8814
8930
|
const queue = [...globals];
|
|
8815
|
-
for (const global of globals) reachable.add(
|
|
8931
|
+
for (const global of globals) reachable.add(path61.normalize(global));
|
|
8816
8932
|
while (queue.length > 0) {
|
|
8817
8933
|
const from = queue.shift();
|
|
8818
8934
|
if (!from) continue;
|
|
8819
8935
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
8820
8936
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
8821
8937
|
if (!target) continue;
|
|
8822
|
-
const normalized =
|
|
8938
|
+
const normalized = path61.normalize(target);
|
|
8823
8939
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
8824
8940
|
reachable.add(normalized);
|
|
8825
8941
|
queue.push(normalized);
|
|
@@ -8831,7 +8947,7 @@ function buildStylesheetGraph(options) {
|
|
|
8831
8947
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
8832
8948
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
8833
8949
|
if (!target) continue;
|
|
8834
|
-
const normalized =
|
|
8950
|
+
const normalized = path61.normalize(target);
|
|
8835
8951
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
8836
8952
|
}
|
|
8837
8953
|
}
|
|
@@ -8839,8 +8955,8 @@ function buildStylesheetGraph(options) {
|
|
|
8839
8955
|
}
|
|
8840
8956
|
|
|
8841
8957
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
8842
|
-
var APP_STYLES_DIR =
|
|
8843
|
-
var GLOBAL_STYLESHEET_PATH =
|
|
8958
|
+
var APP_STYLES_DIR = path62.join("app", "styles");
|
|
8959
|
+
var GLOBAL_STYLESHEET_PATH = path62.join(APP_STYLES_DIR, "globals.css");
|
|
8844
8960
|
var cssEntryPointRule = {
|
|
8845
8961
|
meta: {
|
|
8846
8962
|
schema: [],
|
|
@@ -8866,8 +8982,8 @@ var cssEntryPointRule = {
|
|
|
8866
8982
|
return {
|
|
8867
8983
|
"StyleSheet:exit"(node) {
|
|
8868
8984
|
if (globals.length === 0) return;
|
|
8869
|
-
const current =
|
|
8870
|
-
const relative =
|
|
8985
|
+
const current = path62.normalize(path62.resolve(context.filename));
|
|
8986
|
+
const relative = path62.relative(sourceRoot, current);
|
|
8871
8987
|
if (globals.includes(current)) {
|
|
8872
8988
|
if (globals.length > 1) {
|
|
8873
8989
|
context.report({
|
|
@@ -8883,7 +8999,7 @@ var cssEntryPointRule = {
|
|
|
8883
8999
|
});
|
|
8884
9000
|
return;
|
|
8885
9001
|
}
|
|
8886
|
-
const basename =
|
|
9002
|
+
const basename = path62.basename(current);
|
|
8887
9003
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
8888
9004
|
if (importCount !== 1) {
|
|
8889
9005
|
context.report({
|
|
@@ -8893,7 +9009,7 @@ var cssEntryPointRule = {
|
|
|
8893
9009
|
}
|
|
8894
9010
|
return;
|
|
8895
9011
|
}
|
|
8896
|
-
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${
|
|
9012
|
+
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${path62.sep}`);
|
|
8897
9013
|
if (!isInAppStyles) {
|
|
8898
9014
|
context.report({
|
|
8899
9015
|
node,
|
|
@@ -9382,7 +9498,7 @@ var tailwindRules = {
|
|
|
9382
9498
|
};
|
|
9383
9499
|
|
|
9384
9500
|
// eslint/rules/type-extraction.ts
|
|
9385
|
-
import
|
|
9501
|
+
import path63 from "path";
|
|
9386
9502
|
var typeExtractionRule = {
|
|
9387
9503
|
meta: {
|
|
9388
9504
|
schema: [],
|
|
@@ -9393,7 +9509,7 @@ var typeExtractionRule = {
|
|
|
9393
9509
|
},
|
|
9394
9510
|
create(context) {
|
|
9395
9511
|
const sourceRoot = sourceRootOf(context);
|
|
9396
|
-
const file =
|
|
9512
|
+
const file = path63.resolve(context.filename);
|
|
9397
9513
|
const segments = segmentsOf(file, sourceRoot);
|
|
9398
9514
|
if (segments.length === 0) return {};
|
|
9399
9515
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -9534,7 +9650,7 @@ var uiStateRule = {
|
|
|
9534
9650
|
// eslint/rules/unknown-utility.ts
|
|
9535
9651
|
import { existsSync as existsSync6, readdirSync as readdirSync4, readFileSync as readFileSync12, statSync as statSync6 } from "fs";
|
|
9536
9652
|
import { createRequire } from "module";
|
|
9537
|
-
import
|
|
9653
|
+
import path64 from "path";
|
|
9538
9654
|
var PREFIX_NAMESPACES = {
|
|
9539
9655
|
bg: ["color"],
|
|
9540
9656
|
text: ["color", "text"],
|
|
@@ -9774,7 +9890,7 @@ function stylesheetFiles(dir) {
|
|
|
9774
9890
|
}
|
|
9775
9891
|
return entries.flatMap((entry) => {
|
|
9776
9892
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
9777
|
-
const entryPath =
|
|
9893
|
+
const entryPath = path64.join(dir, entry);
|
|
9778
9894
|
let stats;
|
|
9779
9895
|
try {
|
|
9780
9896
|
stats = statSync6(entryPath);
|
|
@@ -9782,7 +9898,7 @@ function stylesheetFiles(dir) {
|
|
|
9782
9898
|
return [];
|
|
9783
9899
|
}
|
|
9784
9900
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
9785
|
-
return
|
|
9901
|
+
return path64.extname(entry) === ".css" ? [entryPath] : [];
|
|
9786
9902
|
});
|
|
9787
9903
|
}
|
|
9788
9904
|
function packageNameOf(specifier) {
|
|
@@ -9793,10 +9909,10 @@ function packageNameOf(specifier) {
|
|
|
9793
9909
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
9794
9910
|
const packageName = packageNameOf(specifier);
|
|
9795
9911
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
9796
|
-
let directory =
|
|
9797
|
-
while (directory !==
|
|
9798
|
-
const packageRoot =
|
|
9799
|
-
const manifestPath =
|
|
9912
|
+
let directory = path64.dirname(fromFile);
|
|
9913
|
+
while (directory !== path64.dirname(directory)) {
|
|
9914
|
+
const packageRoot = path64.join(directory, "node_modules", packageName);
|
|
9915
|
+
const manifestPath = path64.join(packageRoot, "package.json");
|
|
9800
9916
|
if (existsSync6(manifestPath)) {
|
|
9801
9917
|
try {
|
|
9802
9918
|
const manifest = readFileSync12(manifestPath, "utf8");
|
|
@@ -9804,13 +9920,13 @@ function resolvePackageStylesheet(fromFile, specifier) {
|
|
|
9804
9920
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
9805
9921
|
const target = stylesheet ?? main;
|
|
9806
9922
|
if (!target) return void 0;
|
|
9807
|
-
const resolved =
|
|
9923
|
+
const resolved = path64.resolve(packageRoot, target);
|
|
9808
9924
|
return existsSync6(resolved) ? resolved : void 0;
|
|
9809
9925
|
} catch {
|
|
9810
9926
|
return void 0;
|
|
9811
9927
|
}
|
|
9812
9928
|
}
|
|
9813
|
-
directory =
|
|
9929
|
+
directory = path64.dirname(directory);
|
|
9814
9930
|
}
|
|
9815
9931
|
return void 0;
|
|
9816
9932
|
}
|
|
@@ -10061,7 +10177,7 @@ var unknownUtilityRule = {
|
|
|
10061
10177
|
};
|
|
10062
10178
|
|
|
10063
10179
|
// eslint/rules/util-file-name.ts
|
|
10064
|
-
import
|
|
10180
|
+
import path65 from "path";
|
|
10065
10181
|
function toKebabCase2(value) {
|
|
10066
10182
|
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();
|
|
10067
10183
|
}
|
|
@@ -10074,7 +10190,7 @@ var utilFileNameRule = {
|
|
|
10074
10190
|
}
|
|
10075
10191
|
},
|
|
10076
10192
|
create(context) {
|
|
10077
|
-
const filename =
|
|
10193
|
+
const filename = path65.resolve(context.filename);
|
|
10078
10194
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
10079
10195
|
if (!segments.includes("utils")) return {};
|
|
10080
10196
|
let module;
|
|
@@ -10088,13 +10204,13 @@ var utilFileNameRule = {
|
|
|
10088
10204
|
const functionName = functions[0]?.name;
|
|
10089
10205
|
if (!functionName) return {};
|
|
10090
10206
|
const expected = toKebabCase2(functionName);
|
|
10091
|
-
const actual =
|
|
10207
|
+
const actual = path65.basename(filename, path65.extname(filename));
|
|
10092
10208
|
if (!expected || actual === expected) return {};
|
|
10093
10209
|
return {
|
|
10094
10210
|
Program(node) {
|
|
10095
10211
|
context.report({
|
|
10096
10212
|
node,
|
|
10097
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
10213
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path65.extname(filename).slice(1)}.`
|
|
10098
10214
|
});
|
|
10099
10215
|
}
|
|
10100
10216
|
};
|
|
@@ -10102,7 +10218,7 @@ var utilFileNameRule = {
|
|
|
10102
10218
|
};
|
|
10103
10219
|
|
|
10104
10220
|
// eslint/rules/value-extraction.ts
|
|
10105
|
-
import
|
|
10221
|
+
import path66 from "path";
|
|
10106
10222
|
var valueExtractionRule = {
|
|
10107
10223
|
meta: {
|
|
10108
10224
|
schema: [],
|
|
@@ -10113,7 +10229,7 @@ var valueExtractionRule = {
|
|
|
10113
10229
|
},
|
|
10114
10230
|
create(context) {
|
|
10115
10231
|
const sourceRoot = sourceRootOf(context);
|
|
10116
|
-
const file =
|
|
10232
|
+
const file = path66.resolve(context.filename);
|
|
10117
10233
|
const segments = segmentsOf(file, sourceRoot);
|
|
10118
10234
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
10119
10235
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -10135,7 +10251,7 @@ var valueExtractionRule = {
|
|
|
10135
10251
|
|
|
10136
10252
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
10137
10253
|
import { existsSync as existsSync7, readFileSync as readFileSync13 } from "fs";
|
|
10138
|
-
import
|
|
10254
|
+
import path67 from "path";
|
|
10139
10255
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
10140
10256
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
10141
10257
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -10168,8 +10284,8 @@ var trackedDocsRule = {
|
|
|
10168
10284
|
if (!context.filename.endsWith("package.json")) return;
|
|
10169
10285
|
const root = node.body;
|
|
10170
10286
|
if (root.type !== "Object") return;
|
|
10171
|
-
const projectRoot =
|
|
10172
|
-
const configPath =
|
|
10287
|
+
const projectRoot = path67.dirname(path67.resolve(context.filename));
|
|
10288
|
+
const configPath = path67.join(projectRoot, "vulyk.config.ts");
|
|
10173
10289
|
if (!existsSync7(configPath)) {
|
|
10174
10290
|
context.report({
|
|
10175
10291
|
node,
|
|
@@ -10194,7 +10310,7 @@ var trackedDocsRule = {
|
|
|
10194
10310
|
});
|
|
10195
10311
|
}
|
|
10196
10312
|
}
|
|
10197
|
-
const agentsPath =
|
|
10313
|
+
const agentsPath = path67.join(projectRoot, "AGENTS.md");
|
|
10198
10314
|
if (!existsSync7(agentsPath)) {
|
|
10199
10315
|
context.report({
|
|
10200
10316
|
node,
|
|
@@ -10255,9 +10371,9 @@ var vulykRules = {
|
|
|
10255
10371
|
// eslint/rules/with-response-helper.ts
|
|
10256
10372
|
var HELPER3 = "withResponse";
|
|
10257
10373
|
var ENTRY3 = "pasika/with-response";
|
|
10258
|
-
var
|
|
10259
|
-
var DECLARED3 = `A repository must not declare its own ${HELPER3}; import it from ${ENTRY3}. See ${
|
|
10260
|
-
var IMPORTED3 = `${HELPER3} must be imported from ${ENTRY3}. See ${
|
|
10374
|
+
var DOC8 = "docs/pasika-adoption-guide/rules/with-response-helper-rule.md";
|
|
10375
|
+
var DECLARED3 = `A repository must not declare its own ${HELPER3}; import it from ${ENTRY3}. See ${DOC8}`;
|
|
10376
|
+
var IMPORTED3 = `${HELPER3} must be imported from ${ENTRY3}. See ${DOC8}`;
|
|
10261
10377
|
function isNamed3(node, name) {
|
|
10262
10378
|
return node?.type === "Identifier" && node.name === name;
|
|
10263
10379
|
}
|
|
@@ -10294,7 +10410,7 @@ var withResponseHelperRule = {
|
|
|
10294
10410
|
|
|
10295
10411
|
// eslint/rules/zirka-baseline.ts
|
|
10296
10412
|
import fs7 from "fs";
|
|
10297
|
-
import
|
|
10413
|
+
import path68 from "path";
|
|
10298
10414
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
10299
10415
|
var PRETTIER_CONFIGS = [
|
|
10300
10416
|
"prettier.config.mjs",
|
|
@@ -10313,10 +10429,10 @@ var zirkaBaselineRule = {
|
|
|
10313
10429
|
}
|
|
10314
10430
|
},
|
|
10315
10431
|
create(context) {
|
|
10316
|
-
const filename =
|
|
10317
|
-
const basename =
|
|
10432
|
+
const filename = path68.resolve(context.filename);
|
|
10433
|
+
const basename = path68.basename(filename);
|
|
10318
10434
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
10319
|
-
const projectRoot =
|
|
10435
|
+
const projectRoot = path68.dirname(filename);
|
|
10320
10436
|
const report3 = (message) => {
|
|
10321
10437
|
context.report({
|
|
10322
10438
|
node: context.sourceCode.ast,
|
|
@@ -10331,7 +10447,7 @@ var zirkaBaselineRule = {
|
|
|
10331
10447
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
10332
10448
|
);
|
|
10333
10449
|
}
|
|
10334
|
-
const tsconfigPath =
|
|
10450
|
+
const tsconfigPath = path68.join(projectRoot, "tsconfig.json");
|
|
10335
10451
|
if (!fs7.existsSync(tsconfigPath)) {
|
|
10336
10452
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
10337
10453
|
} else {
|
|
@@ -10349,13 +10465,13 @@ var zirkaBaselineRule = {
|
|
|
10349
10465
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
10350
10466
|
}
|
|
10351
10467
|
}
|
|
10352
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(
|
|
10468
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(path68.join(projectRoot, name)));
|
|
10353
10469
|
if (!prettierConfigFile) {
|
|
10354
10470
|
report3(
|
|
10355
10471
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
10356
10472
|
);
|
|
10357
10473
|
} else {
|
|
10358
|
-
const content = fs7.readFileSync(
|
|
10474
|
+
const content = fs7.readFileSync(path68.join(projectRoot, prettierConfigFile), "utf8");
|
|
10359
10475
|
if (!content.includes("zirka")) {
|
|
10360
10476
|
report3(
|
|
10361
10477
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|
|
@@ -10378,10 +10494,10 @@ function referencesZirka(sourceCode) {
|
|
|
10378
10494
|
// eslint/rules/zod-fetch-helper.ts
|
|
10379
10495
|
var HELPER4 = "zodFetch";
|
|
10380
10496
|
var ENTRY4 = "pasika/zod-fetch";
|
|
10381
|
-
var
|
|
10382
|
-
var FETCHED = `fetch must not be called; make the request through ${HELPER4} from ${ENTRY4}. See ${
|
|
10383
|
-
var DECLARED4 = `A file must not declare its own ${HELPER4}; import it from ${ENTRY4}. See ${
|
|
10384
|
-
var IMPORTED4 = `${HELPER4} must be imported from ${ENTRY4}. See ${
|
|
10497
|
+
var DOC9 = "docs/pasika-adoption-guide/rules/zod-fetch-helper-rule.md";
|
|
10498
|
+
var FETCHED = `fetch must not be called; make the request through ${HELPER4} from ${ENTRY4}. See ${DOC9}`;
|
|
10499
|
+
var DECLARED4 = `A file must not declare its own ${HELPER4}; import it from ${ENTRY4}. See ${DOC9}`;
|
|
10500
|
+
var IMPORTED4 = `${HELPER4} must be imported from ${ENTRY4}. See ${DOC9}`;
|
|
10385
10501
|
var GLOBAL_OBJECTS = /* @__PURE__ */ new Set(["globalThis", "window", "self", "global"]);
|
|
10386
10502
|
var TEST_FILE2 = /(?:^|[\\/])(?:__tests__|tests)[\\/]|[.](?:test|spec)[.][cm]?[jt]sx?$/;
|
|
10387
10503
|
function isNamed4(node, name) {
|
|
@@ -10562,6 +10678,7 @@ var pasikaNextjsAppRules = {
|
|
|
10562
10678
|
"util-file-name": utilFileNameRule,
|
|
10563
10679
|
"no-util-barrel": noUtilBarrelRule,
|
|
10564
10680
|
"no-redundant-alias": noRedundantAliasRule,
|
|
10681
|
+
"no-inline-runtime-literal": noInlineRuntimeLiteralRule,
|
|
10565
10682
|
"enforce-barrel-exports": enforceBarrelExportsRule,
|
|
10566
10683
|
"require-barrel-star-exports": requireBarrelStarExportsRule,
|
|
10567
10684
|
"config-extraction": configExtractionRule,
|