pasika 0.10.103 → 0.10.105
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 +469 -276
- package/package.json +1 -1
|
@@ -3340,6 +3340,8 @@ var enumPlacementRule = {
|
|
|
3340
3340
|
if (!filename.startsWith(sourceRoot + path25.sep)) return {};
|
|
3341
3341
|
const inConstantsFolder = path25.basename(path25.dirname(filename)) === "constants";
|
|
3342
3342
|
const index = getProjectIndex(sourceRoot);
|
|
3343
|
+
const component = index?.modules.get(filename)?.exports.find((entry) => entry.kind === "component");
|
|
3344
|
+
const componentConsumers = component ? index?.symbolConsumers.get(symbolKey(filename, component.name)) : void 0;
|
|
3343
3345
|
return {
|
|
3344
3346
|
TSEnumDeclaration(node) {
|
|
3345
3347
|
const enumBody = "body" in node ? node.body : void 0;
|
|
@@ -3354,11 +3356,12 @@ var enumPlacementRule = {
|
|
|
3354
3356
|
});
|
|
3355
3357
|
return;
|
|
3356
3358
|
}
|
|
3357
|
-
const
|
|
3358
|
-
if (inConstantsFolder || !
|
|
3359
|
+
const consumers = index?.symbolConsumers.get(symbolKey(filename, enumName));
|
|
3360
|
+
if (inConstantsFolder || !consumers || consumers.size === 0) return;
|
|
3361
|
+
if (component && [...consumers].every((consumer) => componentConsumers?.has(consumer))) return;
|
|
3359
3362
|
context.report({
|
|
3360
3363
|
node,
|
|
3361
|
-
message: "An enum imported
|
|
3364
|
+
message: "An enum imported independently of its component must live in constants/ at its CCF; keep component-owned enums beside their component. See docs/next-codebase-guide/rules/constants-rule.md"
|
|
3362
3365
|
});
|
|
3363
3366
|
}
|
|
3364
3367
|
};
|
|
@@ -5376,13 +5379,148 @@ var noArbitraryTailwindRule = {
|
|
|
5376
5379
|
}
|
|
5377
5380
|
};
|
|
5378
5381
|
|
|
5379
|
-
// eslint/rules/no-
|
|
5380
|
-
import
|
|
5382
|
+
// eslint/rules/no-duplicate-jsx-classes.ts
|
|
5383
|
+
import path40 from "path";
|
|
5381
5384
|
|
|
5382
|
-
// eslint/project/
|
|
5385
|
+
// eslint/project/jsx-class-reuse.ts
|
|
5383
5386
|
import { readFileSync as readFileSync9 } from "fs";
|
|
5384
|
-
import path40 from "path";
|
|
5385
5387
|
import ts8 from "typescript";
|
|
5388
|
+
var MIN_SHARED_CLASSES = 5;
|
|
5389
|
+
var cache3 = /* @__PURE__ */ new WeakMap();
|
|
5390
|
+
function staticClassText(expression) {
|
|
5391
|
+
if (ts8.isStringLiteral(expression) || ts8.isNoSubstitutionTemplateLiteral(expression)) {
|
|
5392
|
+
return expression.text;
|
|
5393
|
+
}
|
|
5394
|
+
if (ts8.isParenthesizedExpression(expression)) return staticClassText(expression.expression);
|
|
5395
|
+
if (!ts8.isCallExpression(expression) || !ts8.isIdentifier(expression.expression)) return void 0;
|
|
5396
|
+
if (expression.expression.text !== "cn") return void 0;
|
|
5397
|
+
const chunks = [];
|
|
5398
|
+
for (const arg of expression.arguments) {
|
|
5399
|
+
if (ts8.isSpreadElement(arg)) return void 0;
|
|
5400
|
+
const text = staticClassText(arg);
|
|
5401
|
+
if (text === void 0) return void 0;
|
|
5402
|
+
chunks.push(text);
|
|
5403
|
+
}
|
|
5404
|
+
return chunks.join(" ");
|
|
5405
|
+
}
|
|
5406
|
+
function occurrencesInFile(file) {
|
|
5407
|
+
const source = ts8.createSourceFile(file, readFileSync9(file, "utf8"), ts8.ScriptTarget.Latest, true, ts8.ScriptKind.TSX);
|
|
5408
|
+
const result = [];
|
|
5409
|
+
const visit = (node) => {
|
|
5410
|
+
if (ts8.isJsxOpeningElement(node) || ts8.isJsxSelfClosingElement(node)) {
|
|
5411
|
+
const tag = node.tagName.getText(source);
|
|
5412
|
+
if (/^[a-z][a-z0-9-]*$/.test(tag)) {
|
|
5413
|
+
const attribute = node.attributes.properties.find(
|
|
5414
|
+
(item) => ts8.isJsxAttribute(item) && ts8.isIdentifier(item.name) && item.name.text === "className"
|
|
5415
|
+
);
|
|
5416
|
+
if (attribute && ts8.isJsxAttribute(attribute)) {
|
|
5417
|
+
const initializer = attribute.initializer;
|
|
5418
|
+
let text;
|
|
5419
|
+
if (initializer && ts8.isStringLiteral(initializer)) {
|
|
5420
|
+
text = initializer.text;
|
|
5421
|
+
} else if (initializer && ts8.isJsxExpression(initializer) && initializer.expression) {
|
|
5422
|
+
text = staticClassText(initializer.expression);
|
|
5423
|
+
}
|
|
5424
|
+
if (text !== void 0) {
|
|
5425
|
+
const classes = [...new Set(text.split(/\s+/).filter(Boolean))].sort();
|
|
5426
|
+
if (classes.length >= MIN_SHARED_CLASSES) {
|
|
5427
|
+
const location = source.getLineAndCharacterOfPosition(attribute.getStart(source));
|
|
5428
|
+
result.push({
|
|
5429
|
+
file,
|
|
5430
|
+
line: location.line + 1,
|
|
5431
|
+
column: location.character,
|
|
5432
|
+
tag,
|
|
5433
|
+
classes
|
|
5434
|
+
});
|
|
5435
|
+
}
|
|
5436
|
+
}
|
|
5437
|
+
}
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5440
|
+
ts8.forEachChild(node, visit);
|
|
5441
|
+
};
|
|
5442
|
+
visit(source);
|
|
5443
|
+
return result;
|
|
5444
|
+
}
|
|
5445
|
+
function reuseIndex(index) {
|
|
5446
|
+
const byTagAndClasses = /* @__PURE__ */ new Map();
|
|
5447
|
+
for (const file of [...index.modules.keys()].sort()) {
|
|
5448
|
+
if (!/\.(?:tsx|jsx)$/.test(file) || /\.(?:test|spec)\.(?:tsx|jsx)$/.test(file)) continue;
|
|
5449
|
+
try {
|
|
5450
|
+
for (const occurrence of occurrencesInFile(file)) {
|
|
5451
|
+
const key = JSON.stringify([occurrence.tag, occurrence.classes]);
|
|
5452
|
+
const members = byTagAndClasses.get(key) ?? [];
|
|
5453
|
+
members.push(occurrence);
|
|
5454
|
+
byTagAndClasses.set(key, members);
|
|
5455
|
+
}
|
|
5456
|
+
} catch {
|
|
5457
|
+
}
|
|
5458
|
+
}
|
|
5459
|
+
const matches = /* @__PURE__ */ new Map();
|
|
5460
|
+
const groups = [];
|
|
5461
|
+
for (const members of byTagAndClasses.values()) {
|
|
5462
|
+
if (new Set(members.map((member) => member.file)).size < 2) continue;
|
|
5463
|
+
const first = members[0];
|
|
5464
|
+
if (!first) continue;
|
|
5465
|
+
groups.push({ tag: first.tag, members, commonClasses: first.classes });
|
|
5466
|
+
for (const occurrence of members.slice(1)) {
|
|
5467
|
+
const original = members.find((member) => member.file !== occurrence.file);
|
|
5468
|
+
if (!original) continue;
|
|
5469
|
+
const entries = matches.get(occurrence.file) ?? [];
|
|
5470
|
+
entries.push({ occurrence, original, commonClasses: first.classes });
|
|
5471
|
+
matches.set(occurrence.file, entries);
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
return { matches, groups };
|
|
5475
|
+
}
|
|
5476
|
+
function getJsxReuseAnalysis(sourceRoot) {
|
|
5477
|
+
const index = getProjectIndex(sourceRoot);
|
|
5478
|
+
if (!index) return { matches: /* @__PURE__ */ new Map(), groups: [] };
|
|
5479
|
+
const existing = cache3.get(index);
|
|
5480
|
+
if (existing) return existing;
|
|
5481
|
+
const result = reuseIndex(index);
|
|
5482
|
+
cache3.set(index, result);
|
|
5483
|
+
return result;
|
|
5484
|
+
}
|
|
5485
|
+
function getJsxClassReuses(sourceRoot) {
|
|
5486
|
+
return getJsxReuseAnalysis(sourceRoot).matches;
|
|
5487
|
+
}
|
|
5488
|
+
|
|
5489
|
+
// eslint/rules/no-duplicate-jsx-classes.ts
|
|
5490
|
+
var noDuplicateJsxClassesRule = {
|
|
5491
|
+
meta: {
|
|
5492
|
+
schema: [],
|
|
5493
|
+
type: "problem",
|
|
5494
|
+
docs: { description: "Extract identical static JSX class sets into reusable components." }
|
|
5495
|
+
},
|
|
5496
|
+
create(context) {
|
|
5497
|
+
const file = path40.resolve(context.filename);
|
|
5498
|
+
if (!/\.(?:jsx|tsx)$/.test(file) || /\.(?:test|spec)\.(?:jsx|tsx)$/.test(file)) return {};
|
|
5499
|
+
const root = sourceRootOf(context);
|
|
5500
|
+
const matches = getJsxClassReuses(root).get(file) ?? [];
|
|
5501
|
+
if (matches.length === 0) return {};
|
|
5502
|
+
return {
|
|
5503
|
+
Program(node) {
|
|
5504
|
+
for (const { occurrence, original, commonClasses } of matches) {
|
|
5505
|
+
const reference = path40.relative(path40.dirname(root), original.file).split(path40.sep).join("/");
|
|
5506
|
+
context.report({
|
|
5507
|
+
node,
|
|
5508
|
+
loc: { line: occurrence.line, column: occurrence.column },
|
|
5509
|
+
message: `<${occurrence.tag}> repeats the same set of ${String(commonClasses.length)} classes as ${reference}:${String(original.line)}. Extract a shared component. See docs/next-tailwind-guide/rules/tailwind-class-reuse-rule.md`
|
|
5510
|
+
});
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
};
|
|
5514
|
+
}
|
|
5515
|
+
};
|
|
5516
|
+
|
|
5517
|
+
// eslint/rules/no-inline-runtime-literal.ts
|
|
5518
|
+
import path42 from "path";
|
|
5519
|
+
|
|
5520
|
+
// eslint/project/semantic-literals.ts
|
|
5521
|
+
import { readFileSync as readFileSync10 } from "fs";
|
|
5522
|
+
import path41 from "path";
|
|
5523
|
+
import ts9 from "typescript";
|
|
5386
5524
|
var excludedProperties = /* @__PURE__ */ new Set([
|
|
5387
5525
|
"label",
|
|
5388
5526
|
"title",
|
|
@@ -5420,33 +5558,33 @@ var columnMethods = /* @__PURE__ */ new Set([
|
|
|
5420
5558
|
var eventMethods = /* @__PURE__ */ new Set(["emit", "on", "off", "once", "addListener", "removeListener"]);
|
|
5421
5559
|
var ignoredNumbers = /* @__PURE__ */ new Set([-1, 0, 1]);
|
|
5422
5560
|
function isProductionSource(file, root) {
|
|
5423
|
-
const parts =
|
|
5424
|
-
return !(/\.(?:test|spec|mock)\.[^.]+$/.test(
|
|
5561
|
+
const parts = path41.relative(root, file).split(path41.sep);
|
|
5562
|
+
return !(/\.(?:test|spec|mock)\.[^.]+$/.test(path41.basename(file)) || parts.some((part) => part === "__tests__" || part === "__mocks__" || part === "mocks"));
|
|
5425
5563
|
}
|
|
5426
5564
|
function featureOf(file, root) {
|
|
5427
|
-
const parts =
|
|
5565
|
+
const parts = path41.relative(root, file).split(path41.sep);
|
|
5428
5566
|
if (parts[0] === "features" && parts[1]) return `feature:${parts[1]}`;
|
|
5429
5567
|
return `layer:${parts[0] ?? "src"}`;
|
|
5430
5568
|
}
|
|
5431
5569
|
function nameOf(property) {
|
|
5432
|
-
if (
|
|
5570
|
+
if (ts9.isIdentifier(property) || ts9.isStringLiteral(property)) return property.text;
|
|
5433
5571
|
return void 0;
|
|
5434
5572
|
}
|
|
5435
5573
|
function literalOf(node) {
|
|
5436
|
-
if (
|
|
5437
|
-
if (
|
|
5438
|
-
if (
|
|
5574
|
+
if (ts9.isStringLiteral(node)) return node.text;
|
|
5575
|
+
if (ts9.isNumericLiteral(node)) return Number(node.text.replaceAll("_", ""));
|
|
5576
|
+
if (ts9.isPrefixUnaryExpression(node) && node.operator === ts9.SyntaxKind.MinusToken && ts9.isNumericLiteral(node.operand)) {
|
|
5439
5577
|
return -Number(node.operand.text.replaceAll("_", ""));
|
|
5440
5578
|
}
|
|
5441
5579
|
return void 0;
|
|
5442
5580
|
}
|
|
5443
5581
|
function isLiteralRoot(node) {
|
|
5444
|
-
if (
|
|
5445
|
-
return (
|
|
5582
|
+
if (ts9.isPrefixUnaryExpression(node)) return literalOf(node) !== void 0;
|
|
5583
|
+
return (ts9.isStringLiteral(node) || ts9.isNumericLiteral(node)) && !(ts9.isPrefixUnaryExpression(node.parent) && node.parent.operand === node);
|
|
5446
5584
|
}
|
|
5447
5585
|
function invocation(node) {
|
|
5448
|
-
if (
|
|
5449
|
-
if (
|
|
5586
|
+
if (ts9.isIdentifier(node.expression)) return { method: node.expression.text };
|
|
5587
|
+
if (ts9.isPropertyAccessExpression(node.expression)) {
|
|
5450
5588
|
const receiver = node.expression.expression.getText();
|
|
5451
5589
|
if (!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)?$/.test(receiver)) return void 0;
|
|
5452
5590
|
return { method: node.expression.name.text, receiver };
|
|
@@ -5454,7 +5592,7 @@ function invocation(node) {
|
|
|
5454
5592
|
return void 0;
|
|
5455
5593
|
}
|
|
5456
5594
|
function isPathname(node) {
|
|
5457
|
-
return
|
|
5595
|
+
return ts9.isPropertyAccessExpression(node) && node.name.text === "pathname";
|
|
5458
5596
|
}
|
|
5459
5597
|
function contextFor(node, value, file, root) {
|
|
5460
5598
|
if (typeof value === "number" && ignoredNumbers.has(value)) return void 0;
|
|
@@ -5463,7 +5601,7 @@ function contextFor(node, value, file, root) {
|
|
|
5463
5601
|
const scope = featureOf(file, root);
|
|
5464
5602
|
const isApiRoute = typeof value === "string" && value.startsWith("/api/") && !/[?&#\s]/.test(value);
|
|
5465
5603
|
const route = () => ({ role: "api-route", family: "api-route" });
|
|
5466
|
-
if (
|
|
5604
|
+
if (ts9.isPropertyAssignment(parent) && parent.initializer === node) {
|
|
5467
5605
|
const name = nameOf(parent.name);
|
|
5468
5606
|
if (!name) return void 0;
|
|
5469
5607
|
if (name === "path" && isApiRoute) return route();
|
|
@@ -5472,14 +5610,14 @@ function contextFor(node, value, file, root) {
|
|
|
5472
5610
|
if (isApiRoute && /route|path|endpoint/i.test(name)) return route();
|
|
5473
5611
|
return { role: `property:${name}:${scope}`, family: `property:${name}` };
|
|
5474
5612
|
}
|
|
5475
|
-
if (
|
|
5613
|
+
if (ts9.isVariableDeclaration(parent) && parent.initializer === node && ts9.isIdentifier(parent.name)) {
|
|
5476
5614
|
if (typeof value === "number") return void 0;
|
|
5477
5615
|
const name = parent.name.text;
|
|
5478
5616
|
if (excludedProperties.has(name) || !semanticVariableName.test(name)) return void 0;
|
|
5479
5617
|
if (isApiRoute && /route|path|endpoint/i.test(name)) return route();
|
|
5480
5618
|
return { role: `variable:${name}:${scope}`, family: `variable:${name}` };
|
|
5481
5619
|
}
|
|
5482
|
-
if (
|
|
5620
|
+
if (ts9.isCallExpression(parent)) {
|
|
5483
5621
|
const position = parent.arguments.findIndex((argument) => argument === node);
|
|
5484
5622
|
if (position < 0) return void 0;
|
|
5485
5623
|
const call = invocation(parent);
|
|
@@ -5498,29 +5636,29 @@ function contextFor(node, value, file, root) {
|
|
|
5498
5636
|
return { role: `column:${scope}`, family: "column" };
|
|
5499
5637
|
}
|
|
5500
5638
|
}
|
|
5501
|
-
if (isApiRoute &&
|
|
5639
|
+
if (isApiRoute && ts9.isBinaryExpression(parent) && (parent.operatorToken.kind === ts9.SyntaxKind.EqualsEqualsEqualsToken || parent.operatorToken.kind === ts9.SyntaxKind.ExclamationEqualsEqualsToken) && (parent.left === node && isPathname(parent.right) || parent.right === node && isPathname(parent.left))) {
|
|
5502
5640
|
return route();
|
|
5503
5641
|
}
|
|
5504
|
-
if (isApiRoute &&
|
|
5642
|
+
if (isApiRoute && ts9.isCallExpression(parent) && parent.arguments[0] === node && ts9.isPropertyAccessExpression(parent.expression) && parent.expression.name.text === "startsWith" && isPathname(parent.expression.expression)) {
|
|
5505
5643
|
return route();
|
|
5506
5644
|
}
|
|
5507
5645
|
return void 0;
|
|
5508
5646
|
}
|
|
5509
5647
|
function isExported2(node) {
|
|
5510
|
-
return
|
|
5648
|
+
return ts9.canHaveModifiers(node) && (ts9.getModifiers(node) ?? []).some((modifier) => modifier.kind === ts9.SyntaxKind.ExportKeyword);
|
|
5511
5649
|
}
|
|
5512
5650
|
function parse(file, root, output) {
|
|
5513
5651
|
if (!isProductionSource(file, root)) return;
|
|
5514
|
-
const source =
|
|
5652
|
+
const source = ts9.createSourceFile(
|
|
5515
5653
|
file,
|
|
5516
|
-
|
|
5517
|
-
|
|
5654
|
+
readFileSync10(file, "utf8"),
|
|
5655
|
+
ts9.ScriptTarget.Latest,
|
|
5518
5656
|
true,
|
|
5519
|
-
file.endsWith(".tsx") || file.endsWith(".jsx") ?
|
|
5657
|
+
file.endsWith(".tsx") || file.endsWith(".jsx") ? ts9.ScriptKind.TSX : ts9.ScriptKind.TS
|
|
5520
5658
|
);
|
|
5521
|
-
const inConstants =
|
|
5659
|
+
const inConstants = path41.relative(root, file).split(path41.sep).includes("constants");
|
|
5522
5660
|
for (const statement of source.statements) {
|
|
5523
|
-
if (inConstants &&
|
|
5661
|
+
if (inConstants && ts9.isEnumDeclaration(statement) && isExported2(statement)) {
|
|
5524
5662
|
for (const member of statement.members) {
|
|
5525
5663
|
const value = member.initializer && literalOf(member.initializer);
|
|
5526
5664
|
const memberName10 = nameOf(member.name);
|
|
@@ -5534,9 +5672,9 @@ function parse(file, root, output) {
|
|
|
5534
5672
|
});
|
|
5535
5673
|
}
|
|
5536
5674
|
}
|
|
5537
|
-
if (inConstants &&
|
|
5675
|
+
if (inConstants && ts9.isVariableStatement(statement) && isExported2(statement)) {
|
|
5538
5676
|
for (const declaration of statement.declarationList.declarations) {
|
|
5539
|
-
if (!
|
|
5677
|
+
if (!ts9.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
5540
5678
|
const value = literalOf(declaration.initializer);
|
|
5541
5679
|
if (value === void 0) continue;
|
|
5542
5680
|
output.canonicals.push({
|
|
@@ -5555,7 +5693,7 @@ function parse(file, root, output) {
|
|
|
5555
5693
|
const semantic = contextFor(node, value, file, root);
|
|
5556
5694
|
if (semantic) {
|
|
5557
5695
|
const declaration = node.parent;
|
|
5558
|
-
const isCanonicalDefinition = inConstants && (
|
|
5696
|
+
const isCanonicalDefinition = inConstants && (ts9.isVariableDeclaration(declaration) && ts9.isVariableStatement(declaration.parent.parent) && isExported2(declaration.parent.parent) || ts9.isEnumMember(declaration));
|
|
5559
5697
|
if ((!inConstants || semantic.family === "api-route") && !isCanonicalDefinition) {
|
|
5560
5698
|
const position = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
5561
5699
|
output.uses.push({
|
|
@@ -5570,13 +5708,13 @@ function parse(file, root, output) {
|
|
|
5570
5708
|
}
|
|
5571
5709
|
}
|
|
5572
5710
|
}
|
|
5573
|
-
|
|
5711
|
+
ts9.forEachChild(node, visit);
|
|
5574
5712
|
};
|
|
5575
5713
|
visit(source);
|
|
5576
5714
|
}
|
|
5577
|
-
var
|
|
5715
|
+
var cache4 = /* @__PURE__ */ new WeakMap();
|
|
5578
5716
|
function getSemanticLiteralIndex(index) {
|
|
5579
|
-
const previous =
|
|
5717
|
+
const previous = cache4.get(index);
|
|
5580
5718
|
if (previous) return previous;
|
|
5581
5719
|
const result = { uses: [], canonicals: [] };
|
|
5582
5720
|
for (const file of index.modules.keys()) {
|
|
@@ -5585,7 +5723,7 @@ function getSemanticLiteralIndex(index) {
|
|
|
5585
5723
|
} catch {
|
|
5586
5724
|
}
|
|
5587
5725
|
}
|
|
5588
|
-
|
|
5726
|
+
cache4.set(index, result);
|
|
5589
5727
|
return result;
|
|
5590
5728
|
}
|
|
5591
5729
|
|
|
@@ -5611,7 +5749,7 @@ function isStaticDataComponentMarker(node) {
|
|
|
5611
5749
|
return typeof name === "object" && name !== null && "name" in name && name.name === "data-component";
|
|
5612
5750
|
}
|
|
5613
5751
|
function isStaticMatcherValue(node, root, file) {
|
|
5614
|
-
const relativeFile =
|
|
5752
|
+
const relativeFile = path42.relative(root, file);
|
|
5615
5753
|
if (relativeFile !== "middleware.ts" && relativeFile !== "proxy.ts") return false;
|
|
5616
5754
|
let current = node;
|
|
5617
5755
|
while (current.parent) {
|
|
@@ -5674,11 +5812,11 @@ function isSyntacticString(node) {
|
|
|
5674
5812
|
return false;
|
|
5675
5813
|
}
|
|
5676
5814
|
function isRuntimeMockSource(file, root) {
|
|
5677
|
-
const parts =
|
|
5678
|
-
return parts.includes("mocks") && !parts.some((part) => part === "__tests__" || part === "__mocks__") && !/\.(?:test|spec|mock)\.[^.]+$/.test(
|
|
5815
|
+
const parts = path42.relative(root, file).split(path42.sep);
|
|
5816
|
+
return parts.includes("mocks") && !parts.some((part) => part === "__tests__" || part === "__mocks__") && !/\.(?:test|spec|mock)\.[^.]+$/.test(path42.basename(file));
|
|
5679
5817
|
}
|
|
5680
5818
|
function isCanonicalLocaleString(node, root, file) {
|
|
5681
|
-
const relative =
|
|
5819
|
+
const relative = path42.relative(root, file).split(path42.sep);
|
|
5682
5820
|
let namespace;
|
|
5683
5821
|
if (relative.length === 2 && relative[0] === "locales" && relative[1] !== "index.ts" && /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*\.ts$/.test(relative[1] ?? "")) {
|
|
5684
5822
|
namespace = (relative[1] ?? "").slice(0, -3).replace(/-[a-z]/g, (match) => match.slice(1).toUpperCase());
|
|
@@ -5702,8 +5840,8 @@ var noInlineRuntimeLiteralRule = {
|
|
|
5702
5840
|
},
|
|
5703
5841
|
create(context) {
|
|
5704
5842
|
const root = sourceRootOf(context);
|
|
5705
|
-
const file =
|
|
5706
|
-
if (!file.startsWith(root +
|
|
5843
|
+
const file = path42.resolve(context.filename);
|
|
5844
|
+
if (!file.startsWith(root + path42.sep) || !isProductionSource(file, root) && !isRuntimeMockSource(file, root)) {
|
|
5707
5845
|
return {};
|
|
5708
5846
|
}
|
|
5709
5847
|
return {
|
|
@@ -5800,8 +5938,33 @@ var noLiteralInlineStyleRule = {
|
|
|
5800
5938
|
};
|
|
5801
5939
|
|
|
5802
5940
|
// eslint/rules/no-mixed-concerns.ts
|
|
5803
|
-
import { readFileSync as
|
|
5804
|
-
import
|
|
5941
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
5942
|
+
import path43 from "path";
|
|
5943
|
+
function isComponentSupportKind(kind) {
|
|
5944
|
+
return kind === "constant" || kind === "type" || kind === "schema";
|
|
5945
|
+
}
|
|
5946
|
+
function componentSupportExport(file, name, index, visited = /* @__PURE__ */ new Set()) {
|
|
5947
|
+
const key = symbolKey(file, name);
|
|
5948
|
+
if (visited.has(key)) return void 0;
|
|
5949
|
+
visited.add(key);
|
|
5950
|
+
const module = index.modules.get(file);
|
|
5951
|
+
if (!module) return void 0;
|
|
5952
|
+
const supportFolder = path43.basename(path43.dirname(file));
|
|
5953
|
+
if (["constants", "types", "schemas"].includes(supportFolder)) {
|
|
5954
|
+
const exported = module.exports.find((item) => item.name === name && isComponentSupportKind(item.kind));
|
|
5955
|
+
if (exported && isComponentSupportKind(exported.kind)) {
|
|
5956
|
+
return { file, name, kind: exported.kind };
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
for (const forwarded of module.reexports) {
|
|
5960
|
+
if (forwarded.names.length > 0 && !forwarded.names.includes(name)) continue;
|
|
5961
|
+
const target = resolveSpecifier(file, forwarded.specifier, index.sourceRoot);
|
|
5962
|
+
if (!target) continue;
|
|
5963
|
+
const exported = componentSupportExport(target, name, index, visited);
|
|
5964
|
+
if (exported) return exported;
|
|
5965
|
+
}
|
|
5966
|
+
return void 0;
|
|
5967
|
+
}
|
|
5805
5968
|
var noMixedConcernsRule = {
|
|
5806
5969
|
meta: {
|
|
5807
5970
|
schema: [],
|
|
@@ -5825,10 +5988,39 @@ var noMixedConcernsRule = {
|
|
|
5825
5988
|
if (components.length > 1) return;
|
|
5826
5989
|
const componentName = components[0]?.name;
|
|
5827
5990
|
if (!componentName) return;
|
|
5828
|
-
const file =
|
|
5991
|
+
const file = path43.resolve(context.filename);
|
|
5829
5992
|
const sourceRoot = sourceRootOf(context);
|
|
5830
5993
|
const index = getProjectIndex(sourceRoot);
|
|
5831
5994
|
const componentConsumers = index?.symbolConsumers.get(symbolKey(file, componentName)) ?? /* @__PURE__ */ new Set();
|
|
5995
|
+
if (index) {
|
|
5996
|
+
const examined = /* @__PURE__ */ new Set();
|
|
5997
|
+
for (const imported of index.modules.get(file)?.imports ?? []) {
|
|
5998
|
+
const importedFile = resolveSpecifier(file, imported.specifier, sourceRoot);
|
|
5999
|
+
if (!importedFile) continue;
|
|
6000
|
+
for (const name of imported.names) {
|
|
6001
|
+
const support = componentSupportExport(importedFile, name, index);
|
|
6002
|
+
if (!support) continue;
|
|
6003
|
+
const key = symbolKey(support.file, support.name);
|
|
6004
|
+
if (examined.has(key)) continue;
|
|
6005
|
+
examined.add(key);
|
|
6006
|
+
const consumers = /* @__PURE__ */ new Set([
|
|
6007
|
+
...index.symbolConsumers.get(key) ?? [],
|
|
6008
|
+
...index.symbolConsumers.get(symbolKey(importedFile, name)) ?? []
|
|
6009
|
+
]);
|
|
6010
|
+
if (!consumers.has(file)) continue;
|
|
6011
|
+
const independentlyUsed = [...consumers].some((consumer) => {
|
|
6012
|
+
if (consumer === file || componentConsumers.has(consumer)) return false;
|
|
6013
|
+
const isForwarder = index.modules.get(consumer)?.reexports.some((forwarded) => forwarded.names.length === 0 || forwarded.names.includes(name));
|
|
6014
|
+
return !isForwarder;
|
|
6015
|
+
});
|
|
6016
|
+
if (independentlyUsed) continue;
|
|
6017
|
+
context.report({
|
|
6018
|
+
loc: { line: imported.line, column: 0 },
|
|
6019
|
+
message: `Supporting ${support.kind} "${support.name}" is consumed only with component "${componentName}". Define it in the component file; extract it into a support folder only when consumed independently. See docs/next-codebase-guide/rules/no-mixed-concerns-rule.md`
|
|
6020
|
+
});
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
5832
6024
|
const isNextPageOrLayout = /(?:^|[/\\])src[/\\]app[/\\](?:[^/\\]+[/\\])*(?:page|layout)\.tsx$/.test(
|
|
5833
6025
|
context.filename
|
|
5834
6026
|
);
|
|
@@ -5870,7 +6062,7 @@ var noMixedConcernsRule = {
|
|
|
5870
6062
|
continue;
|
|
5871
6063
|
}
|
|
5872
6064
|
const target = typeof statement.source?.value === "string" ? resolveSpecifier(file, statement.source.value, sourceRoot) : void 0;
|
|
5873
|
-
const forwardedComponents = target?.endsWith(".tsx") ? parseComponentInfo(
|
|
6065
|
+
const forwardedComponents = target?.endsWith(".tsx") ? parseComponentInfo(readFileSync11(target, "utf8"), target).map((component) => component.name) : [];
|
|
5874
6066
|
for (const specifier of statement.specifiers) {
|
|
5875
6067
|
if (/^type\b/.test(context.sourceCode.getText(specifier))) continue;
|
|
5876
6068
|
if (specifier.local.type !== "Identifier") continue;
|
|
@@ -5904,11 +6096,11 @@ var noMixedConcernsRule = {
|
|
|
5904
6096
|
};
|
|
5905
6097
|
|
|
5906
6098
|
// eslint/rules/no-redundant-alias.ts
|
|
5907
|
-
import
|
|
6099
|
+
import path45 from "path";
|
|
5908
6100
|
|
|
5909
6101
|
// eslint/rules/contract-ownership.ts
|
|
5910
|
-
import
|
|
5911
|
-
import
|
|
6102
|
+
import path44 from "path";
|
|
6103
|
+
import ts10 from "typescript";
|
|
5912
6104
|
function isTsProgram(value) {
|
|
5913
6105
|
return typeof value === "object" && value !== null && "getTypeChecker" in value && typeof value.getTypeChecker === "function" && "getSourceFiles" in value && typeof value.getSourceFiles === "function";
|
|
5914
6106
|
}
|
|
@@ -5926,8 +6118,8 @@ function normalizePath(value) {
|
|
|
5926
6118
|
return value.replaceAll("\\", "/").toLowerCase();
|
|
5927
6119
|
}
|
|
5928
6120
|
function isWithin2(root, file) {
|
|
5929
|
-
const relative =
|
|
5930
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
6121
|
+
const relative = path44.relative(root, file);
|
|
6122
|
+
return relative === "" || !relative.startsWith("..") && !path44.isAbsolute(relative);
|
|
5931
6123
|
}
|
|
5932
6124
|
function mergeOwnership(values) {
|
|
5933
6125
|
if (values.length === 0 || values.includes("unknown")) return "unknown";
|
|
@@ -5942,11 +6134,11 @@ function endpointOwnership(pathValue) {
|
|
|
5942
6134
|
return "unknown";
|
|
5943
6135
|
}
|
|
5944
6136
|
function resolvedSymbol(checker, symbol) {
|
|
5945
|
-
return symbol.flags ===
|
|
6137
|
+
return symbol.flags === ts10.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
5946
6138
|
}
|
|
5947
6139
|
function propertyName4(node) {
|
|
5948
6140
|
if (!node) return void 0;
|
|
5949
|
-
if (
|
|
6141
|
+
if (ts10.isIdentifier(node) || ts10.isStringLiteral(node) || ts10.isNumericLiteral(node)) return node.text;
|
|
5950
6142
|
return void 0;
|
|
5951
6143
|
}
|
|
5952
6144
|
var ContractOwnershipIndex = class {
|
|
@@ -5970,7 +6162,7 @@ var ContractOwnershipIndex = class {
|
|
|
5970
6162
|
}
|
|
5971
6163
|
if (declarations.length > 0) return this.endpointFromDeclarations(declarations);
|
|
5972
6164
|
let object;
|
|
5973
|
-
if (
|
|
6165
|
+
if (ts10.isPropertyAccessExpression(node) || ts10.isElementAccessExpression(node)) object = node.expression;
|
|
5974
6166
|
if (!object) return { kind: "missing", ownership: "unknown" };
|
|
5975
6167
|
const type = this.checker.getTypeAtLocation(object);
|
|
5976
6168
|
const typeDeclarations = this.typeDeclarations(type);
|
|
@@ -5978,7 +6170,7 @@ var ContractOwnershipIndex = class {
|
|
|
5978
6170
|
return this.endpointFromDeclarations(typeDeclarations);
|
|
5979
6171
|
}
|
|
5980
6172
|
sourceBinding(node, name) {
|
|
5981
|
-
if (!
|
|
6173
|
+
if (!ts10.isVariableDeclaration(node) || !node.initializer) {
|
|
5982
6174
|
return { kind: "missing", ownership: "unknown" };
|
|
5983
6175
|
}
|
|
5984
6176
|
const sourceType = this.checker.getTypeAtLocation(node.initializer);
|
|
@@ -5987,11 +6179,11 @@ var ContractOwnershipIndex = class {
|
|
|
5987
6179
|
return this.endpointFromDeclarations(declarations);
|
|
5988
6180
|
}
|
|
5989
6181
|
targetProperty(node, name) {
|
|
5990
|
-
if (!
|
|
6182
|
+
if (!ts10.isPropertyAssignment(node) && !ts10.isShorthandPropertyAssignment(node)) {
|
|
5991
6183
|
return { kind: "missing", ownership: "unknown" };
|
|
5992
6184
|
}
|
|
5993
6185
|
const object = node.parent;
|
|
5994
|
-
if (!
|
|
6186
|
+
if (!ts10.isObjectLiteralExpression(object)) return { kind: "missing", ownership: "unknown" };
|
|
5995
6187
|
const contextualType = this.checker.getContextualType(object);
|
|
5996
6188
|
if (!contextualType) return { kind: "missing", ownership: "unknown" };
|
|
5997
6189
|
const declarations = this.propertyDeclarations(contextualType, name);
|
|
@@ -5999,8 +6191,8 @@ var ContractOwnershipIndex = class {
|
|
|
5999
6191
|
return this.endpointFromDeclarations(declarations);
|
|
6000
6192
|
}
|
|
6001
6193
|
memberNameSymbol(node) {
|
|
6002
|
-
if (
|
|
6003
|
-
if (
|
|
6194
|
+
if (ts10.isPropertyAccessExpression(node)) return this.checker.getSymbolAtLocation(node.name);
|
|
6195
|
+
if (ts10.isElementAccessExpression(node)) return this.checker.getSymbolAtLocation(node.argumentExpression);
|
|
6004
6196
|
return void 0;
|
|
6005
6197
|
}
|
|
6006
6198
|
propertyDeclarations(type, name) {
|
|
@@ -6030,14 +6222,14 @@ var ContractOwnershipIndex = class {
|
|
|
6030
6222
|
if (declarations.some((declaration) => this.isDataContractField(declaration))) {
|
|
6031
6223
|
return { kind: "data-contract", ownership };
|
|
6032
6224
|
}
|
|
6033
|
-
if (declarations.some((declaration) =>
|
|
6225
|
+
if (declarations.some((declaration) => ts10.isPropertySignature(declaration) || ts10.isPropertyDeclaration(declaration))) {
|
|
6034
6226
|
return { kind: "typed-local", ownership };
|
|
6035
6227
|
}
|
|
6036
6228
|
return { kind: "non-contract", ownership };
|
|
6037
6229
|
}
|
|
6038
6230
|
isDataContractField(declaration) {
|
|
6039
6231
|
if (this.isZodSchemaField(declaration)) return true;
|
|
6040
|
-
if (!
|
|
6232
|
+
if (!ts10.isPropertySignature(declaration) && !ts10.isPropertyDeclaration(declaration)) return false;
|
|
6041
6233
|
const fileName = normalizePath(declaration.getSourceFile().fileName);
|
|
6042
6234
|
return /(?:^|\/)database(?:[-.]generated)?\.ts$/u.test(fileName);
|
|
6043
6235
|
}
|
|
@@ -6046,10 +6238,10 @@ var ContractOwnershipIndex = class {
|
|
|
6046
6238
|
return this.checker.getPropertyOfType(type, "_zod") !== void 0 && this.checker.getPropertyOfType(type, "parse") !== void 0 && this.checker.getPropertyOfType(type, "safeParse") !== void 0;
|
|
6047
6239
|
}
|
|
6048
6240
|
isZodSchemaField(declaration) {
|
|
6049
|
-
if (!
|
|
6241
|
+
if (!ts10.isPropertyAssignment(declaration)) return false;
|
|
6050
6242
|
let current = declaration.parent;
|
|
6051
|
-
while (!
|
|
6052
|
-
if (
|
|
6243
|
+
while (!ts10.isSourceFile(current)) {
|
|
6244
|
+
if (ts10.isVariableDeclaration(current) && ts10.isIdentifier(current.name) && current.name.text.endsWith("Schema")) {
|
|
6053
6245
|
return true;
|
|
6054
6246
|
}
|
|
6055
6247
|
current = current.parent;
|
|
@@ -6067,12 +6259,12 @@ var ContractOwnershipIndex = class {
|
|
|
6067
6259
|
const normalized = normalizePath(fileName);
|
|
6068
6260
|
if (/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u.test(normalized)) return "platform";
|
|
6069
6261
|
if (normalized.includes("/node_modules/")) return "third-party";
|
|
6070
|
-
if (isWithin2(this.cwd,
|
|
6262
|
+
if (isWithin2(this.cwd, path44.resolve(fileName))) return "first-party";
|
|
6071
6263
|
return "unknown";
|
|
6072
6264
|
}
|
|
6073
6265
|
schemaOwnership(declaration) {
|
|
6074
6266
|
let current = declaration;
|
|
6075
|
-
while (!
|
|
6267
|
+
while (!ts10.isSourceFile(current)) {
|
|
6076
6268
|
const ownership = this.schemaNodeOwnership.get(current);
|
|
6077
6269
|
if (ownership !== void 0) return ownership;
|
|
6078
6270
|
current = current.parent;
|
|
@@ -6081,31 +6273,31 @@ var ContractOwnershipIndex = class {
|
|
|
6081
6273
|
}
|
|
6082
6274
|
indexApiContracts() {
|
|
6083
6275
|
for (const sourceFile of this.program.getSourceFiles()) {
|
|
6084
|
-
if (sourceFile.isDeclarationFile || !isWithin2(this.cwd,
|
|
6276
|
+
if (sourceFile.isDeclarationFile || !isWithin2(this.cwd, path44.resolve(sourceFile.fileName))) continue;
|
|
6085
6277
|
const visit = (node) => {
|
|
6086
|
-
if (
|
|
6087
|
-
|
|
6278
|
+
if (ts10.isCallExpression(node) && this.isDefineApiContractCall(node)) this.indexApiContractCall(node);
|
|
6279
|
+
ts10.forEachChild(node, visit);
|
|
6088
6280
|
};
|
|
6089
6281
|
visit(sourceFile);
|
|
6090
6282
|
}
|
|
6091
6283
|
}
|
|
6092
6284
|
isDefineApiContractCall(node) {
|
|
6093
|
-
if (
|
|
6094
|
-
return
|
|
6285
|
+
if (ts10.isIdentifier(node.expression)) return node.expression.text === "defineApiContract";
|
|
6286
|
+
return ts10.isPropertyAccessExpression(node.expression) && node.expression.name.text === "defineApiContract";
|
|
6095
6287
|
}
|
|
6096
6288
|
indexApiContractCall(node) {
|
|
6097
6289
|
const argument = node.arguments[0];
|
|
6098
|
-
if (!argument || !
|
|
6290
|
+
if (!argument || !ts10.isObjectLiteralExpression(argument)) return;
|
|
6099
6291
|
let pathExpression;
|
|
6100
6292
|
const schemaExpressions = [];
|
|
6101
6293
|
for (const property of argument.properties) {
|
|
6102
|
-
if (
|
|
6294
|
+
if (ts10.isPropertyAssignment(property)) {
|
|
6103
6295
|
const name = propertyName4(property.name);
|
|
6104
6296
|
if (name === "path") pathExpression = property.initializer;
|
|
6105
6297
|
if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.initializer);
|
|
6106
6298
|
continue;
|
|
6107
6299
|
}
|
|
6108
|
-
if (
|
|
6300
|
+
if (ts10.isShorthandPropertyAssignment(property)) {
|
|
6109
6301
|
const name = property.name.text;
|
|
6110
6302
|
if (name === "path") pathExpression = property.name;
|
|
6111
6303
|
if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.name);
|
|
@@ -6119,13 +6311,13 @@ var ContractOwnershipIndex = class {
|
|
|
6119
6311
|
}
|
|
6120
6312
|
staticString(node, seen) {
|
|
6121
6313
|
if (!node) return void 0;
|
|
6122
|
-
if (
|
|
6123
|
-
if (
|
|
6314
|
+
if (ts10.isStringLiteralLike(node)) return node.text;
|
|
6315
|
+
if (ts10.isIdentifier(node)) {
|
|
6124
6316
|
const symbol = this.checker.getSymbolAtLocation(node);
|
|
6125
6317
|
if (!symbol || seen.has(symbol)) return void 0;
|
|
6126
6318
|
seen.add(symbol);
|
|
6127
6319
|
for (const declaration of resolvedSymbol(this.checker, symbol).declarations ?? []) {
|
|
6128
|
-
if (
|
|
6320
|
+
if (ts10.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
6129
6321
|
const value = this.staticString(declaration.initializer, seen);
|
|
6130
6322
|
if (value !== void 0) return value;
|
|
6131
6323
|
}
|
|
@@ -6143,20 +6335,20 @@ var ContractOwnershipIndex = class {
|
|
|
6143
6335
|
this.followSchemaDeclaration(declaration, ownership, seen);
|
|
6144
6336
|
}
|
|
6145
6337
|
}
|
|
6146
|
-
|
|
6338
|
+
ts10.forEachChild(node, (child) => {
|
|
6147
6339
|
this.markSchemaExpression(child, ownership, seen);
|
|
6148
6340
|
});
|
|
6149
6341
|
}
|
|
6150
6342
|
schemaReferenceSymbol(node) {
|
|
6151
|
-
if (
|
|
6343
|
+
if (ts10.isIdentifier(node)) {
|
|
6152
6344
|
if (!node.text.endsWith("Schema")) return void 0;
|
|
6153
6345
|
return this.checker.getSymbolAtLocation(node);
|
|
6154
6346
|
}
|
|
6155
|
-
if (
|
|
6347
|
+
if (ts10.isPropertyAccessExpression(node)) {
|
|
6156
6348
|
if (!node.name.text.endsWith("Schema")) return void 0;
|
|
6157
6349
|
return this.checker.getSymbolAtLocation(node.name);
|
|
6158
6350
|
}
|
|
6159
|
-
if (
|
|
6351
|
+
if (ts10.isElementAccessExpression(node) && ts10.isStringLiteralLike(node.argumentExpression)) {
|
|
6160
6352
|
if (!node.argumentExpression.text.endsWith("Schema")) return void 0;
|
|
6161
6353
|
return this.checker.getSymbolAtLocation(node.argumentExpression);
|
|
6162
6354
|
}
|
|
@@ -6164,15 +6356,15 @@ var ContractOwnershipIndex = class {
|
|
|
6164
6356
|
}
|
|
6165
6357
|
followSchemaDeclaration(declaration, ownership, seen) {
|
|
6166
6358
|
this.setSchemaOwnership(declaration, ownership);
|
|
6167
|
-
if (
|
|
6359
|
+
if (ts10.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
6168
6360
|
this.markSchemaExpression(declaration.initializer, ownership, seen);
|
|
6169
6361
|
return;
|
|
6170
6362
|
}
|
|
6171
|
-
if (
|
|
6363
|
+
if (ts10.isPropertyAssignment(declaration)) {
|
|
6172
6364
|
this.markSchemaExpression(declaration.initializer, ownership, seen);
|
|
6173
6365
|
return;
|
|
6174
6366
|
}
|
|
6175
|
-
if (
|
|
6367
|
+
if (ts10.isShorthandPropertyAssignment(declaration)) {
|
|
6176
6368
|
const valueSymbol = this.checker.getShorthandAssignmentValueSymbol(declaration);
|
|
6177
6369
|
if (!valueSymbol || seen.has(valueSymbol)) return;
|
|
6178
6370
|
seen.add(valueSymbol);
|
|
@@ -6352,7 +6544,7 @@ var noRedundantAliasRule = {
|
|
|
6352
6544
|
if (declaration.type !== "VariableDeclaration" || declaration.kind !== "const") return;
|
|
6353
6545
|
if (node.init.type === "Identifier") {
|
|
6354
6546
|
const exported = declaration.parent.type === "ExportNamedDeclaration";
|
|
6355
|
-
const frameworkRouteAlias =
|
|
6547
|
+
const frameworkRouteAlias = path45.basename(context.filename) === "route.ts" && exported && HTTP_METHODS.has(node.id.name);
|
|
6356
6548
|
if (frameworkRouteAlias || VALUE_SENTINELS.has(node.init.name)) return;
|
|
6357
6549
|
context.report({
|
|
6358
6550
|
node,
|
|
@@ -6475,7 +6667,7 @@ var noRedundantAliasRule = {
|
|
|
6475
6667
|
const source = specifier.local.name;
|
|
6476
6668
|
const alias = specifier.exported.name;
|
|
6477
6669
|
if (source === alias) continue;
|
|
6478
|
-
const frameworkRouteAlias =
|
|
6670
|
+
const frameworkRouteAlias = path45.basename(context.filename) === "route.ts" && HTTP_METHODS.has(alias);
|
|
6479
6671
|
if (frameworkRouteAlias) continue;
|
|
6480
6672
|
context.report({
|
|
6481
6673
|
node: specifier,
|
|
@@ -6500,7 +6692,7 @@ var noRedundantAliasRule = {
|
|
|
6500
6692
|
};
|
|
6501
6693
|
|
|
6502
6694
|
// eslint/rules/no-util-barrel.ts
|
|
6503
|
-
import
|
|
6695
|
+
import path46 from "path";
|
|
6504
6696
|
var noUtilBarrelRule = {
|
|
6505
6697
|
meta: {
|
|
6506
6698
|
schema: [],
|
|
@@ -6510,7 +6702,7 @@ var noUtilBarrelRule = {
|
|
|
6510
6702
|
}
|
|
6511
6703
|
},
|
|
6512
6704
|
create(context) {
|
|
6513
|
-
const filename =
|
|
6705
|
+
const filename = path46.resolve(context.filename);
|
|
6514
6706
|
const sourceRoot = sourceRootOf3(context, filename);
|
|
6515
6707
|
return {
|
|
6516
6708
|
Program(node) {
|
|
@@ -6519,7 +6711,7 @@ var noUtilBarrelRule = {
|
|
|
6519
6711
|
if (!target) continue;
|
|
6520
6712
|
const segments = target.replace(/\\/g, "/").split("/");
|
|
6521
6713
|
const utilsIndex = segments.lastIndexOf("utils");
|
|
6522
|
-
if (utilsIndex < 0 || !
|
|
6714
|
+
if (utilsIndex < 0 || !path46.basename(target).startsWith("index.")) continue;
|
|
6523
6715
|
context.report({
|
|
6524
6716
|
node,
|
|
6525
6717
|
message: `Import utilities directly instead of through "${specifier}". See docs/next-codebase-guide/rules/utilities-rule.md`
|
|
@@ -6539,15 +6731,15 @@ function importSpecifiers2(source) {
|
|
|
6539
6731
|
return specifiers;
|
|
6540
6732
|
}
|
|
6541
6733
|
function sourceRootOf3(context, filename) {
|
|
6542
|
-
const marker = `${
|
|
6734
|
+
const marker = `${path46.sep}src${path46.sep}`;
|
|
6543
6735
|
const srcIndex = filename.lastIndexOf(marker);
|
|
6544
6736
|
if (srcIndex >= 0) return filename.slice(0, srcIndex + marker.length - 1);
|
|
6545
|
-
return
|
|
6737
|
+
return path46.resolve(context.cwd ?? process.cwd(), "src");
|
|
6546
6738
|
}
|
|
6547
6739
|
|
|
6548
6740
|
// eslint/rules/package-json/ci-checks.ts
|
|
6549
|
-
import { existsSync as existsSync6, readFileSync as
|
|
6550
|
-
import
|
|
6741
|
+
import { existsSync as existsSync6, readFileSync as readFileSync12, readdirSync as readdirSync4 } from "fs";
|
|
6742
|
+
import path47 from "path";
|
|
6551
6743
|
import { parse as parse2 } from "yaml";
|
|
6552
6744
|
function mapping(value) {
|
|
6553
6745
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value)) : void 0;
|
|
@@ -6605,7 +6797,7 @@ function readWorkflows(dir) {
|
|
|
6605
6797
|
const errors = [];
|
|
6606
6798
|
for (const file of readdirSync4(dir).filter((name) => /\.ya?ml$/i.test(name)).sort()) {
|
|
6607
6799
|
try {
|
|
6608
|
-
const parsed = parse2(
|
|
6800
|
+
const parsed = parse2(readFileSync12(path47.join(dir, file), "utf8"), { uniqueKeys: true });
|
|
6609
6801
|
const content = mapping(parsed);
|
|
6610
6802
|
if (!content) throw new Error("expected a YAML mapping");
|
|
6611
6803
|
workflows.push(content);
|
|
@@ -6627,7 +6819,7 @@ var ciChecksRule = {
|
|
|
6627
6819
|
return {
|
|
6628
6820
|
Document(node) {
|
|
6629
6821
|
if (!context.filename.endsWith("package.json")) return;
|
|
6630
|
-
const dir =
|
|
6822
|
+
const dir = path47.join(context.cwd, ".github", "workflows");
|
|
6631
6823
|
if (!existsSync6(dir)) return;
|
|
6632
6824
|
const report3 = (message) => {
|
|
6633
6825
|
context.report({ node, message });
|
|
@@ -6889,8 +7081,8 @@ var nextjsStackRule = {
|
|
|
6889
7081
|
};
|
|
6890
7082
|
|
|
6891
7083
|
// eslint/rules/package-json/vitest-coverage.ts
|
|
6892
|
-
import { existsSync as existsSync7, readFileSync as
|
|
6893
|
-
import
|
|
7084
|
+
import { existsSync as existsSync7, readFileSync as readFileSync13 } from "fs";
|
|
7085
|
+
import path48 from "path";
|
|
6894
7086
|
function memberName6(member) {
|
|
6895
7087
|
return member.name.type === "String" ? member.name.value : member.name.name;
|
|
6896
7088
|
}
|
|
@@ -6960,7 +7152,7 @@ var vitestCoverageRule = {
|
|
|
6960
7152
|
message: 'package.json must declare a "test:unit:coverage" script that runs Vitest with coverage.'
|
|
6961
7153
|
});
|
|
6962
7154
|
}
|
|
6963
|
-
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync7(
|
|
7155
|
+
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync7(path48.join(context.cwd, name)));
|
|
6964
7156
|
if (!configName) {
|
|
6965
7157
|
context.report({
|
|
6966
7158
|
node,
|
|
@@ -6968,7 +7160,7 @@ var vitestCoverageRule = {
|
|
|
6968
7160
|
});
|
|
6969
7161
|
return;
|
|
6970
7162
|
}
|
|
6971
|
-
const content =
|
|
7163
|
+
const content = readFileSync13(path48.join(context.cwd, configName), "utf8");
|
|
6972
7164
|
for (const metric of THRESHOLD_METRICS) {
|
|
6973
7165
|
if (!new RegExp(`\\b${metric}\\s*:\\s*[1-9]\\d*`).test(content)) {
|
|
6974
7166
|
context.report({ node, message: `${configName} must set a coverage threshold above zero for ${metric}.` });
|
|
@@ -7015,8 +7207,8 @@ var nextjsPackageJsonRules = {
|
|
|
7015
7207
|
};
|
|
7016
7208
|
|
|
7017
7209
|
// eslint/rules/prefer-enum.ts
|
|
7018
|
-
import
|
|
7019
|
-
import
|
|
7210
|
+
import path49 from "path";
|
|
7211
|
+
import ts11 from "typescript";
|
|
7020
7212
|
function isConstAssertion(node) {
|
|
7021
7213
|
const typeAnnotation = node.typeAnnotation;
|
|
7022
7214
|
return typeAnnotation?.type === "TSTypeReference" && typeAnnotation.typeName?.type === "Identifier" && typeAnnotation.typeName.name === "const";
|
|
@@ -7070,13 +7262,13 @@ function isLiteralTupleAssertion(node) {
|
|
|
7070
7262
|
return values.every((value) => value !== void 0) && new Set(values).size >= 2;
|
|
7071
7263
|
}
|
|
7072
7264
|
function isTsLiteralTupleDeclaration(declaration) {
|
|
7073
|
-
if (!
|
|
7265
|
+
if (!ts11.isVariableDeclaration(declaration) || !declaration.initializer) return false;
|
|
7074
7266
|
const init = declaration.initializer;
|
|
7075
|
-
if (!
|
|
7267
|
+
if (!ts11.isAsExpression(init) || !ts11.isTypeReferenceNode(init.type) || !ts11.isIdentifier(init.type.typeName) || init.type.typeName.text !== "const" || !ts11.isArrayLiteralExpression(init.expression) || init.expression.elements.length < 2) {
|
|
7076
7268
|
return false;
|
|
7077
7269
|
}
|
|
7078
7270
|
const values = init.expression.elements.map(
|
|
7079
|
-
(element) =>
|
|
7271
|
+
(element) => ts11.isStringLiteral(element) || ts11.isNumericLiteral(element) ? element.text : void 0
|
|
7080
7272
|
);
|
|
7081
7273
|
return values.every((value) => value !== void 0) && new Set(values).size >= 2;
|
|
7082
7274
|
}
|
|
@@ -7089,9 +7281,9 @@ var preferEnumRule = {
|
|
|
7089
7281
|
}
|
|
7090
7282
|
},
|
|
7091
7283
|
create(context) {
|
|
7092
|
-
const filename =
|
|
7284
|
+
const filename = path49.resolve(context.filename);
|
|
7093
7285
|
const sourceRoot = sourceRootOf(context);
|
|
7094
|
-
if (!filename.startsWith(sourceRoot +
|
|
7286
|
+
if (!filename.startsWith(sourceRoot + path49.sep)) return {};
|
|
7095
7287
|
const objectSchemas = /* @__PURE__ */ new Map();
|
|
7096
7288
|
const literalTuples = /* @__PURE__ */ new Set();
|
|
7097
7289
|
const enumTupleUses = [];
|
|
@@ -7105,7 +7297,7 @@ var preferEnumRule = {
|
|
|
7105
7297
|
const checker = services.program.getTypeChecker();
|
|
7106
7298
|
const symbol = checker.getSymbolAtLocation(tsNode);
|
|
7107
7299
|
if (!symbol) return false;
|
|
7108
|
-
const original = symbol.flags ===
|
|
7300
|
+
const original = symbol.flags === ts11.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
7109
7301
|
return (original.declarations ?? []).some(isTsLiteralTupleDeclaration);
|
|
7110
7302
|
}
|
|
7111
7303
|
return {
|
|
@@ -7200,7 +7392,7 @@ var preferEnumRule = {
|
|
|
7200
7392
|
};
|
|
7201
7393
|
|
|
7202
7394
|
// eslint/rules/prefer-object-destructuring.ts
|
|
7203
|
-
import
|
|
7395
|
+
import ts12 from "typescript";
|
|
7204
7396
|
var DOC7 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
7205
7397
|
function hasTypeAnnotation(identifier) {
|
|
7206
7398
|
return "typeAnnotation" in identifier && identifier.typeAnnotation !== void 0;
|
|
@@ -7293,8 +7485,8 @@ function enumValueResolver(context) {
|
|
|
7293
7485
|
const checker = services.program.getTypeChecker();
|
|
7294
7486
|
const { esTreeNodeToTSNodeMap: nodeMap } = services;
|
|
7295
7487
|
const isEnumSymbol = (symbol) => {
|
|
7296
|
-
const resolved = symbol.flags ===
|
|
7297
|
-
return (resolved.declarations ?? []).some((declaration) =>
|
|
7488
|
+
const resolved = symbol.flags === ts12.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
7489
|
+
return (resolved.declarations ?? []).some((declaration) => ts12.isEnumDeclaration(declaration));
|
|
7298
7490
|
};
|
|
7299
7491
|
return (node) => {
|
|
7300
7492
|
const tsNode = nodeMap.get(node);
|
|
@@ -7310,18 +7502,18 @@ function detachableCallResolver(context) {
|
|
|
7310
7502
|
if (!services) return () => false;
|
|
7311
7503
|
const checker = services.program.getTypeChecker();
|
|
7312
7504
|
const { esTreeNodeToTSNodeMap: nodeMap } = services;
|
|
7313
|
-
const isUnboundFunctionType = (type) =>
|
|
7505
|
+
const isUnboundFunctionType = (type) => ts12.isFunctionTypeNode(type) && !type.parameters.some((parameter) => ts12.isIdentifier(parameter.name) && parameter.name.text === "this");
|
|
7314
7506
|
return (member) => {
|
|
7315
7507
|
const node = nodeMap.get(member);
|
|
7316
|
-
if (!node || !
|
|
7508
|
+
if (!node || !ts12.isPropertyAccessExpression(node)) return false;
|
|
7317
7509
|
const symbol = checker.getSymbolAtLocation(node.name);
|
|
7318
7510
|
const declarations = symbol?.declarations;
|
|
7319
7511
|
if (!declarations?.length) return false;
|
|
7320
7512
|
return declarations.every((declaration) => {
|
|
7321
|
-
if (
|
|
7322
|
-
return declaration.type !== void 0 && isUnboundFunctionType(declaration.type) ||
|
|
7513
|
+
if (ts12.isPropertySignature(declaration) || ts12.isPropertyDeclaration(declaration)) {
|
|
7514
|
+
return declaration.type !== void 0 && isUnboundFunctionType(declaration.type) || ts12.isPropertyDeclaration(declaration) && declaration.initializer !== void 0 && ts12.isArrowFunction(declaration.initializer);
|
|
7323
7515
|
}
|
|
7324
|
-
if (
|
|
7516
|
+
if (ts12.isPropertyAssignment(declaration)) return ts12.isArrowFunction(declaration.initializer);
|
|
7325
7517
|
return false;
|
|
7326
7518
|
});
|
|
7327
7519
|
};
|
|
@@ -7741,7 +7933,7 @@ ${indentation}`;
|
|
|
7741
7933
|
};
|
|
7742
7934
|
|
|
7743
7935
|
// eslint/rules/pure-function-extract.ts
|
|
7744
|
-
import
|
|
7936
|
+
import path50 from "path";
|
|
7745
7937
|
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
7746
7938
|
"GET",
|
|
7747
7939
|
"POST",
|
|
@@ -7806,12 +7998,12 @@ var pureFunctionExtractRule = {
|
|
|
7806
7998
|
},
|
|
7807
7999
|
create(context) {
|
|
7808
8000
|
const filename = context.filename;
|
|
7809
|
-
const isRouteFile =
|
|
8001
|
+
const isRouteFile = path50.basename(filename) === "route.ts";
|
|
7810
8002
|
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
7811
8003
|
const sourceRoot = sourceRootOf(context);
|
|
7812
|
-
const relative =
|
|
8004
|
+
const relative = path50.relative(sourceRoot, filename);
|
|
7813
8005
|
if (relative.startsWith("..")) return {};
|
|
7814
|
-
const segments = relative.split(
|
|
8006
|
+
const segments = relative.split(path50.sep);
|
|
7815
8007
|
const folders = segments.slice(0, -1);
|
|
7816
8008
|
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
7817
8009
|
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
@@ -7871,15 +8063,15 @@ var pureFunctionExtractRule = {
|
|
|
7871
8063
|
};
|
|
7872
8064
|
|
|
7873
8065
|
// eslint/rules/repeated-numeric-value.ts
|
|
7874
|
-
import
|
|
8066
|
+
import path51 from "path";
|
|
7875
8067
|
function isNonProductionFile(file, sourceRoot) {
|
|
7876
|
-
const relative =
|
|
7877
|
-
const segments = relative.split(
|
|
7878
|
-
const basename =
|
|
8068
|
+
const relative = path51.relative(sourceRoot, file);
|
|
8069
|
+
const segments = relative.split(path51.sep);
|
|
8070
|
+
const basename = path51.basename(file);
|
|
7879
8071
|
return /\.(?:test|spec|mock)\.[^.]+$/.test(basename) || segments.some((segment) => segment === "__tests__" || segment === "__mocks__" || segment === "mocks");
|
|
7880
8072
|
}
|
|
7881
8073
|
function isCanonicalConstantFile(file, sourceRoot) {
|
|
7882
|
-
const segments =
|
|
8074
|
+
const segments = path51.relative(sourceRoot, file).split(path51.sep);
|
|
7883
8075
|
return segments.includes("constants") || segments[0] === "config";
|
|
7884
8076
|
}
|
|
7885
8077
|
function groupKey(literal) {
|
|
@@ -7895,7 +8087,7 @@ var repeatedNumericValueRule = {
|
|
|
7895
8087
|
},
|
|
7896
8088
|
create(context) {
|
|
7897
8089
|
const sourceRoot = sourceRootOf(context);
|
|
7898
|
-
const file =
|
|
8090
|
+
const file = path51.resolve(context.filename);
|
|
7899
8091
|
if (isNonProductionFile(file, sourceRoot) || isCanonicalConstantFile(file, sourceRoot)) return {};
|
|
7900
8092
|
const index = getProjectIndex(sourceRoot);
|
|
7901
8093
|
if (!index) return {};
|
|
@@ -7932,11 +8124,11 @@ var repeatedNumericValueRule = {
|
|
|
7932
8124
|
};
|
|
7933
8125
|
|
|
7934
8126
|
// eslint/rules/repeated-semantic-literal.ts
|
|
7935
|
-
import
|
|
8127
|
+
import path53 from "path";
|
|
7936
8128
|
|
|
7937
8129
|
// eslint/rules/imported-enum-literals.ts
|
|
7938
|
-
import
|
|
7939
|
-
import
|
|
8130
|
+
import path52 from "path";
|
|
8131
|
+
import ts13 from "typescript";
|
|
7940
8132
|
var columnMethods2 = /* @__PURE__ */ new Set([
|
|
7941
8133
|
"eq",
|
|
7942
8134
|
"neq",
|
|
@@ -7953,12 +8145,12 @@ var columnMethods2 = /* @__PURE__ */ new Set([
|
|
|
7953
8145
|
"not"
|
|
7954
8146
|
]);
|
|
7955
8147
|
function memberName7(name) {
|
|
7956
|
-
if (
|
|
8148
|
+
if (ts13.isIdentifier(name) || ts13.isStringLiteral(name)) return name.text;
|
|
7957
8149
|
return void 0;
|
|
7958
8150
|
}
|
|
7959
8151
|
function isWithin3(root, file) {
|
|
7960
|
-
const relative =
|
|
7961
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
8152
|
+
const relative = path52.relative(root, file);
|
|
8153
|
+
return relative === "" || !relative.startsWith("..") && !path52.isAbsolute(relative);
|
|
7962
8154
|
}
|
|
7963
8155
|
function domainOf(name) {
|
|
7964
8156
|
if (name.endsWith("ColumnEnum")) return "column";
|
|
@@ -7968,22 +8160,22 @@ function domainOf(name) {
|
|
|
7968
8160
|
function importedEnums(file, checker, sourceRoot, importedNames) {
|
|
7969
8161
|
const matches = /* @__PURE__ */ new Map();
|
|
7970
8162
|
for (const statement of file.statements) {
|
|
7971
|
-
if (!
|
|
8163
|
+
if (!ts13.isImportDeclaration(statement) || !statement.importClause?.namedBindings || !ts13.isNamedImports(statement.importClause.namedBindings)) {
|
|
7972
8164
|
continue;
|
|
7973
8165
|
}
|
|
7974
8166
|
for (const specifier of statement.importClause.namedBindings.elements) {
|
|
7975
8167
|
if (!importedNames.has(specifier.name.text)) continue;
|
|
7976
8168
|
const symbol = checker.getSymbolAtLocation(specifier.name);
|
|
7977
8169
|
if (!symbol) continue;
|
|
7978
|
-
const resolved = symbol.flags ===
|
|
8170
|
+
const resolved = symbol.flags === ts13.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
7979
8171
|
for (const declaration of resolved.declarations ?? []) {
|
|
7980
|
-
if (!
|
|
7981
|
-
const declarationFile =
|
|
8172
|
+
if (!ts13.isEnumDeclaration(declaration)) continue;
|
|
8173
|
+
const declarationFile = path52.resolve(declaration.getSourceFile().fileName);
|
|
7982
8174
|
if (!isWithin3(sourceRoot, declarationFile)) continue;
|
|
7983
8175
|
const domain = domainOf(declaration.name.text);
|
|
7984
8176
|
if (!domain) continue;
|
|
7985
8177
|
for (const member of declaration.members) {
|
|
7986
|
-
if (!member.initializer || !
|
|
8178
|
+
if (!member.initializer || !ts13.isStringLiteral(member.initializer)) continue;
|
|
7987
8179
|
const name = memberName7(member.name);
|
|
7988
8180
|
if (!name) continue;
|
|
7989
8181
|
const entries = matches.get(member.initializer.text) ?? [];
|
|
@@ -8000,25 +8192,25 @@ function importedEnums(file, checker, sourceRoot, importedNames) {
|
|
|
8000
8192
|
return matches;
|
|
8001
8193
|
}
|
|
8002
8194
|
function isPathname2(node) {
|
|
8003
|
-
return
|
|
8195
|
+
return ts13.isPropertyAccessExpression(node) && node.name.text === "pathname";
|
|
8004
8196
|
}
|
|
8005
8197
|
function domainForUse(node) {
|
|
8006
8198
|
const parent = node.parent;
|
|
8007
|
-
if (
|
|
8199
|
+
if (ts13.isPropertyAssignment(parent) && parent.initializer === node && memberName7(parent.name) === "path") {
|
|
8008
8200
|
return "route";
|
|
8009
8201
|
}
|
|
8010
|
-
if (
|
|
8202
|
+
if (ts13.isCallExpression(parent) && parent.arguments[0] === node && ts13.isPropertyAccessExpression(parent.expression)) {
|
|
8011
8203
|
const { expression, name } = parent.expression;
|
|
8012
8204
|
if (columnMethods2.has(name.text)) return "column";
|
|
8013
8205
|
if (name.text === "startsWith" && isPathname2(expression)) return "route";
|
|
8014
8206
|
}
|
|
8015
|
-
if (
|
|
8207
|
+
if (ts13.isBinaryExpression(parent) && (parent.operatorToken.kind === ts13.SyntaxKind.EqualsEqualsEqualsToken || parent.operatorToken.kind === ts13.SyntaxKind.ExclamationEqualsEqualsToken) && (parent.left === node && isPathname2(parent.right) || parent.right === node && isPathname2(parent.left))) {
|
|
8016
8208
|
return "route";
|
|
8017
8209
|
}
|
|
8018
8210
|
return void 0;
|
|
8019
8211
|
}
|
|
8020
8212
|
function importedEnumLiteralUses(context, root) {
|
|
8021
|
-
const filename =
|
|
8213
|
+
const filename = path52.resolve(context.filename);
|
|
8022
8214
|
if (!isWithin3(root, filename)) return [];
|
|
8023
8215
|
const services = typedParserServices(context.sourceCode.parserServices);
|
|
8024
8216
|
if (!services) return [];
|
|
@@ -8034,7 +8226,7 @@ function importedEnumLiteralUses(context, root) {
|
|
|
8034
8226
|
if (matches.size === 0) return [];
|
|
8035
8227
|
const uses = [];
|
|
8036
8228
|
const visit = (node) => {
|
|
8037
|
-
if (
|
|
8229
|
+
if (ts13.isStringLiteral(node)) {
|
|
8038
8230
|
const domain = domainForUse(node);
|
|
8039
8231
|
const candidates = matches.get(node.text)?.filter((entry) => entry.domain === domain) ?? [];
|
|
8040
8232
|
if (candidates.length === 1) {
|
|
@@ -8051,7 +8243,7 @@ function importedEnumLiteralUses(context, root) {
|
|
|
8051
8243
|
}
|
|
8052
8244
|
}
|
|
8053
8245
|
}
|
|
8054
|
-
|
|
8246
|
+
ts13.forEachChild(node, visit);
|
|
8055
8247
|
};
|
|
8056
8248
|
visit(file);
|
|
8057
8249
|
return uses;
|
|
@@ -8072,7 +8264,7 @@ function canonicalMatches(use, canonical, sourceRoot) {
|
|
|
8072
8264
|
const semanticName2 = use.family.split(":")[1];
|
|
8073
8265
|
if (!semanticName2 || !name.toLowerCase().includes(semanticName2.toLowerCase())) return false;
|
|
8074
8266
|
const location = featureOf(canonical.file, sourceRoot);
|
|
8075
|
-
return location === featureOf(use.file, sourceRoot) ||
|
|
8267
|
+
return location === featureOf(use.file, sourceRoot) || path53.relative(sourceRoot, canonical.file).split(path53.sep)[0] === "constants";
|
|
8076
8268
|
}
|
|
8077
8269
|
return false;
|
|
8078
8270
|
}
|
|
@@ -8086,7 +8278,7 @@ function messageFor(use, matches, duplicateRouteDomains, existingRouteEnum, root
|
|
|
8086
8278
|
const count = new Set(matches.map((match) => match.file)).size;
|
|
8087
8279
|
const kind = use.kind === "string" ? "string" : "numeric";
|
|
8088
8280
|
if (use.family === "api-route" && existingRouteEnum?.owner) {
|
|
8089
|
-
const location =
|
|
8281
|
+
const location = path53.relative(root, existingRouteEnum.file).replaceAll(path53.sep, "/");
|
|
8090
8282
|
return `The route ${formatValue(use)} repeats; add a member to existing ${existingRouteEnum.owner} in src/${location} and reuse it. ${DOC8}`;
|
|
8091
8283
|
}
|
|
8092
8284
|
if (count === 1) {
|
|
@@ -8105,7 +8297,7 @@ var repeatedSemanticLiteralRule = {
|
|
|
8105
8297
|
},
|
|
8106
8298
|
create(context) {
|
|
8107
8299
|
const root = sourceRootOf(context);
|
|
8108
|
-
const file =
|
|
8300
|
+
const file = path53.resolve(context.filename);
|
|
8109
8301
|
if (!isProductionSource(file, root)) return {};
|
|
8110
8302
|
const project = getProjectIndex(root);
|
|
8111
8303
|
if (!project?.modules.has(file)) return {};
|
|
@@ -8150,7 +8342,7 @@ var repeatedSemanticLiteralRule = {
|
|
|
8150
8342
|
return {
|
|
8151
8343
|
Program(node) {
|
|
8152
8344
|
for (const use of imported) {
|
|
8153
|
-
const relative =
|
|
8345
|
+
const relative = path53.relative(root, use.sourceFile).replaceAll(path53.sep, "/");
|
|
8154
8346
|
context.report({
|
|
8155
8347
|
node,
|
|
8156
8348
|
loc: { line: use.line, column: use.column },
|
|
@@ -8165,7 +8357,7 @@ var repeatedSemanticLiteralRule = {
|
|
|
8165
8357
|
if (candidates.length === 1) {
|
|
8166
8358
|
const canonical = candidates[0];
|
|
8167
8359
|
if (!canonical) continue;
|
|
8168
|
-
const relative =
|
|
8360
|
+
const relative = path53.relative(root, canonical.file).replaceAll(path53.sep, "/");
|
|
8169
8361
|
context.report({
|
|
8170
8362
|
node,
|
|
8171
8363
|
loc: { line: use.line, column: use.column },
|
|
@@ -8178,7 +8370,7 @@ var repeatedSemanticLiteralRule = {
|
|
|
8178
8370
|
const peers = groups.get(key) ?? [];
|
|
8179
8371
|
if (peers.length < 2) {
|
|
8180
8372
|
if (use.family === "api-route" && existingRouteEnum?.owner) {
|
|
8181
|
-
const location =
|
|
8373
|
+
const location = path53.relative(root, existingRouteEnum.file).replaceAll(path53.sep, "/");
|
|
8182
8374
|
context.report({
|
|
8183
8375
|
node,
|
|
8184
8376
|
loc: { line: use.line, column: use.column },
|
|
@@ -8390,7 +8582,7 @@ var repeatedStructureRule = {
|
|
|
8390
8582
|
|
|
8391
8583
|
// eslint/rules/require-barrel-star-exports.ts
|
|
8392
8584
|
import fs5 from "fs";
|
|
8393
|
-
import
|
|
8585
|
+
import path54 from "path";
|
|
8394
8586
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
8395
8587
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
8396
8588
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
@@ -8398,9 +8590,9 @@ function resolveSiblingModule(indexFile, specifier) {
|
|
|
8398
8590
|
if (!specifier.startsWith("./")) return void 0;
|
|
8399
8591
|
const relative = specifier.slice(2);
|
|
8400
8592
|
if (!relative || relative.includes("/")) return void 0;
|
|
8401
|
-
const directory =
|
|
8402
|
-
const direct =
|
|
8403
|
-
const candidates =
|
|
8593
|
+
const directory = path54.dirname(indexFile);
|
|
8594
|
+
const direct = path54.resolve(directory, relative);
|
|
8595
|
+
const candidates = path54.extname(direct) ? [direct] : MODULE_EXTENSIONS3.map((extension) => `${direct}${extension}`);
|
|
8404
8596
|
return candidates.find((candidate) => fs5.existsSync(candidate) && fs5.statSync(candidate).isFile());
|
|
8405
8597
|
}
|
|
8406
8598
|
var requireBarrelStarExportsRule = {
|
|
@@ -8413,9 +8605,9 @@ var requireBarrelStarExportsRule = {
|
|
|
8413
8605
|
fixable: "code"
|
|
8414
8606
|
},
|
|
8415
8607
|
create(context) {
|
|
8416
|
-
const filename =
|
|
8417
|
-
if (!INDEX_NAMES.has(
|
|
8418
|
-
if (!SUPPORT_FOLDERS3.has(
|
|
8608
|
+
const filename = path54.resolve(context.filename);
|
|
8609
|
+
if (!INDEX_NAMES.has(path54.basename(filename))) return {};
|
|
8610
|
+
if (!SUPPORT_FOLDERS3.has(path54.basename(path54.dirname(filename)))) return {};
|
|
8419
8611
|
return {
|
|
8420
8612
|
ExportNamedDeclaration(node) {
|
|
8421
8613
|
const sourceNode = node.source;
|
|
@@ -8468,7 +8660,7 @@ var requireBarrelStarExportsRule = {
|
|
|
8468
8660
|
};
|
|
8469
8661
|
|
|
8470
8662
|
// eslint/rules/root-support-placement.ts
|
|
8471
|
-
import
|
|
8663
|
+
import path55 from "path";
|
|
8472
8664
|
function isSupportFolder(value) {
|
|
8473
8665
|
return value === "utils" || value === "types" || value === "schemas" || value === "constants";
|
|
8474
8666
|
}
|
|
@@ -8501,7 +8693,7 @@ var rootSupportPlacementRule = {
|
|
|
8501
8693
|
},
|
|
8502
8694
|
create(context) {
|
|
8503
8695
|
const sourceRoot = sourceRootOf(context);
|
|
8504
|
-
const file =
|
|
8696
|
+
const file = path55.resolve(context.filename);
|
|
8505
8697
|
const segments = segmentsOf(file, sourceRoot);
|
|
8506
8698
|
const folderSegments = folderSegmentsOf(file, sourceRoot);
|
|
8507
8699
|
const supportFolder = folderSegments[folderSegments.length - 1];
|
|
@@ -8547,11 +8739,11 @@ var rootSupportPlacementRule = {
|
|
|
8547
8739
|
};
|
|
8548
8740
|
|
|
8549
8741
|
// eslint/rules/route-handler-shape.ts
|
|
8550
|
-
import
|
|
8551
|
-
import
|
|
8742
|
+
import path57 from "path";
|
|
8743
|
+
import ts14 from "typescript";
|
|
8552
8744
|
|
|
8553
8745
|
// eslint/rules/route-single-use-delegation.ts
|
|
8554
|
-
import
|
|
8746
|
+
import path56 from "path";
|
|
8555
8747
|
function responseCall(expression) {
|
|
8556
8748
|
if (!expression) return void 0;
|
|
8557
8749
|
if (expression.type === "AwaitExpression") return responseCall(expression.argument);
|
|
@@ -8593,7 +8785,7 @@ function soleDelegation(handler) {
|
|
|
8593
8785
|
return isData && property.value.type === "Identifier" && property.value.name === variable.id.name ? call : void 0;
|
|
8594
8786
|
}
|
|
8595
8787
|
function isTestFile2(file) {
|
|
8596
|
-
return /(?:\.test|\.spec)\.[cm]?[jt]sx?$/.test(file) ||
|
|
8788
|
+
return /(?:\.test|\.spec)\.[cm]?[jt]sx?$/.test(file) || path56.normalize(file).split(path56.sep).includes("__tests__");
|
|
8597
8789
|
}
|
|
8598
8790
|
function functionSource(index, file, name, sourceRoot, visited = /* @__PURE__ */ new Set()) {
|
|
8599
8791
|
if (visited.has(file)) return void 0;
|
|
@@ -8662,33 +8854,33 @@ function findHandler(node) {
|
|
|
8662
8854
|
return void 0;
|
|
8663
8855
|
}
|
|
8664
8856
|
function isLoop(node) {
|
|
8665
|
-
return
|
|
8857
|
+
return ts14.isForStatement(node) || ts14.isForOfStatement(node) || ts14.isForInStatement(node) || ts14.isWhileStatement(node) || ts14.isDoStatement(node);
|
|
8666
8858
|
}
|
|
8667
8859
|
function isFunctionBoundary(node) {
|
|
8668
|
-
return
|
|
8860
|
+
return ts14.isFunctionExpression(node) || ts14.isArrowFunction(node) || ts14.isFunctionDeclaration(node);
|
|
8669
8861
|
}
|
|
8670
8862
|
function analyzeHandlerBody(body, sourceText) {
|
|
8671
8863
|
const start = body.range?.[0] ?? 0;
|
|
8672
8864
|
const end = body.range?.[1] ?? sourceText.length;
|
|
8673
|
-
const sourceFile =
|
|
8865
|
+
const sourceFile = ts14.createSourceFile(
|
|
8674
8866
|
"route.ts",
|
|
8675
8867
|
sourceText.slice(start, end),
|
|
8676
|
-
|
|
8868
|
+
ts14.ScriptTarget.Latest,
|
|
8677
8869
|
true,
|
|
8678
|
-
|
|
8870
|
+
ts14.ScriptKind.TS
|
|
8679
8871
|
);
|
|
8680
8872
|
const kinds = /* @__PURE__ */ new Set();
|
|
8681
8873
|
const calledNames = /* @__PURE__ */ new Set();
|
|
8682
8874
|
const visit = (node) => {
|
|
8683
|
-
if (
|
|
8875
|
+
if (ts14.isTryStatement(node)) kinds.add("try");
|
|
8684
8876
|
if (isLoop(node)) kinds.add("loop");
|
|
8685
|
-
if (
|
|
8686
|
-
if (
|
|
8877
|
+
if (ts14.isIfStatement(node)) kinds.add("if");
|
|
8878
|
+
if (ts14.isCallExpression(node) && ts14.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map") {
|
|
8687
8879
|
kinds.add("map");
|
|
8688
8880
|
}
|
|
8689
|
-
if (
|
|
8881
|
+
if (ts14.isCallExpression(node) && ts14.isIdentifier(node.expression)) calledNames.add(node.expression.text);
|
|
8690
8882
|
if (isFunctionBoundary(node)) return;
|
|
8691
|
-
|
|
8883
|
+
ts14.forEachChild(node, visit);
|
|
8692
8884
|
};
|
|
8693
8885
|
visit(sourceFile);
|
|
8694
8886
|
return { kinds, calledNames };
|
|
@@ -8728,7 +8920,7 @@ var routeHandlerShapeRule = {
|
|
|
8728
8920
|
}
|
|
8729
8921
|
},
|
|
8730
8922
|
create(context) {
|
|
8731
|
-
if (
|
|
8923
|
+
if (path57.basename(context.filename) !== "route.ts") return {};
|
|
8732
8924
|
const sourceText = context.sourceCode.text;
|
|
8733
8925
|
function reportUnwrapped(node, name) {
|
|
8734
8926
|
context.report({
|
|
@@ -8794,7 +8986,7 @@ var routeHandlerShapeRule = {
|
|
|
8794
8986
|
};
|
|
8795
8987
|
|
|
8796
8988
|
// eslint/rules/schema-casing.ts
|
|
8797
|
-
import
|
|
8989
|
+
import path58 from "path";
|
|
8798
8990
|
function isCamelCase(name) {
|
|
8799
8991
|
return /^[a-z][a-zA-Z0-9]*$/.test(name);
|
|
8800
8992
|
}
|
|
@@ -8822,9 +9014,9 @@ var schemaCasingRule = {
|
|
|
8822
9014
|
}
|
|
8823
9015
|
},
|
|
8824
9016
|
create(context) {
|
|
8825
|
-
const filename =
|
|
9017
|
+
const filename = path58.resolve(context.filename);
|
|
8826
9018
|
const sourceRoot = sourceRootOf(context);
|
|
8827
|
-
if (!filename.startsWith(sourceRoot +
|
|
9019
|
+
if (!filename.startsWith(sourceRoot + path58.sep)) return {};
|
|
8828
9020
|
let zodLocalName;
|
|
8829
9021
|
return {
|
|
8830
9022
|
ImportDeclaration(node) {
|
|
@@ -8856,39 +9048,39 @@ var schemaCasingRule = {
|
|
|
8856
9048
|
};
|
|
8857
9049
|
|
|
8858
9050
|
// eslint/rules/sole-state-owner.ts
|
|
8859
|
-
import
|
|
8860
|
-
import
|
|
9051
|
+
import path59 from "path";
|
|
9052
|
+
import ts15 from "typescript";
|
|
8861
9053
|
function findStateHooks(node) {
|
|
8862
9054
|
const hooks = [];
|
|
8863
9055
|
const visit = (child) => {
|
|
8864
|
-
if (
|
|
8865
|
-
if (
|
|
9056
|
+
if (ts15.isCallExpression(child) && ts15.isIdentifier(child.expression) && child.expression.text === "useState") {
|
|
9057
|
+
if (ts15.isVariableDeclaration(child.parent)) {
|
|
8866
9058
|
const { name } = child.parent;
|
|
8867
|
-
if (
|
|
9059
|
+
if (ts15.isArrayBindingPattern(name) && name.elements.length >= 2) {
|
|
8868
9060
|
const value = name.elements[0];
|
|
8869
9061
|
const updater = name.elements[1];
|
|
8870
|
-
if (value && updater &&
|
|
9062
|
+
if (value && updater && ts15.isBindingElement(value) && ts15.isBindingElement(updater)) {
|
|
8871
9063
|
const valueName = value.name;
|
|
8872
9064
|
const updaterName = updater.name;
|
|
8873
|
-
if (
|
|
9065
|
+
if (ts15.isIdentifier(valueName) && ts15.isIdentifier(updaterName)) {
|
|
8874
9066
|
hooks.push({ value: valueName.text, updater: updaterName.text });
|
|
8875
9067
|
}
|
|
8876
9068
|
}
|
|
8877
9069
|
}
|
|
8878
9070
|
}
|
|
8879
9071
|
}
|
|
8880
|
-
|
|
9072
|
+
ts15.forEachChild(child, visit);
|
|
8881
9073
|
};
|
|
8882
9074
|
visit(node);
|
|
8883
9075
|
return hooks;
|
|
8884
9076
|
}
|
|
8885
9077
|
function isHookUsage(node, hook) {
|
|
8886
|
-
if (
|
|
9078
|
+
if (ts15.isCallExpression(node) && ts15.isIdentifier(node.expression) && node.expression.text === hook.updater) {
|
|
8887
9079
|
return "updater";
|
|
8888
9080
|
}
|
|
8889
|
-
if (
|
|
9081
|
+
if (ts15.isIdentifier(node) && node.text === hook.value) {
|
|
8890
9082
|
const parent = node.parent;
|
|
8891
|
-
if (
|
|
9083
|
+
if (ts15.isBindingElement(parent) || ts15.isPropertyAccessExpression(parent) || ts15.isShorthandPropertyAssignment(parent)) {
|
|
8892
9084
|
return void 0;
|
|
8893
9085
|
}
|
|
8894
9086
|
return "value";
|
|
@@ -8898,16 +9090,16 @@ function isHookUsage(node, hook) {
|
|
|
8898
9090
|
function topLevelJsxChildren(initial) {
|
|
8899
9091
|
if (!initial) return void 0;
|
|
8900
9092
|
let expression = initial;
|
|
8901
|
-
while (
|
|
8902
|
-
if (
|
|
9093
|
+
while (ts15.isParenthesizedExpression(expression)) expression = expression.expression;
|
|
9094
|
+
if (ts15.isJsxFragment(expression)) {
|
|
8903
9095
|
const children = expression.children.filter(
|
|
8904
|
-
(c) => !
|
|
9096
|
+
(c) => !ts15.isJsxText(c) && !ts15.isJsxSpreadAttribute(c)
|
|
8905
9097
|
);
|
|
8906
9098
|
return { root: expression, children };
|
|
8907
9099
|
}
|
|
8908
|
-
if (
|
|
9100
|
+
if (ts15.isJsxElement(expression)) {
|
|
8909
9101
|
const children = expression.children.filter(
|
|
8910
|
-
(c) => !
|
|
9102
|
+
(c) => !ts15.isJsxText(c) && !ts15.isJsxSpreadAttribute(c)
|
|
8911
9103
|
);
|
|
8912
9104
|
return { root: expression, children };
|
|
8913
9105
|
}
|
|
@@ -8921,8 +9113,8 @@ function collectUsesIn(child, hook) {
|
|
|
8921
9113
|
positions.push(node);
|
|
8922
9114
|
count += 1;
|
|
8923
9115
|
}
|
|
8924
|
-
if (
|
|
8925
|
-
|
|
9116
|
+
if (ts15.isFunctionDeclaration(node) || ts15.isClassDeclaration(node)) return;
|
|
9117
|
+
ts15.forEachChild(node, visit);
|
|
8926
9118
|
};
|
|
8927
9119
|
visit(child);
|
|
8928
9120
|
return { positions, count };
|
|
@@ -8936,7 +9128,7 @@ var soleStateOwnerRule = {
|
|
|
8936
9128
|
}
|
|
8937
9129
|
},
|
|
8938
9130
|
create(context) {
|
|
8939
|
-
const filename =
|
|
9131
|
+
const filename = path59.resolve(context.filename);
|
|
8940
9132
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
8941
9133
|
const text = context.sourceCode.text;
|
|
8942
9134
|
const components = parseComponentInfo(text, filename);
|
|
@@ -8961,18 +9153,18 @@ var soleStateOwnerRule = {
|
|
|
8961
9153
|
}
|
|
8962
9154
|
};
|
|
8963
9155
|
function analyzeSoleOwner(declaration, hook) {
|
|
8964
|
-
const body =
|
|
8965
|
-
if (!body || !
|
|
9156
|
+
const body = ts15.isFunctionDeclaration(declaration) ? declaration.body : void 0;
|
|
9157
|
+
if (!body || !ts15.isBlock(body)) return void 0;
|
|
8966
9158
|
const returns = [];
|
|
8967
9159
|
const visit = (node) => {
|
|
8968
|
-
if (node !== body && (
|
|
8969
|
-
if (
|
|
8970
|
-
|
|
9160
|
+
if (node !== body && (ts15.isFunctionLike(node) || ts15.isClassLike(node))) return;
|
|
9161
|
+
if (ts15.isReturnStatement(node)) returns.push(node);
|
|
9162
|
+
ts15.forEachChild(node, visit);
|
|
8971
9163
|
};
|
|
8972
9164
|
visit(body);
|
|
8973
9165
|
if (returns.length !== 1) return void 0;
|
|
8974
9166
|
const single = returns[0];
|
|
8975
|
-
if (!single?.expression || !
|
|
9167
|
+
if (!single?.expression || !ts15.isExpression(single.expression)) return void 0;
|
|
8976
9168
|
const returnExpression = single.expression;
|
|
8977
9169
|
const root = topLevelJsxChildren(returnExpression);
|
|
8978
9170
|
if (!root || root.children.length === 0) return void 0;
|
|
@@ -8995,11 +9187,11 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
8995
9187
|
let outside = false;
|
|
8996
9188
|
const visit = (node) => {
|
|
8997
9189
|
if (outside) return;
|
|
8998
|
-
if (node !== declaration && (
|
|
9190
|
+
if (node !== declaration && (ts15.isFunctionDeclaration(node) || ts15.isClassDeclaration(node))) return;
|
|
8999
9191
|
if (isHookUsage(node, hook)) {
|
|
9000
9192
|
let current = node;
|
|
9001
9193
|
let isInJsxChild = false;
|
|
9002
|
-
while (!
|
|
9194
|
+
while (!ts15.isSourceFile(current)) {
|
|
9003
9195
|
if (children.includes(current)) {
|
|
9004
9196
|
isInJsxChild = true;
|
|
9005
9197
|
break;
|
|
@@ -9008,14 +9200,14 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
9008
9200
|
}
|
|
9009
9201
|
if (!isInJsxChild) outside = true;
|
|
9010
9202
|
}
|
|
9011
|
-
|
|
9203
|
+
ts15.forEachChild(node, visit);
|
|
9012
9204
|
};
|
|
9013
9205
|
visit(declaration);
|
|
9014
9206
|
return outside;
|
|
9015
9207
|
}
|
|
9016
9208
|
|
|
9017
9209
|
// eslint/rules/source-under-src.ts
|
|
9018
|
-
import
|
|
9210
|
+
import path60 from "path";
|
|
9019
9211
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
9020
9212
|
".agents",
|
|
9021
9213
|
".cache",
|
|
@@ -9056,14 +9248,14 @@ var sourceUnderSrcRule = {
|
|
|
9056
9248
|
}
|
|
9057
9249
|
},
|
|
9058
9250
|
create(context) {
|
|
9059
|
-
const filename =
|
|
9251
|
+
const filename = path60.resolve(context.filename);
|
|
9060
9252
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
9061
|
-
const relative =
|
|
9253
|
+
const relative = path60.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
9062
9254
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
9063
9255
|
const topLevel = relative.split("/")[0] ?? "";
|
|
9064
9256
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
9065
9257
|
if (!relative.includes("/")) {
|
|
9066
|
-
const basename =
|
|
9258
|
+
const basename = path60.basename(filename);
|
|
9067
9259
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
9068
9260
|
}
|
|
9069
9261
|
return {
|
|
@@ -9079,7 +9271,7 @@ var sourceUnderSrcRule = {
|
|
|
9079
9271
|
};
|
|
9080
9272
|
|
|
9081
9273
|
// eslint/rules/stay-flat.ts
|
|
9082
|
-
import
|
|
9274
|
+
import path61 from "path";
|
|
9083
9275
|
var stayFlatRule = {
|
|
9084
9276
|
meta: {
|
|
9085
9277
|
schema: [],
|
|
@@ -9090,7 +9282,7 @@ var stayFlatRule = {
|
|
|
9090
9282
|
},
|
|
9091
9283
|
create(context) {
|
|
9092
9284
|
const sourceRoot = sourceRootOf(context);
|
|
9093
|
-
const file =
|
|
9285
|
+
const file = path61.resolve(context.filename);
|
|
9094
9286
|
const segments = segmentsOf(file, sourceRoot);
|
|
9095
9287
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
9096
9288
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -9130,7 +9322,7 @@ var stayFlatRule = {
|
|
|
9130
9322
|
};
|
|
9131
9323
|
|
|
9132
9324
|
// eslint/rules/support-file-placement.ts
|
|
9133
|
-
import
|
|
9325
|
+
import path62 from "path";
|
|
9134
9326
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
9135
9327
|
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
9136
9328
|
["constants", "constant"],
|
|
@@ -9155,7 +9347,7 @@ var supportFilePlacementRule = {
|
|
|
9155
9347
|
},
|
|
9156
9348
|
create(context) {
|
|
9157
9349
|
const sourceRoot = sourceRootOf(context);
|
|
9158
|
-
const supportFile =
|
|
9350
|
+
const supportFile = path62.resolve(context.filename);
|
|
9159
9351
|
const currentFolder = folderSegmentsOf(supportFile, sourceRoot);
|
|
9160
9352
|
const supportFolder = currentFolder[currentFolder.length - 1];
|
|
9161
9353
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS.has(supportFolder)) return {};
|
|
@@ -9209,7 +9401,7 @@ var supportFilePlacementRule = {
|
|
|
9209
9401
|
|
|
9210
9402
|
// eslint/rules/support-folder-shape.ts
|
|
9211
9403
|
import fs6 from "fs";
|
|
9212
|
-
import
|
|
9404
|
+
import path63 from "path";
|
|
9213
9405
|
var SUPPORT_FOLDERS4 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
9214
9406
|
var INDEX_NAMES2 = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
9215
9407
|
var supportFolderShapeRule = {
|
|
@@ -9221,12 +9413,12 @@ var supportFolderShapeRule = {
|
|
|
9221
9413
|
}
|
|
9222
9414
|
},
|
|
9223
9415
|
create(context) {
|
|
9224
|
-
const filename =
|
|
9225
|
-
const baseName =
|
|
9416
|
+
const filename = path63.resolve(context.filename);
|
|
9417
|
+
const baseName = path63.basename(filename);
|
|
9226
9418
|
if (!INDEX_NAMES2.has(baseName)) return {};
|
|
9227
|
-
const folder =
|
|
9419
|
+
const folder = path63.basename(path63.dirname(filename));
|
|
9228
9420
|
if (!SUPPORT_FOLDERS4.has(folder)) return {};
|
|
9229
|
-
const directory =
|
|
9421
|
+
const directory = path63.dirname(filename);
|
|
9230
9422
|
let entries;
|
|
9231
9423
|
try {
|
|
9232
9424
|
entries = fs6.readdirSync(directory);
|
|
@@ -9244,7 +9436,7 @@ var supportFolderShapeRule = {
|
|
|
9244
9436
|
for (const match of source.matchAll(exportPattern)) {
|
|
9245
9437
|
hasAnyReExport = true;
|
|
9246
9438
|
const specifier = match.groups?.specifier;
|
|
9247
|
-
if (specifier?.startsWith(".")) exportedFiles.add(
|
|
9439
|
+
if (specifier?.startsWith(".")) exportedFiles.add(path63.basename(specifier));
|
|
9248
9440
|
}
|
|
9249
9441
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
9250
9442
|
if (siblingModules.length === 0) {
|
|
@@ -9423,11 +9615,11 @@ var baseLayerPairRule = {
|
|
|
9423
9615
|
|
|
9424
9616
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
9425
9617
|
import { statSync as statSync4 } from "fs";
|
|
9426
|
-
import
|
|
9618
|
+
import path66 from "path";
|
|
9427
9619
|
|
|
9428
9620
|
// eslint/rules/tailwind/source-files.ts
|
|
9429
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
9430
|
-
import
|
|
9621
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync14, statSync as statSync3 } from "fs";
|
|
9622
|
+
import path64 from "path";
|
|
9431
9623
|
var CSS_EXTENSIONS = [".css"];
|
|
9432
9624
|
var MODULE_EXTENSIONS4 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
9433
9625
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS4, ...CSS_EXTENSIONS];
|
|
@@ -9440,7 +9632,7 @@ function findFiles(dir, extensions) {
|
|
|
9440
9632
|
}
|
|
9441
9633
|
return entries.flatMap((entry) => {
|
|
9442
9634
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
9443
|
-
const entryPath =
|
|
9635
|
+
const entryPath = path64.join(dir, entry);
|
|
9444
9636
|
let stats;
|
|
9445
9637
|
try {
|
|
9446
9638
|
stats = statSync3(entryPath);
|
|
@@ -9448,7 +9640,7 @@ function findFiles(dir, extensions) {
|
|
|
9448
9640
|
return [];
|
|
9449
9641
|
}
|
|
9450
9642
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
9451
|
-
return extensions.includes(
|
|
9643
|
+
return extensions.includes(path64.extname(entry)) ? [entryPath] : [];
|
|
9452
9644
|
});
|
|
9453
9645
|
}
|
|
9454
9646
|
function cachedTextReader() {
|
|
@@ -9457,7 +9649,7 @@ function cachedTextReader() {
|
|
|
9457
9649
|
let text = texts.get(file);
|
|
9458
9650
|
if (text === void 0) {
|
|
9459
9651
|
try {
|
|
9460
|
-
text =
|
|
9652
|
+
text = readFileSync14(file, "utf8");
|
|
9461
9653
|
} catch {
|
|
9462
9654
|
text = "";
|
|
9463
9655
|
}
|
|
@@ -9471,7 +9663,7 @@ function escapeRegExp(text) {
|
|
|
9471
9663
|
}
|
|
9472
9664
|
|
|
9473
9665
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
9474
|
-
import
|
|
9666
|
+
import path65 from "path";
|
|
9475
9667
|
function registersTailwind(text) {
|
|
9476
9668
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
9477
9669
|
}
|
|
@@ -9485,25 +9677,25 @@ function moduleImports(text, fileName) {
|
|
|
9485
9677
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
9486
9678
|
}
|
|
9487
9679
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
9488
|
-
if (spec.startsWith("/")) return
|
|
9489
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
9490
|
-
if (spec.startsWith("@/")) return
|
|
9680
|
+
if (spec.startsWith("/")) return path65.resolve(spec);
|
|
9681
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path65.resolve(path65.dirname(fromFile), spec);
|
|
9682
|
+
if (spec.startsWith("@/")) return path65.resolve(sourceRoot, spec.slice(2));
|
|
9491
9683
|
return void 0;
|
|
9492
9684
|
}
|
|
9493
9685
|
function buildStylesheetGraph(options) {
|
|
9494
9686
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
9495
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
9687
|
+
const cssSet = new Set(cssFiles.map((file) => path65.normalize(file)));
|
|
9496
9688
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
9497
9689
|
const reachable = /* @__PURE__ */ new Set();
|
|
9498
9690
|
const queue = [...globals];
|
|
9499
|
-
for (const global of globals) reachable.add(
|
|
9691
|
+
for (const global of globals) reachable.add(path65.normalize(global));
|
|
9500
9692
|
while (queue.length > 0) {
|
|
9501
9693
|
const from = queue.shift();
|
|
9502
9694
|
if (!from) continue;
|
|
9503
9695
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
9504
9696
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
9505
9697
|
if (!target) continue;
|
|
9506
|
-
const normalized =
|
|
9698
|
+
const normalized = path65.normalize(target);
|
|
9507
9699
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
9508
9700
|
reachable.add(normalized);
|
|
9509
9701
|
queue.push(normalized);
|
|
@@ -9515,7 +9707,7 @@ function buildStylesheetGraph(options) {
|
|
|
9515
9707
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
9516
9708
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
9517
9709
|
if (!target) continue;
|
|
9518
|
-
const normalized =
|
|
9710
|
+
const normalized = path65.normalize(target);
|
|
9519
9711
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
9520
9712
|
}
|
|
9521
9713
|
}
|
|
@@ -9523,8 +9715,8 @@ function buildStylesheetGraph(options) {
|
|
|
9523
9715
|
}
|
|
9524
9716
|
|
|
9525
9717
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
9526
|
-
var APP_STYLES_DIR =
|
|
9527
|
-
var GLOBAL_STYLESHEET_PATH =
|
|
9718
|
+
var APP_STYLES_DIR = path66.join("app", "styles");
|
|
9719
|
+
var GLOBAL_STYLESHEET_PATH = path66.join(APP_STYLES_DIR, "globals.css");
|
|
9528
9720
|
var cssEntryPointRule = {
|
|
9529
9721
|
meta: {
|
|
9530
9722
|
schema: [],
|
|
@@ -9550,8 +9742,8 @@ var cssEntryPointRule = {
|
|
|
9550
9742
|
return {
|
|
9551
9743
|
"StyleSheet:exit"(node) {
|
|
9552
9744
|
if (globals.length === 0) return;
|
|
9553
|
-
const current =
|
|
9554
|
-
const relative =
|
|
9745
|
+
const current = path66.normalize(path66.resolve(context.filename));
|
|
9746
|
+
const relative = path66.relative(sourceRoot, current);
|
|
9555
9747
|
if (globals.includes(current)) {
|
|
9556
9748
|
if (globals.length > 1) {
|
|
9557
9749
|
context.report({
|
|
@@ -9567,7 +9759,7 @@ var cssEntryPointRule = {
|
|
|
9567
9759
|
});
|
|
9568
9760
|
return;
|
|
9569
9761
|
}
|
|
9570
|
-
const basename =
|
|
9762
|
+
const basename = path66.basename(current);
|
|
9571
9763
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
9572
9764
|
if (importCount !== 1) {
|
|
9573
9765
|
context.report({
|
|
@@ -9577,7 +9769,7 @@ var cssEntryPointRule = {
|
|
|
9577
9769
|
}
|
|
9578
9770
|
return;
|
|
9579
9771
|
}
|
|
9580
|
-
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${
|
|
9772
|
+
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${path66.sep}`);
|
|
9581
9773
|
if (!isInAppStyles) {
|
|
9582
9774
|
context.report({
|
|
9583
9775
|
node,
|
|
@@ -10066,7 +10258,7 @@ var tailwindRules = {
|
|
|
10066
10258
|
};
|
|
10067
10259
|
|
|
10068
10260
|
// eslint/rules/type-extraction.ts
|
|
10069
|
-
import
|
|
10261
|
+
import path67 from "path";
|
|
10070
10262
|
var typeExtractionRule = {
|
|
10071
10263
|
meta: {
|
|
10072
10264
|
schema: [],
|
|
@@ -10077,7 +10269,7 @@ var typeExtractionRule = {
|
|
|
10077
10269
|
},
|
|
10078
10270
|
create(context) {
|
|
10079
10271
|
const sourceRoot = sourceRootOf(context);
|
|
10080
|
-
const file =
|
|
10272
|
+
const file = path67.resolve(context.filename);
|
|
10081
10273
|
const segments = segmentsOf(file, sourceRoot);
|
|
10082
10274
|
if (segments.length === 0) return {};
|
|
10083
10275
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -10216,9 +10408,9 @@ var uiStateRule = {
|
|
|
10216
10408
|
};
|
|
10217
10409
|
|
|
10218
10410
|
// eslint/rules/unknown-utility.ts
|
|
10219
|
-
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as
|
|
10411
|
+
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync15, statSync as statSync6 } from "fs";
|
|
10220
10412
|
import { createRequire } from "module";
|
|
10221
|
-
import
|
|
10413
|
+
import path68 from "path";
|
|
10222
10414
|
var PREFIX_NAMESPACES = {
|
|
10223
10415
|
bg: ["color"],
|
|
10224
10416
|
text: ["color", "text"],
|
|
@@ -10458,7 +10650,7 @@ function stylesheetFiles(dir) {
|
|
|
10458
10650
|
}
|
|
10459
10651
|
return entries.flatMap((entry) => {
|
|
10460
10652
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
10461
|
-
const entryPath =
|
|
10653
|
+
const entryPath = path68.join(dir, entry);
|
|
10462
10654
|
let stats;
|
|
10463
10655
|
try {
|
|
10464
10656
|
stats = statSync6(entryPath);
|
|
@@ -10466,7 +10658,7 @@ function stylesheetFiles(dir) {
|
|
|
10466
10658
|
return [];
|
|
10467
10659
|
}
|
|
10468
10660
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
10469
|
-
return
|
|
10661
|
+
return path68.extname(entry) === ".css" ? [entryPath] : [];
|
|
10470
10662
|
});
|
|
10471
10663
|
}
|
|
10472
10664
|
function packageNameOf(specifier) {
|
|
@@ -10477,24 +10669,24 @@ function packageNameOf(specifier) {
|
|
|
10477
10669
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
10478
10670
|
const packageName = packageNameOf(specifier);
|
|
10479
10671
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
10480
|
-
let directory =
|
|
10481
|
-
while (directory !==
|
|
10482
|
-
const packageRoot =
|
|
10483
|
-
const manifestPath =
|
|
10672
|
+
let directory = path68.dirname(fromFile);
|
|
10673
|
+
while (directory !== path68.dirname(directory)) {
|
|
10674
|
+
const packageRoot = path68.join(directory, "node_modules", packageName);
|
|
10675
|
+
const manifestPath = path68.join(packageRoot, "package.json");
|
|
10484
10676
|
if (existsSync8(manifestPath)) {
|
|
10485
10677
|
try {
|
|
10486
|
-
const manifest =
|
|
10678
|
+
const manifest = readFileSync15(manifestPath, "utf8");
|
|
10487
10679
|
const stylesheet = /"style"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
10488
10680
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
10489
10681
|
const target = stylesheet ?? main;
|
|
10490
10682
|
if (!target) return void 0;
|
|
10491
|
-
const resolved =
|
|
10683
|
+
const resolved = path68.resolve(packageRoot, target);
|
|
10492
10684
|
return existsSync8(resolved) ? resolved : void 0;
|
|
10493
10685
|
} catch {
|
|
10494
10686
|
return void 0;
|
|
10495
10687
|
}
|
|
10496
10688
|
}
|
|
10497
|
-
directory =
|
|
10689
|
+
directory = path68.dirname(directory);
|
|
10498
10690
|
}
|
|
10499
10691
|
return void 0;
|
|
10500
10692
|
}
|
|
@@ -10503,7 +10695,7 @@ function inventoryStylesheetFiles(projectFiles) {
|
|
|
10503
10695
|
for (const file of projectFiles) {
|
|
10504
10696
|
let css2;
|
|
10505
10697
|
try {
|
|
10506
|
-
css2 =
|
|
10698
|
+
css2 = readFileSync15(file, "utf8");
|
|
10507
10699
|
} catch {
|
|
10508
10700
|
continue;
|
|
10509
10701
|
}
|
|
@@ -10569,7 +10761,7 @@ function readInventory(files) {
|
|
|
10569
10761
|
for (const file of files) {
|
|
10570
10762
|
let css2;
|
|
10571
10763
|
try {
|
|
10572
|
-
css2 =
|
|
10764
|
+
css2 = readFileSync15(file, "utf8");
|
|
10573
10765
|
} catch {
|
|
10574
10766
|
continue;
|
|
10575
10767
|
}
|
|
@@ -10745,7 +10937,7 @@ var unknownUtilityRule = {
|
|
|
10745
10937
|
};
|
|
10746
10938
|
|
|
10747
10939
|
// eslint/rules/util-file-name.ts
|
|
10748
|
-
import
|
|
10940
|
+
import path69 from "path";
|
|
10749
10941
|
function toKebabCase2(value) {
|
|
10750
10942
|
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();
|
|
10751
10943
|
}
|
|
@@ -10758,7 +10950,7 @@ var utilFileNameRule = {
|
|
|
10758
10950
|
}
|
|
10759
10951
|
},
|
|
10760
10952
|
create(context) {
|
|
10761
|
-
const filename =
|
|
10953
|
+
const filename = path69.resolve(context.filename);
|
|
10762
10954
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
10763
10955
|
if (!segments.includes("utils")) return {};
|
|
10764
10956
|
let module;
|
|
@@ -10772,13 +10964,13 @@ var utilFileNameRule = {
|
|
|
10772
10964
|
const functionName = functions[0]?.name;
|
|
10773
10965
|
if (!functionName) return {};
|
|
10774
10966
|
const expected = toKebabCase2(functionName);
|
|
10775
|
-
const actual =
|
|
10967
|
+
const actual = path69.basename(filename, path69.extname(filename));
|
|
10776
10968
|
if (!expected || actual === expected) return {};
|
|
10777
10969
|
return {
|
|
10778
10970
|
Program(node) {
|
|
10779
10971
|
context.report({
|
|
10780
10972
|
node,
|
|
10781
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
10973
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path69.extname(filename).slice(1)}.`
|
|
10782
10974
|
});
|
|
10783
10975
|
}
|
|
10784
10976
|
};
|
|
@@ -10786,7 +10978,7 @@ var utilFileNameRule = {
|
|
|
10786
10978
|
};
|
|
10787
10979
|
|
|
10788
10980
|
// eslint/rules/value-extraction.ts
|
|
10789
|
-
import
|
|
10981
|
+
import path70 from "path";
|
|
10790
10982
|
var valueExtractionRule = {
|
|
10791
10983
|
meta: {
|
|
10792
10984
|
schema: [],
|
|
@@ -10797,7 +10989,7 @@ var valueExtractionRule = {
|
|
|
10797
10989
|
},
|
|
10798
10990
|
create(context) {
|
|
10799
10991
|
const sourceRoot = sourceRootOf(context);
|
|
10800
|
-
const file =
|
|
10992
|
+
const file = path70.resolve(context.filename);
|
|
10801
10993
|
const segments = segmentsOf(file, sourceRoot);
|
|
10802
10994
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
10803
10995
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -10818,8 +11010,8 @@ var valueExtractionRule = {
|
|
|
10818
11010
|
};
|
|
10819
11011
|
|
|
10820
11012
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
10821
|
-
import { existsSync as existsSync9, readFileSync as
|
|
10822
|
-
import
|
|
11013
|
+
import { existsSync as existsSync9, readFileSync as readFileSync16 } from "fs";
|
|
11014
|
+
import path71 from "path";
|
|
10823
11015
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
10824
11016
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
10825
11017
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -10852,8 +11044,8 @@ var trackedDocsRule = {
|
|
|
10852
11044
|
if (!context.filename.endsWith("package.json")) return;
|
|
10853
11045
|
const root = node.body;
|
|
10854
11046
|
if (root.type !== "Object") return;
|
|
10855
|
-
const projectRoot =
|
|
10856
|
-
const configPath =
|
|
11047
|
+
const projectRoot = path71.dirname(path71.resolve(context.filename));
|
|
11048
|
+
const configPath = path71.join(projectRoot, "vulyk.config.ts");
|
|
10857
11049
|
if (!existsSync9(configPath)) {
|
|
10858
11050
|
context.report({
|
|
10859
11051
|
node,
|
|
@@ -10861,7 +11053,7 @@ var trackedDocsRule = {
|
|
|
10861
11053
|
});
|
|
10862
11054
|
return;
|
|
10863
11055
|
}
|
|
10864
|
-
const config =
|
|
11056
|
+
const config = readFileSync16(configPath, "utf8");
|
|
10865
11057
|
if (!config.includes(PASIKA_REPO)) {
|
|
10866
11058
|
context.report({
|
|
10867
11059
|
node,
|
|
@@ -10878,7 +11070,7 @@ var trackedDocsRule = {
|
|
|
10878
11070
|
});
|
|
10879
11071
|
}
|
|
10880
11072
|
}
|
|
10881
|
-
const agentsPath =
|
|
11073
|
+
const agentsPath = path71.join(projectRoot, "AGENTS.md");
|
|
10882
11074
|
if (!existsSync9(agentsPath)) {
|
|
10883
11075
|
context.report({
|
|
10884
11076
|
node,
|
|
@@ -10978,7 +11170,7 @@ var withResponseHelperRule = {
|
|
|
10978
11170
|
|
|
10979
11171
|
// eslint/rules/zirka-baseline.ts
|
|
10980
11172
|
import fs7 from "fs";
|
|
10981
|
-
import
|
|
11173
|
+
import path72 from "path";
|
|
10982
11174
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
10983
11175
|
var PRETTIER_CONFIGS = [
|
|
10984
11176
|
"prettier.config.mjs",
|
|
@@ -10997,10 +11189,10 @@ var zirkaBaselineRule = {
|
|
|
10997
11189
|
}
|
|
10998
11190
|
},
|
|
10999
11191
|
create(context) {
|
|
11000
|
-
const filename =
|
|
11001
|
-
const basename =
|
|
11192
|
+
const filename = path72.resolve(context.filename);
|
|
11193
|
+
const basename = path72.basename(filename);
|
|
11002
11194
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
11003
|
-
const projectRoot =
|
|
11195
|
+
const projectRoot = path72.dirname(filename);
|
|
11004
11196
|
const report3 = (message) => {
|
|
11005
11197
|
context.report({
|
|
11006
11198
|
node: context.sourceCode.ast,
|
|
@@ -11015,7 +11207,7 @@ var zirkaBaselineRule = {
|
|
|
11015
11207
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
11016
11208
|
);
|
|
11017
11209
|
}
|
|
11018
|
-
const tsconfigPath =
|
|
11210
|
+
const tsconfigPath = path72.join(projectRoot, "tsconfig.json");
|
|
11019
11211
|
if (!fs7.existsSync(tsconfigPath)) {
|
|
11020
11212
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
11021
11213
|
} else {
|
|
@@ -11033,13 +11225,13 @@ var zirkaBaselineRule = {
|
|
|
11033
11225
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
11034
11226
|
}
|
|
11035
11227
|
}
|
|
11036
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(
|
|
11228
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(path72.join(projectRoot, name)));
|
|
11037
11229
|
if (!prettierConfigFile) {
|
|
11038
11230
|
report3(
|
|
11039
11231
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
11040
11232
|
);
|
|
11041
11233
|
} else {
|
|
11042
|
-
const content = fs7.readFileSync(
|
|
11234
|
+
const content = fs7.readFileSync(path72.join(projectRoot, prettierConfigFile), "utf8");
|
|
11043
11235
|
if (!content.includes("zirka")) {
|
|
11044
11236
|
report3(
|
|
11045
11237
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|
|
@@ -11185,14 +11377,14 @@ var zodSchemaValidationRule = {
|
|
|
11185
11377
|
};
|
|
11186
11378
|
|
|
11187
11379
|
// eslint/ts-alignment.ts
|
|
11188
|
-
import { readFileSync as
|
|
11380
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
11189
11381
|
import { createRequire as createRequire2 } from "module";
|
|
11190
11382
|
import { join } from "path";
|
|
11191
11383
|
var ownRequire = createRequire2(import.meta.url);
|
|
11192
11384
|
var majorOf = (version) => Number(version.split(".")[0]);
|
|
11193
11385
|
function versionOf(packagePath) {
|
|
11194
11386
|
try {
|
|
11195
|
-
const parsed = JSON.parse(
|
|
11387
|
+
const parsed = JSON.parse(readFileSync17(packagePath, "utf8"));
|
|
11196
11388
|
if (typeof parsed !== "object" || parsed === null || !("version" in parsed)) return null;
|
|
11197
11389
|
return typeof parsed.version === "string" ? parsed.version : null;
|
|
11198
11390
|
} catch {
|
|
@@ -11270,6 +11462,7 @@ var pasikaNextjsAppRules = {
|
|
|
11270
11462
|
"interactive-component": interactiveComponentRule,
|
|
11271
11463
|
"ui-state": uiStateRule,
|
|
11272
11464
|
"no-mixed-concerns": noMixedConcernsRule,
|
|
11465
|
+
"no-duplicate-jsx-classes": noDuplicateJsxClassesRule,
|
|
11273
11466
|
"no-arbitrary-tailwind": noArbitraryTailwindRule,
|
|
11274
11467
|
"no-literal-inline-style": noLiteralInlineStyleRule,
|
|
11275
11468
|
"unknown-utility": unknownUtilityRule,
|