pasika 0.10.89 → 0.10.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint/pasika/index.js +278 -184
- package/package.json +1 -1
|
@@ -5120,20 +5120,21 @@ var noLiteralInlineStyleRule = {
|
|
|
5120
5120
|
};
|
|
5121
5121
|
|
|
5122
5122
|
// eslint/rules/no-mixed-concerns.ts
|
|
5123
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
5124
|
+
import path39 from "path";
|
|
5123
5125
|
var noMixedConcernsRule = {
|
|
5124
5126
|
meta: {
|
|
5125
5127
|
schema: [],
|
|
5126
5128
|
type: "problem",
|
|
5127
5129
|
docs: {
|
|
5128
|
-
description: "Enforce one React component
|
|
5130
|
+
description: "Enforce one React component per .tsx file and colocated exports consumed alongside it."
|
|
5129
5131
|
}
|
|
5130
5132
|
},
|
|
5131
5133
|
create(context) {
|
|
5132
5134
|
if (!context.filename.endsWith(".tsx")) return {};
|
|
5133
|
-
const sourceCode = context.sourceCode.text;
|
|
5134
5135
|
return {
|
|
5135
5136
|
"Program:exit"() {
|
|
5136
|
-
const components = parseComponentInfo(sourceCode, context.filename, { includeNonExported: true });
|
|
5137
|
+
const components = parseComponentInfo(context.sourceCode.text, context.filename, { includeNonExported: true });
|
|
5137
5138
|
if (components.length === 0) return;
|
|
5138
5139
|
for (const extra of components.slice(1)) {
|
|
5139
5140
|
context.report({
|
|
@@ -5144,44 +5145,77 @@ var noMixedConcernsRule = {
|
|
|
5144
5145
|
if (components.length > 1) return;
|
|
5145
5146
|
const componentName = components[0]?.name;
|
|
5146
5147
|
if (!componentName) return;
|
|
5148
|
+
const file = path39.resolve(context.filename);
|
|
5149
|
+
const sourceRoot = sourceRootOf(context);
|
|
5150
|
+
const index = getProjectIndex(sourceRoot);
|
|
5151
|
+
const componentConsumers = index?.symbolConsumers.get(symbolKey(file, componentName)) ?? /* @__PURE__ */ new Set();
|
|
5147
5152
|
const isNextPageOrLayout = /(?:^|[/\\])src[/\\]app[/\\](?:[^/\\]+[/\\])*(?:page|layout)\.tsx$/.test(
|
|
5148
5153
|
context.filename
|
|
5149
5154
|
);
|
|
5155
|
+
const checkSupportingExport = (name, loc) => {
|
|
5156
|
+
if (name === componentName) return;
|
|
5157
|
+
if (isNextPageOrLayout) {
|
|
5158
|
+
if (["metadata", "viewport", "generateMetadata", "generateViewport"].includes(name)) return;
|
|
5159
|
+
context.report({
|
|
5160
|
+
loc,
|
|
5161
|
+
message: `Next.js page/layout files cannot export "${name}". Use a separate module for supporting values.`
|
|
5162
|
+
});
|
|
5163
|
+
return;
|
|
5164
|
+
}
|
|
5165
|
+
const consumers = index?.symbolConsumers.get(symbolKey(file, name));
|
|
5166
|
+
if (!consumers) return;
|
|
5167
|
+
const independent = [...consumers].filter((consumer) => !componentConsumers.has(consumer));
|
|
5168
|
+
if (independent.length > 0) {
|
|
5169
|
+
context.report({
|
|
5170
|
+
loc,
|
|
5171
|
+
message: `Supporting export "${name}" is imported without its component "${componentName}". Import them together or extract the supporting value to its appropriate module. See docs/next-codebase-guide/rules/no-mixed-concerns-rule.md`
|
|
5172
|
+
});
|
|
5173
|
+
}
|
|
5174
|
+
};
|
|
5150
5175
|
for (const statement of context.sourceCode.ast.body) {
|
|
5151
5176
|
if (statement.type === "ExportNamedDeclaration") {
|
|
5152
5177
|
if (/^export\s+(?:type|interface)\b/.test(context.sourceCode.getText(statement))) continue;
|
|
5153
5178
|
const declaration = statement.declaration;
|
|
5154
|
-
if (
|
|
5155
|
-
(
|
|
5156
|
-
)) {
|
|
5179
|
+
if (declaration?.type === "FunctionDeclaration" || declaration?.type === "ClassDeclaration") {
|
|
5180
|
+
checkSupportingExport(declaration.id.name, statement.loc?.start ?? { line: 1, column: 0 });
|
|
5157
5181
|
continue;
|
|
5158
5182
|
}
|
|
5159
|
-
if (
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5183
|
+
if (declaration?.type === "VariableDeclaration") {
|
|
5184
|
+
for (const variable of declaration.declarations) {
|
|
5185
|
+
if (variable.id.type === "Identifier") {
|
|
5186
|
+
checkSupportingExport(variable.id.name, statement.loc?.start ?? { line: 1, column: 0 });
|
|
5187
|
+
}
|
|
5188
|
+
}
|
|
5164
5189
|
continue;
|
|
5165
5190
|
}
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
)
|
|
5169
|
-
continue;
|
|
5191
|
+
const target = typeof statement.source?.value === "string" ? resolveSpecifier(file, statement.source.value, sourceRoot) : void 0;
|
|
5192
|
+
const forwardedComponents = target?.endsWith(".tsx") ? parseComponentInfo(readFileSync8(target, "utf8"), target).map((component) => component.name) : [];
|
|
5193
|
+
for (const specifier of statement.specifiers) {
|
|
5194
|
+
if (/^type\b/.test(context.sourceCode.getText(specifier))) continue;
|
|
5195
|
+
if (specifier.local.type !== "Identifier") continue;
|
|
5196
|
+
if (target && forwardedComponents.includes(specifier.local.name)) {
|
|
5197
|
+
context.report({
|
|
5198
|
+
node: statement,
|
|
5199
|
+
message: `Component file "${componentName}" must not re-export another component "${specifier.local.name}". Import that component directly.`
|
|
5200
|
+
});
|
|
5201
|
+
} else if (!statement.source) {
|
|
5202
|
+
checkSupportingExport(specifier.local.name, statement.loc?.start ?? { line: 1, column: 0 });
|
|
5203
|
+
} else if (specifier.exported.type === "Identifier") {
|
|
5204
|
+
checkSupportingExport(specifier.exported.name, statement.loc?.start ?? { line: 1, column: 0 });
|
|
5205
|
+
}
|
|
5170
5206
|
}
|
|
5171
5207
|
} else if (statement.type === "ExportAllDeclaration") {
|
|
5172
5208
|
if (/^export\s+type\b/.test(context.sourceCode.getText(statement))) continue;
|
|
5209
|
+
context.report({
|
|
5210
|
+
node: statement,
|
|
5211
|
+
message: `Component file "${componentName}" must not use a wildcard runtime re-export. Export named supporting values only.`
|
|
5212
|
+
});
|
|
5173
5213
|
} else if (statement.type === "ExportDefaultDeclaration") {
|
|
5174
|
-
|
|
5175
|
-
if (
|
|
5176
|
-
|
|
5177
|
-
}
|
|
5178
|
-
} else {
|
|
5179
|
-
continue;
|
|
5214
|
+
const declaration = statement.declaration;
|
|
5215
|
+
if (declaration.type === "Identifier" && declaration.name === componentName) continue;
|
|
5216
|
+
if (declaration.type === "FunctionDeclaration" && declaration.id?.name === componentName) continue;
|
|
5217
|
+
checkSupportingExport("default", statement.loc?.start ?? { line: 1, column: 0 });
|
|
5180
5218
|
}
|
|
5181
|
-
context.report({
|
|
5182
|
-
node: statement,
|
|
5183
|
-
message: `Component files must export only their own component "${componentName}". Import other values directly from their files.`
|
|
5184
|
-
});
|
|
5185
5219
|
}
|
|
5186
5220
|
}
|
|
5187
5221
|
};
|
|
@@ -5189,10 +5223,10 @@ var noMixedConcernsRule = {
|
|
|
5189
5223
|
};
|
|
5190
5224
|
|
|
5191
5225
|
// eslint/rules/no-redundant-alias.ts
|
|
5192
|
-
import
|
|
5226
|
+
import path41 from "path";
|
|
5193
5227
|
|
|
5194
5228
|
// eslint/rules/contract-ownership.ts
|
|
5195
|
-
import
|
|
5229
|
+
import path40 from "path";
|
|
5196
5230
|
import ts7 from "typescript";
|
|
5197
5231
|
function isTsProgram(value) {
|
|
5198
5232
|
return typeof value === "object" && value !== null && "getTypeChecker" in value && typeof value.getTypeChecker === "function" && "getSourceFiles" in value && typeof value.getSourceFiles === "function";
|
|
@@ -5211,8 +5245,8 @@ function normalizePath(value) {
|
|
|
5211
5245
|
return value.replaceAll("\\", "/").toLowerCase();
|
|
5212
5246
|
}
|
|
5213
5247
|
function isWithin2(root, file) {
|
|
5214
|
-
const relative =
|
|
5215
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
5248
|
+
const relative = path40.relative(root, file);
|
|
5249
|
+
return relative === "" || !relative.startsWith("..") && !path40.isAbsolute(relative);
|
|
5216
5250
|
}
|
|
5217
5251
|
function mergeOwnership(values) {
|
|
5218
5252
|
if (values.length === 0 || values.includes("unknown")) return "unknown";
|
|
@@ -5352,7 +5386,7 @@ var ContractOwnershipIndex = class {
|
|
|
5352
5386
|
const normalized = normalizePath(fileName);
|
|
5353
5387
|
if (/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u.test(normalized)) return "platform";
|
|
5354
5388
|
if (normalized.includes("/node_modules/")) return "third-party";
|
|
5355
|
-
if (isWithin2(this.cwd,
|
|
5389
|
+
if (isWithin2(this.cwd, path40.resolve(fileName))) return "first-party";
|
|
5356
5390
|
return "unknown";
|
|
5357
5391
|
}
|
|
5358
5392
|
schemaOwnership(declaration) {
|
|
@@ -5366,7 +5400,7 @@ var ContractOwnershipIndex = class {
|
|
|
5366
5400
|
}
|
|
5367
5401
|
indexApiContracts() {
|
|
5368
5402
|
for (const sourceFile of this.program.getSourceFiles()) {
|
|
5369
|
-
if (sourceFile.isDeclarationFile || !isWithin2(this.cwd,
|
|
5403
|
+
if (sourceFile.isDeclarationFile || !isWithin2(this.cwd, path40.resolve(sourceFile.fileName))) continue;
|
|
5370
5404
|
const visit = (node) => {
|
|
5371
5405
|
if (ts7.isCallExpression(node) && this.isDefineApiContractCall(node)) this.indexApiContractCall(node);
|
|
5372
5406
|
ts7.forEachChild(node, visit);
|
|
@@ -5637,7 +5671,7 @@ var noRedundantAliasRule = {
|
|
|
5637
5671
|
if (declaration.type !== "VariableDeclaration" || declaration.kind !== "const") return;
|
|
5638
5672
|
if (node.init.type === "Identifier") {
|
|
5639
5673
|
const exported = declaration.parent.type === "ExportNamedDeclaration";
|
|
5640
|
-
const frameworkRouteAlias =
|
|
5674
|
+
const frameworkRouteAlias = path41.basename(context.filename) === "route.ts" && exported && HTTP_METHODS.has(node.id.name);
|
|
5641
5675
|
if (frameworkRouteAlias || VALUE_SENTINELS.has(node.init.name)) return;
|
|
5642
5676
|
context.report({
|
|
5643
5677
|
node,
|
|
@@ -5755,7 +5789,7 @@ var noRedundantAliasRule = {
|
|
|
5755
5789
|
const source = specifier.local.name;
|
|
5756
5790
|
const alias = specifier.exported.name;
|
|
5757
5791
|
if (source === alias) continue;
|
|
5758
|
-
const frameworkRouteAlias =
|
|
5792
|
+
const frameworkRouteAlias = path41.basename(context.filename) === "route.ts" && HTTP_METHODS.has(alias);
|
|
5759
5793
|
if (frameworkRouteAlias) continue;
|
|
5760
5794
|
context.report({
|
|
5761
5795
|
node: specifier,
|
|
@@ -5780,7 +5814,7 @@ var noRedundantAliasRule = {
|
|
|
5780
5814
|
};
|
|
5781
5815
|
|
|
5782
5816
|
// eslint/rules/no-util-barrel.ts
|
|
5783
|
-
import
|
|
5817
|
+
import path42 from "path";
|
|
5784
5818
|
var noUtilBarrelRule = {
|
|
5785
5819
|
meta: {
|
|
5786
5820
|
schema: [],
|
|
@@ -5790,7 +5824,7 @@ var noUtilBarrelRule = {
|
|
|
5790
5824
|
}
|
|
5791
5825
|
},
|
|
5792
5826
|
create(context) {
|
|
5793
|
-
const filename =
|
|
5827
|
+
const filename = path42.resolve(context.filename);
|
|
5794
5828
|
const sourceRoot = sourceRootOf3(context, filename);
|
|
5795
5829
|
return {
|
|
5796
5830
|
Program(node) {
|
|
@@ -5799,7 +5833,7 @@ var noUtilBarrelRule = {
|
|
|
5799
5833
|
if (!target) continue;
|
|
5800
5834
|
const segments = target.replace(/\\/g, "/").split("/");
|
|
5801
5835
|
const utilsIndex = segments.lastIndexOf("utils");
|
|
5802
|
-
if (utilsIndex < 0 || !
|
|
5836
|
+
if (utilsIndex < 0 || !path42.basename(target).startsWith("index.")) continue;
|
|
5803
5837
|
context.report({
|
|
5804
5838
|
node,
|
|
5805
5839
|
message: `Import utilities directly instead of through "${specifier}". See docs/next-codebase-guide/rules/utilities-rule.md`
|
|
@@ -5819,10 +5853,10 @@ function importSpecifiers2(source) {
|
|
|
5819
5853
|
return specifiers;
|
|
5820
5854
|
}
|
|
5821
5855
|
function sourceRootOf3(context, filename) {
|
|
5822
|
-
const marker = `${
|
|
5856
|
+
const marker = `${path42.sep}src${path42.sep}`;
|
|
5823
5857
|
const srcIndex = filename.lastIndexOf(marker);
|
|
5824
5858
|
if (srcIndex >= 0) return filename.slice(0, srcIndex + marker.length - 1);
|
|
5825
|
-
return
|
|
5859
|
+
return path42.resolve(context.cwd ?? process.cwd(), "src");
|
|
5826
5860
|
}
|
|
5827
5861
|
|
|
5828
5862
|
// eslint/rules/package-json/exact-version.ts
|
|
@@ -6040,8 +6074,8 @@ var nextjsStackRule = {
|
|
|
6040
6074
|
};
|
|
6041
6075
|
|
|
6042
6076
|
// eslint/rules/package-json/vitest-coverage.ts
|
|
6043
|
-
import { existsSync as existsSync5, readFileSync as
|
|
6044
|
-
import
|
|
6077
|
+
import { existsSync as existsSync5, readFileSync as readFileSync9 } from "fs";
|
|
6078
|
+
import path43 from "path";
|
|
6045
6079
|
function memberName5(member) {
|
|
6046
6080
|
return member.name.type === "String" ? member.name.value : member.name.name;
|
|
6047
6081
|
}
|
|
@@ -6111,7 +6145,7 @@ var vitestCoverageRule = {
|
|
|
6111
6145
|
message: 'package.json must declare a "test:unit:coverage" script that runs Vitest with coverage.'
|
|
6112
6146
|
});
|
|
6113
6147
|
}
|
|
6114
|
-
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync5(
|
|
6148
|
+
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync5(path43.join(context.cwd, name)));
|
|
6115
6149
|
if (!configName) {
|
|
6116
6150
|
context.report({
|
|
6117
6151
|
node,
|
|
@@ -6119,7 +6153,7 @@ var vitestCoverageRule = {
|
|
|
6119
6153
|
});
|
|
6120
6154
|
return;
|
|
6121
6155
|
}
|
|
6122
|
-
const content =
|
|
6156
|
+
const content = readFileSync9(path43.join(context.cwd, configName), "utf8");
|
|
6123
6157
|
for (const metric of THRESHOLD_METRICS) {
|
|
6124
6158
|
if (!new RegExp(`\\b${metric}\\s*:\\s*[1-9]\\d*`).test(content)) {
|
|
6125
6159
|
context.report({ node, message: `${configName} must set a coverage threshold above zero for ${metric}.` });
|
|
@@ -6165,7 +6199,8 @@ var nextjsPackageJsonRules = {
|
|
|
6165
6199
|
};
|
|
6166
6200
|
|
|
6167
6201
|
// eslint/rules/prefer-enum.ts
|
|
6168
|
-
import
|
|
6202
|
+
import path44 from "path";
|
|
6203
|
+
import ts8 from "typescript";
|
|
6169
6204
|
function isConstAssertion(node) {
|
|
6170
6205
|
const typeAnnotation = node.typeAnnotation;
|
|
6171
6206
|
return typeAnnotation?.type === "TSTypeReference" && typeAnnotation.typeName?.type === "Identifier" && typeAnnotation.typeName.name === "const";
|
|
@@ -6208,33 +6243,88 @@ function rawZodDiscriminantLiteral(schemaCall, discriminator) {
|
|
|
6208
6243
|
}
|
|
6209
6244
|
return void 0;
|
|
6210
6245
|
}
|
|
6246
|
+
function isLiteralTupleAssertion(node) {
|
|
6247
|
+
if (!isConstAssertion(node)) return false;
|
|
6248
|
+
const expression = node.expression;
|
|
6249
|
+
if (expression?.type !== "ArrayExpression" || expression.elements.length < 2) return false;
|
|
6250
|
+
const values = expression.elements.map((element) => {
|
|
6251
|
+
if (element?.type !== "Literal") return void 0;
|
|
6252
|
+
return typeof element.value === "string" || typeof element.value === "number" ? element.value : void 0;
|
|
6253
|
+
});
|
|
6254
|
+
return values.every((value) => value !== void 0) && new Set(values).size >= 2;
|
|
6255
|
+
}
|
|
6256
|
+
function isTsLiteralTupleDeclaration(declaration) {
|
|
6257
|
+
if (!ts8.isVariableDeclaration(declaration) || !declaration.initializer) return false;
|
|
6258
|
+
const init = declaration.initializer;
|
|
6259
|
+
if (!ts8.isAsExpression(init) || !ts8.isTypeReferenceNode(init.type) || !ts8.isIdentifier(init.type.typeName) || init.type.typeName.text !== "const" || !ts8.isArrayLiteralExpression(init.expression) || init.expression.elements.length < 2) {
|
|
6260
|
+
return false;
|
|
6261
|
+
}
|
|
6262
|
+
const values = init.expression.elements.map(
|
|
6263
|
+
(element) => ts8.isStringLiteral(element) || ts8.isNumericLiteral(element) ? element.text : void 0
|
|
6264
|
+
);
|
|
6265
|
+
return values.every((value) => value !== void 0) && new Set(values).size >= 2;
|
|
6266
|
+
}
|
|
6211
6267
|
var preferEnumRule = {
|
|
6212
6268
|
meta: {
|
|
6213
6269
|
schema: [],
|
|
6214
6270
|
type: "problem",
|
|
6215
6271
|
docs: {
|
|
6216
|
-
description: "Require fixed sets of named string/number values to be TypeScript enums, including Zod discriminated-union discriminator values."
|
|
6272
|
+
description: "Require fixed sets of named string/number values to be TypeScript enums, including named Zod enum tuples and discriminated-union discriminator values."
|
|
6217
6273
|
}
|
|
6218
6274
|
},
|
|
6219
6275
|
create(context) {
|
|
6220
|
-
const filename =
|
|
6276
|
+
const filename = path44.resolve(context.filename);
|
|
6221
6277
|
const sourceRoot = sourceRootOf(context);
|
|
6222
|
-
if (!filename.startsWith(sourceRoot +
|
|
6278
|
+
if (!filename.startsWith(sourceRoot + path44.sep)) return {};
|
|
6223
6279
|
const objectSchemas = /* @__PURE__ */ new Map();
|
|
6280
|
+
const literalTuples = /* @__PURE__ */ new Set();
|
|
6281
|
+
const enumTupleUses = [];
|
|
6224
6282
|
const discriminatedUnions = [];
|
|
6225
6283
|
const reportedDiscriminants = /* @__PURE__ */ new Set();
|
|
6284
|
+
const services = typedParserServices(context.sourceCode.parserServices);
|
|
6285
|
+
function isTupleDomain(name) {
|
|
6286
|
+
if (!services) return literalTuples.has(name.name);
|
|
6287
|
+
const tsNode = services.esTreeNodeToTSNodeMap.get(name);
|
|
6288
|
+
if (!tsNode) return false;
|
|
6289
|
+
const checker = services.program.getTypeChecker();
|
|
6290
|
+
const symbol = checker.getSymbolAtLocation(tsNode);
|
|
6291
|
+
if (!symbol) return false;
|
|
6292
|
+
const original = symbol.flags === ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
6293
|
+
return (original.declarations ?? []).some(isTsLiteralTupleDeclaration);
|
|
6294
|
+
}
|
|
6226
6295
|
return {
|
|
6227
6296
|
VariableDeclarator(node) {
|
|
6228
6297
|
const { id, init } = node;
|
|
6229
|
-
if (id?.type !== "Identifier" ||
|
|
6230
|
-
|
|
6298
|
+
if (id?.type !== "Identifier" || !init) return;
|
|
6299
|
+
if (init.type === "CallExpression" && isZodCall(init, "object")) {
|
|
6300
|
+
objectSchemas.set(id.name, init);
|
|
6301
|
+
}
|
|
6231
6302
|
},
|
|
6232
6303
|
CallExpression(node) {
|
|
6233
6304
|
if (isZodCall(node, "discriminatedUnion")) {
|
|
6234
6305
|
discriminatedUnions.push(node);
|
|
6235
6306
|
}
|
|
6307
|
+
const argument = node.arguments?.[0];
|
|
6308
|
+
if (isZodCall(node, "enum") && argument?.type === "Identifier") {
|
|
6309
|
+
enumTupleUses.push({ name: argument, node });
|
|
6310
|
+
}
|
|
6311
|
+
},
|
|
6312
|
+
TSIndexedAccessType(node) {
|
|
6313
|
+
const { objectType, indexType } = node;
|
|
6314
|
+
if (objectType?.type === "TSTypeQuery" && objectType.exprName?.type === "Identifier" && indexType?.type === "TSNumberKeyword") {
|
|
6315
|
+
enumTupleUses.push({ name: objectType.exprName, node });
|
|
6316
|
+
}
|
|
6236
6317
|
},
|
|
6237
6318
|
"Program:exit"() {
|
|
6319
|
+
const reportedTuples = /* @__PURE__ */ new Set();
|
|
6320
|
+
for (const use of enumTupleUses) {
|
|
6321
|
+
if (reportedTuples.has(use.name.name) || !isTupleDomain(use.name)) continue;
|
|
6322
|
+
reportedTuples.add(use.name.name);
|
|
6323
|
+
context.report({
|
|
6324
|
+
node: use.node,
|
|
6325
|
+
message: "A const tuple used as a named enum domain must be replaced with a TypeScript enum. See docs/next-codebase-guide/rules/constants-rule.md"
|
|
6326
|
+
});
|
|
6327
|
+
}
|
|
6238
6328
|
for (const unionCall of discriminatedUnions) {
|
|
6239
6329
|
const [discriminatorArg, optionsArg] = unionCall.arguments ?? [];
|
|
6240
6330
|
if (discriminatorArg?.type !== "Literal" || typeof discriminatorArg.value !== "string" || optionsArg?.type !== "ArrayExpression") {
|
|
@@ -6261,6 +6351,10 @@ var preferEnumRule = {
|
|
|
6261
6351
|
},
|
|
6262
6352
|
TSAsExpression(node) {
|
|
6263
6353
|
if (!isConstAssertion(node)) return;
|
|
6354
|
+
if (isLiteralTupleAssertion(node) && node.parent?.type === "VariableDeclarator") {
|
|
6355
|
+
const { id } = node.parent;
|
|
6356
|
+
if (id.type === "Identifier") literalTuples.add(id.name);
|
|
6357
|
+
}
|
|
6264
6358
|
const expression = node.expression;
|
|
6265
6359
|
if (!expression || expression.type !== "ObjectExpression") return;
|
|
6266
6360
|
if (expression.properties.length === 0) return;
|
|
@@ -6290,7 +6384,7 @@ var preferEnumRule = {
|
|
|
6290
6384
|
};
|
|
6291
6385
|
|
|
6292
6386
|
// eslint/rules/prefer-object-destructuring.ts
|
|
6293
|
-
import
|
|
6387
|
+
import ts9 from "typescript";
|
|
6294
6388
|
var DOC5 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
6295
6389
|
function hasTypeAnnotation(identifier) {
|
|
6296
6390
|
return "typeAnnotation" in identifier && identifier.typeAnnotation !== void 0;
|
|
@@ -6379,8 +6473,8 @@ function enumValueResolver(context) {
|
|
|
6379
6473
|
const checker = services.program.getTypeChecker();
|
|
6380
6474
|
const { esTreeNodeToTSNodeMap: nodeMap } = services;
|
|
6381
6475
|
const isEnumSymbol = (symbol) => {
|
|
6382
|
-
const resolved = symbol.flags ===
|
|
6383
|
-
return (resolved.declarations ?? []).some((declaration) =>
|
|
6476
|
+
const resolved = symbol.flags === ts9.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
6477
|
+
return (resolved.declarations ?? []).some((declaration) => ts9.isEnumDeclaration(declaration));
|
|
6384
6478
|
};
|
|
6385
6479
|
return (node) => {
|
|
6386
6480
|
const tsNode = nodeMap.get(node);
|
|
@@ -6762,7 +6856,7 @@ ${indentation}`;
|
|
|
6762
6856
|
};
|
|
6763
6857
|
|
|
6764
6858
|
// eslint/rules/pure-function-extract.ts
|
|
6765
|
-
import
|
|
6859
|
+
import path45 from "path";
|
|
6766
6860
|
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
6767
6861
|
"GET",
|
|
6768
6862
|
"POST",
|
|
@@ -6827,12 +6921,12 @@ var pureFunctionExtractRule = {
|
|
|
6827
6921
|
},
|
|
6828
6922
|
create(context) {
|
|
6829
6923
|
const filename = context.filename;
|
|
6830
|
-
const isRouteFile =
|
|
6924
|
+
const isRouteFile = path45.basename(filename) === "route.ts";
|
|
6831
6925
|
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
6832
6926
|
const sourceRoot = sourceRootOf(context);
|
|
6833
|
-
const relative =
|
|
6927
|
+
const relative = path45.relative(sourceRoot, filename);
|
|
6834
6928
|
if (relative.startsWith("..")) return {};
|
|
6835
|
-
const segments = relative.split(
|
|
6929
|
+
const segments = relative.split(path45.sep);
|
|
6836
6930
|
const folders = segments.slice(0, -1);
|
|
6837
6931
|
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
6838
6932
|
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
@@ -6892,16 +6986,16 @@ var pureFunctionExtractRule = {
|
|
|
6892
6986
|
};
|
|
6893
6987
|
|
|
6894
6988
|
// eslint/rules/repeated-numeric-value.ts
|
|
6895
|
-
import
|
|
6989
|
+
import path46 from "path";
|
|
6896
6990
|
var ignoredValues = /* @__PURE__ */ new Set([-1, 0, 1]);
|
|
6897
6991
|
function isNonProductionFile(file, sourceRoot) {
|
|
6898
|
-
const relative =
|
|
6899
|
-
const segments = relative.split(
|
|
6900
|
-
const basename =
|
|
6992
|
+
const relative = path46.relative(sourceRoot, file);
|
|
6993
|
+
const segments = relative.split(path46.sep);
|
|
6994
|
+
const basename = path46.basename(file);
|
|
6901
6995
|
return /\.(?:test|spec|mock)\.[^.]+$/.test(basename) || segments.some((segment) => segment === "__tests__" || segment === "__mocks__" || segment === "mocks");
|
|
6902
6996
|
}
|
|
6903
6997
|
function isCanonicalConstantFile(file, sourceRoot) {
|
|
6904
|
-
const segments =
|
|
6998
|
+
const segments = path46.relative(sourceRoot, file).split(path46.sep);
|
|
6905
6999
|
return segments.includes("constants") || segments[0] === "config";
|
|
6906
7000
|
}
|
|
6907
7001
|
function groupKey(literal) {
|
|
@@ -6917,7 +7011,7 @@ var repeatedNumericValueRule = {
|
|
|
6917
7011
|
},
|
|
6918
7012
|
create(context) {
|
|
6919
7013
|
const sourceRoot = sourceRootOf(context);
|
|
6920
|
-
const file =
|
|
7014
|
+
const file = path46.resolve(context.filename);
|
|
6921
7015
|
if (isNonProductionFile(file, sourceRoot) || isCanonicalConstantFile(file, sourceRoot)) return {};
|
|
6922
7016
|
const index = getProjectIndex(sourceRoot);
|
|
6923
7017
|
if (!index) return {};
|
|
@@ -7137,7 +7231,7 @@ var repeatedStructureRule = {
|
|
|
7137
7231
|
|
|
7138
7232
|
// eslint/rules/require-barrel-star-exports.ts
|
|
7139
7233
|
import fs5 from "fs";
|
|
7140
|
-
import
|
|
7234
|
+
import path47 from "path";
|
|
7141
7235
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
7142
7236
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
7143
7237
|
var MODULE_EXTENSIONS3 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
@@ -7145,9 +7239,9 @@ function resolveSiblingModule(indexFile, specifier) {
|
|
|
7145
7239
|
if (!specifier.startsWith("./")) return void 0;
|
|
7146
7240
|
const relative = specifier.slice(2);
|
|
7147
7241
|
if (!relative || relative.includes("/")) return void 0;
|
|
7148
|
-
const directory =
|
|
7149
|
-
const direct =
|
|
7150
|
-
const candidates =
|
|
7242
|
+
const directory = path47.dirname(indexFile);
|
|
7243
|
+
const direct = path47.resolve(directory, relative);
|
|
7244
|
+
const candidates = path47.extname(direct) ? [direct] : MODULE_EXTENSIONS3.map((extension) => `${direct}${extension}`);
|
|
7151
7245
|
return candidates.find((candidate) => fs5.existsSync(candidate) && fs5.statSync(candidate).isFile());
|
|
7152
7246
|
}
|
|
7153
7247
|
var requireBarrelStarExportsRule = {
|
|
@@ -7160,9 +7254,9 @@ var requireBarrelStarExportsRule = {
|
|
|
7160
7254
|
fixable: "code"
|
|
7161
7255
|
},
|
|
7162
7256
|
create(context) {
|
|
7163
|
-
const filename =
|
|
7164
|
-
if (!INDEX_NAMES.has(
|
|
7165
|
-
if (!SUPPORT_FOLDERS3.has(
|
|
7257
|
+
const filename = path47.resolve(context.filename);
|
|
7258
|
+
if (!INDEX_NAMES.has(path47.basename(filename))) return {};
|
|
7259
|
+
if (!SUPPORT_FOLDERS3.has(path47.basename(path47.dirname(filename)))) return {};
|
|
7166
7260
|
return {
|
|
7167
7261
|
ExportNamedDeclaration(node) {
|
|
7168
7262
|
const sourceNode = node.source;
|
|
@@ -7215,7 +7309,7 @@ var requireBarrelStarExportsRule = {
|
|
|
7215
7309
|
};
|
|
7216
7310
|
|
|
7217
7311
|
// eslint/rules/root-support-placement.ts
|
|
7218
|
-
import
|
|
7312
|
+
import path48 from "path";
|
|
7219
7313
|
function isSupportFolder(value) {
|
|
7220
7314
|
return value === "utils" || value === "types" || value === "schemas" || value === "constants";
|
|
7221
7315
|
}
|
|
@@ -7248,7 +7342,7 @@ var rootSupportPlacementRule = {
|
|
|
7248
7342
|
},
|
|
7249
7343
|
create(context) {
|
|
7250
7344
|
const sourceRoot = sourceRootOf(context);
|
|
7251
|
-
const file =
|
|
7345
|
+
const file = path48.resolve(context.filename);
|
|
7252
7346
|
const segments = segmentsOf(file, sourceRoot);
|
|
7253
7347
|
const folderSegments = folderSegmentsOf(file, sourceRoot);
|
|
7254
7348
|
const supportFolder = folderSegments[folderSegments.length - 1];
|
|
@@ -7294,8 +7388,8 @@ var rootSupportPlacementRule = {
|
|
|
7294
7388
|
};
|
|
7295
7389
|
|
|
7296
7390
|
// eslint/rules/route-handler-shape.ts
|
|
7297
|
-
import
|
|
7298
|
-
import
|
|
7391
|
+
import path49 from "path";
|
|
7392
|
+
import ts10 from "typescript";
|
|
7299
7393
|
var HTTP_METHODS2 = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
7300
7394
|
var REQUIRED_BOUNDARY = "withResponse";
|
|
7301
7395
|
function isFunctionLike(node) {
|
|
@@ -7313,33 +7407,33 @@ function findHandler(node) {
|
|
|
7313
7407
|
return void 0;
|
|
7314
7408
|
}
|
|
7315
7409
|
function isLoop(node) {
|
|
7316
|
-
return
|
|
7410
|
+
return ts10.isForStatement(node) || ts10.isForOfStatement(node) || ts10.isForInStatement(node) || ts10.isWhileStatement(node) || ts10.isDoStatement(node);
|
|
7317
7411
|
}
|
|
7318
7412
|
function isFunctionBoundary(node) {
|
|
7319
|
-
return
|
|
7413
|
+
return ts10.isFunctionExpression(node) || ts10.isArrowFunction(node) || ts10.isFunctionDeclaration(node);
|
|
7320
7414
|
}
|
|
7321
7415
|
function analyzeHandlerBody(body, sourceText) {
|
|
7322
7416
|
const start = body.range?.[0] ?? 0;
|
|
7323
7417
|
const end = body.range?.[1] ?? sourceText.length;
|
|
7324
|
-
const sourceFile =
|
|
7418
|
+
const sourceFile = ts10.createSourceFile(
|
|
7325
7419
|
"route.ts",
|
|
7326
7420
|
sourceText.slice(start, end),
|
|
7327
|
-
|
|
7421
|
+
ts10.ScriptTarget.Latest,
|
|
7328
7422
|
true,
|
|
7329
|
-
|
|
7423
|
+
ts10.ScriptKind.TS
|
|
7330
7424
|
);
|
|
7331
7425
|
const kinds = /* @__PURE__ */ new Set();
|
|
7332
7426
|
const calledNames = /* @__PURE__ */ new Set();
|
|
7333
7427
|
const visit = (node) => {
|
|
7334
|
-
if (
|
|
7428
|
+
if (ts10.isTryStatement(node)) kinds.add("try");
|
|
7335
7429
|
if (isLoop(node)) kinds.add("loop");
|
|
7336
|
-
if (
|
|
7337
|
-
if (
|
|
7430
|
+
if (ts10.isIfStatement(node)) kinds.add("if");
|
|
7431
|
+
if (ts10.isCallExpression(node) && ts10.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map") {
|
|
7338
7432
|
kinds.add("map");
|
|
7339
7433
|
}
|
|
7340
|
-
if (
|
|
7434
|
+
if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression)) calledNames.add(node.expression.text);
|
|
7341
7435
|
if (isFunctionBoundary(node)) return;
|
|
7342
|
-
|
|
7436
|
+
ts10.forEachChild(node, visit);
|
|
7343
7437
|
};
|
|
7344
7438
|
visit(sourceFile);
|
|
7345
7439
|
return { kinds, calledNames };
|
|
@@ -7379,7 +7473,7 @@ var routeHandlerShapeRule = {
|
|
|
7379
7473
|
}
|
|
7380
7474
|
},
|
|
7381
7475
|
create(context) {
|
|
7382
|
-
if (
|
|
7476
|
+
if (path49.basename(context.filename) !== "route.ts") return {};
|
|
7383
7477
|
const sourceText = context.sourceCode.text;
|
|
7384
7478
|
function reportUnwrapped(node, name) {
|
|
7385
7479
|
context.report({
|
|
@@ -7438,7 +7532,7 @@ var routeHandlerShapeRule = {
|
|
|
7438
7532
|
};
|
|
7439
7533
|
|
|
7440
7534
|
// eslint/rules/schema-casing.ts
|
|
7441
|
-
import
|
|
7535
|
+
import path50 from "path";
|
|
7442
7536
|
function isCamelCase(name) {
|
|
7443
7537
|
return /^[a-z][a-zA-Z0-9]*$/.test(name);
|
|
7444
7538
|
}
|
|
@@ -7466,9 +7560,9 @@ var schemaCasingRule = {
|
|
|
7466
7560
|
}
|
|
7467
7561
|
},
|
|
7468
7562
|
create(context) {
|
|
7469
|
-
const filename =
|
|
7563
|
+
const filename = path50.resolve(context.filename);
|
|
7470
7564
|
const sourceRoot = sourceRootOf(context);
|
|
7471
|
-
if (!filename.startsWith(sourceRoot +
|
|
7565
|
+
if (!filename.startsWith(sourceRoot + path50.sep)) return {};
|
|
7472
7566
|
let zodLocalName;
|
|
7473
7567
|
return {
|
|
7474
7568
|
ImportDeclaration(node) {
|
|
@@ -7500,39 +7594,39 @@ var schemaCasingRule = {
|
|
|
7500
7594
|
};
|
|
7501
7595
|
|
|
7502
7596
|
// eslint/rules/sole-state-owner.ts
|
|
7503
|
-
import
|
|
7504
|
-
import
|
|
7597
|
+
import path51 from "path";
|
|
7598
|
+
import ts11 from "typescript";
|
|
7505
7599
|
function findStateHooks(node) {
|
|
7506
7600
|
const hooks = [];
|
|
7507
7601
|
const visit = (child) => {
|
|
7508
|
-
if (
|
|
7509
|
-
if (
|
|
7602
|
+
if (ts11.isCallExpression(child) && ts11.isIdentifier(child.expression) && child.expression.text === "useState") {
|
|
7603
|
+
if (ts11.isVariableDeclaration(child.parent)) {
|
|
7510
7604
|
const { name } = child.parent;
|
|
7511
|
-
if (
|
|
7605
|
+
if (ts11.isArrayBindingPattern(name) && name.elements.length >= 2) {
|
|
7512
7606
|
const value = name.elements[0];
|
|
7513
7607
|
const updater = name.elements[1];
|
|
7514
|
-
if (value && updater &&
|
|
7608
|
+
if (value && updater && ts11.isBindingElement(value) && ts11.isBindingElement(updater)) {
|
|
7515
7609
|
const valueName = value.name;
|
|
7516
7610
|
const updaterName = updater.name;
|
|
7517
|
-
if (
|
|
7611
|
+
if (ts11.isIdentifier(valueName) && ts11.isIdentifier(updaterName)) {
|
|
7518
7612
|
hooks.push({ value: valueName.text, updater: updaterName.text });
|
|
7519
7613
|
}
|
|
7520
7614
|
}
|
|
7521
7615
|
}
|
|
7522
7616
|
}
|
|
7523
7617
|
}
|
|
7524
|
-
|
|
7618
|
+
ts11.forEachChild(child, visit);
|
|
7525
7619
|
};
|
|
7526
7620
|
visit(node);
|
|
7527
7621
|
return hooks;
|
|
7528
7622
|
}
|
|
7529
7623
|
function isHookUsage(node, hook) {
|
|
7530
|
-
if (
|
|
7624
|
+
if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === hook.updater) {
|
|
7531
7625
|
return "updater";
|
|
7532
7626
|
}
|
|
7533
|
-
if (
|
|
7627
|
+
if (ts11.isIdentifier(node) && node.text === hook.value) {
|
|
7534
7628
|
const parent = node.parent;
|
|
7535
|
-
if (
|
|
7629
|
+
if (ts11.isBindingElement(parent) || ts11.isPropertyAccessExpression(parent) || ts11.isShorthandPropertyAssignment(parent)) {
|
|
7536
7630
|
return void 0;
|
|
7537
7631
|
}
|
|
7538
7632
|
return "value";
|
|
@@ -7542,16 +7636,16 @@ function isHookUsage(node, hook) {
|
|
|
7542
7636
|
function topLevelJsxChildren(initial) {
|
|
7543
7637
|
if (!initial) return void 0;
|
|
7544
7638
|
let expression = initial;
|
|
7545
|
-
while (
|
|
7546
|
-
if (
|
|
7639
|
+
while (ts11.isParenthesizedExpression(expression)) expression = expression.expression;
|
|
7640
|
+
if (ts11.isJsxFragment(expression)) {
|
|
7547
7641
|
const children = expression.children.filter(
|
|
7548
|
-
(c) => !
|
|
7642
|
+
(c) => !ts11.isJsxText(c) && !ts11.isJsxSpreadAttribute(c)
|
|
7549
7643
|
);
|
|
7550
7644
|
return { root: expression, children };
|
|
7551
7645
|
}
|
|
7552
|
-
if (
|
|
7646
|
+
if (ts11.isJsxElement(expression)) {
|
|
7553
7647
|
const children = expression.children.filter(
|
|
7554
|
-
(c) => !
|
|
7648
|
+
(c) => !ts11.isJsxText(c) && !ts11.isJsxSpreadAttribute(c)
|
|
7555
7649
|
);
|
|
7556
7650
|
return { root: expression, children };
|
|
7557
7651
|
}
|
|
@@ -7565,8 +7659,8 @@ function collectUsesIn(child, hook) {
|
|
|
7565
7659
|
positions.push(node);
|
|
7566
7660
|
count += 1;
|
|
7567
7661
|
}
|
|
7568
|
-
if (
|
|
7569
|
-
|
|
7662
|
+
if (ts11.isFunctionDeclaration(node) || ts11.isClassDeclaration(node)) return;
|
|
7663
|
+
ts11.forEachChild(node, visit);
|
|
7570
7664
|
};
|
|
7571
7665
|
visit(child);
|
|
7572
7666
|
return { positions, count };
|
|
@@ -7580,7 +7674,7 @@ var soleStateOwnerRule = {
|
|
|
7580
7674
|
}
|
|
7581
7675
|
},
|
|
7582
7676
|
create(context) {
|
|
7583
|
-
const filename =
|
|
7677
|
+
const filename = path51.resolve(context.filename);
|
|
7584
7678
|
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx")) return {};
|
|
7585
7679
|
const text = context.sourceCode.text;
|
|
7586
7680
|
const components = parseComponentInfo(text, filename);
|
|
@@ -7605,18 +7699,18 @@ var soleStateOwnerRule = {
|
|
|
7605
7699
|
}
|
|
7606
7700
|
};
|
|
7607
7701
|
function analyzeSoleOwner(declaration, hook) {
|
|
7608
|
-
const body =
|
|
7609
|
-
if (!body || !
|
|
7702
|
+
const body = ts11.isFunctionDeclaration(declaration) ? declaration.body : void 0;
|
|
7703
|
+
if (!body || !ts11.isBlock(body)) return void 0;
|
|
7610
7704
|
const returns = [];
|
|
7611
7705
|
const visit = (node) => {
|
|
7612
|
-
if (node !== body && (
|
|
7613
|
-
if (
|
|
7614
|
-
|
|
7706
|
+
if (node !== body && (ts11.isFunctionLike(node) || ts11.isClassLike(node))) return;
|
|
7707
|
+
if (ts11.isReturnStatement(node)) returns.push(node);
|
|
7708
|
+
ts11.forEachChild(node, visit);
|
|
7615
7709
|
};
|
|
7616
7710
|
visit(body);
|
|
7617
7711
|
if (returns.length !== 1) return void 0;
|
|
7618
7712
|
const single = returns[0];
|
|
7619
|
-
if (!single?.expression || !
|
|
7713
|
+
if (!single?.expression || !ts11.isExpression(single.expression)) return void 0;
|
|
7620
7714
|
const returnExpression = single.expression;
|
|
7621
7715
|
const root = topLevelJsxChildren(returnExpression);
|
|
7622
7716
|
if (!root || root.children.length === 0) return void 0;
|
|
@@ -7639,11 +7733,11 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
7639
7733
|
let outside = false;
|
|
7640
7734
|
const visit = (node) => {
|
|
7641
7735
|
if (outside) return;
|
|
7642
|
-
if (node !== declaration && (
|
|
7736
|
+
if (node !== declaration && (ts11.isFunctionDeclaration(node) || ts11.isClassDeclaration(node))) return;
|
|
7643
7737
|
if (isHookUsage(node, hook)) {
|
|
7644
7738
|
let current = node;
|
|
7645
7739
|
let isInJsxChild = false;
|
|
7646
|
-
while (!
|
|
7740
|
+
while (!ts11.isSourceFile(current)) {
|
|
7647
7741
|
if (children.includes(current)) {
|
|
7648
7742
|
isInJsxChild = true;
|
|
7649
7743
|
break;
|
|
@@ -7652,14 +7746,14 @@ function usesOutsideJsx(declaration, hook, children) {
|
|
|
7652
7746
|
}
|
|
7653
7747
|
if (!isInJsxChild) outside = true;
|
|
7654
7748
|
}
|
|
7655
|
-
|
|
7749
|
+
ts11.forEachChild(node, visit);
|
|
7656
7750
|
};
|
|
7657
7751
|
visit(declaration);
|
|
7658
7752
|
return outside;
|
|
7659
7753
|
}
|
|
7660
7754
|
|
|
7661
7755
|
// eslint/rules/source-under-src.ts
|
|
7662
|
-
import
|
|
7756
|
+
import path52 from "path";
|
|
7663
7757
|
var NON_SOURCE_ROOT_DIRS = /* @__PURE__ */ new Set([
|
|
7664
7758
|
".agents",
|
|
7665
7759
|
".cache",
|
|
@@ -7700,14 +7794,14 @@ var sourceUnderSrcRule = {
|
|
|
7700
7794
|
}
|
|
7701
7795
|
},
|
|
7702
7796
|
create(context) {
|
|
7703
|
-
const filename =
|
|
7797
|
+
const filename = path52.resolve(context.filename);
|
|
7704
7798
|
if (!MODULE_EXTENSION.test(filename)) return {};
|
|
7705
|
-
const relative =
|
|
7799
|
+
const relative = path52.relative(context.cwd, filename).replace(/\\/g, "/");
|
|
7706
7800
|
if (relative === "src" || relative.startsWith("src/")) return {};
|
|
7707
7801
|
const topLevel = relative.split("/")[0] ?? "";
|
|
7708
7802
|
if (NON_SOURCE_ROOT_DIRS.has(topLevel)) return {};
|
|
7709
7803
|
if (!relative.includes("/")) {
|
|
7710
|
-
const basename =
|
|
7804
|
+
const basename = path52.basename(filename);
|
|
7711
7805
|
if (CONFIG_FILE.test(basename) || DECLARATION_FILE.test(basename) || basename.startsWith(".")) return {};
|
|
7712
7806
|
}
|
|
7713
7807
|
return {
|
|
@@ -7723,7 +7817,7 @@ var sourceUnderSrcRule = {
|
|
|
7723
7817
|
};
|
|
7724
7818
|
|
|
7725
7819
|
// eslint/rules/stay-flat.ts
|
|
7726
|
-
import
|
|
7820
|
+
import path53 from "path";
|
|
7727
7821
|
var stayFlatRule = {
|
|
7728
7822
|
meta: {
|
|
7729
7823
|
schema: [],
|
|
@@ -7734,7 +7828,7 @@ var stayFlatRule = {
|
|
|
7734
7828
|
},
|
|
7735
7829
|
create(context) {
|
|
7736
7830
|
const sourceRoot = sourceRootOf(context);
|
|
7737
|
-
const file =
|
|
7831
|
+
const file = path53.resolve(context.filename);
|
|
7738
7832
|
const segments = segmentsOf(file, sourceRoot);
|
|
7739
7833
|
if (segments.length !== 3 || segments[0] !== "features") return {};
|
|
7740
7834
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -7774,7 +7868,7 @@ var stayFlatRule = {
|
|
|
7774
7868
|
};
|
|
7775
7869
|
|
|
7776
7870
|
// eslint/rules/support-file-placement.ts
|
|
7777
|
-
import
|
|
7871
|
+
import path54 from "path";
|
|
7778
7872
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
7779
7873
|
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
7780
7874
|
["constants", "constant"],
|
|
@@ -7799,7 +7893,7 @@ var supportFilePlacementRule = {
|
|
|
7799
7893
|
},
|
|
7800
7894
|
create(context) {
|
|
7801
7895
|
const sourceRoot = sourceRootOf(context);
|
|
7802
|
-
const supportFile =
|
|
7896
|
+
const supportFile = path54.resolve(context.filename);
|
|
7803
7897
|
const currentFolder = folderSegmentsOf(supportFile, sourceRoot);
|
|
7804
7898
|
const supportFolder = currentFolder[currentFolder.length - 1];
|
|
7805
7899
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS.has(supportFolder)) return {};
|
|
@@ -7853,7 +7947,7 @@ var supportFilePlacementRule = {
|
|
|
7853
7947
|
|
|
7854
7948
|
// eslint/rules/support-folder-shape.ts
|
|
7855
7949
|
import fs6 from "fs";
|
|
7856
|
-
import
|
|
7950
|
+
import path55 from "path";
|
|
7857
7951
|
var SUPPORT_FOLDERS4 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
7858
7952
|
var INDEX_NAMES2 = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
7859
7953
|
var supportFolderShapeRule = {
|
|
@@ -7865,12 +7959,12 @@ var supportFolderShapeRule = {
|
|
|
7865
7959
|
}
|
|
7866
7960
|
},
|
|
7867
7961
|
create(context) {
|
|
7868
|
-
const filename =
|
|
7869
|
-
const baseName =
|
|
7962
|
+
const filename = path55.resolve(context.filename);
|
|
7963
|
+
const baseName = path55.basename(filename);
|
|
7870
7964
|
if (!INDEX_NAMES2.has(baseName)) return {};
|
|
7871
|
-
const folder =
|
|
7965
|
+
const folder = path55.basename(path55.dirname(filename));
|
|
7872
7966
|
if (!SUPPORT_FOLDERS4.has(folder)) return {};
|
|
7873
|
-
const directory =
|
|
7967
|
+
const directory = path55.dirname(filename);
|
|
7874
7968
|
let entries;
|
|
7875
7969
|
try {
|
|
7876
7970
|
entries = fs6.readdirSync(directory);
|
|
@@ -7888,7 +7982,7 @@ var supportFolderShapeRule = {
|
|
|
7888
7982
|
for (const match of source.matchAll(exportPattern)) {
|
|
7889
7983
|
hasAnyReExport = true;
|
|
7890
7984
|
const specifier = match.groups?.specifier;
|
|
7891
|
-
if (specifier?.startsWith(".")) exportedFiles.add(
|
|
7985
|
+
if (specifier?.startsWith(".")) exportedFiles.add(path55.basename(specifier));
|
|
7892
7986
|
}
|
|
7893
7987
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
7894
7988
|
if (siblingModules.length === 0) {
|
|
@@ -8067,11 +8161,11 @@ var baseLayerPairRule = {
|
|
|
8067
8161
|
|
|
8068
8162
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
8069
8163
|
import { statSync as statSync4 } from "fs";
|
|
8070
|
-
import
|
|
8164
|
+
import path58 from "path";
|
|
8071
8165
|
|
|
8072
8166
|
// eslint/rules/tailwind/source-files.ts
|
|
8073
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
8074
|
-
import
|
|
8167
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync10, statSync as statSync3 } from "fs";
|
|
8168
|
+
import path56 from "path";
|
|
8075
8169
|
var CSS_EXTENSIONS = [".css"];
|
|
8076
8170
|
var MODULE_EXTENSIONS4 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
8077
8171
|
var SOURCE_EXTENSIONS = [...MODULE_EXTENSIONS4, ...CSS_EXTENSIONS];
|
|
@@ -8084,7 +8178,7 @@ function findFiles(dir, extensions) {
|
|
|
8084
8178
|
}
|
|
8085
8179
|
return entries.flatMap((entry) => {
|
|
8086
8180
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
8087
|
-
const entryPath =
|
|
8181
|
+
const entryPath = path56.join(dir, entry);
|
|
8088
8182
|
let stats;
|
|
8089
8183
|
try {
|
|
8090
8184
|
stats = statSync3(entryPath);
|
|
@@ -8092,7 +8186,7 @@ function findFiles(dir, extensions) {
|
|
|
8092
8186
|
return [];
|
|
8093
8187
|
}
|
|
8094
8188
|
if (stats.isDirectory()) return findFiles(entryPath, extensions);
|
|
8095
|
-
return extensions.includes(
|
|
8189
|
+
return extensions.includes(path56.extname(entry)) ? [entryPath] : [];
|
|
8096
8190
|
});
|
|
8097
8191
|
}
|
|
8098
8192
|
function cachedTextReader() {
|
|
@@ -8101,7 +8195,7 @@ function cachedTextReader() {
|
|
|
8101
8195
|
let text = texts.get(file);
|
|
8102
8196
|
if (text === void 0) {
|
|
8103
8197
|
try {
|
|
8104
|
-
text =
|
|
8198
|
+
text = readFileSync10(file, "utf8");
|
|
8105
8199
|
} catch {
|
|
8106
8200
|
text = "";
|
|
8107
8201
|
}
|
|
@@ -8115,7 +8209,7 @@ function escapeRegExp(text) {
|
|
|
8115
8209
|
}
|
|
8116
8210
|
|
|
8117
8211
|
// eslint/rules/tailwind/stylesheet-graph.ts
|
|
8118
|
-
import
|
|
8212
|
+
import path57 from "path";
|
|
8119
8213
|
function registersTailwind(text) {
|
|
8120
8214
|
return /@import\s+(?:url\(\s*)?["']tailwindcss["']\s*\)?/i.test(text);
|
|
8121
8215
|
}
|
|
@@ -8129,25 +8223,25 @@ function moduleImports(text, fileName) {
|
|
|
8129
8223
|
return new RegExp(`(?:import|require)\\s*\\(?\\s*["'][^"']*${escaped}["']`, "i").test(text);
|
|
8130
8224
|
}
|
|
8131
8225
|
function resolveSpecifier2(fromFile, spec, sourceRoot) {
|
|
8132
|
-
if (spec.startsWith("/")) return
|
|
8133
|
-
if (spec.startsWith("./") || spec.startsWith("../")) return
|
|
8134
|
-
if (spec.startsWith("@/")) return
|
|
8226
|
+
if (spec.startsWith("/")) return path57.resolve(spec);
|
|
8227
|
+
if (spec.startsWith("./") || spec.startsWith("../")) return path57.resolve(path57.dirname(fromFile), spec);
|
|
8228
|
+
if (spec.startsWith("@/")) return path57.resolve(sourceRoot, spec.slice(2));
|
|
8135
8229
|
return void 0;
|
|
8136
8230
|
}
|
|
8137
8231
|
function buildStylesheetGraph(options) {
|
|
8138
8232
|
const { cssFiles, sourceRoot, textOf } = options;
|
|
8139
|
-
const cssSet = new Set(cssFiles.map((file) =>
|
|
8233
|
+
const cssSet = new Set(cssFiles.map((file) => path57.normalize(file)));
|
|
8140
8234
|
const globals = cssFiles.filter((file) => registersTailwind(textOf(file)));
|
|
8141
8235
|
const reachable = /* @__PURE__ */ new Set();
|
|
8142
8236
|
const queue = [...globals];
|
|
8143
|
-
for (const global of globals) reachable.add(
|
|
8237
|
+
for (const global of globals) reachable.add(path57.normalize(global));
|
|
8144
8238
|
while (queue.length > 0) {
|
|
8145
8239
|
const from = queue.shift();
|
|
8146
8240
|
if (!from) continue;
|
|
8147
8241
|
for (const spec of importedSpecifiers(textOf(from))) {
|
|
8148
8242
|
const target = resolveSpecifier2(from, spec, sourceRoot);
|
|
8149
8243
|
if (!target) continue;
|
|
8150
|
-
const normalized =
|
|
8244
|
+
const normalized = path57.normalize(target);
|
|
8151
8245
|
if (cssSet.has(normalized) && !reachable.has(normalized)) {
|
|
8152
8246
|
reachable.add(normalized);
|
|
8153
8247
|
queue.push(normalized);
|
|
@@ -8159,7 +8253,7 @@ function buildStylesheetGraph(options) {
|
|
|
8159
8253
|
for (const spec of importedSpecifiers(textOf(global))) {
|
|
8160
8254
|
const target = resolveSpecifier2(global, spec, sourceRoot);
|
|
8161
8255
|
if (!target) continue;
|
|
8162
|
-
const normalized =
|
|
8256
|
+
const normalized = path57.normalize(target);
|
|
8163
8257
|
if (cssSet.has(normalized)) directChildren.add(normalized);
|
|
8164
8258
|
}
|
|
8165
8259
|
}
|
|
@@ -8167,8 +8261,8 @@ function buildStylesheetGraph(options) {
|
|
|
8167
8261
|
}
|
|
8168
8262
|
|
|
8169
8263
|
// eslint/rules/tailwind/css-entry-point.ts
|
|
8170
|
-
var APP_STYLES_DIR =
|
|
8171
|
-
var GLOBAL_STYLESHEET_PATH =
|
|
8264
|
+
var APP_STYLES_DIR = path58.join("app", "styles");
|
|
8265
|
+
var GLOBAL_STYLESHEET_PATH = path58.join(APP_STYLES_DIR, "globals.css");
|
|
8172
8266
|
var cssEntryPointRule = {
|
|
8173
8267
|
meta: {
|
|
8174
8268
|
schema: [],
|
|
@@ -8194,8 +8288,8 @@ var cssEntryPointRule = {
|
|
|
8194
8288
|
return {
|
|
8195
8289
|
"StyleSheet:exit"(node) {
|
|
8196
8290
|
if (globals.length === 0) return;
|
|
8197
|
-
const current =
|
|
8198
|
-
const relative =
|
|
8291
|
+
const current = path58.normalize(path58.resolve(context.filename));
|
|
8292
|
+
const relative = path58.relative(sourceRoot, current);
|
|
8199
8293
|
if (globals.includes(current)) {
|
|
8200
8294
|
if (globals.length > 1) {
|
|
8201
8295
|
context.report({
|
|
@@ -8211,7 +8305,7 @@ var cssEntryPointRule = {
|
|
|
8211
8305
|
});
|
|
8212
8306
|
return;
|
|
8213
8307
|
}
|
|
8214
|
-
const basename =
|
|
8308
|
+
const basename = path58.basename(current);
|
|
8215
8309
|
const importCount = moduleFiles.filter((modulePath) => moduleImports(textOf(modulePath), basename)).length;
|
|
8216
8310
|
if (importCount !== 1) {
|
|
8217
8311
|
context.report({
|
|
@@ -8221,7 +8315,7 @@ var cssEntryPointRule = {
|
|
|
8221
8315
|
}
|
|
8222
8316
|
return;
|
|
8223
8317
|
}
|
|
8224
|
-
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${
|
|
8318
|
+
const isInAppStyles = relative === APP_STYLES_DIR || relative.startsWith(`${APP_STYLES_DIR}${path58.sep}`);
|
|
8225
8319
|
if (!isInAppStyles) {
|
|
8226
8320
|
context.report({
|
|
8227
8321
|
node,
|
|
@@ -8710,7 +8804,7 @@ var tailwindRules = {
|
|
|
8710
8804
|
};
|
|
8711
8805
|
|
|
8712
8806
|
// eslint/rules/type-extraction.ts
|
|
8713
|
-
import
|
|
8807
|
+
import path59 from "path";
|
|
8714
8808
|
var typeExtractionRule = {
|
|
8715
8809
|
meta: {
|
|
8716
8810
|
schema: [],
|
|
@@ -8721,7 +8815,7 @@ var typeExtractionRule = {
|
|
|
8721
8815
|
},
|
|
8722
8816
|
create(context) {
|
|
8723
8817
|
const sourceRoot = sourceRootOf(context);
|
|
8724
|
-
const file =
|
|
8818
|
+
const file = path59.resolve(context.filename);
|
|
8725
8819
|
const segments = segmentsOf(file, sourceRoot);
|
|
8726
8820
|
if (segments.length === 0) return {};
|
|
8727
8821
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -8860,9 +8954,9 @@ var uiStateRule = {
|
|
|
8860
8954
|
};
|
|
8861
8955
|
|
|
8862
8956
|
// eslint/rules/unknown-utility.ts
|
|
8863
|
-
import { existsSync as existsSync6, readdirSync as readdirSync4, readFileSync as
|
|
8957
|
+
import { existsSync as existsSync6, readdirSync as readdirSync4, readFileSync as readFileSync11, statSync as statSync6 } from "fs";
|
|
8864
8958
|
import { createRequire } from "module";
|
|
8865
|
-
import
|
|
8959
|
+
import path60 from "path";
|
|
8866
8960
|
var PREFIX_NAMESPACES = {
|
|
8867
8961
|
bg: ["color"],
|
|
8868
8962
|
text: ["color", "text"],
|
|
@@ -9102,7 +9196,7 @@ function stylesheetFiles(dir) {
|
|
|
9102
9196
|
}
|
|
9103
9197
|
return entries.flatMap((entry) => {
|
|
9104
9198
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
9105
|
-
const entryPath =
|
|
9199
|
+
const entryPath = path60.join(dir, entry);
|
|
9106
9200
|
let stats;
|
|
9107
9201
|
try {
|
|
9108
9202
|
stats = statSync6(entryPath);
|
|
@@ -9110,7 +9204,7 @@ function stylesheetFiles(dir) {
|
|
|
9110
9204
|
return [];
|
|
9111
9205
|
}
|
|
9112
9206
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
9113
|
-
return
|
|
9207
|
+
return path60.extname(entry) === ".css" ? [entryPath] : [];
|
|
9114
9208
|
});
|
|
9115
9209
|
}
|
|
9116
9210
|
function packageNameOf(specifier) {
|
|
@@ -9121,24 +9215,24 @@ function packageNameOf(specifier) {
|
|
|
9121
9215
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
9122
9216
|
const packageName = packageNameOf(specifier);
|
|
9123
9217
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
9124
|
-
let directory =
|
|
9125
|
-
while (directory !==
|
|
9126
|
-
const packageRoot =
|
|
9127
|
-
const manifestPath =
|
|
9218
|
+
let directory = path60.dirname(fromFile);
|
|
9219
|
+
while (directory !== path60.dirname(directory)) {
|
|
9220
|
+
const packageRoot = path60.join(directory, "node_modules", packageName);
|
|
9221
|
+
const manifestPath = path60.join(packageRoot, "package.json");
|
|
9128
9222
|
if (existsSync6(manifestPath)) {
|
|
9129
9223
|
try {
|
|
9130
|
-
const manifest =
|
|
9224
|
+
const manifest = readFileSync11(manifestPath, "utf8");
|
|
9131
9225
|
const stylesheet = /"style"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
9132
9226
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
9133
9227
|
const target = stylesheet ?? main;
|
|
9134
9228
|
if (!target) return void 0;
|
|
9135
|
-
const resolved =
|
|
9229
|
+
const resolved = path60.resolve(packageRoot, target);
|
|
9136
9230
|
return existsSync6(resolved) ? resolved : void 0;
|
|
9137
9231
|
} catch {
|
|
9138
9232
|
return void 0;
|
|
9139
9233
|
}
|
|
9140
9234
|
}
|
|
9141
|
-
directory =
|
|
9235
|
+
directory = path60.dirname(directory);
|
|
9142
9236
|
}
|
|
9143
9237
|
return void 0;
|
|
9144
9238
|
}
|
|
@@ -9147,7 +9241,7 @@ function inventoryStylesheetFiles(projectFiles) {
|
|
|
9147
9241
|
for (const file of projectFiles) {
|
|
9148
9242
|
let css2;
|
|
9149
9243
|
try {
|
|
9150
|
-
css2 =
|
|
9244
|
+
css2 = readFileSync11(file, "utf8");
|
|
9151
9245
|
} catch {
|
|
9152
9246
|
continue;
|
|
9153
9247
|
}
|
|
@@ -9213,7 +9307,7 @@ function readInventory(files) {
|
|
|
9213
9307
|
for (const file of files) {
|
|
9214
9308
|
let css2;
|
|
9215
9309
|
try {
|
|
9216
|
-
css2 =
|
|
9310
|
+
css2 = readFileSync11(file, "utf8");
|
|
9217
9311
|
} catch {
|
|
9218
9312
|
continue;
|
|
9219
9313
|
}
|
|
@@ -9389,7 +9483,7 @@ var unknownUtilityRule = {
|
|
|
9389
9483
|
};
|
|
9390
9484
|
|
|
9391
9485
|
// eslint/rules/util-file-name.ts
|
|
9392
|
-
import
|
|
9486
|
+
import path61 from "path";
|
|
9393
9487
|
function toKebabCase2(value) {
|
|
9394
9488
|
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();
|
|
9395
9489
|
}
|
|
@@ -9402,7 +9496,7 @@ var utilFileNameRule = {
|
|
|
9402
9496
|
}
|
|
9403
9497
|
},
|
|
9404
9498
|
create(context) {
|
|
9405
|
-
const filename =
|
|
9499
|
+
const filename = path61.resolve(context.filename);
|
|
9406
9500
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
9407
9501
|
if (!segments.includes("utils")) return {};
|
|
9408
9502
|
let module;
|
|
@@ -9416,13 +9510,13 @@ var utilFileNameRule = {
|
|
|
9416
9510
|
const functionName = functions[0]?.name;
|
|
9417
9511
|
if (!functionName) return {};
|
|
9418
9512
|
const expected = toKebabCase2(functionName);
|
|
9419
|
-
const actual =
|
|
9513
|
+
const actual = path61.basename(filename, path61.extname(filename));
|
|
9420
9514
|
if (!expected || actual === expected) return {};
|
|
9421
9515
|
return {
|
|
9422
9516
|
Program(node) {
|
|
9423
9517
|
context.report({
|
|
9424
9518
|
node,
|
|
9425
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
9519
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path61.extname(filename).slice(1)}.`
|
|
9426
9520
|
});
|
|
9427
9521
|
}
|
|
9428
9522
|
};
|
|
@@ -9430,7 +9524,7 @@ var utilFileNameRule = {
|
|
|
9430
9524
|
};
|
|
9431
9525
|
|
|
9432
9526
|
// eslint/rules/value-extraction.ts
|
|
9433
|
-
import
|
|
9527
|
+
import path62 from "path";
|
|
9434
9528
|
var valueExtractionRule = {
|
|
9435
9529
|
meta: {
|
|
9436
9530
|
schema: [],
|
|
@@ -9441,7 +9535,7 @@ var valueExtractionRule = {
|
|
|
9441
9535
|
},
|
|
9442
9536
|
create(context) {
|
|
9443
9537
|
const sourceRoot = sourceRootOf(context);
|
|
9444
|
-
const file =
|
|
9538
|
+
const file = path62.resolve(context.filename);
|
|
9445
9539
|
const segments = segmentsOf(file, sourceRoot);
|
|
9446
9540
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
9447
9541
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -9462,8 +9556,8 @@ var valueExtractionRule = {
|
|
|
9462
9556
|
};
|
|
9463
9557
|
|
|
9464
9558
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
9465
|
-
import { existsSync as existsSync7, readFileSync as
|
|
9466
|
-
import
|
|
9559
|
+
import { existsSync as existsSync7, readFileSync as readFileSync12 } from "fs";
|
|
9560
|
+
import path63 from "path";
|
|
9467
9561
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
9468
9562
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
9469
9563
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -9496,8 +9590,8 @@ var trackedDocsRule = {
|
|
|
9496
9590
|
if (!context.filename.endsWith("package.json")) return;
|
|
9497
9591
|
const root = node.body;
|
|
9498
9592
|
if (root.type !== "Object") return;
|
|
9499
|
-
const projectRoot =
|
|
9500
|
-
const configPath =
|
|
9593
|
+
const projectRoot = path63.dirname(path63.resolve(context.filename));
|
|
9594
|
+
const configPath = path63.join(projectRoot, "vulyk.config.ts");
|
|
9501
9595
|
if (!existsSync7(configPath)) {
|
|
9502
9596
|
context.report({
|
|
9503
9597
|
node,
|
|
@@ -9505,7 +9599,7 @@ var trackedDocsRule = {
|
|
|
9505
9599
|
});
|
|
9506
9600
|
return;
|
|
9507
9601
|
}
|
|
9508
|
-
const config =
|
|
9602
|
+
const config = readFileSync12(configPath, "utf8");
|
|
9509
9603
|
if (!config.includes(PASIKA_REPO)) {
|
|
9510
9604
|
context.report({
|
|
9511
9605
|
node,
|
|
@@ -9522,7 +9616,7 @@ var trackedDocsRule = {
|
|
|
9522
9616
|
});
|
|
9523
9617
|
}
|
|
9524
9618
|
}
|
|
9525
|
-
const agentsPath =
|
|
9619
|
+
const agentsPath = path63.join(projectRoot, "AGENTS.md");
|
|
9526
9620
|
if (!existsSync7(agentsPath)) {
|
|
9527
9621
|
context.report({
|
|
9528
9622
|
node,
|
|
@@ -9622,7 +9716,7 @@ var withResponseHelperRule = {
|
|
|
9622
9716
|
|
|
9623
9717
|
// eslint/rules/zirka-baseline.ts
|
|
9624
9718
|
import fs7 from "fs";
|
|
9625
|
-
import
|
|
9719
|
+
import path64 from "path";
|
|
9626
9720
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
9627
9721
|
var PRETTIER_CONFIGS = [
|
|
9628
9722
|
"prettier.config.mjs",
|
|
@@ -9641,10 +9735,10 @@ var zirkaBaselineRule = {
|
|
|
9641
9735
|
}
|
|
9642
9736
|
},
|
|
9643
9737
|
create(context) {
|
|
9644
|
-
const filename =
|
|
9645
|
-
const basename =
|
|
9738
|
+
const filename = path64.resolve(context.filename);
|
|
9739
|
+
const basename = path64.basename(filename);
|
|
9646
9740
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
9647
|
-
const projectRoot =
|
|
9741
|
+
const projectRoot = path64.dirname(filename);
|
|
9648
9742
|
const report3 = (message) => {
|
|
9649
9743
|
context.report({
|
|
9650
9744
|
node: context.sourceCode.ast,
|
|
@@ -9659,7 +9753,7 @@ var zirkaBaselineRule = {
|
|
|
9659
9753
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
9660
9754
|
);
|
|
9661
9755
|
}
|
|
9662
|
-
const tsconfigPath =
|
|
9756
|
+
const tsconfigPath = path64.join(projectRoot, "tsconfig.json");
|
|
9663
9757
|
if (!fs7.existsSync(tsconfigPath)) {
|
|
9664
9758
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
9665
9759
|
} else {
|
|
@@ -9677,13 +9771,13 @@ var zirkaBaselineRule = {
|
|
|
9677
9771
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
9678
9772
|
}
|
|
9679
9773
|
}
|
|
9680
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(
|
|
9774
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(path64.join(projectRoot, name)));
|
|
9681
9775
|
if (!prettierConfigFile) {
|
|
9682
9776
|
report3(
|
|
9683
9777
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
9684
9778
|
);
|
|
9685
9779
|
} else {
|
|
9686
|
-
const content = fs7.readFileSync(
|
|
9780
|
+
const content = fs7.readFileSync(path64.join(projectRoot, prettierConfigFile), "utf8");
|
|
9687
9781
|
if (!content.includes("zirka")) {
|
|
9688
9782
|
report3(
|
|
9689
9783
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|
|
@@ -9829,14 +9923,14 @@ var zodSchemaValidationRule = {
|
|
|
9829
9923
|
};
|
|
9830
9924
|
|
|
9831
9925
|
// eslint/ts-alignment.ts
|
|
9832
|
-
import { readFileSync as
|
|
9926
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
9833
9927
|
import { createRequire as createRequire2 } from "module";
|
|
9834
9928
|
import { join } from "path";
|
|
9835
9929
|
var ownRequire = createRequire2(import.meta.url);
|
|
9836
9930
|
var majorOf = (version) => Number(version.split(".")[0]);
|
|
9837
9931
|
function versionOf(packagePath) {
|
|
9838
9932
|
try {
|
|
9839
|
-
const parsed = JSON.parse(
|
|
9933
|
+
const parsed = JSON.parse(readFileSync13(packagePath, "utf8"));
|
|
9840
9934
|
if (typeof parsed !== "object" || parsed === null || !("version" in parsed)) return null;
|
|
9841
9935
|
return typeof parsed.version === "string" ? parsed.version : null;
|
|
9842
9936
|
} catch {
|