pasika 0.10.105 → 0.10.107
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 +161 -65
- package/package.json +1 -1
|
@@ -38,8 +38,8 @@ function memberPropertyName(node) {
|
|
|
38
38
|
}
|
|
39
39
|
return void 0;
|
|
40
40
|
}
|
|
41
|
-
function importedContractMember(expression,
|
|
42
|
-
if (expression?.type !== "MemberExpression" || memberPropertyName(expression) !==
|
|
41
|
+
function importedContractMember(expression, propertyName7, imports) {
|
|
42
|
+
if (expression?.type !== "MemberExpression" || memberPropertyName(expression) !== propertyName7 || expression.object.type !== "Identifier" || !imports.has(expression.object.name)) {
|
|
43
43
|
return void 0;
|
|
44
44
|
}
|
|
45
45
|
return expression.object.name;
|
|
@@ -5727,6 +5727,69 @@ function getSemanticLiteralIndex(index) {
|
|
|
5727
5727
|
return result;
|
|
5728
5728
|
}
|
|
5729
5729
|
|
|
5730
|
+
// eslint/rules/next-font-literals.ts
|
|
5731
|
+
var fontLoaderOptions = /* @__PURE__ */ new Set([
|
|
5732
|
+
"subsets",
|
|
5733
|
+
"weight",
|
|
5734
|
+
"style",
|
|
5735
|
+
"display",
|
|
5736
|
+
"variable",
|
|
5737
|
+
"fallback",
|
|
5738
|
+
"adjustFontFallback",
|
|
5739
|
+
"axes",
|
|
5740
|
+
"src",
|
|
5741
|
+
"declarations"
|
|
5742
|
+
]);
|
|
5743
|
+
function propertyName3(key) {
|
|
5744
|
+
if (typeof key !== "object" || key === null || !("type" in key)) return void 0;
|
|
5745
|
+
if (key.type === "Identifier" && "name" in key && typeof key.name === "string") return key.name;
|
|
5746
|
+
if (key.type === "Literal" && "value" in key && typeof key.value === "string") return key.value;
|
|
5747
|
+
return void 0;
|
|
5748
|
+
}
|
|
5749
|
+
function isImportedNextFont(context, node, callee) {
|
|
5750
|
+
if (typeof callee !== "object" || callee === null || !("type" in callee) || callee.type !== "Identifier" || !("name" in callee) || typeof callee.name !== "string") {
|
|
5751
|
+
return false;
|
|
5752
|
+
}
|
|
5753
|
+
let scope = context.sourceCode.getScope(node);
|
|
5754
|
+
for (; ; ) {
|
|
5755
|
+
const variable = scope.set.get(callee.name);
|
|
5756
|
+
if (variable) {
|
|
5757
|
+
return variable.defs.some((definition) => {
|
|
5758
|
+
if (definition.type !== "ImportBinding") return false;
|
|
5759
|
+
const module = definition.parent.source.value;
|
|
5760
|
+
return module === "next/font/google" && definition.node.type === "ImportSpecifier" || module === "next/font/local" && definition.node.type === "ImportDefaultSpecifier";
|
|
5761
|
+
});
|
|
5762
|
+
}
|
|
5763
|
+
if (scope.upper === null) return false;
|
|
5764
|
+
scope = scope.upper;
|
|
5765
|
+
}
|
|
5766
|
+
}
|
|
5767
|
+
function isStaticNextFontLiteral(node, context) {
|
|
5768
|
+
let current = node;
|
|
5769
|
+
let option;
|
|
5770
|
+
while (current.parent) {
|
|
5771
|
+
const parent = current.parent;
|
|
5772
|
+
if (parent.type === "ArrayExpression" && Array.isArray(parent.elements) && parent.elements.includes(current)) {
|
|
5773
|
+
current = parent;
|
|
5774
|
+
continue;
|
|
5775
|
+
}
|
|
5776
|
+
if (parent.type === "Property" && parent.value === current && parent.computed === false) {
|
|
5777
|
+
const owner = parent.parent;
|
|
5778
|
+
if (owner?.type === "ObjectExpression" && owner.parent?.type === "CallExpression") {
|
|
5779
|
+
option = propertyName3(parent.key);
|
|
5780
|
+
}
|
|
5781
|
+
current = parent;
|
|
5782
|
+
continue;
|
|
5783
|
+
}
|
|
5784
|
+
if (parent.type === "ObjectExpression" && Array.isArray(parent.properties) && parent.properties.includes(current)) {
|
|
5785
|
+
current = parent;
|
|
5786
|
+
continue;
|
|
5787
|
+
}
|
|
5788
|
+
return parent.type === "CallExpression" && current.type === "ObjectExpression" && Array.isArray(parent.arguments) && parent.arguments[0] === current && option !== void 0 && fontLoaderOptions.has(option) && isImportedNextFont(context, node, parent.callee);
|
|
5789
|
+
}
|
|
5790
|
+
return false;
|
|
5791
|
+
}
|
|
5792
|
+
|
|
5730
5793
|
// eslint/rules/no-inline-runtime-literal.ts
|
|
5731
5794
|
var DOC5 = "See docs/next-codebase-guide/rules/constants-rule.md";
|
|
5732
5795
|
var MESSAGE2 = `Every runtime string or numeric value must use a named constant or enum member, including single-use values. Inline JSX className/data-component, canonical locale strings, and static Next.js matchers are exempt. ${DOC5}`;
|
|
@@ -5849,7 +5912,7 @@ var noInlineRuntimeLiteralRule = {
|
|
|
5849
5912
|
if (typeof node.value !== "string" && typeof node.value !== "number" && typeof node.value !== "bigint" && !("bigint" in node && typeof node.bigint === "string")) {
|
|
5850
5913
|
return;
|
|
5851
5914
|
}
|
|
5852
|
-
if (typeof node.value === "string" && (isClassNameProp(node) || isStaticDataComponentMarker(node) || isCanonicalLocaleString(node, root, file)) || isStaticMatcherValue(node, root, file) || isNamedValue(node) || isSyntacticString(node)) {
|
|
5915
|
+
if (typeof node.value === "string" && (isClassNameProp(node) || isStaticDataComponentMarker(node) || isCanonicalLocaleString(node, root, file)) || isStaticMatcherValue(node, root, file) || isStaticNextFontLiteral(node, context) || isNamedValue(node) || isSyntacticString(node)) {
|
|
5853
5916
|
return;
|
|
5854
5917
|
}
|
|
5855
5918
|
context.report({ node, message: MESSAGE2 });
|
|
@@ -5888,7 +5951,7 @@ function isStaticValue(value) {
|
|
|
5888
5951
|
}
|
|
5889
5952
|
return false;
|
|
5890
5953
|
}
|
|
5891
|
-
function
|
|
5954
|
+
function propertyName4(property) {
|
|
5892
5955
|
if (!property.computed && property.key.type === "Identifier") return property.key.name;
|
|
5893
5956
|
if (property.key.type === "Literal" && typeof property.key.value === "string") return property.key.value;
|
|
5894
5957
|
return void 0;
|
|
@@ -5896,7 +5959,7 @@ function propertyName3(property) {
|
|
|
5896
5959
|
function findStaticDeclaration(expression) {
|
|
5897
5960
|
for (const property of expression.properties) {
|
|
5898
5961
|
if (property.type !== "Property" || property.kind !== "init") continue;
|
|
5899
|
-
const name =
|
|
5962
|
+
const name = propertyName4(property);
|
|
5900
5963
|
if (!name) continue;
|
|
5901
5964
|
if (isStaticValue(property.value)) return name;
|
|
5902
5965
|
}
|
|
@@ -6136,7 +6199,7 @@ function endpointOwnership(pathValue) {
|
|
|
6136
6199
|
function resolvedSymbol(checker, symbol) {
|
|
6137
6200
|
return symbol.flags === ts10.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
6138
6201
|
}
|
|
6139
|
-
function
|
|
6202
|
+
function propertyName5(node) {
|
|
6140
6203
|
if (!node) return void 0;
|
|
6141
6204
|
if (ts10.isIdentifier(node) || ts10.isStringLiteral(node) || ts10.isNumericLiteral(node)) return node.text;
|
|
6142
6205
|
return void 0;
|
|
@@ -6292,7 +6355,7 @@ var ContractOwnershipIndex = class {
|
|
|
6292
6355
|
const schemaExpressions = [];
|
|
6293
6356
|
for (const property of argument.properties) {
|
|
6294
6357
|
if (ts10.isPropertyAssignment(property)) {
|
|
6295
|
-
const name =
|
|
6358
|
+
const name = propertyName5(property.name);
|
|
6296
6359
|
if (name === "path") pathExpression = property.initializer;
|
|
6297
6360
|
if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.initializer);
|
|
6298
6361
|
continue;
|
|
@@ -6446,9 +6509,9 @@ function aliasMessage(alias, source) {
|
|
|
6446
6509
|
function bindingAliasMessage(alias, source) {
|
|
6447
6510
|
return `"${alias}" renames "${source}" while creating a binding. Keep the original name and map it only at the object boundary. ${DOC6}`;
|
|
6448
6511
|
}
|
|
6449
|
-
function objectPropertyMessage(
|
|
6450
|
-
if (source ===
|
|
6451
|
-
return `"${
|
|
6512
|
+
function objectPropertyMessage(propertyName7, source) {
|
|
6513
|
+
if (source === propertyName7) return `Use property shorthand for "${propertyName7}". ${DOC6}`;
|
|
6514
|
+
return `"${propertyName7}" maps the local "${source}". Keep the local name or map directly from its source object instead. ${DOC6}`;
|
|
6452
6515
|
}
|
|
6453
6516
|
function normalizePropertyName(name) {
|
|
6454
6517
|
return name.replace(/[-_\s]/g, "").toLowerCase();
|
|
@@ -6461,12 +6524,12 @@ function memberPropertyName2(node) {
|
|
|
6461
6524
|
}
|
|
6462
6525
|
return void 0;
|
|
6463
6526
|
}
|
|
6464
|
-
function isNamedMemberValue(
|
|
6465
|
-
return /^[A-Z]/.test(
|
|
6527
|
+
function isNamedMemberValue(propertyName7) {
|
|
6528
|
+
return /^[A-Z]/.test(propertyName7);
|
|
6466
6529
|
}
|
|
6467
|
-
function isQualifiedSourceField(
|
|
6530
|
+
function isQualifiedSourceField(propertyName7, sourceMember, sourcePropertyName) {
|
|
6468
6531
|
if (sourceMember.type !== "MemberExpression" || sourceMember.object.type !== "Identifier") return false;
|
|
6469
|
-
return normalizePropertyName(
|
|
6532
|
+
return normalizePropertyName(propertyName7) === normalizePropertyName(`${sourceMember.object.name}${sourcePropertyName}`);
|
|
6470
6533
|
}
|
|
6471
6534
|
function isInsideSchemaDeclaration(node) {
|
|
6472
6535
|
let current = node;
|
|
@@ -6478,11 +6541,11 @@ function isInsideSchemaDeclaration(node) {
|
|
|
6478
6541
|
}
|
|
6479
6542
|
return false;
|
|
6480
6543
|
}
|
|
6481
|
-
function semanticMappingMessage(
|
|
6482
|
-
return `"${
|
|
6544
|
+
function semanticMappingMessage(propertyName7, sourcePropertyName) {
|
|
6545
|
+
return `"${propertyName7}" maps from "${sourcePropertyName}" between first-party contracts. Use one canonical field name across the contracts. ${DOC6}`;
|
|
6483
6546
|
}
|
|
6484
|
-
function unknownContractOwnershipMessage(
|
|
6485
|
-
return `Cannot determine contract ownership for mapping "${
|
|
6547
|
+
function unknownContractOwnershipMessage(propertyName7, sourcePropertyName) {
|
|
6548
|
+
return `Cannot determine contract ownership for mapping "${propertyName7}" from "${sourcePropertyName}". Define or propagate a concrete contract, make the boundary schema explicit, or connect a mirrored external schema to its defineApiContract. ${DOC6}`;
|
|
6486
6549
|
}
|
|
6487
6550
|
function destructuredBindingSource(context, identifier) {
|
|
6488
6551
|
const initialScope = context.sourceCode.getScope(identifier);
|
|
@@ -6509,7 +6572,7 @@ function destructuredBindingSource(context, identifier) {
|
|
|
6509
6572
|
}
|
|
6510
6573
|
return void 0;
|
|
6511
6574
|
}
|
|
6512
|
-
function contractMappingViolation(
|
|
6575
|
+
function contractMappingViolation(propertyName7, sourcePropertyName, sourceResolution, targetResolution) {
|
|
6513
6576
|
if (sourceResolution.kind === "non-contract" || targetResolution.kind === "non-contract") return void 0;
|
|
6514
6577
|
if ((sourceResolution.ownership === "third-party" || sourceResolution.ownership === "platform") && targetResolution.kind !== "missing") {
|
|
6515
6578
|
return void 0;
|
|
@@ -6520,11 +6583,11 @@ function contractMappingViolation(propertyName6, sourcePropertyName, sourceResol
|
|
|
6520
6583
|
const hasDataContract = sourceResolution.kind === "data-contract" || targetResolution.kind === "data-contract";
|
|
6521
6584
|
if (!hasDataContract) return void 0;
|
|
6522
6585
|
if (sourceResolution.kind === "missing" || targetResolution.kind === "missing" || sourceResolution.ownership === "unknown" || targetResolution.ownership === "unknown") {
|
|
6523
|
-
return unknownContractOwnershipMessage(
|
|
6586
|
+
return unknownContractOwnershipMessage(propertyName7, sourcePropertyName);
|
|
6524
6587
|
}
|
|
6525
6588
|
if (sourceResolution.kind !== "data-contract") return void 0;
|
|
6526
6589
|
if (sourceResolution.ownership !== "first-party" || targetResolution.ownership !== "first-party") return void 0;
|
|
6527
|
-
return semanticMappingMessage(
|
|
6590
|
+
return semanticMappingMessage(propertyName7, sourcePropertyName);
|
|
6528
6591
|
}
|
|
6529
6592
|
var noRedundantAliasRule = {
|
|
6530
6593
|
meta: {
|
|
@@ -6553,14 +6616,14 @@ var noRedundantAliasRule = {
|
|
|
6553
6616
|
return;
|
|
6554
6617
|
}
|
|
6555
6618
|
if (node.init.type !== "MemberExpression") return;
|
|
6556
|
-
let
|
|
6619
|
+
let propertyName7;
|
|
6557
6620
|
if (!node.init.computed && node.init.property.type === "Identifier") {
|
|
6558
|
-
|
|
6621
|
+
propertyName7 = node.init.property.name;
|
|
6559
6622
|
}
|
|
6560
6623
|
if (node.init.computed && node.init.property.type === "Literal" && typeof node.init.property.value === "string") {
|
|
6561
|
-
|
|
6624
|
+
propertyName7 = node.init.property.value;
|
|
6562
6625
|
}
|
|
6563
|
-
if (
|
|
6626
|
+
if (propertyName7 === void 0 || propertyName7 === node.id.name) return;
|
|
6564
6627
|
context.report({
|
|
6565
6628
|
node,
|
|
6566
6629
|
message: bindingAliasMessage(node.id.name, context.sourceCode.getText(node.init))
|
|
@@ -6568,22 +6631,22 @@ var noRedundantAliasRule = {
|
|
|
6568
6631
|
},
|
|
6569
6632
|
Property(node) {
|
|
6570
6633
|
if (node.computed) return;
|
|
6571
|
-
let
|
|
6572
|
-
if (node.key.type === "Identifier")
|
|
6634
|
+
let propertyName7;
|
|
6635
|
+
if (node.key.type === "Identifier") propertyName7 = node.key.name;
|
|
6573
6636
|
if (node.key.type === "Literal" && typeof node.key.value === "string") {
|
|
6574
|
-
|
|
6637
|
+
propertyName7 = node.key.value;
|
|
6575
6638
|
}
|
|
6576
|
-
if (
|
|
6639
|
+
if (propertyName7 === void 0) return;
|
|
6577
6640
|
if (node.parent.type === "ObjectPattern") {
|
|
6578
6641
|
let binding;
|
|
6579
6642
|
if (node.value.type === "Identifier") binding = node.value;
|
|
6580
6643
|
if (node.value.type === "AssignmentPattern" && node.value.left.type === "Identifier") {
|
|
6581
6644
|
binding = node.value.left;
|
|
6582
6645
|
}
|
|
6583
|
-
if (!binding || binding.name ===
|
|
6646
|
+
if (!binding || binding.name === propertyName7) return;
|
|
6584
6647
|
context.report({
|
|
6585
6648
|
node,
|
|
6586
|
-
message: bindingAliasMessage(binding.name,
|
|
6649
|
+
message: bindingAliasMessage(binding.name, propertyName7)
|
|
6587
6650
|
});
|
|
6588
6651
|
return;
|
|
6589
6652
|
}
|
|
@@ -6592,12 +6655,12 @@ var noRedundantAliasRule = {
|
|
|
6592
6655
|
if (node.value.type === "Identifier") {
|
|
6593
6656
|
if (node.shorthand) return;
|
|
6594
6657
|
const source = node.value.name;
|
|
6595
|
-
if (
|
|
6658
|
+
if (propertyName7 === source) {
|
|
6596
6659
|
context.report({
|
|
6597
6660
|
node,
|
|
6598
|
-
message: objectPropertyMessage(
|
|
6661
|
+
message: objectPropertyMessage(propertyName7, source),
|
|
6599
6662
|
fix(fixer) {
|
|
6600
|
-
return fixer.replaceText(node,
|
|
6663
|
+
return fixer.replaceText(node, propertyName7);
|
|
6601
6664
|
}
|
|
6602
6665
|
});
|
|
6603
6666
|
return;
|
|
@@ -6605,29 +6668,29 @@ var noRedundantAliasRule = {
|
|
|
6605
6668
|
const bindingSource = destructuredBindingSource(context, node.value);
|
|
6606
6669
|
if (!bindingSource || !ownershipResolver) return;
|
|
6607
6670
|
const sourcePropertyName2 = bindingSource.propertyName;
|
|
6608
|
-
if (normalizePropertyName(
|
|
6609
|
-
if (FRAMEWORK_MAPPING_KEYS.has(
|
|
6671
|
+
if (normalizePropertyName(propertyName7) === normalizePropertyName(sourcePropertyName2)) return;
|
|
6672
|
+
if (FRAMEWORK_MAPPING_KEYS.has(propertyName7) || isNamedMemberValue(sourcePropertyName2)) return;
|
|
6610
6673
|
const sourceResolution2 = ownershipResolver.sourceBinding(bindingSource.declarator, sourcePropertyName2);
|
|
6611
|
-
const targetResolution2 = ownershipResolver.targetProperty(node,
|
|
6674
|
+
const targetResolution2 = ownershipResolver.targetProperty(node, propertyName7);
|
|
6612
6675
|
const hasDataContract = sourceResolution2.kind === "data-contract" || targetResolution2.kind === "data-contract";
|
|
6613
6676
|
if (!hasDataContract) return;
|
|
6614
6677
|
context.report({
|
|
6615
6678
|
node,
|
|
6616
|
-
message: contractMappingViolation(
|
|
6679
|
+
message: contractMappingViolation(propertyName7, sourcePropertyName2, sourceResolution2, targetResolution2) ?? objectPropertyMessage(propertyName7, source)
|
|
6617
6680
|
});
|
|
6618
6681
|
return;
|
|
6619
6682
|
}
|
|
6620
6683
|
if (node.value.type !== "MemberExpression") return;
|
|
6621
6684
|
const sourcePropertyName = memberPropertyName2(node.value);
|
|
6622
6685
|
if (sourcePropertyName === void 0) return;
|
|
6623
|
-
if (normalizePropertyName(
|
|
6624
|
-
if (FRAMEWORK_MAPPING_KEYS.has(
|
|
6625
|
-
if (isQualifiedSourceField(
|
|
6686
|
+
if (normalizePropertyName(propertyName7) === normalizePropertyName(sourcePropertyName)) return;
|
|
6687
|
+
if (FRAMEWORK_MAPPING_KEYS.has(propertyName7) || isNamedMemberValue(sourcePropertyName)) return;
|
|
6688
|
+
if (isQualifiedSourceField(propertyName7, node.value, sourcePropertyName)) return;
|
|
6626
6689
|
if (!ownershipResolver) return;
|
|
6627
6690
|
const sourceResolution = ownershipResolver.sourceMember(node.value);
|
|
6628
|
-
const targetResolution = ownershipResolver.targetProperty(node,
|
|
6691
|
+
const targetResolution = ownershipResolver.targetProperty(node, propertyName7);
|
|
6629
6692
|
const violation = contractMappingViolation(
|
|
6630
|
-
|
|
6693
|
+
propertyName7,
|
|
6631
6694
|
sourcePropertyName,
|
|
6632
6695
|
sourceResolution,
|
|
6633
6696
|
targetResolution
|
|
@@ -7230,7 +7293,7 @@ function isZodCall(node, method) {
|
|
|
7230
7293
|
const { callee } = node;
|
|
7231
7294
|
return callee?.type === "MemberExpression" && !callee.computed && callee.object.type === "Identifier" && callee.object.name === "z" && callee.property.type === "Identifier" && callee.property.name === method;
|
|
7232
7295
|
}
|
|
7233
|
-
function
|
|
7296
|
+
function propertyName6(property) {
|
|
7234
7297
|
if (property.computed) return void 0;
|
|
7235
7298
|
if (property.key.type === "Identifier") return property.key.name;
|
|
7236
7299
|
if (property.key.type === "Literal" && typeof property.key.value === "string") return property.key.value;
|
|
@@ -7241,7 +7304,7 @@ function rawZodDiscriminantLiteral(schemaCall, discriminator) {
|
|
|
7241
7304
|
const shape = schemaCall.arguments[0];
|
|
7242
7305
|
if (shape?.type !== "ObjectExpression") return void 0;
|
|
7243
7306
|
for (const property of shape.properties) {
|
|
7244
|
-
if (property.type !== "Property" ||
|
|
7307
|
+
if (property.type !== "Property" || propertyName6(property) !== discriminator) continue;
|
|
7245
7308
|
if (property.value.type !== "CallExpression" || !isZodCall(property.value, "literal")) return void 0;
|
|
7246
7309
|
const literal = property.value.arguments[0];
|
|
7247
7310
|
if (literal?.type === "Literal" && (typeof literal.value === "string" || typeof literal.value === "number")) {
|
|
@@ -7405,19 +7468,19 @@ function directPropertyBinding(context, declarator, isEnumValue) {
|
|
|
7405
7468
|
if (member.computed || member.optional || member.property.type !== "Identifier") return void 0;
|
|
7406
7469
|
if (!memberCanBecomeLocal(member)) return void 0;
|
|
7407
7470
|
if (context.sourceCode.getCommentsInside(declarator).length > 0) return void 0;
|
|
7408
|
-
const
|
|
7471
|
+
const propertyName7 = member.property.name;
|
|
7409
7472
|
const localName = declarator.id.name;
|
|
7410
|
-
if (
|
|
7473
|
+
if (propertyName7 !== localName) return void 0;
|
|
7411
7474
|
const source = member.object;
|
|
7412
7475
|
const sourceText = context.sourceCode.getText(source);
|
|
7413
7476
|
return {
|
|
7414
7477
|
declarator,
|
|
7415
7478
|
member,
|
|
7416
|
-
propertyName:
|
|
7479
|
+
propertyName: propertyName7,
|
|
7417
7480
|
localName,
|
|
7418
7481
|
source,
|
|
7419
7482
|
sourceText,
|
|
7420
|
-
bindingText:
|
|
7483
|
+
bindingText: propertyName7
|
|
7421
7484
|
};
|
|
7422
7485
|
}
|
|
7423
7486
|
function canGroupSource(source) {
|
|
@@ -7435,8 +7498,8 @@ function rootIdentifierName(node) {
|
|
|
7435
7498
|
if (node.type !== "MemberExpression" || node.object.type === "Super") return void 0;
|
|
7436
7499
|
return rootIdentifierName(node.object);
|
|
7437
7500
|
}
|
|
7438
|
-
function isCompliantLocalName(
|
|
7439
|
-
return !
|
|
7501
|
+
function isCompliantLocalName(propertyName7) {
|
|
7502
|
+
return !propertyName7.includes("_") || /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/u.test(propertyName7);
|
|
7440
7503
|
}
|
|
7441
7504
|
function propertyNameOf(node) {
|
|
7442
7505
|
if (node.type !== "Property" || node.computed) return void 0;
|
|
@@ -7558,10 +7621,10 @@ function recordMemberUsage(context, scope, ownershipResolver, member, isEnumValu
|
|
|
7558
7621
|
if (!isGroupedUsageSource(member.object) || !memberIsRead(context, member, detachableCall)) return;
|
|
7559
7622
|
const sourceText = context.sourceCode.getText(member.object);
|
|
7560
7623
|
const usage = objectUsage(scope, sourceText);
|
|
7561
|
-
const
|
|
7562
|
-
usage.propertyNames.add(
|
|
7624
|
+
const propertyName7 = member.property.name;
|
|
7625
|
+
usage.propertyNames.add(propertyName7);
|
|
7563
7626
|
if (!memberIsDirectVariableInitializer(context, member)) {
|
|
7564
|
-
usage.directMembers.push({ member, propertyName:
|
|
7627
|
+
usage.directMembers.push({ member, propertyName: propertyName7 });
|
|
7565
7628
|
}
|
|
7566
7629
|
}
|
|
7567
7630
|
function recordDestructuringUsage(context, scope, declaration, isEnumValue) {
|
|
@@ -7688,13 +7751,13 @@ function groupedDestructuringSelections(context, first, isEnumValue) {
|
|
|
7688
7751
|
if (!previous || nextNode?.type !== "VariableDeclaration" || nextNode.kind !== first.declaration.kind) break;
|
|
7689
7752
|
const next = destructuringSelection(context, nextNode, isEnumValue);
|
|
7690
7753
|
if (next?.sourceText !== first.sourceText) break;
|
|
7691
|
-
if (next.propertyNames.some((
|
|
7754
|
+
if (next.propertyNames.some((propertyName7) => seenProperties.has(propertyName7))) break;
|
|
7692
7755
|
const [, previousEnd] = context.sourceCode.getRange(previous);
|
|
7693
7756
|
const [nextStart] = context.sourceCode.getRange(nextNode);
|
|
7694
7757
|
const gap = context.sourceCode.text.slice(previousEnd, nextStart);
|
|
7695
7758
|
if (!whitespaceKeepsStatementsAdjacent(gap)) break;
|
|
7696
7759
|
group.push(next);
|
|
7697
|
-
for (const
|
|
7760
|
+
for (const propertyName7 of next.propertyNames) seenProperties.add(propertyName7);
|
|
7698
7761
|
}
|
|
7699
7762
|
return group;
|
|
7700
7763
|
}
|
|
@@ -7748,9 +7811,9 @@ var preferObjectDestructuringRule = {
|
|
|
7748
7811
|
const { member: firstDirectMember } = firstDirectUsage;
|
|
7749
7812
|
const propertyNames = [...usage.propertyNames];
|
|
7750
7813
|
const missingPropertyNames = propertyNames.filter(
|
|
7751
|
-
(
|
|
7814
|
+
(propertyName7) => !usage.destructuring?.propertyNames.has(propertyName7)
|
|
7752
7815
|
);
|
|
7753
|
-
if (missingPropertyNames.some((
|
|
7816
|
+
if (missingPropertyNames.some((propertyName7) => hasBinding(context, firstDirectMember, propertyName7))) {
|
|
7754
7817
|
continue;
|
|
7755
7818
|
}
|
|
7756
7819
|
context.report({
|
|
@@ -7764,7 +7827,7 @@ var preferObjectDestructuringRule = {
|
|
|
7764
7827
|
return null;
|
|
7765
7828
|
}
|
|
7766
7829
|
const memberFixes = usage.directMembers.map(
|
|
7767
|
-
({ member, propertyName:
|
|
7830
|
+
({ member, propertyName: propertyName7 }) => fixer.replaceText(member, propertyName7)
|
|
7768
7831
|
);
|
|
7769
7832
|
if (usage.destructuring) {
|
|
7770
7833
|
if (missingPropertyNames.length === 0) return memberFixes;
|
|
@@ -7803,7 +7866,7 @@ ${indentation}`;
|
|
|
7803
7866
|
continue;
|
|
7804
7867
|
}
|
|
7805
7868
|
if (fromSameSource.length > 1) {
|
|
7806
|
-
const names = new Set(fromSameSource.map(({ propertyName:
|
|
7869
|
+
const names = new Set(fromSameSource.map(({ propertyName: propertyName7 }) => propertyName7));
|
|
7807
7870
|
if (names.size > 1) {
|
|
7808
7871
|
context.report({ node: binding.node, message: scopeUsageMessage(binding.sourceText, names) });
|
|
7809
7872
|
continue;
|
|
@@ -7843,12 +7906,12 @@ ${indentation}`;
|
|
|
7843
7906
|
if (group.length <= 1) {
|
|
7844
7907
|
if (node.kind === "const" && selection.propertyNames.length === 1 && supportsSinglePropertySource(selection.source)) {
|
|
7845
7908
|
const declarator = node.declarations[0];
|
|
7846
|
-
const
|
|
7847
|
-
if (declarator &&
|
|
7909
|
+
const propertyName7 = selection.propertyNames[0];
|
|
7910
|
+
if (declarator && propertyName7) {
|
|
7848
7911
|
currentUsageScope()?.singleProperties.push({
|
|
7849
7912
|
node: declarator.id,
|
|
7850
7913
|
sourceText: selection.sourceText,
|
|
7851
|
-
propertyName:
|
|
7914
|
+
propertyName: propertyName7
|
|
7852
7915
|
});
|
|
7853
7916
|
}
|
|
7854
7917
|
}
|
|
@@ -7878,7 +7941,7 @@ ${indentation}`;
|
|
|
7878
7941
|
if (bindings.length === 0) return;
|
|
7879
7942
|
const firstBinding = bindings[0];
|
|
7880
7943
|
if (!firstBinding) return;
|
|
7881
|
-
const sameSourceBindings = bindings.length > 1 && bindings.length === node.declarations.length && bindings.every(({ sourceText }) => sourceText === firstBinding.sourceText) && new Set(bindings.map(({ propertyName:
|
|
7944
|
+
const sameSourceBindings = bindings.length > 1 && bindings.length === node.declarations.length && bindings.every(({ sourceText }) => sourceText === firstBinding.sourceText) && new Set(bindings.map(({ propertyName: propertyName7 }) => propertyName7)).size === bindings.length;
|
|
7882
7945
|
if (sameSourceBindings) {
|
|
7883
7946
|
context.report({
|
|
7884
7947
|
node,
|
|
@@ -9800,6 +9863,12 @@ var cssEntryPointRule = {
|
|
|
9800
9863
|
}
|
|
9801
9864
|
};
|
|
9802
9865
|
|
|
9866
|
+
// eslint/project/semantic-color-role.ts
|
|
9867
|
+
var BOUNDARY_PROPERTY_WORDS = /* @__PURE__ */ new Set(["border", "outline", "ring", "stroke"]);
|
|
9868
|
+
function violatesBoundaryColorRole(token) {
|
|
9869
|
+
return !token.endsWith("-edge") && token.split("-").some((word) => BOUNDARY_PROPERTY_WORDS.has(word));
|
|
9870
|
+
}
|
|
9871
|
+
|
|
9803
9872
|
// eslint/rules/tailwind/css-variable-naming.ts
|
|
9804
9873
|
var EDGE_PROPERTY_WORDS = /* @__PURE__ */ new Set(["border", "outline", "ring", "stroke"]);
|
|
9805
9874
|
var NON_COLOR_WORDS = /* @__PURE__ */ new Set(["height", "leading", "offset", "radius", "size", "spacing", "style", "width"]);
|
|
@@ -9847,7 +9916,15 @@ var cssVariableNamingRule = {
|
|
|
9847
9916
|
Declaration(node) {
|
|
9848
9917
|
const property = node.property;
|
|
9849
9918
|
if (!property.startsWith("--")) return;
|
|
9850
|
-
if (isTailwindThemeVariable(property))
|
|
9919
|
+
if (isTailwindThemeVariable(property)) {
|
|
9920
|
+
if (property.startsWith("--color-") && violatesBoundaryColorRole(property.slice("--color-".length))) {
|
|
9921
|
+
context.report({
|
|
9922
|
+
node,
|
|
9923
|
+
message: `Theme color "${property}" names a boundary using a CSS property; use --color-<role>-edge and border-<role>-edge instead.`
|
|
9924
|
+
});
|
|
9925
|
+
}
|
|
9926
|
+
return;
|
|
9927
|
+
}
|
|
9851
9928
|
const lower = property.toLowerCase();
|
|
9852
9929
|
if ((lower.includes("bg") || lower.includes("background")) && !lower.endsWith("-canvas")) {
|
|
9853
9930
|
context.report({
|
|
@@ -10807,6 +10884,18 @@ function isColorToken(token, inventory) {
|
|
|
10807
10884
|
if (hyphen === -1) return false;
|
|
10808
10885
|
return DEFAULT_PALETTE_FAMILIES.has(token.slice(0, hyphen)) && DEFAULT_PALETTE_SHADES.has(token.slice(hyphen + 1));
|
|
10809
10886
|
}
|
|
10887
|
+
function isInvalidBoundaryColorClass(className, inventory) {
|
|
10888
|
+
if (className.includes("[") || className.includes("(")) return false;
|
|
10889
|
+
const utility = (className.replace(/!+$/, "").split(":").pop() ?? "").split("/")[0] ?? "";
|
|
10890
|
+
const compound = Object.keys(PREFIX_NAMESPACES).find(
|
|
10891
|
+
(prefix2) => prefix2.includes("-") && utility.startsWith(`${prefix2}-`)
|
|
10892
|
+
);
|
|
10893
|
+
const dash = utility.indexOf("-");
|
|
10894
|
+
if (dash === -1) return false;
|
|
10895
|
+
const prefix = compound ?? utility.slice(0, dash);
|
|
10896
|
+
const token = utility.slice(prefix.length + 1);
|
|
10897
|
+
return (PREFIX_NAMESPACES[prefix]?.includes("color") ?? false) && (inventory.themeTokens.get("color")?.has(token) ?? false) && violatesBoundaryColorRole(token);
|
|
10898
|
+
}
|
|
10810
10899
|
function isKnown(className, inventory) {
|
|
10811
10900
|
if (className.includes("[") || className.includes("(")) return true;
|
|
10812
10901
|
const segments = className.replace(/!+$/, "").split(":");
|
|
@@ -10867,6 +10956,13 @@ var unknownUtilityRule = {
|
|
|
10867
10956
|
for (const candidate of value.split(/\s+/)) {
|
|
10868
10957
|
if (!candidate || seen.has(candidate)) continue;
|
|
10869
10958
|
seen.add(candidate);
|
|
10959
|
+
if (isInvalidBoundaryColorClass(candidate, inventory)) {
|
|
10960
|
+
context.report({
|
|
10961
|
+
node,
|
|
10962
|
+
message: `Utility class "${candidate}" uses a boundary color token named after a CSS property; use a semantic -edge color token instead (for example, border-control-edge).`
|
|
10963
|
+
});
|
|
10964
|
+
continue;
|
|
10965
|
+
}
|
|
10870
10966
|
if (isKnown(candidate, inventory)) continue;
|
|
10871
10967
|
const plainBase = candidate.replace(/!+$/, "").split(":").pop() ?? "";
|
|
10872
10968
|
if (inventory.plainClasses.has(plainBase)) {
|