@pandacss/eslint-plugin 0.1.15 → 0.2.0
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/index.js +945 -440
- package/dist/index.mjs +946 -442
- package/dist/utils/worker.js +5 -8
- package/dist/utils/worker.mjs +5 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7957,7 +7957,7 @@ init_cjs_shims();
|
|
|
7957
7957
|
|
|
7958
7958
|
// package.json
|
|
7959
7959
|
var name = "@pandacss/eslint-plugin";
|
|
7960
|
-
var version = "0.
|
|
7960
|
+
var version = "0.2.0";
|
|
7961
7961
|
|
|
7962
7962
|
// src/configs/all.ts
|
|
7963
7963
|
init_cjs_shims();
|
|
@@ -7984,7 +7984,8 @@ var syncAction = (...args) => {
|
|
|
7984
7984
|
try {
|
|
7985
7985
|
return _syncAction(...args);
|
|
7986
7986
|
} catch (error) {
|
|
7987
|
-
|
|
7987
|
+
console.error("syncAction error:", error);
|
|
7988
|
+
return void 0;
|
|
7988
7989
|
}
|
|
7989
7990
|
};
|
|
7990
7991
|
|
|
@@ -8063,13 +8064,17 @@ var _getImports = (context) => {
|
|
|
8063
8064
|
}));
|
|
8064
8065
|
return imports;
|
|
8065
8066
|
};
|
|
8067
|
+
var importsCache = /* @__PURE__ */ new WeakMap();
|
|
8066
8068
|
var getImports = (context) => {
|
|
8069
|
+
if (importsCache.has(context)) {
|
|
8070
|
+
return importsCache.get(context);
|
|
8071
|
+
}
|
|
8067
8072
|
const imports = _getImports(context);
|
|
8068
|
-
|
|
8073
|
+
const filteredImports = imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8074
|
+
importsCache.set(context, filteredImports);
|
|
8075
|
+
return filteredImports;
|
|
8069
8076
|
};
|
|
8070
8077
|
var isValidStyledProp = (node, context) => {
|
|
8071
|
-
if (typeof node === "string")
|
|
8072
|
-
return;
|
|
8073
8078
|
return isJSXIdentifier(node) && isValidProperty(node.name, context);
|
|
8074
8079
|
};
|
|
8075
8080
|
var isPandaIsh = (name2, context) => {
|
|
@@ -8087,7 +8092,8 @@ var findDeclaration = (name2, context) => {
|
|
|
8087
8092
|
if (isVariableDeclarator(decl))
|
|
8088
8093
|
return decl;
|
|
8089
8094
|
} catch (error) {
|
|
8090
|
-
|
|
8095
|
+
console.error("Error in findDeclaration:", error);
|
|
8096
|
+
return void 0;
|
|
8091
8097
|
}
|
|
8092
8098
|
};
|
|
8093
8099
|
var isLocalStyledFactory = (node, context) => {
|
|
@@ -8163,6 +8169,8 @@ var isInJSXProp = (node, context) => {
|
|
|
8163
8169
|
return;
|
|
8164
8170
|
if (!isPandaProp(jsxAttrAncestor, context))
|
|
8165
8171
|
return;
|
|
8172
|
+
if (typeof jsxAttrAncestor.name === "string")
|
|
8173
|
+
return;
|
|
8166
8174
|
if (!isValidStyledProp(jsxAttrAncestor.name, context))
|
|
8167
8175
|
return;
|
|
8168
8176
|
return true;
|
|
@@ -8191,6 +8199,7 @@ var isColorToken = (value, context) => {
|
|
|
8191
8199
|
return;
|
|
8192
8200
|
return syncAction("isColorToken", getSyncOpts(context), value);
|
|
8193
8201
|
};
|
|
8202
|
+
var invalidTokensCache = /* @__PURE__ */ new Map();
|
|
8194
8203
|
var extractTokens = (value) => {
|
|
8195
8204
|
const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{}]+)\}/g;
|
|
8196
8205
|
const matches = [];
|
|
@@ -8208,10 +8217,15 @@ var extractTokens = (value) => {
|
|
|
8208
8217
|
return matches.filter(Boolean);
|
|
8209
8218
|
};
|
|
8210
8219
|
var getInvalidTokens = (value, context) => {
|
|
8220
|
+
if (invalidTokensCache.has(value)) {
|
|
8221
|
+
return invalidTokensCache.get(value);
|
|
8222
|
+
}
|
|
8211
8223
|
const tokens = extractTokens(value);
|
|
8212
8224
|
if (!tokens.length)
|
|
8213
8225
|
return [];
|
|
8214
|
-
|
|
8226
|
+
const invalidTokens = syncAction("filterInvalidTokens", getSyncOpts(context), tokens);
|
|
8227
|
+
invalidTokensCache.set(value, invalidTokens);
|
|
8228
|
+
return invalidTokens;
|
|
8215
8229
|
};
|
|
8216
8230
|
var getTokenImport = (context) => {
|
|
8217
8231
|
const imports = _getImports(context);
|
|
@@ -8259,31 +8273,38 @@ function isRecipeVariant(node, context) {
|
|
|
8259
8273
|
}
|
|
8260
8274
|
|
|
8261
8275
|
// src/rules/file-not-included.ts
|
|
8276
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
8262
8277
|
var RULE_NAME = "file-not-included";
|
|
8263
8278
|
var rule = createRule({
|
|
8264
8279
|
name: RULE_NAME,
|
|
8265
8280
|
meta: {
|
|
8266
8281
|
docs: {
|
|
8267
|
-
description: "Disallow the use of
|
|
8282
|
+
description: "Disallow the use of Panda CSS in files that are not included in the specified Panda CSS `include` config."
|
|
8268
8283
|
},
|
|
8269
8284
|
messages: {
|
|
8270
|
-
include: "The use of Panda CSS is not allowed in this file. Please
|
|
8285
|
+
include: "The use of Panda CSS is not allowed in this file. Please ensure the file is included in the Panda CSS `include` configuration."
|
|
8271
8286
|
},
|
|
8272
|
-
type: "
|
|
8287
|
+
type: "problem",
|
|
8273
8288
|
schema: []
|
|
8274
8289
|
},
|
|
8275
8290
|
defaultOptions: [],
|
|
8276
8291
|
create(context) {
|
|
8292
|
+
const isFileIncluded = isValidFile(context);
|
|
8293
|
+
if (isFileIncluded) {
|
|
8294
|
+
return {};
|
|
8295
|
+
}
|
|
8296
|
+
let hasReported = false;
|
|
8277
8297
|
return {
|
|
8278
8298
|
ImportDeclaration(node) {
|
|
8279
|
-
if (
|
|
8299
|
+
if (hasReported)
|
|
8280
8300
|
return;
|
|
8281
|
-
if (
|
|
8301
|
+
if (!isPandaImport(node, context))
|
|
8282
8302
|
return;
|
|
8283
8303
|
context.report({
|
|
8284
8304
|
node,
|
|
8285
8305
|
messageId: "include"
|
|
8286
8306
|
});
|
|
8307
|
+
hasReported = true;
|
|
8287
8308
|
}
|
|
8288
8309
|
};
|
|
8289
8310
|
}
|
|
@@ -8292,56 +8313,82 @@ var file_not_included_default = rule;
|
|
|
8292
8313
|
|
|
8293
8314
|
// src/rules/no-config-function-in-source.ts
|
|
8294
8315
|
init_cjs_shims();
|
|
8316
|
+
var import_utils6 = require("@typescript-eslint/utils");
|
|
8295
8317
|
var RULE_NAME2 = "no-config-function-in-source";
|
|
8318
|
+
var CONFIG_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
8319
|
+
"defineConfig",
|
|
8320
|
+
"defineRecipe",
|
|
8321
|
+
"defineSlotRecipe",
|
|
8322
|
+
"defineParts",
|
|
8323
|
+
"definePattern",
|
|
8324
|
+
"definePreset",
|
|
8325
|
+
"defineKeyframes",
|
|
8326
|
+
"defineGlobalStyles",
|
|
8327
|
+
"defineUtility",
|
|
8328
|
+
"defineTextStyles",
|
|
8329
|
+
"defineLayerStyles",
|
|
8330
|
+
"defineStyles",
|
|
8331
|
+
"defineTokens",
|
|
8332
|
+
"defineSemanticTokens"
|
|
8333
|
+
]);
|
|
8296
8334
|
var rule2 = createRule({
|
|
8297
8335
|
name: RULE_NAME2,
|
|
8298
8336
|
meta: {
|
|
8299
8337
|
docs: {
|
|
8300
|
-
description: "Prohibit the use of config functions outside the Panda config."
|
|
8338
|
+
description: "Prohibit the use of config functions outside the Panda config file."
|
|
8301
8339
|
},
|
|
8302
8340
|
messages: {
|
|
8303
|
-
configFunction: "Unnecessary`{{name}}` call.
|
|
8341
|
+
configFunction: "Unnecessary `{{name}}` call. Config functions should only be used in the Panda config file.",
|
|
8304
8342
|
delete: "Delete `{{name}}` call."
|
|
8305
8343
|
},
|
|
8306
|
-
type: "
|
|
8344
|
+
type: "problem",
|
|
8307
8345
|
hasSuggestions: true,
|
|
8308
8346
|
schema: []
|
|
8309
8347
|
},
|
|
8310
8348
|
defaultOptions: [],
|
|
8311
8349
|
create(context) {
|
|
8312
|
-
if (!hasPkgImport(context))
|
|
8350
|
+
if (!hasPkgImport(context)) {
|
|
8351
|
+
return {};
|
|
8352
|
+
}
|
|
8353
|
+
const isPandaFile = isValidFile(context);
|
|
8354
|
+
if (!isPandaFile) {
|
|
8313
8355
|
return {};
|
|
8356
|
+
}
|
|
8314
8357
|
return {
|
|
8315
8358
|
CallExpression(node) {
|
|
8316
|
-
if (!isValidFile(context))
|
|
8317
|
-
return;
|
|
8318
8359
|
if (!isIdentifier(node.callee))
|
|
8319
8360
|
return;
|
|
8320
|
-
|
|
8361
|
+
const functionName = node.callee.name;
|
|
8362
|
+
if (!CONFIG_FUNCTIONS.has(functionName))
|
|
8321
8363
|
return;
|
|
8322
|
-
if (!isPandaConfigFunction(context,
|
|
8364
|
+
if (!isPandaConfigFunction(context, functionName))
|
|
8323
8365
|
return;
|
|
8324
8366
|
context.report({
|
|
8325
8367
|
node,
|
|
8326
8368
|
messageId: "configFunction",
|
|
8327
8369
|
data: {
|
|
8328
|
-
name:
|
|
8370
|
+
name: functionName
|
|
8329
8371
|
},
|
|
8330
8372
|
suggest: [
|
|
8331
8373
|
{
|
|
8332
8374
|
messageId: "delete",
|
|
8333
8375
|
data: {
|
|
8334
|
-
name:
|
|
8376
|
+
name: functionName
|
|
8335
8377
|
},
|
|
8336
8378
|
fix(fixer) {
|
|
8337
8379
|
const declaration = getAncestor(isVariableDeclaration, node);
|
|
8338
|
-
const
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
fixer.remove(declaration
|
|
8343
|
-
|
|
8344
|
-
|
|
8380
|
+
const importSpecifiers = getImportSpecifiers(context);
|
|
8381
|
+
const importSpec = importSpecifiers.find((s) => s.specifier.local.name === functionName);
|
|
8382
|
+
const fixes = [];
|
|
8383
|
+
if (declaration) {
|
|
8384
|
+
fixes.push(fixer.remove(declaration));
|
|
8385
|
+
} else {
|
|
8386
|
+
fixes.push(fixer.remove(node));
|
|
8387
|
+
}
|
|
8388
|
+
if (importSpec?.specifier) {
|
|
8389
|
+
fixes.push(fixer.remove(importSpec.specifier));
|
|
8390
|
+
}
|
|
8391
|
+
return fixes;
|
|
8345
8392
|
}
|
|
8346
8393
|
}
|
|
8347
8394
|
]
|
|
@@ -8351,25 +8398,10 @@ var rule2 = createRule({
|
|
|
8351
8398
|
}
|
|
8352
8399
|
});
|
|
8353
8400
|
var no_config_function_in_source_default = rule2;
|
|
8354
|
-
var CONFIG_FUNCTIONS = [
|
|
8355
|
-
"defineConfig",
|
|
8356
|
-
"defineRecipe",
|
|
8357
|
-
"defineSlotRecipe",
|
|
8358
|
-
"defineParts",
|
|
8359
|
-
"definePattern",
|
|
8360
|
-
"definePreset",
|
|
8361
|
-
"defineKeyframes",
|
|
8362
|
-
"defineGlobalStyles",
|
|
8363
|
-
"defineUtility",
|
|
8364
|
-
"defineTextStyles",
|
|
8365
|
-
"defineLayerStyles",
|
|
8366
|
-
"defineStyles",
|
|
8367
|
-
"defineTokens",
|
|
8368
|
-
"defineSemanticTokens"
|
|
8369
|
-
];
|
|
8370
8401
|
|
|
8371
8402
|
// src/rules/no-debug.ts
|
|
8372
8403
|
init_cjs_shims();
|
|
8404
|
+
var import_utils8 = require("@typescript-eslint/utils");
|
|
8373
8405
|
var RULE_NAME3 = "no-debug";
|
|
8374
8406
|
var rule3 = createRule({
|
|
8375
8407
|
name: RULE_NAME3,
|
|
@@ -8382,16 +8414,14 @@ var rule3 = createRule({
|
|
|
8382
8414
|
prop: "Remove the debug prop.",
|
|
8383
8415
|
property: "Remove the debug property."
|
|
8384
8416
|
},
|
|
8385
|
-
type: "
|
|
8417
|
+
type: "problem",
|
|
8386
8418
|
hasSuggestions: true,
|
|
8387
8419
|
schema: []
|
|
8388
8420
|
},
|
|
8389
8421
|
defaultOptions: [],
|
|
8390
8422
|
create(context) {
|
|
8391
8423
|
return {
|
|
8392
|
-
JSXAttribute(node) {
|
|
8393
|
-
if (!isJSXIdentifier(node.name) || node.name.name !== "debug")
|
|
8394
|
-
return;
|
|
8424
|
+
'JSXAttribute[name.name="debug"]'(node) {
|
|
8395
8425
|
if (!isPandaProp(node, context))
|
|
8396
8426
|
return;
|
|
8397
8427
|
context.report({
|
|
@@ -8405,9 +8435,7 @@ var rule3 = createRule({
|
|
|
8405
8435
|
]
|
|
8406
8436
|
});
|
|
8407
8437
|
},
|
|
8408
|
-
Property(node) {
|
|
8409
|
-
if (!isIdentifier(node.key) || node.key.name !== "debug")
|
|
8410
|
-
return;
|
|
8438
|
+
'Property[key.name="debug"]'(node) {
|
|
8411
8439
|
if (!isPandaAttribute(node, context))
|
|
8412
8440
|
return;
|
|
8413
8441
|
if (isRecipeVariant(node, context))
|
|
@@ -8430,47 +8458,72 @@ var no_debug_default = rule3;
|
|
|
8430
8458
|
|
|
8431
8459
|
// src/rules/no-dynamic-styling.ts
|
|
8432
8460
|
init_cjs_shims();
|
|
8461
|
+
var import_utils9 = require("@typescript-eslint/utils");
|
|
8433
8462
|
var RULE_NAME4 = "no-dynamic-styling";
|
|
8434
8463
|
var rule4 = createRule({
|
|
8435
8464
|
name: RULE_NAME4,
|
|
8436
8465
|
meta: {
|
|
8437
8466
|
docs: {
|
|
8438
|
-
description: "Ensure
|
|
8467
|
+
description: "Ensure users don't use dynamic styling. Prefer static styles, leverage CSS variables, or recipes for known dynamic styles."
|
|
8439
8468
|
},
|
|
8440
8469
|
messages: {
|
|
8441
|
-
dynamic: "Remove dynamic value. Prefer static styles",
|
|
8442
|
-
dynamicProperty: "Remove dynamic property. Prefer static style property",
|
|
8443
|
-
dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition"
|
|
8470
|
+
dynamic: "Remove dynamic value. Prefer static styles.",
|
|
8471
|
+
dynamicProperty: "Remove dynamic property. Prefer static style property.",
|
|
8472
|
+
dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition."
|
|
8444
8473
|
},
|
|
8445
|
-
type: "
|
|
8474
|
+
type: "problem",
|
|
8446
8475
|
schema: []
|
|
8447
8476
|
},
|
|
8448
8477
|
defaultOptions: [],
|
|
8449
8478
|
create(context) {
|
|
8479
|
+
function isStaticValue(node) {
|
|
8480
|
+
if (!node)
|
|
8481
|
+
return false;
|
|
8482
|
+
if (isLiteral(node))
|
|
8483
|
+
return true;
|
|
8484
|
+
if (isTemplateLiteral(node) && node.expressions.length === 0)
|
|
8485
|
+
return true;
|
|
8486
|
+
if (isObjectExpression(node))
|
|
8487
|
+
return true;
|
|
8488
|
+
return false;
|
|
8489
|
+
}
|
|
8490
|
+
function checkArrayElements(array) {
|
|
8491
|
+
array.elements.forEach((element) => {
|
|
8492
|
+
if (!element)
|
|
8493
|
+
return;
|
|
8494
|
+
if (isStaticValue(element))
|
|
8495
|
+
return;
|
|
8496
|
+
context.report({
|
|
8497
|
+
node: element,
|
|
8498
|
+
messageId: "dynamic"
|
|
8499
|
+
});
|
|
8500
|
+
});
|
|
8501
|
+
}
|
|
8450
8502
|
return {
|
|
8503
|
+
// JSX Attributes
|
|
8451
8504
|
JSXAttribute(node) {
|
|
8452
8505
|
if (!node.value)
|
|
8453
8506
|
return;
|
|
8454
8507
|
if (isLiteral(node.value))
|
|
8455
8508
|
return;
|
|
8456
|
-
if (isJSXExpressionContainer(node.value) && isLiteral(node.value.expression))
|
|
8457
|
-
return;
|
|
8458
|
-
if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
|
|
8459
|
-
return;
|
|
8460
|
-
if (isObjectExpression(node.value.expression))
|
|
8461
|
-
return;
|
|
8462
8509
|
if (!isPandaProp(node, context))
|
|
8463
8510
|
return;
|
|
8464
|
-
if (
|
|
8465
|
-
|
|
8511
|
+
if (isJSXExpressionContainer(node.value)) {
|
|
8512
|
+
const expr = node.value.expression;
|
|
8513
|
+
if (isStaticValue(expr))
|
|
8514
|
+
return;
|
|
8515
|
+
if (isArrayExpression(expr)) {
|
|
8516
|
+
checkArrayElements(expr);
|
|
8517
|
+
return;
|
|
8518
|
+
}
|
|
8466
8519
|
}
|
|
8467
8520
|
context.report({
|
|
8468
8521
|
node: node.value,
|
|
8469
8522
|
messageId: "dynamic"
|
|
8470
8523
|
});
|
|
8471
8524
|
},
|
|
8472
|
-
// Dynamic properties
|
|
8473
|
-
"Property[computed=true]"(node) {
|
|
8525
|
+
// Dynamic properties with computed keys
|
|
8526
|
+
"Property[computed=true]": (node) => {
|
|
8474
8527
|
if (!isInPandaFunction(node, context))
|
|
8475
8528
|
return;
|
|
8476
8529
|
context.report({
|
|
@@ -8478,19 +8531,19 @@ var rule4 = createRule({
|
|
|
8478
8531
|
messageId: isRecipeVariant(node, context) ? "dynamicRecipeVariant" : "dynamicProperty"
|
|
8479
8532
|
});
|
|
8480
8533
|
},
|
|
8534
|
+
// Object Properties
|
|
8481
8535
|
Property(node) {
|
|
8482
8536
|
if (!isIdentifier(node.key))
|
|
8483
8537
|
return;
|
|
8484
|
-
if (
|
|
8485
|
-
return;
|
|
8486
|
-
if (isTemplateLiteral(node.value) && node.value.expressions.length === 0)
|
|
8538
|
+
if (!isPandaAttribute(node, context))
|
|
8487
8539
|
return;
|
|
8488
|
-
if (
|
|
8540
|
+
if (isRecipeVariant(node, context))
|
|
8489
8541
|
return;
|
|
8490
|
-
if (
|
|
8542
|
+
if (isStaticValue(node.value))
|
|
8491
8543
|
return;
|
|
8492
8544
|
if (isArrayExpression(node.value)) {
|
|
8493
|
-
|
|
8545
|
+
checkArrayElements(node.value);
|
|
8546
|
+
return;
|
|
8494
8547
|
}
|
|
8495
8548
|
context.report({
|
|
8496
8549
|
node: node.value,
|
|
@@ -8500,25 +8553,12 @@ var rule4 = createRule({
|
|
|
8500
8553
|
};
|
|
8501
8554
|
}
|
|
8502
8555
|
});
|
|
8503
|
-
function checkArrayElements(array, context) {
|
|
8504
|
-
array.elements.forEach((node) => {
|
|
8505
|
-
if (!node)
|
|
8506
|
-
return;
|
|
8507
|
-
if (isLiteral(node))
|
|
8508
|
-
return;
|
|
8509
|
-
if (isTemplateLiteral(node) && node.expressions.length === 0)
|
|
8510
|
-
return;
|
|
8511
|
-
context.report({
|
|
8512
|
-
node,
|
|
8513
|
-
messageId: "dynamic"
|
|
8514
|
-
});
|
|
8515
|
-
});
|
|
8516
|
-
}
|
|
8517
8556
|
var no_dynamic_styling_default = rule4;
|
|
8518
8557
|
|
|
8519
8558
|
// src/rules/no-escape-hatch.ts
|
|
8520
8559
|
init_cjs_shims();
|
|
8521
8560
|
var import_shared = require("@pandacss/shared");
|
|
8561
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
8522
8562
|
var RULE_NAME5 = "no-escape-hatch";
|
|
8523
8563
|
var rule5 = createRule({
|
|
8524
8564
|
name: RULE_NAME5,
|
|
@@ -8527,47 +8567,37 @@ var rule5 = createRule({
|
|
|
8527
8567
|
description: "Prohibit the use of escape hatch syntax in the code."
|
|
8528
8568
|
},
|
|
8529
8569
|
messages: {
|
|
8530
|
-
escapeHatch: "Avoid using the escape hatch [value] for undefined tokens.
|
|
8570
|
+
escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. Define a corresponding token in your design system for better consistency and maintainability.",
|
|
8531
8571
|
remove: "Remove the square brackets (`[]`)."
|
|
8532
8572
|
},
|
|
8533
|
-
type: "
|
|
8573
|
+
type: "problem",
|
|
8534
8574
|
hasSuggestions: true,
|
|
8535
8575
|
schema: []
|
|
8536
8576
|
},
|
|
8537
8577
|
defaultOptions: [],
|
|
8538
8578
|
create(context) {
|
|
8539
|
-
const
|
|
8579
|
+
const removeBrackets = (range) => {
|
|
8580
|
+
const [start, end] = range;
|
|
8581
|
+
return [start + 1, end - 1];
|
|
8582
|
+
};
|
|
8540
8583
|
const hasEscapeHatch = (value) => {
|
|
8541
8584
|
if (!value)
|
|
8542
8585
|
return false;
|
|
8586
|
+
if (!value.includes("["))
|
|
8587
|
+
return false;
|
|
8543
8588
|
return (0, import_shared.getArbitraryValue)(value) !== value.trim();
|
|
8544
8589
|
};
|
|
8545
|
-
const
|
|
8546
|
-
if (!
|
|
8547
|
-
return;
|
|
8548
|
-
if (!hasEscapeHatch(node.value?.toString()))
|
|
8549
|
-
return;
|
|
8550
|
-
sendReport(node);
|
|
8551
|
-
};
|
|
8552
|
-
const handleTemplateLiteral = (node) => {
|
|
8553
|
-
if (!isTemplateLiteral(node))
|
|
8590
|
+
const handleNodeValue = (node, value) => {
|
|
8591
|
+
if (!hasEscapeHatch(value))
|
|
8554
8592
|
return;
|
|
8555
|
-
|
|
8556
|
-
return;
|
|
8557
|
-
if (!hasEscapeHatch(node.quasis[0].value.raw))
|
|
8558
|
-
return;
|
|
8559
|
-
sendReport(node.quasis[0], node.quasis[0].value.raw);
|
|
8560
|
-
};
|
|
8561
|
-
const sendReport = (node, _value) => {
|
|
8562
|
-
const value = _value ?? node.value?.toString();
|
|
8563
|
-
return context.report({
|
|
8593
|
+
context.report({
|
|
8564
8594
|
node,
|
|
8565
8595
|
messageId: "escapeHatch",
|
|
8566
8596
|
suggest: [
|
|
8567
8597
|
{
|
|
8568
8598
|
messageId: "remove",
|
|
8569
8599
|
fix: (fixer) => {
|
|
8570
|
-
return fixer.replaceTextRange(
|
|
8600
|
+
return fixer.replaceTextRange(removeBrackets(node.range), (0, import_shared.getArbitraryValue)(value));
|
|
8571
8601
|
}
|
|
8572
8602
|
}
|
|
8573
8603
|
]
|
|
@@ -8579,23 +8609,36 @@ var rule5 = createRule({
|
|
|
8579
8609
|
return;
|
|
8580
8610
|
if (!isPandaProp(node, context))
|
|
8581
8611
|
return;
|
|
8582
|
-
|
|
8583
|
-
if (
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8612
|
+
const { value } = node;
|
|
8613
|
+
if (isLiteral(value)) {
|
|
8614
|
+
const val = value.value?.toString() ?? "";
|
|
8615
|
+
handleNodeValue(value, val);
|
|
8616
|
+
} else if (isJSXExpressionContainer(value)) {
|
|
8617
|
+
const expr = value.expression;
|
|
8618
|
+
if (isLiteral(expr)) {
|
|
8619
|
+
const val = expr.value?.toString() ?? "";
|
|
8620
|
+
handleNodeValue(expr, val);
|
|
8621
|
+
} else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
|
|
8622
|
+
const val = expr.quasis[0].value.raw;
|
|
8623
|
+
handleNodeValue(expr.quasis[0], val);
|
|
8624
|
+
}
|
|
8625
|
+
}
|
|
8587
8626
|
},
|
|
8588
8627
|
Property(node) {
|
|
8589
8628
|
if (!isIdentifier(node.key))
|
|
8590
8629
|
return;
|
|
8591
|
-
if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
|
|
8592
|
-
return;
|
|
8593
8630
|
if (!isPandaAttribute(node, context))
|
|
8594
8631
|
return;
|
|
8595
8632
|
if (isRecipeVariant(node, context))
|
|
8596
8633
|
return;
|
|
8597
|
-
|
|
8598
|
-
|
|
8634
|
+
const value = node.value;
|
|
8635
|
+
if (isLiteral(value)) {
|
|
8636
|
+
const val = value.value?.toString() ?? "";
|
|
8637
|
+
handleNodeValue(value, val);
|
|
8638
|
+
} else if (isTemplateLiteral(value) && value.expressions.length === 0) {
|
|
8639
|
+
const val = value.quasis[0].value.raw;
|
|
8640
|
+
handleNodeValue(value.quasis[0], val);
|
|
8641
|
+
}
|
|
8599
8642
|
}
|
|
8600
8643
|
};
|
|
8601
8644
|
}
|
|
@@ -8604,6 +8647,7 @@ var no_escape_hatch_default = rule5;
|
|
|
8604
8647
|
|
|
8605
8648
|
// src/rules/no-hardcoded-color.ts
|
|
8606
8649
|
init_cjs_shims();
|
|
8650
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
8607
8651
|
var RULE_NAME6 = "no-hardcoded-color";
|
|
8608
8652
|
var rule6 = createRule({
|
|
8609
8653
|
name: RULE_NAME6,
|
|
@@ -8614,7 +8658,7 @@ var rule6 = createRule({
|
|
|
8614
8658
|
messages: {
|
|
8615
8659
|
invalidColor: "`{{color}}` is not a valid color token."
|
|
8616
8660
|
},
|
|
8617
|
-
type: "
|
|
8661
|
+
type: "problem",
|
|
8618
8662
|
schema: [
|
|
8619
8663
|
{
|
|
8620
8664
|
type: "object",
|
|
@@ -8622,7 +8666,8 @@ var rule6 = createRule({
|
|
|
8622
8666
|
noOpacity: {
|
|
8623
8667
|
type: "boolean"
|
|
8624
8668
|
}
|
|
8625
|
-
}
|
|
8669
|
+
},
|
|
8670
|
+
additionalProperties: false
|
|
8626
8671
|
}
|
|
8627
8672
|
]
|
|
8628
8673
|
},
|
|
@@ -8633,19 +8678,55 @@ var rule6 = createRule({
|
|
|
8633
8678
|
],
|
|
8634
8679
|
create(context) {
|
|
8635
8680
|
const noOpacity = context.options[0]?.noOpacity;
|
|
8636
|
-
const
|
|
8681
|
+
const colorTokenCache = /* @__PURE__ */ new Map();
|
|
8682
|
+
const colorAttributeCache = /* @__PURE__ */ new Map();
|
|
8683
|
+
const isColorToken2 = (token) => {
|
|
8684
|
+
if (colorTokenCache.has(token)) {
|
|
8685
|
+
return colorTokenCache.get(token);
|
|
8686
|
+
}
|
|
8687
|
+
const result = isColorToken(token, context);
|
|
8688
|
+
colorTokenCache.set(token, result);
|
|
8689
|
+
return !!result;
|
|
8690
|
+
};
|
|
8691
|
+
const isColorAttribute2 = (attribute) => {
|
|
8692
|
+
if (colorAttributeCache.has(attribute)) {
|
|
8693
|
+
return colorAttributeCache.get(attribute);
|
|
8694
|
+
}
|
|
8695
|
+
const result = isColorAttribute(attribute, context);
|
|
8696
|
+
colorAttributeCache.set(attribute, result);
|
|
8697
|
+
return result;
|
|
8698
|
+
};
|
|
8699
|
+
const isTokenFunctionUsed = (value) => {
|
|
8637
8700
|
if (!value)
|
|
8638
8701
|
return false;
|
|
8639
8702
|
const tokens = extractTokens(value);
|
|
8640
8703
|
return tokens.length > 0;
|
|
8641
8704
|
};
|
|
8642
|
-
const
|
|
8705
|
+
const isValidColorToken = (value) => {
|
|
8643
8706
|
if (!value)
|
|
8644
8707
|
return false;
|
|
8645
|
-
const
|
|
8646
|
-
const
|
|
8647
|
-
const isValidToken =
|
|
8648
|
-
return noOpacity ? isValidToken && !
|
|
8708
|
+
const [colorToken, opacity] = value.split("/");
|
|
8709
|
+
const hasOpacity = opacity !== void 0 && opacity.length > 0;
|
|
8710
|
+
const isValidToken = isColorToken2(colorToken);
|
|
8711
|
+
return noOpacity ? isValidToken && !hasOpacity : isValidToken;
|
|
8712
|
+
};
|
|
8713
|
+
const reportInvalidColor = (node, color) => {
|
|
8714
|
+
context.report({
|
|
8715
|
+
node,
|
|
8716
|
+
messageId: "invalidColor",
|
|
8717
|
+
data: {
|
|
8718
|
+
color
|
|
8719
|
+
}
|
|
8720
|
+
});
|
|
8721
|
+
};
|
|
8722
|
+
const checkColorValue = (node, value, attributeName) => {
|
|
8723
|
+
if (!isColorAttribute2(attributeName))
|
|
8724
|
+
return;
|
|
8725
|
+
if (isTokenFunctionUsed(value))
|
|
8726
|
+
return;
|
|
8727
|
+
if (isValidColorToken(value))
|
|
8728
|
+
return;
|
|
8729
|
+
reportInvalidColor(node, value);
|
|
8649
8730
|
};
|
|
8650
8731
|
return {
|
|
8651
8732
|
JSXAttribute(node) {
|
|
@@ -8653,49 +8734,38 @@ var rule6 = createRule({
|
|
|
8653
8734
|
return;
|
|
8654
8735
|
if (!isPandaProp(node, context) || !node.value)
|
|
8655
8736
|
return;
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
messageId: "invalidColor",
|
|
8671
|
-
data: {
|
|
8672
|
-
color: node.value.expression.value?.toString()
|
|
8673
|
-
}
|
|
8674
|
-
});
|
|
8737
|
+
const attributeName = node.name.name;
|
|
8738
|
+
const valueNode = node.value;
|
|
8739
|
+
if (isLiteral(valueNode)) {
|
|
8740
|
+
const value = valueNode.value?.toString() || "";
|
|
8741
|
+
checkColorValue(valueNode, value, attributeName);
|
|
8742
|
+
} else if (isJSXExpressionContainer(valueNode)) {
|
|
8743
|
+
const expression = valueNode.expression;
|
|
8744
|
+
if (isLiteral(expression)) {
|
|
8745
|
+
const value = expression.value?.toString() || "";
|
|
8746
|
+
checkColorValue(expression, value, attributeName);
|
|
8747
|
+
} else if (isTemplateLiteral(expression) && expression.expressions.length === 0) {
|
|
8748
|
+
const value = expression.quasis[0].value.raw;
|
|
8749
|
+
checkColorValue(expression.quasis[0], value, attributeName);
|
|
8750
|
+
}
|
|
8675
8751
|
}
|
|
8676
8752
|
},
|
|
8677
8753
|
Property(node) {
|
|
8678
8754
|
if (!isIdentifier(node.key))
|
|
8679
8755
|
return;
|
|
8680
|
-
if (!isLiteral(node.value))
|
|
8681
|
-
return;
|
|
8682
8756
|
if (!isPandaAttribute(node, context))
|
|
8683
8757
|
return;
|
|
8684
8758
|
if (isRecipeVariant(node, context))
|
|
8685
8759
|
return;
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
if (
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
data: {
|
|
8696
|
-
color: node.value.value?.toString()
|
|
8697
|
-
}
|
|
8698
|
-
});
|
|
8760
|
+
const attributeName = node.key.name;
|
|
8761
|
+
const valueNode = node.value;
|
|
8762
|
+
if (isLiteral(valueNode)) {
|
|
8763
|
+
const value = valueNode.value?.toString() || "";
|
|
8764
|
+
checkColorValue(valueNode, value, attributeName);
|
|
8765
|
+
} else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
|
|
8766
|
+
const value = valueNode.quasis[0].value.raw;
|
|
8767
|
+
checkColorValue(valueNode.quasis[0], value, attributeName);
|
|
8768
|
+
}
|
|
8699
8769
|
}
|
|
8700
8770
|
};
|
|
8701
8771
|
}
|
|
@@ -8705,6 +8775,7 @@ var no_hardcoded_color_default = rule6;
|
|
|
8705
8775
|
// src/rules/no-important.ts
|
|
8706
8776
|
init_cjs_shims();
|
|
8707
8777
|
var import_shared2 = require("@pandacss/shared");
|
|
8778
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
8708
8779
|
var exclamationRegex = /\s*!$/;
|
|
8709
8780
|
var importantRegex = /\s*!important\s*$/;
|
|
8710
8781
|
var RULE_NAME7 = "no-important";
|
|
@@ -8712,56 +8783,72 @@ var rule7 = createRule({
|
|
|
8712
8783
|
name: RULE_NAME7,
|
|
8713
8784
|
meta: {
|
|
8714
8785
|
docs: {
|
|
8715
|
-
description: "Disallow usage of important keyword.
|
|
8786
|
+
description: "Disallow usage of !important keyword. Prioritize specificity for a maintainable and predictable styling structure."
|
|
8716
8787
|
},
|
|
8717
8788
|
messages: {
|
|
8718
|
-
important: "Avoid using the
|
|
8789
|
+
important: "Avoid using the {{keyword}} keyword. Refactor your code to prioritize specificity for predictable styling.",
|
|
8719
8790
|
remove: "Remove the `{{keyword}}` keyword."
|
|
8720
8791
|
},
|
|
8721
|
-
type: "
|
|
8792
|
+
type: "problem",
|
|
8722
8793
|
hasSuggestions: true,
|
|
8723
8794
|
schema: []
|
|
8724
8795
|
},
|
|
8725
8796
|
defaultOptions: [],
|
|
8726
8797
|
create(context) {
|
|
8727
|
-
const removeQuotes = (
|
|
8728
|
-
|
|
8729
|
-
|
|
8798
|
+
const removeQuotes = (range) => {
|
|
8799
|
+
const [start, end] = range;
|
|
8800
|
+
return [start + 1, end - 1];
|
|
8801
|
+
};
|
|
8802
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
8803
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
8804
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
8805
|
+
const isCachedPandaProp = (node) => {
|
|
8806
|
+
if (pandaPropCache.has(node)) {
|
|
8807
|
+
return pandaPropCache.get(node);
|
|
8808
|
+
}
|
|
8809
|
+
const result = isPandaProp(node, context);
|
|
8810
|
+
pandaPropCache.set(node, result);
|
|
8811
|
+
return !!result;
|
|
8812
|
+
};
|
|
8813
|
+
const isCachedPandaAttribute = (node) => {
|
|
8814
|
+
if (pandaAttributeCache.has(node)) {
|
|
8815
|
+
return pandaAttributeCache.get(node);
|
|
8816
|
+
}
|
|
8817
|
+
const result = isPandaAttribute(node, context);
|
|
8818
|
+
pandaAttributeCache.set(node, result);
|
|
8819
|
+
return !!result;
|
|
8820
|
+
};
|
|
8821
|
+
const isCachedRecipeVariant = (node) => {
|
|
8822
|
+
if (recipeVariantCache.has(node)) {
|
|
8823
|
+
return recipeVariantCache.get(node);
|
|
8824
|
+
}
|
|
8825
|
+
const result = isRecipeVariant(node, context);
|
|
8826
|
+
recipeVariantCache.set(node, result);
|
|
8827
|
+
return !!result;
|
|
8828
|
+
};
|
|
8829
|
+
const hasImportantKeyword = (value) => {
|
|
8830
|
+
if (!value)
|
|
8730
8831
|
return false;
|
|
8731
|
-
const
|
|
8732
|
-
return exclamationRegex.test(
|
|
8832
|
+
const arbitraryValue = (0, import_shared2.getArbitraryValue)(value);
|
|
8833
|
+
return exclamationRegex.test(arbitraryValue) || importantRegex.test(arbitraryValue);
|
|
8733
8834
|
};
|
|
8734
8835
|
const removeImportantKeyword = (input) => {
|
|
8735
|
-
if (
|
|
8736
|
-
return { fixed: input.replace(
|
|
8737
|
-
} else if (
|
|
8738
|
-
return { fixed: input.replace(
|
|
8836
|
+
if (importantRegex.test(input)) {
|
|
8837
|
+
return { fixed: input.replace(importantRegex, "").trimEnd(), keyword: "!important" };
|
|
8838
|
+
} else if (exclamationRegex.test(input)) {
|
|
8839
|
+
return { fixed: input.replace(exclamationRegex, "").trimEnd(), keyword: "!" };
|
|
8739
8840
|
} else {
|
|
8740
8841
|
return { fixed: input, keyword: null };
|
|
8741
8842
|
}
|
|
8742
8843
|
};
|
|
8743
|
-
const
|
|
8744
|
-
if (!
|
|
8745
|
-
return;
|
|
8746
|
-
if (!hasImportantKeyword(node.value?.toString()))
|
|
8844
|
+
const handleNodeValue = (node, value) => {
|
|
8845
|
+
if (!hasImportantKeyword(value))
|
|
8747
8846
|
return;
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
const handleTemplateLiteral = (node) => {
|
|
8751
|
-
if (!isTemplateLiteral(node))
|
|
8752
|
-
return;
|
|
8753
|
-
if (node.expressions.length > 0)
|
|
8754
|
-
return;
|
|
8755
|
-
if (!hasImportantKeyword(node.quasis[0].value.raw))
|
|
8756
|
-
return;
|
|
8757
|
-
sendReport(node.quasis[0], node.quasis[0].value.raw);
|
|
8758
|
-
};
|
|
8759
|
-
const sendReport = (node, _value) => {
|
|
8760
|
-
const value = _value ?? node.value?.toString();
|
|
8761
|
-
const { keyword, fixed } = removeImportantKeyword(value);
|
|
8762
|
-
return context.report({
|
|
8847
|
+
const { fixed, keyword } = removeImportantKeyword(value);
|
|
8848
|
+
context.report({
|
|
8763
8849
|
node,
|
|
8764
8850
|
messageId: "important",
|
|
8851
|
+
data: { keyword },
|
|
8765
8852
|
suggest: [
|
|
8766
8853
|
{
|
|
8767
8854
|
messageId: "remove",
|
|
@@ -8774,28 +8861,43 @@ var rule7 = createRule({
|
|
|
8774
8861
|
});
|
|
8775
8862
|
};
|
|
8776
8863
|
return {
|
|
8864
|
+
// JSX Attributes
|
|
8777
8865
|
JSXAttribute(node) {
|
|
8778
8866
|
if (!node.value)
|
|
8779
8867
|
return;
|
|
8780
|
-
if (!
|
|
8781
|
-
return;
|
|
8782
|
-
handleLiteral(node.value);
|
|
8783
|
-
if (!isJSXExpressionContainer(node.value))
|
|
8868
|
+
if (!isCachedPandaProp(node))
|
|
8784
8869
|
return;
|
|
8785
|
-
|
|
8786
|
-
|
|
8870
|
+
const valueNode = node.value;
|
|
8871
|
+
if (isLiteral(valueNode)) {
|
|
8872
|
+
const val = valueNode.value?.toString() ?? "";
|
|
8873
|
+
handleNodeValue(valueNode, val);
|
|
8874
|
+
} else if (isJSXExpressionContainer(valueNode)) {
|
|
8875
|
+
const expr = valueNode.expression;
|
|
8876
|
+
if (isLiteral(expr)) {
|
|
8877
|
+
const val = expr.value?.toString() ?? "";
|
|
8878
|
+
handleNodeValue(expr, val);
|
|
8879
|
+
} else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
|
|
8880
|
+
const val = expr.quasis[0].value.raw;
|
|
8881
|
+
handleNodeValue(expr.quasis[0], val);
|
|
8882
|
+
}
|
|
8883
|
+
}
|
|
8787
8884
|
},
|
|
8885
|
+
// Object Properties
|
|
8788
8886
|
Property(node) {
|
|
8789
8887
|
if (!isIdentifier(node.key))
|
|
8790
8888
|
return;
|
|
8791
|
-
if (!
|
|
8792
|
-
return;
|
|
8793
|
-
if (!isPandaAttribute(node, context))
|
|
8889
|
+
if (!isCachedPandaAttribute(node))
|
|
8794
8890
|
return;
|
|
8795
|
-
if (
|
|
8891
|
+
if (isCachedRecipeVariant(node))
|
|
8796
8892
|
return;
|
|
8797
|
-
|
|
8798
|
-
|
|
8893
|
+
const valueNode = node.value;
|
|
8894
|
+
if (isLiteral(valueNode)) {
|
|
8895
|
+
const val = valueNode.value?.toString() ?? "";
|
|
8896
|
+
handleNodeValue(valueNode, val);
|
|
8897
|
+
} else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
|
|
8898
|
+
const val = valueNode.quasis[0].value.raw;
|
|
8899
|
+
handleNodeValue(valueNode.quasis[0], val);
|
|
8900
|
+
}
|
|
8799
8901
|
}
|
|
8800
8902
|
};
|
|
8801
8903
|
}
|
|
@@ -8804,40 +8906,84 @@ var no_important_default = rule7;
|
|
|
8804
8906
|
|
|
8805
8907
|
// src/rules/no-invalid-nesting.ts
|
|
8806
8908
|
init_cjs_shims();
|
|
8909
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
8807
8910
|
var RULE_NAME8 = "no-invalid-nesting";
|
|
8808
8911
|
var rule8 = createRule({
|
|
8809
8912
|
name: RULE_NAME8,
|
|
8810
8913
|
meta: {
|
|
8811
8914
|
docs: {
|
|
8812
|
-
description: "Warn against invalid nesting.
|
|
8915
|
+
description: "Warn against invalid nesting. Nested styles must contain the `&` character."
|
|
8813
8916
|
},
|
|
8814
8917
|
messages: {
|
|
8815
8918
|
nesting: "Invalid style nesting. Nested styles must contain the `&` character."
|
|
8816
8919
|
},
|
|
8817
|
-
type: "
|
|
8920
|
+
type: "problem",
|
|
8818
8921
|
schema: []
|
|
8819
8922
|
},
|
|
8820
8923
|
defaultOptions: [],
|
|
8821
8924
|
create(context) {
|
|
8925
|
+
const pandaFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
8926
|
+
const jsxPropCache = /* @__PURE__ */ new WeakMap();
|
|
8927
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
8928
|
+
const styledPropertyCache = /* @__PURE__ */ new WeakMap();
|
|
8929
|
+
const isCachedInPandaFunction = (node) => {
|
|
8930
|
+
if (pandaFunctionCache.has(node)) {
|
|
8931
|
+
return pandaFunctionCache.get(node);
|
|
8932
|
+
}
|
|
8933
|
+
const result = !!isInPandaFunction(node, context);
|
|
8934
|
+
pandaFunctionCache.set(node, result);
|
|
8935
|
+
return !!result;
|
|
8936
|
+
};
|
|
8937
|
+
const isCachedInJSXProp = (node) => {
|
|
8938
|
+
if (jsxPropCache.has(node)) {
|
|
8939
|
+
return jsxPropCache.get(node);
|
|
8940
|
+
}
|
|
8941
|
+
const result = isInJSXProp(node, context);
|
|
8942
|
+
jsxPropCache.set(node, result);
|
|
8943
|
+
return !!result;
|
|
8944
|
+
};
|
|
8945
|
+
const isCachedRecipeVariant = (node) => {
|
|
8946
|
+
if (recipeVariantCache.has(node)) {
|
|
8947
|
+
return recipeVariantCache.get(node);
|
|
8948
|
+
}
|
|
8949
|
+
const result = isRecipeVariant(node, context);
|
|
8950
|
+
recipeVariantCache.set(node, result);
|
|
8951
|
+
return !!result;
|
|
8952
|
+
};
|
|
8953
|
+
const isCachedStyledProperty = (node) => {
|
|
8954
|
+
if (styledPropertyCache.has(node)) {
|
|
8955
|
+
return styledPropertyCache.get(node);
|
|
8956
|
+
}
|
|
8957
|
+
const result = isStyledProperty(node, context);
|
|
8958
|
+
styledPropertyCache.set(node, result);
|
|
8959
|
+
return !!result;
|
|
8960
|
+
};
|
|
8961
|
+
const isInvalidNestingSelector = (node) => {
|
|
8962
|
+
if (isLiteral(node) && typeof node.value === "string") {
|
|
8963
|
+
return !node.value.includes("&");
|
|
8964
|
+
} else if (isTemplateLiteral(node) && node.expressions.length === 0) {
|
|
8965
|
+
return !node.quasis[0].value.raw.includes("&");
|
|
8966
|
+
}
|
|
8967
|
+
return false;
|
|
8968
|
+
};
|
|
8822
8969
|
return {
|
|
8823
|
-
Property
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
const
|
|
8827
|
-
if (!
|
|
8970
|
+
// Use AST selector to target Property nodes with non-Identifier keys whose value is an ObjectExpression
|
|
8971
|
+
'Property[key.type!=/Identifier/][value.type="ObjectExpression"]'(node) {
|
|
8972
|
+
const inPandaFunction = isCachedInPandaFunction(node);
|
|
8973
|
+
const inJSXProp = isCachedInJSXProp(node);
|
|
8974
|
+
if (!inPandaFunction && !inJSXProp)
|
|
8828
8975
|
return;
|
|
8829
|
-
if (
|
|
8830
|
-
return;
|
|
8831
|
-
if (isStyledProperty(node, context))
|
|
8976
|
+
if (isCachedRecipeVariant(node))
|
|
8832
8977
|
return;
|
|
8833
|
-
|
|
8834
|
-
const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
|
|
8835
|
-
if (!(invalidLiteral || invalidTemplateLiteral))
|
|
8978
|
+
if (isCachedStyledProperty(node))
|
|
8836
8979
|
return;
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8980
|
+
const keyNode = node.key;
|
|
8981
|
+
if (isInvalidNestingSelector(keyNode)) {
|
|
8982
|
+
context.report({
|
|
8983
|
+
node: keyNode,
|
|
8984
|
+
messageId: "nesting"
|
|
8985
|
+
});
|
|
8986
|
+
}
|
|
8841
8987
|
}
|
|
8842
8988
|
};
|
|
8843
8989
|
}
|
|
@@ -8846,7 +8992,7 @@ var no_invalid_nesting_default = rule8;
|
|
|
8846
8992
|
|
|
8847
8993
|
// src/rules/no-invalid-token-paths.ts
|
|
8848
8994
|
init_cjs_shims();
|
|
8849
|
-
var
|
|
8995
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
8850
8996
|
var import_ast_utils2 = require("@typescript-eslint/utils/ast-utils");
|
|
8851
8997
|
var RULE_NAME9 = "no-invalid-token-paths";
|
|
8852
8998
|
var rule9 = createRule({
|
|
@@ -8858,87 +9004,89 @@ var rule9 = createRule({
|
|
|
8858
9004
|
messages: {
|
|
8859
9005
|
noInvalidTokenPaths: "`{{token}}` is an invalid token path."
|
|
8860
9006
|
},
|
|
8861
|
-
type: "
|
|
9007
|
+
type: "problem",
|
|
8862
9008
|
schema: []
|
|
8863
9009
|
},
|
|
8864
9010
|
defaultOptions: [],
|
|
8865
9011
|
create(context) {
|
|
8866
|
-
const
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
sendReport(node);
|
|
8870
|
-
};
|
|
8871
|
-
const handleTemplateLiteral = (node) => {
|
|
8872
|
-
if (!isTemplateLiteral(node))
|
|
9012
|
+
const invalidTokensCache2 = /* @__PURE__ */ new Map();
|
|
9013
|
+
const sendReport = (node, value) => {
|
|
9014
|
+
if (!value)
|
|
8873
9015
|
return;
|
|
8874
|
-
|
|
9016
|
+
let tokens = invalidTokensCache2.get(value);
|
|
9017
|
+
if (!tokens) {
|
|
9018
|
+
tokens = getInvalidTokens(value, context);
|
|
9019
|
+
invalidTokensCache2.set(value, tokens);
|
|
9020
|
+
}
|
|
9021
|
+
if (tokens.length === 0)
|
|
8875
9022
|
return;
|
|
8876
|
-
|
|
9023
|
+
tokens.forEach((token) => {
|
|
9024
|
+
context.report({
|
|
9025
|
+
node,
|
|
9026
|
+
messageId: "noInvalidTokenPaths",
|
|
9027
|
+
data: { token }
|
|
9028
|
+
});
|
|
9029
|
+
});
|
|
8877
9030
|
};
|
|
8878
|
-
const
|
|
8879
|
-
|
|
8880
|
-
const tokens = getInvalidTokens(value, context);
|
|
8881
|
-
if (!tokens)
|
|
9031
|
+
const handleLiteralOrTemplate = (node) => {
|
|
9032
|
+
if (!node)
|
|
8882
9033
|
return;
|
|
8883
|
-
if (
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
});
|
|
8890
|
-
});
|
|
9034
|
+
if (isLiteral(node)) {
|
|
9035
|
+
const value = node.value?.toString();
|
|
9036
|
+
sendReport(node, value);
|
|
9037
|
+
} else if (isTemplateLiteral(node) && node.expressions.length === 0) {
|
|
9038
|
+
const value = node.quasis[0].value.raw;
|
|
9039
|
+
sendReport(node.quasis[0], value);
|
|
8891
9040
|
}
|
|
8892
9041
|
};
|
|
8893
9042
|
return {
|
|
8894
9043
|
JSXAttribute(node) {
|
|
8895
|
-
if (!node.value)
|
|
8896
|
-
return;
|
|
8897
|
-
if (!isPandaProp(node, context))
|
|
8898
|
-
return;
|
|
8899
|
-
handleLiteral(node.value);
|
|
8900
|
-
if (!isJSXExpressionContainer(node.value))
|
|
9044
|
+
if (!node.value || !isPandaProp(node, context))
|
|
8901
9045
|
return;
|
|
8902
|
-
|
|
8903
|
-
|
|
9046
|
+
if (isLiteral(node.value)) {
|
|
9047
|
+
handleLiteralOrTemplate(node.value);
|
|
9048
|
+
} else if (isJSXExpressionContainer(node.value)) {
|
|
9049
|
+
handleLiteralOrTemplate(node.value.expression);
|
|
9050
|
+
}
|
|
8904
9051
|
},
|
|
8905
9052
|
Property(node) {
|
|
8906
|
-
if (!isIdentifier(node.key))
|
|
8907
|
-
return;
|
|
8908
|
-
if (!(0, import_ast_utils2.isNodeOfTypes)([import_utils12.AST_NODE_TYPES.Literal, import_utils12.AST_NODE_TYPES.TemplateLiteral])(node.value))
|
|
9053
|
+
if (!isIdentifier(node.key) || !(0, import_ast_utils2.isNodeOfTypes)([import_utils20.AST_NODE_TYPES.Literal, import_utils20.AST_NODE_TYPES.TemplateLiteral])(node.value) || !isPandaAttribute(node, context) || isRecipeVariant(node, context)) {
|
|
8909
9054
|
return;
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
if (isRecipeVariant(node, context))
|
|
8913
|
-
return;
|
|
8914
|
-
handleLiteral(node.value);
|
|
8915
|
-
handleTemplateLiteral(node.value);
|
|
9055
|
+
}
|
|
9056
|
+
handleLiteralOrTemplate(node.value);
|
|
8916
9057
|
},
|
|
8917
9058
|
TaggedTemplateExpression(node) {
|
|
8918
9059
|
const caller = getTaggedTemplateCaller(node);
|
|
8919
|
-
if (!caller)
|
|
9060
|
+
if (!caller || !isPandaIsh(caller, context))
|
|
8920
9061
|
return;
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
const tokens = getInvalidTokens(styles, context);
|
|
8926
|
-
if (!tokens)
|
|
8927
|
-
return;
|
|
8928
|
-
tokens.forEach((token, i, arr) => {
|
|
8929
|
-
if (arr.indexOf(token) < i)
|
|
9062
|
+
const quasis = node.quasi.quasis;
|
|
9063
|
+
quasis.forEach((quasi) => {
|
|
9064
|
+
const styles = quasi.value.raw;
|
|
9065
|
+
if (!styles)
|
|
8930
9066
|
return;
|
|
8931
|
-
let
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
context.report({
|
|
8936
|
-
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
|
|
8937
|
-
messageId: "noInvalidTokenPaths",
|
|
8938
|
-
data: { token }
|
|
8939
|
-
});
|
|
8940
|
-
index = styles.indexOf(token, index + 1);
|
|
9067
|
+
let tokens = invalidTokensCache2.get(styles);
|
|
9068
|
+
if (!tokens) {
|
|
9069
|
+
tokens = getInvalidTokens(styles, context);
|
|
9070
|
+
invalidTokensCache2.set(styles, tokens);
|
|
8941
9071
|
}
|
|
9072
|
+
if (tokens.length === 0)
|
|
9073
|
+
return;
|
|
9074
|
+
tokens.forEach((token) => {
|
|
9075
|
+
let index = styles.indexOf(token);
|
|
9076
|
+
while (index !== -1) {
|
|
9077
|
+
const start = quasi.range[0] + index + 1;
|
|
9078
|
+
const end = start + token.length;
|
|
9079
|
+
context.report({
|
|
9080
|
+
loc: {
|
|
9081
|
+
start: context.sourceCode.getLocFromIndex(start),
|
|
9082
|
+
end: context.sourceCode.getLocFromIndex(end)
|
|
9083
|
+
},
|
|
9084
|
+
messageId: "noInvalidTokenPaths",
|
|
9085
|
+
data: { token }
|
|
9086
|
+
});
|
|
9087
|
+
index = styles.indexOf(token, index + token.length);
|
|
9088
|
+
}
|
|
9089
|
+
});
|
|
8942
9090
|
});
|
|
8943
9091
|
}
|
|
8944
9092
|
};
|
|
@@ -8963,29 +9111,69 @@ var rule10 = createRule({
|
|
|
8963
9111
|
},
|
|
8964
9112
|
defaultOptions: [],
|
|
8965
9113
|
create(context) {
|
|
8966
|
-
const
|
|
9114
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9115
|
+
const getLonghand = (name2) => {
|
|
9116
|
+
if (longhandCache.has(name2)) {
|
|
9117
|
+
return longhandCache.get(name2);
|
|
9118
|
+
}
|
|
9119
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9120
|
+
longhandCache.set(name2, longhand);
|
|
9121
|
+
return longhand;
|
|
9122
|
+
};
|
|
9123
|
+
const marginRegex = /margin/i;
|
|
9124
|
+
const isMarginProperty = (name2) => {
|
|
9125
|
+
const longhand = getLonghand(name2).toLowerCase();
|
|
9126
|
+
return marginRegex.test(longhand);
|
|
9127
|
+
};
|
|
8967
9128
|
const sendReport = (node) => {
|
|
8968
|
-
if (!
|
|
9129
|
+
if (!isMarginProperty(node.name))
|
|
8969
9130
|
return;
|
|
8970
|
-
|
|
9131
|
+
context.report({
|
|
8971
9132
|
node,
|
|
8972
9133
|
messageId: "noMargin"
|
|
8973
9134
|
});
|
|
8974
9135
|
};
|
|
9136
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9137
|
+
const isCachedPandaProp = (node) => {
|
|
9138
|
+
if (pandaPropCache.has(node)) {
|
|
9139
|
+
return pandaPropCache.get(node);
|
|
9140
|
+
}
|
|
9141
|
+
const result = isPandaProp(node, context);
|
|
9142
|
+
pandaPropCache.set(node, result);
|
|
9143
|
+
return !!result;
|
|
9144
|
+
};
|
|
9145
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9146
|
+
const isCachedPandaAttribute = (node) => {
|
|
9147
|
+
if (pandaAttributeCache.has(node)) {
|
|
9148
|
+
return pandaAttributeCache.get(node);
|
|
9149
|
+
}
|
|
9150
|
+
const result = isPandaAttribute(node, context);
|
|
9151
|
+
pandaAttributeCache.set(node, result);
|
|
9152
|
+
return !!result;
|
|
9153
|
+
};
|
|
9154
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9155
|
+
const isCachedRecipeVariant = (node) => {
|
|
9156
|
+
if (recipeVariantCache.has(node)) {
|
|
9157
|
+
return recipeVariantCache.get(node);
|
|
9158
|
+
}
|
|
9159
|
+
const result = isRecipeVariant(node, context);
|
|
9160
|
+
recipeVariantCache.set(node, result);
|
|
9161
|
+
return !!result;
|
|
9162
|
+
};
|
|
8975
9163
|
return {
|
|
8976
9164
|
JSXAttribute(node) {
|
|
8977
9165
|
if (!isJSXIdentifier(node.name))
|
|
8978
9166
|
return;
|
|
8979
|
-
if (!
|
|
9167
|
+
if (!isCachedPandaProp(node))
|
|
8980
9168
|
return;
|
|
8981
9169
|
sendReport(node.name);
|
|
8982
9170
|
},
|
|
8983
9171
|
Property(node) {
|
|
8984
9172
|
if (!isIdentifier(node.key))
|
|
8985
9173
|
return;
|
|
8986
|
-
if (!
|
|
9174
|
+
if (!isCachedPandaAttribute(node))
|
|
8987
9175
|
return;
|
|
8988
|
-
if (
|
|
9176
|
+
if (isCachedRecipeVariant(node))
|
|
8989
9177
|
return;
|
|
8990
9178
|
sendReport(node.key);
|
|
8991
9179
|
}
|
|
@@ -9040,11 +9228,11 @@ var rule11 = createRule({
|
|
|
9040
9228
|
name: RULE_NAME11,
|
|
9041
9229
|
meta: {
|
|
9042
9230
|
docs: {
|
|
9043
|
-
description: "Encourage the use of
|
|
9231
|
+
description: "Encourage the use of logical properties over physical properties to foster a responsive and adaptable user interface."
|
|
9044
9232
|
},
|
|
9045
9233
|
messages: {
|
|
9046
|
-
physical: "Use logical property of {{physical}}
|
|
9047
|
-
replace: "Replace `{{physical}}` with `{{logical}}
|
|
9234
|
+
physical: "Use logical property instead of {{physical}}. Prefer `{{logical}}`.",
|
|
9235
|
+
replace: "Replace `{{physical}}` with `{{logical}}`."
|
|
9048
9236
|
},
|
|
9049
9237
|
type: "suggestion",
|
|
9050
9238
|
hasSuggestions: true,
|
|
@@ -9052,17 +9240,53 @@ var rule11 = createRule({
|
|
|
9052
9240
|
},
|
|
9053
9241
|
defaultOptions: [],
|
|
9054
9242
|
create(context) {
|
|
9055
|
-
const
|
|
9243
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9244
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9245
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9246
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9247
|
+
const getLonghand = (name2) => {
|
|
9248
|
+
if (longhandCache.has(name2)) {
|
|
9249
|
+
return longhandCache.get(name2);
|
|
9250
|
+
}
|
|
9251
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9252
|
+
longhandCache.set(name2, longhand);
|
|
9253
|
+
return longhand;
|
|
9254
|
+
};
|
|
9255
|
+
const isCachedPandaProp = (node) => {
|
|
9256
|
+
if (pandaPropCache.has(node)) {
|
|
9257
|
+
return pandaPropCache.get(node);
|
|
9258
|
+
}
|
|
9259
|
+
const result = isPandaProp(node, context);
|
|
9260
|
+
pandaPropCache.set(node, result);
|
|
9261
|
+
return !!result;
|
|
9262
|
+
};
|
|
9263
|
+
const isCachedPandaAttribute = (node) => {
|
|
9264
|
+
if (pandaAttributeCache.has(node)) {
|
|
9265
|
+
return pandaAttributeCache.get(node);
|
|
9266
|
+
}
|
|
9267
|
+
const result = isPandaAttribute(node, context);
|
|
9268
|
+
pandaAttributeCache.set(node, result);
|
|
9269
|
+
return !!result;
|
|
9270
|
+
};
|
|
9271
|
+
const isCachedRecipeVariant = (node) => {
|
|
9272
|
+
if (recipeVariantCache.has(node)) {
|
|
9273
|
+
return recipeVariantCache.get(node);
|
|
9274
|
+
}
|
|
9275
|
+
const result = isRecipeVariant(node, context);
|
|
9276
|
+
recipeVariantCache.set(node, result);
|
|
9277
|
+
return !!result;
|
|
9278
|
+
};
|
|
9056
9279
|
const sendReport = (node) => {
|
|
9057
|
-
|
|
9280
|
+
const longhandName = getLonghand(node.name);
|
|
9281
|
+
if (!(longhandName in physicalProperties))
|
|
9058
9282
|
return;
|
|
9059
|
-
const logical = physicalProperties[
|
|
9060
|
-
const
|
|
9061
|
-
|
|
9283
|
+
const logical = physicalProperties[longhandName];
|
|
9284
|
+
const physicalName = `\`${node.name}\`${longhandName !== node.name ? ` (resolved to \`${longhandName}\`)` : ""}`;
|
|
9285
|
+
context.report({
|
|
9062
9286
|
node,
|
|
9063
9287
|
messageId: "physical",
|
|
9064
9288
|
data: {
|
|
9065
|
-
physical:
|
|
9289
|
+
physical: physicalName,
|
|
9066
9290
|
logical
|
|
9067
9291
|
},
|
|
9068
9292
|
suggest: [
|
|
@@ -9073,7 +9297,7 @@ var rule11 = createRule({
|
|
|
9073
9297
|
logical
|
|
9074
9298
|
},
|
|
9075
9299
|
fix: (fixer) => {
|
|
9076
|
-
return fixer.
|
|
9300
|
+
return fixer.replaceText(node, logical);
|
|
9077
9301
|
}
|
|
9078
9302
|
}
|
|
9079
9303
|
]
|
|
@@ -9083,16 +9307,16 @@ var rule11 = createRule({
|
|
|
9083
9307
|
JSXAttribute(node) {
|
|
9084
9308
|
if (!isJSXIdentifier(node.name))
|
|
9085
9309
|
return;
|
|
9086
|
-
if (!
|
|
9310
|
+
if (!isCachedPandaProp(node))
|
|
9087
9311
|
return;
|
|
9088
9312
|
sendReport(node.name);
|
|
9089
9313
|
},
|
|
9090
9314
|
Property(node) {
|
|
9091
9315
|
if (!isIdentifier(node.key))
|
|
9092
9316
|
return;
|
|
9093
|
-
if (!
|
|
9317
|
+
if (!isCachedPandaAttribute(node))
|
|
9094
9318
|
return;
|
|
9095
|
-
if (
|
|
9319
|
+
if (isCachedRecipeVariant(node))
|
|
9096
9320
|
return;
|
|
9097
9321
|
sendReport(node.key);
|
|
9098
9322
|
}
|
|
@@ -9108,19 +9332,46 @@ var rule12 = createRule({
|
|
|
9108
9332
|
name: RULE_NAME12,
|
|
9109
9333
|
meta: {
|
|
9110
9334
|
docs: {
|
|
9111
|
-
description: "Ensure
|
|
9335
|
+
description: "Ensure that properties for patterns or style props are not renamed, as it prevents proper tracking."
|
|
9112
9336
|
},
|
|
9113
9337
|
messages: {
|
|
9114
|
-
noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute.
|
|
9338
|
+
noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute. Panda will not track this prop."
|
|
9115
9339
|
},
|
|
9116
|
-
type: "
|
|
9340
|
+
type: "problem",
|
|
9117
9341
|
schema: []
|
|
9118
9342
|
},
|
|
9119
9343
|
defaultOptions: [],
|
|
9120
9344
|
create(context) {
|
|
9345
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9346
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9347
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9348
|
+
const isCachedPandaProp = (node) => {
|
|
9349
|
+
if (pandaPropCache.has(node)) {
|
|
9350
|
+
return pandaPropCache.get(node);
|
|
9351
|
+
}
|
|
9352
|
+
const result = isPandaProp(node, context);
|
|
9353
|
+
pandaPropCache.set(node, result);
|
|
9354
|
+
return !!result;
|
|
9355
|
+
};
|
|
9356
|
+
const isCachedPandaAttribute = (node) => {
|
|
9357
|
+
if (pandaAttributeCache.has(node)) {
|
|
9358
|
+
return pandaAttributeCache.get(node);
|
|
9359
|
+
}
|
|
9360
|
+
const result = isPandaAttribute(node, context);
|
|
9361
|
+
pandaAttributeCache.set(node, result);
|
|
9362
|
+
return !!result;
|
|
9363
|
+
};
|
|
9364
|
+
const isCachedRecipeVariant = (node) => {
|
|
9365
|
+
if (recipeVariantCache.has(node)) {
|
|
9366
|
+
return recipeVariantCache.get(node);
|
|
9367
|
+
}
|
|
9368
|
+
const result = isRecipeVariant(node, context);
|
|
9369
|
+
recipeVariantCache.set(node, result);
|
|
9370
|
+
return !!result;
|
|
9371
|
+
};
|
|
9121
9372
|
const sendReport = (node, expected, prop) => {
|
|
9122
|
-
|
|
9123
|
-
node
|
|
9373
|
+
context.report({
|
|
9374
|
+
node,
|
|
9124
9375
|
messageId: "noRenaming",
|
|
9125
9376
|
data: {
|
|
9126
9377
|
expected,
|
|
@@ -9130,10 +9381,9 @@ var rule12 = createRule({
|
|
|
9130
9381
|
};
|
|
9131
9382
|
const handleReport = (node, value, attr) => {
|
|
9132
9383
|
if (isIdentifier(value) && attr !== value.name) {
|
|
9133
|
-
|
|
9134
|
-
}
|
|
9135
|
-
|
|
9136
|
-
return sendReport(node, attr, value.property.name);
|
|
9384
|
+
sendReport(node, attr, value.name);
|
|
9385
|
+
} else if (isMemberExpression(value) && isIdentifier(value.property) && attr !== value.property.name) {
|
|
9386
|
+
sendReport(node, attr, value.property.name);
|
|
9137
9387
|
}
|
|
9138
9388
|
};
|
|
9139
9389
|
return {
|
|
@@ -9142,24 +9392,24 @@ var rule12 = createRule({
|
|
|
9142
9392
|
return;
|
|
9143
9393
|
if (!isJSXExpressionContainer(node.value))
|
|
9144
9394
|
return;
|
|
9145
|
-
if (!
|
|
9395
|
+
if (!isCachedPandaProp(node))
|
|
9146
9396
|
return;
|
|
9147
9397
|
const attr = node.name.name.toString();
|
|
9148
9398
|
const expression = node.value.expression;
|
|
9149
|
-
handleReport(node, expression, attr);
|
|
9399
|
+
handleReport(node.value, expression, attr);
|
|
9150
9400
|
},
|
|
9151
9401
|
Property(node) {
|
|
9152
9402
|
if (!isIdentifier(node.key))
|
|
9153
9403
|
return;
|
|
9154
9404
|
if (!isIdentifier(node.value) && !isMemberExpression(node.value))
|
|
9155
9405
|
return;
|
|
9156
|
-
if (!
|
|
9406
|
+
if (!isCachedPandaAttribute(node))
|
|
9157
9407
|
return;
|
|
9158
|
-
if (
|
|
9408
|
+
if (isCachedRecipeVariant(node))
|
|
9159
9409
|
return;
|
|
9160
|
-
const attr = node.key.name
|
|
9410
|
+
const attr = node.key.name;
|
|
9161
9411
|
const value = node.value;
|
|
9162
|
-
handleReport(node, value, attr);
|
|
9412
|
+
handleReport(node.value, value, attr);
|
|
9163
9413
|
}
|
|
9164
9414
|
};
|
|
9165
9415
|
}
|
|
@@ -9168,7 +9418,7 @@ var no_property_renaming_default = rule12;
|
|
|
9168
9418
|
|
|
9169
9419
|
// src/rules/no-unsafe-token-fn-usage.ts
|
|
9170
9420
|
init_cjs_shims();
|
|
9171
|
-
var
|
|
9421
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
9172
9422
|
var import_shared3 = require("@pandacss/shared");
|
|
9173
9423
|
var RULE_NAME13 = "no-unsafe-token-fn-usage";
|
|
9174
9424
|
var rule13 = createRule({
|
|
@@ -9178,8 +9428,8 @@ var rule13 = createRule({
|
|
|
9178
9428
|
description: "Prevent users from using the token function in situations where they could simply use the raw design token."
|
|
9179
9429
|
},
|
|
9180
9430
|
messages: {
|
|
9181
|
-
noUnsafeTokenFnUsage: "
|
|
9182
|
-
replace: "Replace token function with `{{safe}}
|
|
9431
|
+
noUnsafeTokenFnUsage: "Unnecessary token function usage. Prefer design token.",
|
|
9432
|
+
replace: "Replace token function with `{{safe}}`."
|
|
9183
9433
|
},
|
|
9184
9434
|
type: "suggestion",
|
|
9185
9435
|
hasSuggestions: true,
|
|
@@ -9187,11 +9437,42 @@ var rule13 = createRule({
|
|
|
9187
9437
|
},
|
|
9188
9438
|
defaultOptions: [],
|
|
9189
9439
|
create(context) {
|
|
9440
|
+
let tokenImportCache;
|
|
9441
|
+
const getCachedTokenImport = () => {
|
|
9442
|
+
if (tokenImportCache !== void 0) {
|
|
9443
|
+
return tokenImportCache;
|
|
9444
|
+
}
|
|
9445
|
+
tokenImportCache = getTokenImport(context);
|
|
9446
|
+
return tokenImportCache;
|
|
9447
|
+
};
|
|
9190
9448
|
const isUnsafeCallExpression = (node) => {
|
|
9191
|
-
const tkImport =
|
|
9449
|
+
const tkImport = getCachedTokenImport();
|
|
9192
9450
|
return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
|
|
9193
9451
|
};
|
|
9194
9452
|
const tokenWrap = (value) => value ? `token(${value})` : "";
|
|
9453
|
+
const isCompositeValue = (input) => {
|
|
9454
|
+
if (!input)
|
|
9455
|
+
return false;
|
|
9456
|
+
const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
|
|
9457
|
+
return !tokenRegex.test(input);
|
|
9458
|
+
};
|
|
9459
|
+
const sendReport = (node, value) => {
|
|
9460
|
+
const tkImports = extractTokens(value);
|
|
9461
|
+
if (!tkImports.length)
|
|
9462
|
+
return;
|
|
9463
|
+
const token = tkImports[0].replace(/^[^.]*\./, "");
|
|
9464
|
+
context.report({
|
|
9465
|
+
node,
|
|
9466
|
+
messageId: "noUnsafeTokenFnUsage",
|
|
9467
|
+
suggest: [
|
|
9468
|
+
{
|
|
9469
|
+
messageId: "replace",
|
|
9470
|
+
data: { safe: token },
|
|
9471
|
+
fix: (fixer) => fixer.replaceText(node, `'${token}'`)
|
|
9472
|
+
}
|
|
9473
|
+
]
|
|
9474
|
+
});
|
|
9475
|
+
};
|
|
9195
9476
|
const handleRuntimeFm = (node) => {
|
|
9196
9477
|
if (!isCallExpression(node))
|
|
9197
9478
|
return;
|
|
@@ -9199,17 +9480,12 @@ var rule13 = createRule({
|
|
|
9199
9480
|
return;
|
|
9200
9481
|
const value = node.arguments[0];
|
|
9201
9482
|
if (isLiteral(value)) {
|
|
9202
|
-
|
|
9483
|
+
const val = (0, import_shared3.getArbitraryValue)(value.value?.toString() ?? "");
|
|
9484
|
+
sendReport(node, tokenWrap(val));
|
|
9485
|
+
} else if (isTemplateLiteral(value) && value.expressions.length === 0) {
|
|
9486
|
+
const val = (0, import_shared3.getArbitraryValue)(value.quasis[0].value.raw);
|
|
9487
|
+
sendReport(node, tokenWrap(val));
|
|
9203
9488
|
}
|
|
9204
|
-
if (isTemplateLiteral(value)) {
|
|
9205
|
-
sendReport(node, tokenWrap((0, import_shared3.getArbitraryValue)(value.quasis[0].value.raw)));
|
|
9206
|
-
}
|
|
9207
|
-
};
|
|
9208
|
-
const isCompositeValue = (input) => {
|
|
9209
|
-
if (!input)
|
|
9210
|
-
return;
|
|
9211
|
-
const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
|
|
9212
|
-
return !tokenRegex.test(input);
|
|
9213
9489
|
};
|
|
9214
9490
|
const handleLiteral = (node) => {
|
|
9215
9491
|
if (!isLiteral(node))
|
|
@@ -9220,54 +9496,63 @@ var rule13 = createRule({
|
|
|
9220
9496
|
sendReport(node, value);
|
|
9221
9497
|
};
|
|
9222
9498
|
const handleTemplateLiteral = (node) => {
|
|
9223
|
-
if (!isTemplateLiteral(node))
|
|
9224
|
-
return;
|
|
9225
|
-
if (node.expressions.length > 0)
|
|
9499
|
+
if (!isTemplateLiteral(node) || node.expressions.length > 0)
|
|
9226
9500
|
return;
|
|
9227
|
-
|
|
9501
|
+
const value = (0, import_shared3.getArbitraryValue)(node.quasis[0].value.raw);
|
|
9502
|
+
sendReport(node, value);
|
|
9228
9503
|
};
|
|
9229
|
-
const
|
|
9230
|
-
|
|
9231
|
-
if (
|
|
9232
|
-
return;
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9504
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9505
|
+
const isCachedPandaProp = (node) => {
|
|
9506
|
+
if (pandaPropCache.has(node)) {
|
|
9507
|
+
return pandaPropCache.get(node);
|
|
9508
|
+
}
|
|
9509
|
+
const result = isPandaProp(node, context);
|
|
9510
|
+
pandaPropCache.set(node, result);
|
|
9511
|
+
return !!result;
|
|
9512
|
+
};
|
|
9513
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9514
|
+
const isCachedPandaAttribute = (node) => {
|
|
9515
|
+
if (pandaAttributeCache.has(node)) {
|
|
9516
|
+
return pandaAttributeCache.get(node);
|
|
9517
|
+
}
|
|
9518
|
+
const result = isPandaAttribute(node, context);
|
|
9519
|
+
pandaAttributeCache.set(node, result);
|
|
9520
|
+
return !!result;
|
|
9521
|
+
};
|
|
9522
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9523
|
+
const isCachedRecipeVariant = (node) => {
|
|
9524
|
+
if (recipeVariantCache.has(node)) {
|
|
9525
|
+
return recipeVariantCache.get(node);
|
|
9526
|
+
}
|
|
9527
|
+
const result = isRecipeVariant(node, context);
|
|
9528
|
+
recipeVariantCache.set(node, result);
|
|
9529
|
+
return !!result;
|
|
9247
9530
|
};
|
|
9248
9531
|
return {
|
|
9249
9532
|
JSXAttribute(node) {
|
|
9250
9533
|
if (!node.value)
|
|
9251
9534
|
return;
|
|
9252
|
-
if (!
|
|
9535
|
+
if (!isCachedPandaProp(node))
|
|
9253
9536
|
return;
|
|
9254
9537
|
handleLiteral(node.value);
|
|
9255
|
-
if (
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9538
|
+
if (isJSXExpressionContainer(node.value)) {
|
|
9539
|
+
const expression = node.value.expression;
|
|
9540
|
+
handleLiteral(expression);
|
|
9541
|
+
handleTemplateLiteral(expression);
|
|
9542
|
+
handleRuntimeFm(expression);
|
|
9543
|
+
}
|
|
9260
9544
|
},
|
|
9261
9545
|
Property(node) {
|
|
9262
|
-
if (!
|
|
9546
|
+
if (!isCachedPandaAttribute(node))
|
|
9263
9547
|
return;
|
|
9264
|
-
if (
|
|
9265
|
-
return;
|
|
9266
|
-
if (isRecipeVariant(node, context))
|
|
9548
|
+
if (isCachedRecipeVariant(node))
|
|
9267
9549
|
return;
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9550
|
+
const valueNode = node.value;
|
|
9551
|
+
if (isCallExpression(valueNode) || isLiteral(valueNode) || isTemplateLiteral(valueNode)) {
|
|
9552
|
+
handleRuntimeFm(valueNode);
|
|
9553
|
+
handleLiteral(valueNode);
|
|
9554
|
+
handleTemplateLiteral(valueNode);
|
|
9555
|
+
}
|
|
9271
9556
|
}
|
|
9272
9557
|
};
|
|
9273
9558
|
}
|
|
@@ -9284,8 +9569,8 @@ var rule14 = createRule({
|
|
|
9284
9569
|
description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
|
|
9285
9570
|
},
|
|
9286
9571
|
messages: {
|
|
9287
|
-
longhand: "Use longhand property of `{{shorthand}}
|
|
9288
|
-
replace: "Replace `{{shorthand}}` with `{{longhand}}
|
|
9572
|
+
longhand: "Use longhand property instead of `{{shorthand}}`. Prefer `{{longhand}}`.",
|
|
9573
|
+
replace: "Replace `{{shorthand}}` with `{{longhand}}`."
|
|
9289
9574
|
},
|
|
9290
9575
|
type: "suggestion",
|
|
9291
9576
|
hasSuggestions: true,
|
|
@@ -9293,15 +9578,51 @@ var rule14 = createRule({
|
|
|
9293
9578
|
},
|
|
9294
9579
|
defaultOptions: [],
|
|
9295
9580
|
create(context) {
|
|
9581
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9582
|
+
const getLonghand = (name2) => {
|
|
9583
|
+
if (longhandCache.has(name2)) {
|
|
9584
|
+
return longhandCache.get(name2);
|
|
9585
|
+
}
|
|
9586
|
+
const longhand = resolveLonghand(name2, context);
|
|
9587
|
+
longhandCache.set(name2, longhand);
|
|
9588
|
+
return longhand;
|
|
9589
|
+
};
|
|
9590
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9591
|
+
const isCachedPandaProp = (node) => {
|
|
9592
|
+
if (pandaPropCache.has(node)) {
|
|
9593
|
+
return pandaPropCache.get(node);
|
|
9594
|
+
}
|
|
9595
|
+
const result = isPandaProp(node, context);
|
|
9596
|
+
pandaPropCache.set(node, result);
|
|
9597
|
+
return !!result;
|
|
9598
|
+
};
|
|
9599
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9600
|
+
const isCachedPandaAttribute = (node) => {
|
|
9601
|
+
if (pandaAttributeCache.has(node)) {
|
|
9602
|
+
return pandaAttributeCache.get(node);
|
|
9603
|
+
}
|
|
9604
|
+
const result = isPandaAttribute(node, context);
|
|
9605
|
+
pandaAttributeCache.set(node, result);
|
|
9606
|
+
return !!result;
|
|
9607
|
+
};
|
|
9608
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9609
|
+
const isCachedRecipeVariant = (node) => {
|
|
9610
|
+
if (recipeVariantCache.has(node)) {
|
|
9611
|
+
return recipeVariantCache.get(node);
|
|
9612
|
+
}
|
|
9613
|
+
const result = isRecipeVariant(node, context);
|
|
9614
|
+
recipeVariantCache.set(node, result);
|
|
9615
|
+
return !!result;
|
|
9616
|
+
};
|
|
9296
9617
|
const sendReport = (node) => {
|
|
9297
|
-
const longhand =
|
|
9298
|
-
if (!longhand)
|
|
9618
|
+
const longhand = getLonghand(node.name);
|
|
9619
|
+
if (!longhand || longhand === node.name)
|
|
9299
9620
|
return;
|
|
9300
9621
|
const data = {
|
|
9301
9622
|
shorthand: node.name,
|
|
9302
9623
|
longhand
|
|
9303
9624
|
};
|
|
9304
|
-
|
|
9625
|
+
context.report({
|
|
9305
9626
|
node,
|
|
9306
9627
|
messageId: "longhand",
|
|
9307
9628
|
data,
|
|
@@ -9309,9 +9630,7 @@ var rule14 = createRule({
|
|
|
9309
9630
|
{
|
|
9310
9631
|
messageId: "replace",
|
|
9311
9632
|
data,
|
|
9312
|
-
fix: (fixer) =>
|
|
9313
|
-
return fixer.replaceTextRange(node.range, longhand);
|
|
9314
|
-
}
|
|
9633
|
+
fix: (fixer) => fixer.replaceText(node, longhand)
|
|
9315
9634
|
}
|
|
9316
9635
|
]
|
|
9317
9636
|
});
|
|
@@ -9320,16 +9639,16 @@ var rule14 = createRule({
|
|
|
9320
9639
|
JSXAttribute(node) {
|
|
9321
9640
|
if (!isJSXIdentifier(node.name))
|
|
9322
9641
|
return;
|
|
9323
|
-
if (!
|
|
9642
|
+
if (!isCachedPandaProp(node))
|
|
9324
9643
|
return;
|
|
9325
9644
|
sendReport(node.name);
|
|
9326
9645
|
},
|
|
9327
9646
|
Property(node) {
|
|
9328
9647
|
if (!isIdentifier(node.key))
|
|
9329
9648
|
return;
|
|
9330
|
-
if (!
|
|
9649
|
+
if (!isCachedPandaAttribute(node))
|
|
9331
9650
|
return;
|
|
9332
|
-
if (
|
|
9651
|
+
if (isCachedRecipeVariant(node))
|
|
9333
9652
|
return;
|
|
9334
9653
|
sendReport(node.key);
|
|
9335
9654
|
}
|
|
@@ -9348,8 +9667,8 @@ var rule15 = createRule({
|
|
|
9348
9667
|
description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
|
|
9349
9668
|
},
|
|
9350
9669
|
messages: {
|
|
9351
|
-
shorthand: "Use shorthand property of `{{longhand}}
|
|
9352
|
-
replace: "Replace `{{longhand}}` with `{{shorthand}}
|
|
9670
|
+
shorthand: "Use shorthand property instead of `{{longhand}}`. Prefer `{{shorthand}}`.",
|
|
9671
|
+
replace: "Replace `{{longhand}}` with `{{shorthand}}`."
|
|
9353
9672
|
},
|
|
9354
9673
|
type: "suggestion",
|
|
9355
9674
|
hasSuggestions: true,
|
|
@@ -9357,19 +9676,64 @@ var rule15 = createRule({
|
|
|
9357
9676
|
},
|
|
9358
9677
|
defaultOptions: [],
|
|
9359
9678
|
create(context) {
|
|
9679
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9680
|
+
const getLonghand = (name2) => {
|
|
9681
|
+
if (longhandCache.has(name2)) {
|
|
9682
|
+
return longhandCache.get(name2);
|
|
9683
|
+
}
|
|
9684
|
+
const longhand = resolveLonghand(name2, context);
|
|
9685
|
+
longhandCache.set(name2, longhand);
|
|
9686
|
+
return longhand;
|
|
9687
|
+
};
|
|
9688
|
+
const shorthandsCache = /* @__PURE__ */ new Map();
|
|
9689
|
+
const getShorthands = (name2) => {
|
|
9690
|
+
if (shorthandsCache.has(name2)) {
|
|
9691
|
+
return shorthandsCache.get(name2);
|
|
9692
|
+
}
|
|
9693
|
+
const shorthands = resolveShorthands(name2, context);
|
|
9694
|
+
shorthandsCache.set(name2, shorthands);
|
|
9695
|
+
return shorthands;
|
|
9696
|
+
};
|
|
9697
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9698
|
+
const isCachedPandaProp = (node) => {
|
|
9699
|
+
if (pandaPropCache.has(node)) {
|
|
9700
|
+
return pandaPropCache.get(node);
|
|
9701
|
+
}
|
|
9702
|
+
const result = isPandaProp(node, context);
|
|
9703
|
+
pandaPropCache.set(node, result);
|
|
9704
|
+
return !!result;
|
|
9705
|
+
};
|
|
9706
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9707
|
+
const isCachedPandaAttribute = (node) => {
|
|
9708
|
+
if (pandaAttributeCache.has(node)) {
|
|
9709
|
+
return pandaAttributeCache.get(node);
|
|
9710
|
+
}
|
|
9711
|
+
const result = isPandaAttribute(node, context);
|
|
9712
|
+
pandaAttributeCache.set(node, result);
|
|
9713
|
+
return !!result;
|
|
9714
|
+
};
|
|
9715
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9716
|
+
const isCachedRecipeVariant = (node) => {
|
|
9717
|
+
if (recipeVariantCache.has(node)) {
|
|
9718
|
+
return recipeVariantCache.get(node);
|
|
9719
|
+
}
|
|
9720
|
+
const result = isRecipeVariant(node, context);
|
|
9721
|
+
recipeVariantCache.set(node, result);
|
|
9722
|
+
return !!result;
|
|
9723
|
+
};
|
|
9360
9724
|
const sendReport = (node) => {
|
|
9361
|
-
const longhand =
|
|
9725
|
+
const longhand = getLonghand(node.name);
|
|
9362
9726
|
if (longhand)
|
|
9363
9727
|
return;
|
|
9364
|
-
const shorthands =
|
|
9365
|
-
if (!shorthands)
|
|
9728
|
+
const shorthands = getShorthands(node.name);
|
|
9729
|
+
if (!shorthands || shorthands.length === 0)
|
|
9366
9730
|
return;
|
|
9367
|
-
const
|
|
9731
|
+
const shorthandList = shorthands.map((s) => `\`${s}\``).join(", ");
|
|
9368
9732
|
const data = {
|
|
9369
9733
|
longhand: node.name,
|
|
9370
|
-
shorthand
|
|
9734
|
+
shorthand: shorthandList
|
|
9371
9735
|
};
|
|
9372
|
-
|
|
9736
|
+
context.report({
|
|
9373
9737
|
node,
|
|
9374
9738
|
messageId: "shorthand",
|
|
9375
9739
|
data,
|
|
@@ -9377,9 +9741,7 @@ var rule15 = createRule({
|
|
|
9377
9741
|
{
|
|
9378
9742
|
messageId: "replace",
|
|
9379
9743
|
data,
|
|
9380
|
-
fix: (fixer) =>
|
|
9381
|
-
return fixer.replaceTextRange(node.range, shorthands[0]);
|
|
9382
|
-
}
|
|
9744
|
+
fix: (fixer) => fixer.replaceText(node, shorthands[0])
|
|
9383
9745
|
}
|
|
9384
9746
|
]
|
|
9385
9747
|
});
|
|
@@ -9388,16 +9750,16 @@ var rule15 = createRule({
|
|
|
9388
9750
|
JSXAttribute(node) {
|
|
9389
9751
|
if (!isJSXIdentifier(node.name))
|
|
9390
9752
|
return;
|
|
9391
|
-
if (!
|
|
9753
|
+
if (!isCachedPandaProp(node))
|
|
9392
9754
|
return;
|
|
9393
9755
|
sendReport(node.name);
|
|
9394
9756
|
},
|
|
9395
9757
|
Property(node) {
|
|
9396
9758
|
if (!isIdentifier(node.key))
|
|
9397
9759
|
return;
|
|
9398
|
-
if (!
|
|
9760
|
+
if (!isCachedPandaAttribute(node))
|
|
9399
9761
|
return;
|
|
9400
|
-
if (
|
|
9762
|
+
if (isCachedRecipeVariant(node))
|
|
9401
9763
|
return;
|
|
9402
9764
|
sendReport(node.key);
|
|
9403
9765
|
}
|
|
@@ -9532,26 +9894,69 @@ var rule16 = createRule({
|
|
|
9532
9894
|
description: "Encourage the use of atomic properties instead of composite properties in the codebase."
|
|
9533
9895
|
},
|
|
9534
9896
|
messages: {
|
|
9535
|
-
atomic: "Use atomic properties of `{{composite}}
|
|
9897
|
+
atomic: "Use atomic properties instead of `{{composite}}`. Prefer: \n{{atomics}}"
|
|
9536
9898
|
},
|
|
9537
9899
|
type: "suggestion",
|
|
9538
9900
|
schema: []
|
|
9539
9901
|
},
|
|
9540
9902
|
defaultOptions: [],
|
|
9541
9903
|
create(context) {
|
|
9904
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9905
|
+
const getLonghand = (name2) => {
|
|
9906
|
+
if (longhandCache.has(name2)) {
|
|
9907
|
+
return longhandCache.get(name2);
|
|
9908
|
+
}
|
|
9909
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9910
|
+
longhandCache.set(name2, longhand);
|
|
9911
|
+
return longhand;
|
|
9912
|
+
};
|
|
9913
|
+
const compositePropertyCache = /* @__PURE__ */ new Map();
|
|
9542
9914
|
const resolveCompositeProperty = (name2) => {
|
|
9543
|
-
if (
|
|
9915
|
+
if (compositePropertyCache.has(name2)) {
|
|
9916
|
+
return compositePropertyCache.get(name2);
|
|
9917
|
+
}
|
|
9918
|
+
if (Object.hasOwn(compositeProperties, name2)) {
|
|
9919
|
+
compositePropertyCache.set(name2, name2);
|
|
9544
9920
|
return name2;
|
|
9545
|
-
|
|
9546
|
-
|
|
9921
|
+
}
|
|
9922
|
+
const longhand = getLonghand(name2);
|
|
9923
|
+
if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand)) {
|
|
9924
|
+
compositePropertyCache.set(name2, longhand);
|
|
9547
9925
|
return longhand;
|
|
9926
|
+
}
|
|
9927
|
+
compositePropertyCache.set(name2, void 0);
|
|
9928
|
+
return void 0;
|
|
9548
9929
|
};
|
|
9549
|
-
const
|
|
9550
|
-
|
|
9551
|
-
if (
|
|
9552
|
-
return;
|
|
9553
|
-
|
|
9554
|
-
|
|
9930
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9931
|
+
const isCachedPandaProp = (node) => {
|
|
9932
|
+
if (pandaPropCache.has(node)) {
|
|
9933
|
+
return pandaPropCache.get(node);
|
|
9934
|
+
}
|
|
9935
|
+
const result = isPandaProp(node, context);
|
|
9936
|
+
pandaPropCache.set(node, result);
|
|
9937
|
+
return !!result;
|
|
9938
|
+
};
|
|
9939
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9940
|
+
const isCachedPandaAttribute = (node) => {
|
|
9941
|
+
if (pandaAttributeCache.has(node)) {
|
|
9942
|
+
return pandaAttributeCache.get(node);
|
|
9943
|
+
}
|
|
9944
|
+
const result = isPandaAttribute(node, context);
|
|
9945
|
+
pandaAttributeCache.set(node, result);
|
|
9946
|
+
return !!result;
|
|
9947
|
+
};
|
|
9948
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9949
|
+
const isCachedRecipeVariant = (node) => {
|
|
9950
|
+
if (recipeVariantCache.has(node)) {
|
|
9951
|
+
return recipeVariantCache.get(node);
|
|
9952
|
+
}
|
|
9953
|
+
const result = isRecipeVariant(node, context);
|
|
9954
|
+
recipeVariantCache.set(node, result);
|
|
9955
|
+
return !!result;
|
|
9956
|
+
};
|
|
9957
|
+
const sendReport = (node, composite) => {
|
|
9958
|
+
const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(",\n");
|
|
9959
|
+
context.report({
|
|
9555
9960
|
node,
|
|
9556
9961
|
messageId: "atomic",
|
|
9557
9962
|
data: {
|
|
@@ -9564,18 +9969,24 @@ var rule16 = createRule({
|
|
|
9564
9969
|
JSXAttribute(node) {
|
|
9565
9970
|
if (!isJSXIdentifier(node.name))
|
|
9566
9971
|
return;
|
|
9567
|
-
if (!
|
|
9972
|
+
if (!isCachedPandaProp(node))
|
|
9568
9973
|
return;
|
|
9569
|
-
|
|
9974
|
+
const composite = resolveCompositeProperty(node.name.name);
|
|
9975
|
+
if (!composite)
|
|
9976
|
+
return;
|
|
9977
|
+
sendReport(node.name, composite);
|
|
9570
9978
|
},
|
|
9571
9979
|
Property(node) {
|
|
9572
9980
|
if (!isIdentifier(node.key))
|
|
9573
9981
|
return;
|
|
9574
|
-
if (!
|
|
9982
|
+
if (!isCachedPandaAttribute(node))
|
|
9575
9983
|
return;
|
|
9576
|
-
if (
|
|
9984
|
+
if (isCachedRecipeVariant(node))
|
|
9577
9985
|
return;
|
|
9578
|
-
|
|
9986
|
+
const composite = resolveCompositeProperty(node.key.name);
|
|
9987
|
+
if (!composite)
|
|
9988
|
+
return;
|
|
9989
|
+
sendReport(node.key, composite);
|
|
9579
9990
|
}
|
|
9580
9991
|
};
|
|
9581
9992
|
}
|
|
@@ -9592,28 +10003,69 @@ var rule17 = createRule({
|
|
|
9592
10003
|
description: "Encourage the use of composite properties instead of atomic properties in the codebase."
|
|
9593
10004
|
},
|
|
9594
10005
|
messages: {
|
|
9595
|
-
composite: "Use composite property of `{{atomic}}
|
|
10006
|
+
composite: "Use composite property instead of `{{atomic}}`. Prefer: `{{composite}}`."
|
|
9596
10007
|
},
|
|
9597
10008
|
type: "suggestion",
|
|
9598
10009
|
schema: []
|
|
9599
10010
|
},
|
|
9600
10011
|
defaultOptions: [],
|
|
9601
10012
|
create(context) {
|
|
9602
|
-
const
|
|
10013
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
10014
|
+
const getLonghand = (name2) => {
|
|
10015
|
+
if (longhandCache.has(name2)) {
|
|
10016
|
+
return longhandCache.get(name2);
|
|
10017
|
+
}
|
|
9603
10018
|
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
return Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
|
|
10019
|
+
longhandCache.set(name2, longhand);
|
|
10020
|
+
return longhand;
|
|
9607
10021
|
};
|
|
9608
|
-
const
|
|
9609
|
-
|
|
9610
|
-
if (
|
|
9611
|
-
return;
|
|
9612
|
-
|
|
10022
|
+
const compositePropertyCache = /* @__PURE__ */ new Map();
|
|
10023
|
+
const resolveCompositeProperty = (name2) => {
|
|
10024
|
+
if (compositePropertyCache.has(name2)) {
|
|
10025
|
+
return compositePropertyCache.get(name2);
|
|
10026
|
+
}
|
|
10027
|
+
const longhand = getLonghand(name2);
|
|
10028
|
+
if (!isValidProperty(longhand, context)) {
|
|
10029
|
+
compositePropertyCache.set(name2, void 0);
|
|
10030
|
+
return void 0;
|
|
10031
|
+
}
|
|
10032
|
+
const composite = Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
|
|
10033
|
+
compositePropertyCache.set(name2, composite);
|
|
10034
|
+
return composite;
|
|
10035
|
+
};
|
|
10036
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
10037
|
+
const isCachedPandaProp = (node) => {
|
|
10038
|
+
if (pandaPropCache.has(node)) {
|
|
10039
|
+
return pandaPropCache.get(node);
|
|
10040
|
+
}
|
|
10041
|
+
const result = isPandaProp(node, context);
|
|
10042
|
+
pandaPropCache.set(node, result);
|
|
10043
|
+
return !!result;
|
|
10044
|
+
};
|
|
10045
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
10046
|
+
const isCachedPandaAttribute = (node) => {
|
|
10047
|
+
if (pandaAttributeCache.has(node)) {
|
|
10048
|
+
return pandaAttributeCache.get(node);
|
|
10049
|
+
}
|
|
10050
|
+
const result = isPandaAttribute(node, context);
|
|
10051
|
+
pandaAttributeCache.set(node, result);
|
|
10052
|
+
return !!result;
|
|
10053
|
+
};
|
|
10054
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
10055
|
+
const isCachedRecipeVariant = (node) => {
|
|
10056
|
+
if (recipeVariantCache.has(node)) {
|
|
10057
|
+
return recipeVariantCache.get(node);
|
|
10058
|
+
}
|
|
10059
|
+
const result = isRecipeVariant(node, context);
|
|
10060
|
+
recipeVariantCache.set(node, result);
|
|
10061
|
+
return !!result;
|
|
10062
|
+
};
|
|
10063
|
+
const sendReport = (node, composite) => {
|
|
10064
|
+
context.report({
|
|
9613
10065
|
node,
|
|
9614
10066
|
messageId: "composite",
|
|
9615
10067
|
data: {
|
|
9616
|
-
composite
|
|
10068
|
+
composite,
|
|
9617
10069
|
atomic: node.name
|
|
9618
10070
|
}
|
|
9619
10071
|
});
|
|
@@ -9622,18 +10074,24 @@ var rule17 = createRule({
|
|
|
9622
10074
|
JSXAttribute(node) {
|
|
9623
10075
|
if (!isJSXIdentifier(node.name))
|
|
9624
10076
|
return;
|
|
9625
|
-
if (!
|
|
10077
|
+
if (!isCachedPandaProp(node))
|
|
9626
10078
|
return;
|
|
9627
|
-
|
|
10079
|
+
const composite = resolveCompositeProperty(node.name.name);
|
|
10080
|
+
if (!composite)
|
|
10081
|
+
return;
|
|
10082
|
+
sendReport(node.name, composite);
|
|
9628
10083
|
},
|
|
9629
10084
|
Property(node) {
|
|
9630
10085
|
if (!isIdentifier(node.key))
|
|
9631
10086
|
return;
|
|
9632
|
-
if (!
|
|
10087
|
+
if (!isCachedPandaAttribute(node))
|
|
9633
10088
|
return;
|
|
9634
|
-
if (
|
|
10089
|
+
if (isCachedRecipeVariant(node))
|
|
9635
10090
|
return;
|
|
9636
|
-
|
|
10091
|
+
const composite = resolveCompositeProperty(node.key.name);
|
|
10092
|
+
if (!composite)
|
|
10093
|
+
return;
|
|
10094
|
+
sendReport(node.key, composite);
|
|
9637
10095
|
}
|
|
9638
10096
|
};
|
|
9639
10097
|
}
|
|
@@ -9647,35 +10105,82 @@ var rule18 = createRule({
|
|
|
9647
10105
|
name: RULE_NAME18,
|
|
9648
10106
|
meta: {
|
|
9649
10107
|
docs: {
|
|
9650
|
-
description: "Discourage
|
|
10108
|
+
description: "Discourage mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results."
|
|
9651
10109
|
},
|
|
9652
10110
|
messages: {
|
|
9653
|
-
unify: "You're mixing atomic {{atomicProperties}} with composite property {{composite}}
|
|
10111
|
+
unify: "You're mixing atomic {{atomicProperties}} with composite property `{{composite}}`. Prefer atomic styling to mixing atomic and composite properties. Remove `{{composite}}` and use one or more of {{atomics}} instead."
|
|
9654
10112
|
},
|
|
9655
10113
|
type: "suggestion",
|
|
9656
10114
|
schema: []
|
|
9657
10115
|
},
|
|
9658
10116
|
defaultOptions: [],
|
|
9659
10117
|
create(context) {
|
|
9660
|
-
const
|
|
10118
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
10119
|
+
const getLonghand = (name2) => {
|
|
10120
|
+
if (longhandCache.has(name2)) {
|
|
10121
|
+
return longhandCache.get(name2);
|
|
10122
|
+
}
|
|
10123
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
10124
|
+
longhandCache.set(name2, longhand);
|
|
10125
|
+
return longhand;
|
|
10126
|
+
};
|
|
10127
|
+
const compositePropertyCache = /* @__PURE__ */ new Map();
|
|
9661
10128
|
const resolveCompositeProperty = (name2) => {
|
|
9662
|
-
if (name2
|
|
10129
|
+
if (compositePropertyCache.has(name2)) {
|
|
10130
|
+
return compositePropertyCache.get(name2);
|
|
10131
|
+
}
|
|
10132
|
+
if (name2 in compositeProperties) {
|
|
10133
|
+
compositePropertyCache.set(name2, name2);
|
|
9663
10134
|
return name2;
|
|
10135
|
+
}
|
|
9664
10136
|
const longhand = getLonghand(name2);
|
|
9665
|
-
if (isValidProperty(longhand, context) && longhand in compositeProperties)
|
|
10137
|
+
if (isValidProperty(longhand, context) && longhand in compositeProperties) {
|
|
10138
|
+
compositePropertyCache.set(name2, longhand);
|
|
9666
10139
|
return longhand;
|
|
10140
|
+
}
|
|
10141
|
+
compositePropertyCache.set(name2, void 0);
|
|
10142
|
+
return void 0;
|
|
10143
|
+
};
|
|
10144
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
10145
|
+
const isCachedPandaProp = (node) => {
|
|
10146
|
+
if (pandaPropCache.has(node)) {
|
|
10147
|
+
return pandaPropCache.get(node);
|
|
10148
|
+
}
|
|
10149
|
+
const result = isPandaProp(node, context);
|
|
10150
|
+
pandaPropCache.set(node, result);
|
|
10151
|
+
return !!result;
|
|
10152
|
+
};
|
|
10153
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
10154
|
+
const isCachedPandaAttribute = (node) => {
|
|
10155
|
+
if (pandaAttributeCache.has(node)) {
|
|
10156
|
+
return pandaAttributeCache.get(node);
|
|
10157
|
+
}
|
|
10158
|
+
const result = isPandaAttribute(node, context);
|
|
10159
|
+
pandaAttributeCache.set(node, result);
|
|
10160
|
+
return !!result;
|
|
9667
10161
|
};
|
|
9668
|
-
const
|
|
9669
|
-
|
|
9670
|
-
if (
|
|
10162
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
10163
|
+
const isCachedRecipeVariant = (node) => {
|
|
10164
|
+
if (recipeVariantCache.has(node)) {
|
|
10165
|
+
return recipeVariantCache.get(node);
|
|
10166
|
+
}
|
|
10167
|
+
const result = isRecipeVariant(node, context);
|
|
10168
|
+
recipeVariantCache.set(node, result);
|
|
10169
|
+
return !!result;
|
|
10170
|
+
};
|
|
10171
|
+
const sendReport = (node, composite, siblings) => {
|
|
10172
|
+
const atomicPropertiesSet = new Set(
|
|
10173
|
+
siblings.filter((prop) => compositeProperties[composite].includes(getLonghand(prop)))
|
|
10174
|
+
);
|
|
10175
|
+
if (atomicPropertiesSet.size === 0)
|
|
9671
10176
|
return;
|
|
9672
|
-
const atomicProperties =
|
|
9673
|
-
const atomics = compositeProperties[
|
|
10177
|
+
const atomicProperties = Array.from(atomicPropertiesSet).map((prop) => `\`${prop}\``).join(", ");
|
|
10178
|
+
const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(", ");
|
|
9674
10179
|
context.report({
|
|
9675
10180
|
node,
|
|
9676
10181
|
messageId: "unify",
|
|
9677
10182
|
data: {
|
|
9678
|
-
composite
|
|
10183
|
+
composite,
|
|
9679
10184
|
atomicProperties,
|
|
9680
10185
|
atomics
|
|
9681
10186
|
}
|
|
@@ -9685,30 +10190,30 @@ var rule18 = createRule({
|
|
|
9685
10190
|
JSXAttribute(node) {
|
|
9686
10191
|
if (!isJSXIdentifier(node.name))
|
|
9687
10192
|
return;
|
|
9688
|
-
if (!
|
|
10193
|
+
if (!isCachedPandaProp(node))
|
|
9689
10194
|
return;
|
|
9690
|
-
const
|
|
9691
|
-
if (!
|
|
10195
|
+
const composite = resolveCompositeProperty(node.name.name);
|
|
10196
|
+
if (!composite)
|
|
9692
10197
|
return;
|
|
9693
10198
|
if (!isJSXOpeningElement(node.parent))
|
|
9694
10199
|
return;
|
|
9695
10200
|
const siblings = node.parent.attributes.map((attr) => attr.name.name);
|
|
9696
|
-
sendReport(node,
|
|
10201
|
+
sendReport(node, composite, siblings);
|
|
9697
10202
|
},
|
|
9698
10203
|
Property(node) {
|
|
9699
10204
|
if (!isIdentifier(node.key))
|
|
9700
10205
|
return;
|
|
9701
|
-
if (!
|
|
10206
|
+
if (!isCachedPandaAttribute(node))
|
|
9702
10207
|
return;
|
|
9703
|
-
if (
|
|
10208
|
+
if (isCachedRecipeVariant(node))
|
|
9704
10209
|
return;
|
|
9705
|
-
const
|
|
9706
|
-
if (!
|
|
10210
|
+
const composite = resolveCompositeProperty(node.key.name);
|
|
10211
|
+
if (!composite)
|
|
9707
10212
|
return;
|
|
9708
10213
|
if (!isObjectExpression(node.parent))
|
|
9709
10214
|
return;
|
|
9710
|
-
const siblings = node.parent.properties.map((prop) => isIdentifier(prop.key)
|
|
9711
|
-
sendReport(node.key,
|
|
10215
|
+
const siblings = node.parent.properties.filter((prop) => prop.type === "Property").map((prop) => isIdentifier(prop.key) ? prop.key.name : "");
|
|
10216
|
+
sendReport(node.key, composite, siblings);
|
|
9712
10217
|
}
|
|
9713
10218
|
};
|
|
9714
10219
|
}
|