@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.mjs CHANGED
@@ -10,7 +10,7 @@ var name, version;
10
10
  var init_package = __esm({
11
11
  "package.json"() {
12
12
  name = "@pandacss/eslint-plugin";
13
- version = "0.1.15";
13
+ version = "0.2.0";
14
14
  }
15
15
  });
16
16
 
@@ -34,7 +34,8 @@ var init_utils = __esm({
34
34
  try {
35
35
  return _syncAction(...args);
36
36
  } catch (error) {
37
- return;
37
+ console.error("syncAction error:", error);
38
+ return void 0;
38
39
  }
39
40
  };
40
41
  }
@@ -8008,7 +8009,7 @@ function isRecipeVariant(node, context) {
8008
8009
  if (length < requiredLength + extraLength)
8009
8010
  return true;
8010
8011
  }
8011
- var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, hasPkgImport, isPandaConfigFunction, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isStyledProperty, isInPandaFunction, isInJSXProp, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport, getTaggedTemplateCaller;
8012
+ var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, hasPkgImport, isPandaConfigFunction, _getImports, importsCache, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isStyledProperty, isInPandaFunction, isInJSXProp, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, invalidTokensCache, extractTokens, getInvalidTokens, getTokenImport, getTaggedTemplateCaller;
8012
8013
  var init_helpers = __esm({
8013
8014
  "src/utils/helpers.ts"() {
8014
8015
  "use strict";
@@ -8064,13 +8065,17 @@ var init_helpers = __esm({
8064
8065
  }));
8065
8066
  return imports;
8066
8067
  };
8068
+ importsCache = /* @__PURE__ */ new WeakMap();
8067
8069
  getImports = (context) => {
8070
+ if (importsCache.has(context)) {
8071
+ return importsCache.get(context);
8072
+ }
8068
8073
  const imports = _getImports(context);
8069
- return imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
8074
+ const filteredImports = imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
8075
+ importsCache.set(context, filteredImports);
8076
+ return filteredImports;
8070
8077
  };
8071
8078
  isValidStyledProp = (node, context) => {
8072
- if (typeof node === "string")
8073
- return;
8074
8079
  return isJSXIdentifier(node) && isValidProperty(node.name, context);
8075
8080
  };
8076
8081
  isPandaIsh = (name2, context) => {
@@ -8088,7 +8093,8 @@ var init_helpers = __esm({
8088
8093
  if (isVariableDeclarator(decl))
8089
8094
  return decl;
8090
8095
  } catch (error) {
8091
- return;
8096
+ console.error("Error in findDeclaration:", error);
8097
+ return void 0;
8092
8098
  }
8093
8099
  };
8094
8100
  isLocalStyledFactory = (node, context) => {
@@ -8164,6 +8170,8 @@ var init_helpers = __esm({
8164
8170
  return;
8165
8171
  if (!isPandaProp(jsxAttrAncestor, context))
8166
8172
  return;
8173
+ if (typeof jsxAttrAncestor.name === "string")
8174
+ return;
8167
8175
  if (!isValidStyledProp(jsxAttrAncestor.name, context))
8168
8176
  return;
8169
8177
  return true;
@@ -8192,6 +8200,7 @@ var init_helpers = __esm({
8192
8200
  return;
8193
8201
  return syncAction("isColorToken", getSyncOpts(context), value);
8194
8202
  };
8203
+ invalidTokensCache = /* @__PURE__ */ new Map();
8195
8204
  extractTokens = (value) => {
8196
8205
  const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{}]+)\}/g;
8197
8206
  const matches = [];
@@ -8209,10 +8218,15 @@ var init_helpers = __esm({
8209
8218
  return matches.filter(Boolean);
8210
8219
  };
8211
8220
  getInvalidTokens = (value, context) => {
8221
+ if (invalidTokensCache.has(value)) {
8222
+ return invalidTokensCache.get(value);
8223
+ }
8212
8224
  const tokens = extractTokens(value);
8213
8225
  if (!tokens.length)
8214
8226
  return [];
8215
- return syncAction("filterInvalidTokens", getSyncOpts(context), tokens);
8227
+ const invalidTokens = syncAction("filterInvalidTokens", getSyncOpts(context), tokens);
8228
+ invalidTokensCache.set(value, invalidTokens);
8229
+ return invalidTokens;
8216
8230
  };
8217
8231
  getTokenImport = (context) => {
8218
8232
  const imports = _getImports(context);
@@ -8237,6 +8251,7 @@ var init_helpers = __esm({
8237
8251
  });
8238
8252
 
8239
8253
  // src/rules/file-not-included.ts
8254
+ import "@typescript-eslint/utils";
8240
8255
  var RULE_NAME, rule, file_not_included_default;
8241
8256
  var init_file_not_included = __esm({
8242
8257
  "src/rules/file-not-included.ts"() {
@@ -8249,26 +8264,32 @@ var init_file_not_included = __esm({
8249
8264
  name: RULE_NAME,
8250
8265
  meta: {
8251
8266
  docs: {
8252
- description: "Disallow the use of panda css in files that are not included in the specified panda `include` config."
8267
+ description: "Disallow the use of Panda CSS in files that are not included in the specified Panda CSS `include` config."
8253
8268
  },
8254
8269
  messages: {
8255
- include: "The use of Panda CSS is not allowed in this file. Please check the specified `include` config."
8270
+ include: "The use of Panda CSS is not allowed in this file. Please ensure the file is included in the Panda CSS `include` configuration."
8256
8271
  },
8257
- type: "suggestion",
8272
+ type: "problem",
8258
8273
  schema: []
8259
8274
  },
8260
8275
  defaultOptions: [],
8261
8276
  create(context) {
8277
+ const isFileIncluded = isValidFile(context);
8278
+ if (isFileIncluded) {
8279
+ return {};
8280
+ }
8281
+ let hasReported = false;
8262
8282
  return {
8263
8283
  ImportDeclaration(node) {
8264
- if (!isPandaImport(node, context))
8284
+ if (hasReported)
8265
8285
  return;
8266
- if (isValidFile(context))
8286
+ if (!isPandaImport(node, context))
8267
8287
  return;
8268
8288
  context.report({
8269
8289
  node,
8270
8290
  messageId: "include"
8271
8291
  });
8292
+ hasReported = true;
8272
8293
  }
8273
8294
  };
8274
8295
  }
@@ -8278,7 +8299,8 @@ var init_file_not_included = __esm({
8278
8299
  });
8279
8300
 
8280
8301
  // src/rules/no-config-function-in-source.ts
8281
- var RULE_NAME2, rule2, no_config_function_in_source_default, CONFIG_FUNCTIONS;
8302
+ import "@typescript-eslint/utils";
8303
+ var RULE_NAME2, CONFIG_FUNCTIONS, rule2, no_config_function_in_source_default;
8282
8304
  var init_no_config_function_in_source = __esm({
8283
8305
  "src/rules/no-config-function-in-source.ts"() {
8284
8306
  "use strict";
@@ -8287,55 +8309,80 @@ var init_no_config_function_in_source = __esm({
8287
8309
  init_utils();
8288
8310
  init_helpers();
8289
8311
  RULE_NAME2 = "no-config-function-in-source";
8312
+ CONFIG_FUNCTIONS = /* @__PURE__ */ new Set([
8313
+ "defineConfig",
8314
+ "defineRecipe",
8315
+ "defineSlotRecipe",
8316
+ "defineParts",
8317
+ "definePattern",
8318
+ "definePreset",
8319
+ "defineKeyframes",
8320
+ "defineGlobalStyles",
8321
+ "defineUtility",
8322
+ "defineTextStyles",
8323
+ "defineLayerStyles",
8324
+ "defineStyles",
8325
+ "defineTokens",
8326
+ "defineSemanticTokens"
8327
+ ]);
8290
8328
  rule2 = createRule({
8291
8329
  name: RULE_NAME2,
8292
8330
  meta: {
8293
8331
  docs: {
8294
- description: "Prohibit the use of config functions outside the Panda config."
8332
+ description: "Prohibit the use of config functions outside the Panda config file."
8295
8333
  },
8296
8334
  messages: {
8297
- configFunction: "Unnecessary`{{name}}` call. \nConfig functions should only be used in panda config.",
8335
+ configFunction: "Unnecessary `{{name}}` call. Config functions should only be used in the Panda config file.",
8298
8336
  delete: "Delete `{{name}}` call."
8299
8337
  },
8300
- type: "suggestion",
8338
+ type: "problem",
8301
8339
  hasSuggestions: true,
8302
8340
  schema: []
8303
8341
  },
8304
8342
  defaultOptions: [],
8305
8343
  create(context) {
8306
- if (!hasPkgImport(context))
8344
+ if (!hasPkgImport(context)) {
8345
+ return {};
8346
+ }
8347
+ const isPandaFile = isValidFile(context);
8348
+ if (!isPandaFile) {
8307
8349
  return {};
8350
+ }
8308
8351
  return {
8309
8352
  CallExpression(node) {
8310
- if (!isValidFile(context))
8311
- return;
8312
8353
  if (!isIdentifier(node.callee))
8313
8354
  return;
8314
- if (!CONFIG_FUNCTIONS.includes(node.callee.name))
8355
+ const functionName = node.callee.name;
8356
+ if (!CONFIG_FUNCTIONS.has(functionName))
8315
8357
  return;
8316
- if (!isPandaConfigFunction(context, node.callee.name))
8358
+ if (!isPandaConfigFunction(context, functionName))
8317
8359
  return;
8318
8360
  context.report({
8319
8361
  node,
8320
8362
  messageId: "configFunction",
8321
8363
  data: {
8322
- name: node.callee.name
8364
+ name: functionName
8323
8365
  },
8324
8366
  suggest: [
8325
8367
  {
8326
8368
  messageId: "delete",
8327
8369
  data: {
8328
- name: node.callee.name
8370
+ name: functionName
8329
8371
  },
8330
8372
  fix(fixer) {
8331
8373
  const declaration = getAncestor(isVariableDeclaration, node);
8332
- const importSpec = getImportSpecifiers(context).find(
8333
- (s) => isIdentifier(node.callee) && s.specifier.local.name === node.callee.name
8334
- );
8335
- return [
8336
- fixer.remove(declaration ?? node),
8337
- importSpec?.specifier ? fixer.remove(importSpec?.specifier) : {}
8338
- ];
8374
+ const importSpecifiers = getImportSpecifiers(context);
8375
+ const importSpec = importSpecifiers.find((s) => s.specifier.local.name === functionName);
8376
+ const fixes = [];
8377
+ if (declaration) {
8378
+ fixes.push(fixer.remove(declaration));
8379
+ } else {
8380
+ fixes.push(fixer.remove(node));
8381
+ }
8382
+ if (importSpec?.specifier) {
8383
+ fixes.push(fixer.remove(importSpec.specifier));
8384
+ }
8385
+ return fixes;
8339
8386
  }
8340
8387
  }
8341
8388
  ]
@@ -8345,32 +8392,16 @@ var init_no_config_function_in_source = __esm({
8345
8392
  }
8346
8393
  });
8347
8394
  no_config_function_in_source_default = rule2;
8348
- CONFIG_FUNCTIONS = [
8349
- "defineConfig",
8350
- "defineRecipe",
8351
- "defineSlotRecipe",
8352
- "defineParts",
8353
- "definePattern",
8354
- "definePreset",
8355
- "defineKeyframes",
8356
- "defineGlobalStyles",
8357
- "defineUtility",
8358
- "defineTextStyles",
8359
- "defineLayerStyles",
8360
- "defineStyles",
8361
- "defineTokens",
8362
- "defineSemanticTokens"
8363
- ];
8364
8395
  }
8365
8396
  });
8366
8397
 
8367
8398
  // src/rules/no-debug.ts
8399
+ import "@typescript-eslint/utils";
8368
8400
  var RULE_NAME3, rule3, no_debug_default;
8369
8401
  var init_no_debug = __esm({
8370
8402
  "src/rules/no-debug.ts"() {
8371
8403
  "use strict";
8372
8404
  init_esm_shims();
8373
- init_nodes();
8374
8405
  init_utils();
8375
8406
  init_helpers();
8376
8407
  RULE_NAME3 = "no-debug";
@@ -8385,16 +8416,14 @@ var init_no_debug = __esm({
8385
8416
  prop: "Remove the debug prop.",
8386
8417
  property: "Remove the debug property."
8387
8418
  },
8388
- type: "suggestion",
8419
+ type: "problem",
8389
8420
  hasSuggestions: true,
8390
8421
  schema: []
8391
8422
  },
8392
8423
  defaultOptions: [],
8393
8424
  create(context) {
8394
8425
  return {
8395
- JSXAttribute(node) {
8396
- if (!isJSXIdentifier(node.name) || node.name.name !== "debug")
8397
- return;
8426
+ 'JSXAttribute[name.name="debug"]'(node) {
8398
8427
  if (!isPandaProp(node, context))
8399
8428
  return;
8400
8429
  context.report({
@@ -8408,9 +8437,7 @@ var init_no_debug = __esm({
8408
8437
  ]
8409
8438
  });
8410
8439
  },
8411
- Property(node) {
8412
- if (!isIdentifier(node.key) || node.key.name !== "debug")
8413
- return;
8440
+ 'Property[key.name="debug"]'(node) {
8414
8441
  if (!isPandaAttribute(node, context))
8415
8442
  return;
8416
8443
  if (isRecipeVariant(node, context))
@@ -8434,20 +8461,7 @@ var init_no_debug = __esm({
8434
8461
  });
8435
8462
 
8436
8463
  // src/rules/no-dynamic-styling.ts
8437
- function checkArrayElements(array, context) {
8438
- array.elements.forEach((node) => {
8439
- if (!node)
8440
- return;
8441
- if (isLiteral(node))
8442
- return;
8443
- if (isTemplateLiteral(node) && node.expressions.length === 0)
8444
- return;
8445
- context.report({
8446
- node,
8447
- messageId: "dynamic"
8448
- });
8449
- });
8450
- }
8464
+ import "@typescript-eslint/utils";
8451
8465
  var RULE_NAME4, rule4, no_dynamic_styling_default;
8452
8466
  var init_no_dynamic_styling = __esm({
8453
8467
  "src/rules/no-dynamic-styling.ts"() {
@@ -8461,42 +8475,66 @@ var init_no_dynamic_styling = __esm({
8461
8475
  name: RULE_NAME4,
8462
8476
  meta: {
8463
8477
  docs: {
8464
- description: "Ensure user doesn't use dynamic styling at any point. \nPrefer to use static styles, leverage css variables or recipes for known dynamic styles."
8478
+ description: "Ensure users don't use dynamic styling. Prefer static styles, leverage CSS variables, or recipes for known dynamic styles."
8465
8479
  },
8466
8480
  messages: {
8467
- dynamic: "Remove dynamic value. Prefer static styles",
8468
- dynamicProperty: "Remove dynamic property. Prefer static style property",
8469
- dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition"
8481
+ dynamic: "Remove dynamic value. Prefer static styles.",
8482
+ dynamicProperty: "Remove dynamic property. Prefer static style property.",
8483
+ dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition."
8470
8484
  },
8471
- type: "suggestion",
8485
+ type: "problem",
8472
8486
  schema: []
8473
8487
  },
8474
8488
  defaultOptions: [],
8475
8489
  create(context) {
8490
+ function isStaticValue(node) {
8491
+ if (!node)
8492
+ return false;
8493
+ if (isLiteral(node))
8494
+ return true;
8495
+ if (isTemplateLiteral(node) && node.expressions.length === 0)
8496
+ return true;
8497
+ if (isObjectExpression(node))
8498
+ return true;
8499
+ return false;
8500
+ }
8501
+ function checkArrayElements(array) {
8502
+ array.elements.forEach((element) => {
8503
+ if (!element)
8504
+ return;
8505
+ if (isStaticValue(element))
8506
+ return;
8507
+ context.report({
8508
+ node: element,
8509
+ messageId: "dynamic"
8510
+ });
8511
+ });
8512
+ }
8476
8513
  return {
8514
+ // JSX Attributes
8477
8515
  JSXAttribute(node) {
8478
8516
  if (!node.value)
8479
8517
  return;
8480
8518
  if (isLiteral(node.value))
8481
8519
  return;
8482
- if (isJSXExpressionContainer(node.value) && isLiteral(node.value.expression))
8483
- return;
8484
- if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
8485
- return;
8486
- if (isObjectExpression(node.value.expression))
8487
- return;
8488
8520
  if (!isPandaProp(node, context))
8489
8521
  return;
8490
- if (isArrayExpression(node.value.expression)) {
8491
- return checkArrayElements(node.value.expression, context);
8522
+ if (isJSXExpressionContainer(node.value)) {
8523
+ const expr = node.value.expression;
8524
+ if (isStaticValue(expr))
8525
+ return;
8526
+ if (isArrayExpression(expr)) {
8527
+ checkArrayElements(expr);
8528
+ return;
8529
+ }
8492
8530
  }
8493
8531
  context.report({
8494
8532
  node: node.value,
8495
8533
  messageId: "dynamic"
8496
8534
  });
8497
8535
  },
8498
- // Dynamic properties
8499
- "Property[computed=true]"(node) {
8536
+ // Dynamic properties with computed keys
8537
+ "Property[computed=true]": (node) => {
8500
8538
  if (!isInPandaFunction(node, context))
8501
8539
  return;
8502
8540
  context.report({
@@ -8504,19 +8542,19 @@ var init_no_dynamic_styling = __esm({
8504
8542
  messageId: isRecipeVariant(node, context) ? "dynamicRecipeVariant" : "dynamicProperty"
8505
8543
  });
8506
8544
  },
8545
+ // Object Properties
8507
8546
  Property(node) {
8508
8547
  if (!isIdentifier(node.key))
8509
8548
  return;
8510
- if (isLiteral(node.value))
8511
- return;
8512
- if (isTemplateLiteral(node.value) && node.value.expressions.length === 0)
8549
+ if (!isPandaAttribute(node, context))
8513
8550
  return;
8514
- if (isObjectExpression(node.value))
8551
+ if (isRecipeVariant(node, context))
8515
8552
  return;
8516
- if (!isPandaAttribute(node, context))
8553
+ if (isStaticValue(node.value))
8517
8554
  return;
8518
8555
  if (isArrayExpression(node.value)) {
8519
- return checkArrayElements(node.value, context);
8556
+ checkArrayElements(node.value);
8557
+ return;
8520
8558
  }
8521
8559
  context.report({
8522
8560
  node: node.value,
@@ -8532,6 +8570,7 @@ var init_no_dynamic_styling = __esm({
8532
8570
 
8533
8571
  // src/rules/no-escape-hatch.ts
8534
8572
  import { getArbitraryValue } from "@pandacss/shared";
8573
+ import "@typescript-eslint/utils";
8535
8574
  var RULE_NAME5, rule5, no_escape_hatch_default;
8536
8575
  var init_no_escape_hatch = __esm({
8537
8576
  "src/rules/no-escape-hatch.ts"() {
@@ -8548,47 +8587,37 @@ var init_no_escape_hatch = __esm({
8548
8587
  description: "Prohibit the use of escape hatch syntax in the code."
8549
8588
  },
8550
8589
  messages: {
8551
- escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. \nDefine a corresponding token in your design system for better consistency and maintainability.",
8590
+ escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. Define a corresponding token in your design system for better consistency and maintainability.",
8552
8591
  remove: "Remove the square brackets (`[]`)."
8553
8592
  },
8554
- type: "suggestion",
8593
+ type: "problem",
8555
8594
  hasSuggestions: true,
8556
8595
  schema: []
8557
8596
  },
8558
8597
  defaultOptions: [],
8559
8598
  create(context) {
8560
- const removeQuotes = ([start, end]) => [start + 1, end - 1];
8599
+ const removeBrackets = (range) => {
8600
+ const [start, end] = range;
8601
+ return [start + 1, end - 1];
8602
+ };
8561
8603
  const hasEscapeHatch = (value) => {
8562
8604
  if (!value)
8563
8605
  return false;
8606
+ if (!value.includes("["))
8607
+ return false;
8564
8608
  return getArbitraryValue(value) !== value.trim();
8565
8609
  };
8566
- const handleLiteral = (node) => {
8567
- if (!isLiteral(node))
8568
- return;
8569
- if (!hasEscapeHatch(node.value?.toString()))
8570
- return;
8571
- sendReport(node);
8572
- };
8573
- const handleTemplateLiteral = (node) => {
8574
- if (!isTemplateLiteral(node))
8575
- return;
8576
- if (node.expressions.length > 0)
8610
+ const handleNodeValue = (node, value) => {
8611
+ if (!hasEscapeHatch(value))
8577
8612
  return;
8578
- if (!hasEscapeHatch(node.quasis[0].value.raw))
8579
- return;
8580
- sendReport(node.quasis[0], node.quasis[0].value.raw);
8581
- };
8582
- const sendReport = (node, _value) => {
8583
- const value = _value ?? node.value?.toString();
8584
- return context.report({
8613
+ context.report({
8585
8614
  node,
8586
8615
  messageId: "escapeHatch",
8587
8616
  suggest: [
8588
8617
  {
8589
8618
  messageId: "remove",
8590
8619
  fix: (fixer) => {
8591
- return fixer.replaceTextRange(removeQuotes(node.range), getArbitraryValue(value));
8620
+ return fixer.replaceTextRange(removeBrackets(node.range), getArbitraryValue(value));
8592
8621
  }
8593
8622
  }
8594
8623
  ]
@@ -8600,23 +8629,36 @@ var init_no_escape_hatch = __esm({
8600
8629
  return;
8601
8630
  if (!isPandaProp(node, context))
8602
8631
  return;
8603
- handleLiteral(node.value);
8604
- if (!isJSXExpressionContainer(node.value))
8605
- return;
8606
- handleLiteral(node.value.expression);
8607
- handleTemplateLiteral(node.value.expression);
8632
+ const { value } = node;
8633
+ if (isLiteral(value)) {
8634
+ const val = value.value?.toString() ?? "";
8635
+ handleNodeValue(value, val);
8636
+ } else if (isJSXExpressionContainer(value)) {
8637
+ const expr = value.expression;
8638
+ if (isLiteral(expr)) {
8639
+ const val = expr.value?.toString() ?? "";
8640
+ handleNodeValue(expr, val);
8641
+ } else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
8642
+ const val = expr.quasis[0].value.raw;
8643
+ handleNodeValue(expr.quasis[0], val);
8644
+ }
8645
+ }
8608
8646
  },
8609
8647
  Property(node) {
8610
8648
  if (!isIdentifier(node.key))
8611
8649
  return;
8612
- if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
8613
- return;
8614
8650
  if (!isPandaAttribute(node, context))
8615
8651
  return;
8616
8652
  if (isRecipeVariant(node, context))
8617
8653
  return;
8618
- handleLiteral(node.value);
8619
- handleTemplateLiteral(node.value);
8654
+ const value = node.value;
8655
+ if (isLiteral(value)) {
8656
+ const val = value.value?.toString() ?? "";
8657
+ handleNodeValue(value, val);
8658
+ } else if (isTemplateLiteral(value) && value.expressions.length === 0) {
8659
+ const val = value.quasis[0].value.raw;
8660
+ handleNodeValue(value.quasis[0], val);
8661
+ }
8620
8662
  }
8621
8663
  };
8622
8664
  }
@@ -8626,6 +8668,7 @@ var init_no_escape_hatch = __esm({
8626
8668
  });
8627
8669
 
8628
8670
  // src/rules/no-hardcoded-color.ts
8671
+ import "@typescript-eslint/utils";
8629
8672
  var RULE_NAME6, rule6, no_hardcoded_color_default;
8630
8673
  var init_no_hardcoded_color = __esm({
8631
8674
  "src/rules/no-hardcoded-color.ts"() {
@@ -8644,7 +8687,7 @@ var init_no_hardcoded_color = __esm({
8644
8687
  messages: {
8645
8688
  invalidColor: "`{{color}}` is not a valid color token."
8646
8689
  },
8647
- type: "suggestion",
8690
+ type: "problem",
8648
8691
  schema: [
8649
8692
  {
8650
8693
  type: "object",
@@ -8652,7 +8695,8 @@ var init_no_hardcoded_color = __esm({
8652
8695
  noOpacity: {
8653
8696
  type: "boolean"
8654
8697
  }
8655
- }
8698
+ },
8699
+ additionalProperties: false
8656
8700
  }
8657
8701
  ]
8658
8702
  },
@@ -8663,19 +8707,55 @@ var init_no_hardcoded_color = __esm({
8663
8707
  ],
8664
8708
  create(context) {
8665
8709
  const noOpacity = context.options[0]?.noOpacity;
8666
- const isTokenFn = (value) => {
8710
+ const colorTokenCache = /* @__PURE__ */ new Map();
8711
+ const colorAttributeCache = /* @__PURE__ */ new Map();
8712
+ const isColorToken2 = (token) => {
8713
+ if (colorTokenCache.has(token)) {
8714
+ return colorTokenCache.get(token);
8715
+ }
8716
+ const result = isColorToken(token, context);
8717
+ colorTokenCache.set(token, result);
8718
+ return !!result;
8719
+ };
8720
+ const isColorAttribute2 = (attribute) => {
8721
+ if (colorAttributeCache.has(attribute)) {
8722
+ return colorAttributeCache.get(attribute);
8723
+ }
8724
+ const result = isColorAttribute(attribute, context);
8725
+ colorAttributeCache.set(attribute, result);
8726
+ return result;
8727
+ };
8728
+ const isTokenFunctionUsed = (value) => {
8667
8729
  if (!value)
8668
8730
  return false;
8669
8731
  const tokens = extractTokens(value);
8670
8732
  return tokens.length > 0;
8671
8733
  };
8672
- const testColorToken = (value) => {
8734
+ const isValidColorToken = (value) => {
8673
8735
  if (!value)
8674
8736
  return false;
8675
- const color = value?.split("/");
8676
- const isOpacityToken = !!color[1]?.length;
8677
- const isValidToken = isColorToken(color[0], context);
8678
- return noOpacity ? isValidToken && !isOpacityToken : isValidToken;
8737
+ const [colorToken, opacity] = value.split("/");
8738
+ const hasOpacity = opacity !== void 0 && opacity.length > 0;
8739
+ const isValidToken = isColorToken2(colorToken);
8740
+ return noOpacity ? isValidToken && !hasOpacity : isValidToken;
8741
+ };
8742
+ const reportInvalidColor = (node, color) => {
8743
+ context.report({
8744
+ node,
8745
+ messageId: "invalidColor",
8746
+ data: {
8747
+ color
8748
+ }
8749
+ });
8750
+ };
8751
+ const checkColorValue = (node, value, attributeName) => {
8752
+ if (!isColorAttribute2(attributeName))
8753
+ return;
8754
+ if (isTokenFunctionUsed(value))
8755
+ return;
8756
+ if (isValidColorToken(value))
8757
+ return;
8758
+ reportInvalidColor(node, value);
8679
8759
  };
8680
8760
  return {
8681
8761
  JSXAttribute(node) {
@@ -8683,49 +8763,38 @@ var init_no_hardcoded_color = __esm({
8683
8763
  return;
8684
8764
  if (!isPandaProp(node, context) || !node.value)
8685
8765
  return;
8686
- if (isLiteral(node.value) && isColorAttribute(node.name.name, context) && !isTokenFn(node.value.value?.toString()) && !testColorToken(node.value.value?.toString())) {
8687
- context.report({
8688
- node: node.value,
8689
- messageId: "invalidColor",
8690
- data: {
8691
- color: node.value.value?.toString()
8692
- }
8693
- });
8694
- }
8695
- if (!isJSXExpressionContainer(node.value))
8696
- return;
8697
- if (isLiteral(node.value.expression) && isColorAttribute(node.name.name, context) && !isTokenFn(node.value.expression.value?.toString()) && !testColorToken(node.value.expression.value?.toString())) {
8698
- context.report({
8699
- node: node.value.expression,
8700
- messageId: "invalidColor",
8701
- data: {
8702
- color: node.value.expression.value?.toString()
8703
- }
8704
- });
8766
+ const attributeName = node.name.name;
8767
+ const valueNode = node.value;
8768
+ if (isLiteral(valueNode)) {
8769
+ const value = valueNode.value?.toString() || "";
8770
+ checkColorValue(valueNode, value, attributeName);
8771
+ } else if (isJSXExpressionContainer(valueNode)) {
8772
+ const expression = valueNode.expression;
8773
+ if (isLiteral(expression)) {
8774
+ const value = expression.value?.toString() || "";
8775
+ checkColorValue(expression, value, attributeName);
8776
+ } else if (isTemplateLiteral(expression) && expression.expressions.length === 0) {
8777
+ const value = expression.quasis[0].value.raw;
8778
+ checkColorValue(expression.quasis[0], value, attributeName);
8779
+ }
8705
8780
  }
8706
8781
  },
8707
8782
  Property(node) {
8708
8783
  if (!isIdentifier(node.key))
8709
8784
  return;
8710
- if (!isLiteral(node.value))
8711
- return;
8712
8785
  if (!isPandaAttribute(node, context))
8713
8786
  return;
8714
8787
  if (isRecipeVariant(node, context))
8715
8788
  return;
8716
- if (!isColorAttribute(node.key.name, context))
8717
- return;
8718
- if (isTokenFn(node.value.value?.toString()))
8719
- return;
8720
- if (testColorToken(node.value.value?.toString()))
8721
- return;
8722
- context.report({
8723
- node: node.value,
8724
- messageId: "invalidColor",
8725
- data: {
8726
- color: node.value.value?.toString()
8727
- }
8728
- });
8789
+ const attributeName = node.key.name;
8790
+ const valueNode = node.value;
8791
+ if (isLiteral(valueNode)) {
8792
+ const value = valueNode.value?.toString() || "";
8793
+ checkColorValue(valueNode, value, attributeName);
8794
+ } else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
8795
+ const value = valueNode.quasis[0].value.raw;
8796
+ checkColorValue(valueNode.quasis[0], value, attributeName);
8797
+ }
8729
8798
  }
8730
8799
  };
8731
8800
  }
@@ -8736,6 +8805,7 @@ var init_no_hardcoded_color = __esm({
8736
8805
 
8737
8806
  // src/rules/no-important.ts
8738
8807
  import { getArbitraryValue as getArbitraryValue2 } from "@pandacss/shared";
8808
+ import "@typescript-eslint/utils";
8739
8809
  var exclamationRegex, importantRegex, RULE_NAME7, rule7, no_important_default;
8740
8810
  var init_no_important = __esm({
8741
8811
  "src/rules/no-important.ts"() {
@@ -8751,56 +8821,72 @@ var init_no_important = __esm({
8751
8821
  name: RULE_NAME7,
8752
8822
  meta: {
8753
8823
  docs: {
8754
- description: "Disallow usage of important keyword. Prioroitize specificity for a maintainable and predictable styling structure."
8824
+ description: "Disallow usage of !important keyword. Prioritize specificity for a maintainable and predictable styling structure."
8755
8825
  },
8756
8826
  messages: {
8757
- important: "Avoid using the !important keyword. Refactor your code to prioritize specificity for predictable styling.",
8827
+ important: "Avoid using the {{keyword}} keyword. Refactor your code to prioritize specificity for predictable styling.",
8758
8828
  remove: "Remove the `{{keyword}}` keyword."
8759
8829
  },
8760
- type: "suggestion",
8830
+ type: "problem",
8761
8831
  hasSuggestions: true,
8762
8832
  schema: []
8763
8833
  },
8764
8834
  defaultOptions: [],
8765
8835
  create(context) {
8766
- const removeQuotes = ([start, end]) => [start + 1, end - 1];
8767
- const hasImportantKeyword = (_value) => {
8768
- if (!_value)
8836
+ const removeQuotes = (range) => {
8837
+ const [start, end] = range;
8838
+ return [start + 1, end - 1];
8839
+ };
8840
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
8841
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
8842
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
8843
+ const isCachedPandaProp = (node) => {
8844
+ if (pandaPropCache.has(node)) {
8845
+ return pandaPropCache.get(node);
8846
+ }
8847
+ const result = isPandaProp(node, context);
8848
+ pandaPropCache.set(node, result);
8849
+ return !!result;
8850
+ };
8851
+ const isCachedPandaAttribute = (node) => {
8852
+ if (pandaAttributeCache.has(node)) {
8853
+ return pandaAttributeCache.get(node);
8854
+ }
8855
+ const result = isPandaAttribute(node, context);
8856
+ pandaAttributeCache.set(node, result);
8857
+ return !!result;
8858
+ };
8859
+ const isCachedRecipeVariant = (node) => {
8860
+ if (recipeVariantCache.has(node)) {
8861
+ return recipeVariantCache.get(node);
8862
+ }
8863
+ const result = isRecipeVariant(node, context);
8864
+ recipeVariantCache.set(node, result);
8865
+ return !!result;
8866
+ };
8867
+ const hasImportantKeyword = (value) => {
8868
+ if (!value)
8769
8869
  return false;
8770
- const value = getArbitraryValue2(_value);
8771
- return exclamationRegex.test(value) || importantRegex.test(value);
8870
+ const arbitraryValue = getArbitraryValue2(value);
8871
+ return exclamationRegex.test(arbitraryValue) || importantRegex.test(arbitraryValue);
8772
8872
  };
8773
8873
  const removeImportantKeyword = (input) => {
8774
- if (exclamationRegex.test(input)) {
8775
- return { fixed: input.replace(exclamationRegex, ""), keyword: "!" };
8776
- } else if (importantRegex.test(input)) {
8777
- return { fixed: input.replace(importantRegex, ""), keyword: "!important" };
8874
+ if (importantRegex.test(input)) {
8875
+ return { fixed: input.replace(importantRegex, "").trimEnd(), keyword: "!important" };
8876
+ } else if (exclamationRegex.test(input)) {
8877
+ return { fixed: input.replace(exclamationRegex, "").trimEnd(), keyword: "!" };
8778
8878
  } else {
8779
8879
  return { fixed: input, keyword: null };
8780
8880
  }
8781
8881
  };
8782
- const handleLiteral = (node) => {
8783
- if (!isLiteral(node))
8784
- return;
8785
- if (!hasImportantKeyword(node.value?.toString()))
8786
- return;
8787
- sendReport(node);
8788
- };
8789
- const handleTemplateLiteral = (node) => {
8790
- if (!isTemplateLiteral(node))
8882
+ const handleNodeValue = (node, value) => {
8883
+ if (!hasImportantKeyword(value))
8791
8884
  return;
8792
- if (node.expressions.length > 0)
8793
- return;
8794
- if (!hasImportantKeyword(node.quasis[0].value.raw))
8795
- return;
8796
- sendReport(node.quasis[0], node.quasis[0].value.raw);
8797
- };
8798
- const sendReport = (node, _value) => {
8799
- const value = _value ?? node.value?.toString();
8800
- const { keyword, fixed } = removeImportantKeyword(value);
8801
- return context.report({
8885
+ const { fixed, keyword } = removeImportantKeyword(value);
8886
+ context.report({
8802
8887
  node,
8803
8888
  messageId: "important",
8889
+ data: { keyword },
8804
8890
  suggest: [
8805
8891
  {
8806
8892
  messageId: "remove",
@@ -8813,28 +8899,43 @@ var init_no_important = __esm({
8813
8899
  });
8814
8900
  };
8815
8901
  return {
8902
+ // JSX Attributes
8816
8903
  JSXAttribute(node) {
8817
8904
  if (!node.value)
8818
8905
  return;
8819
- if (!isPandaProp(node, context))
8820
- return;
8821
- handleLiteral(node.value);
8822
- if (!isJSXExpressionContainer(node.value))
8906
+ if (!isCachedPandaProp(node))
8823
8907
  return;
8824
- handleLiteral(node.value.expression);
8825
- handleTemplateLiteral(node.value.expression);
8908
+ const valueNode = node.value;
8909
+ if (isLiteral(valueNode)) {
8910
+ const val = valueNode.value?.toString() ?? "";
8911
+ handleNodeValue(valueNode, val);
8912
+ } else if (isJSXExpressionContainer(valueNode)) {
8913
+ const expr = valueNode.expression;
8914
+ if (isLiteral(expr)) {
8915
+ const val = expr.value?.toString() ?? "";
8916
+ handleNodeValue(expr, val);
8917
+ } else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
8918
+ const val = expr.quasis[0].value.raw;
8919
+ handleNodeValue(expr.quasis[0], val);
8920
+ }
8921
+ }
8826
8922
  },
8923
+ // Object Properties
8827
8924
  Property(node) {
8828
8925
  if (!isIdentifier(node.key))
8829
8926
  return;
8830
- if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
8927
+ if (!isCachedPandaAttribute(node))
8831
8928
  return;
8832
- if (!isPandaAttribute(node, context))
8929
+ if (isCachedRecipeVariant(node))
8833
8930
  return;
8834
- if (isRecipeVariant(node, context))
8835
- return;
8836
- handleLiteral(node.value);
8837
- handleTemplateLiteral(node.value);
8931
+ const valueNode = node.value;
8932
+ if (isLiteral(valueNode)) {
8933
+ const val = valueNode.value?.toString() ?? "";
8934
+ handleNodeValue(valueNode, val);
8935
+ } else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
8936
+ const val = valueNode.quasis[0].value.raw;
8937
+ handleNodeValue(valueNode.quasis[0], val);
8938
+ }
8838
8939
  }
8839
8940
  };
8840
8941
  }
@@ -8844,6 +8945,7 @@ var init_no_important = __esm({
8844
8945
  });
8845
8946
 
8846
8947
  // src/rules/no-invalid-nesting.ts
8948
+ import "@typescript-eslint/utils";
8847
8949
  var RULE_NAME8, rule8, no_invalid_nesting_default;
8848
8950
  var init_no_invalid_nesting = __esm({
8849
8951
  "src/rules/no-invalid-nesting.ts"() {
@@ -8857,35 +8959,78 @@ var init_no_invalid_nesting = __esm({
8857
8959
  name: RULE_NAME8,
8858
8960
  meta: {
8859
8961
  docs: {
8860
- description: "Warn against invalid nesting. i.e. nested styles that don't contain the `&` character."
8962
+ description: "Warn against invalid nesting. Nested styles must contain the `&` character."
8861
8963
  },
8862
8964
  messages: {
8863
8965
  nesting: "Invalid style nesting. Nested styles must contain the `&` character."
8864
8966
  },
8865
- type: "suggestion",
8967
+ type: "problem",
8866
8968
  schema: []
8867
8969
  },
8868
8970
  defaultOptions: [],
8869
8971
  create(context) {
8972
+ const pandaFunctionCache = /* @__PURE__ */ new WeakMap();
8973
+ const jsxPropCache = /* @__PURE__ */ new WeakMap();
8974
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
8975
+ const styledPropertyCache = /* @__PURE__ */ new WeakMap();
8976
+ const isCachedInPandaFunction = (node) => {
8977
+ if (pandaFunctionCache.has(node)) {
8978
+ return pandaFunctionCache.get(node);
8979
+ }
8980
+ const result = !!isInPandaFunction(node, context);
8981
+ pandaFunctionCache.set(node, result);
8982
+ return !!result;
8983
+ };
8984
+ const isCachedInJSXProp = (node) => {
8985
+ if (jsxPropCache.has(node)) {
8986
+ return jsxPropCache.get(node);
8987
+ }
8988
+ const result = isInJSXProp(node, context);
8989
+ jsxPropCache.set(node, result);
8990
+ return !!result;
8991
+ };
8992
+ const isCachedRecipeVariant = (node) => {
8993
+ if (recipeVariantCache.has(node)) {
8994
+ return recipeVariantCache.get(node);
8995
+ }
8996
+ const result = isRecipeVariant(node, context);
8997
+ recipeVariantCache.set(node, result);
8998
+ return !!result;
8999
+ };
9000
+ const isCachedStyledProperty = (node) => {
9001
+ if (styledPropertyCache.has(node)) {
9002
+ return styledPropertyCache.get(node);
9003
+ }
9004
+ const result = isStyledProperty(node, context);
9005
+ styledPropertyCache.set(node, result);
9006
+ return !!result;
9007
+ };
9008
+ const isInvalidNestingSelector = (node) => {
9009
+ if (isLiteral(node) && typeof node.value === "string") {
9010
+ return !node.value.includes("&");
9011
+ } else if (isTemplateLiteral(node) && node.expressions.length === 0) {
9012
+ return !node.quasis[0].value.raw.includes("&");
9013
+ }
9014
+ return false;
9015
+ };
8870
9016
  return {
8871
- Property(node) {
8872
- if (!isObjectExpression(node.value) || isIdentifier(node.key))
9017
+ // Use AST selector to target Property nodes with non-Identifier keys whose value is an ObjectExpression
9018
+ 'Property[key.type!=/Identifier/][value.type="ObjectExpression"]'(node) {
9019
+ const inPandaFunction = isCachedInPandaFunction(node);
9020
+ const inJSXProp = isCachedInJSXProp(node);
9021
+ if (!inPandaFunction && !inJSXProp)
8873
9022
  return;
8874
- const caller = isInPandaFunction(node, context);
8875
- if (!caller && !isInJSXProp(node, context))
8876
- return;
8877
- if (isRecipeVariant(node, context))
9023
+ if (isCachedRecipeVariant(node))
8878
9024
  return;
8879
- if (isStyledProperty(node, context))
9025
+ if (isCachedStyledProperty(node))
8880
9026
  return;
8881
- const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8882
- const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8883
- if (!(invalidLiteral || invalidTemplateLiteral))
8884
- return;
8885
- context.report({
8886
- node: node.key,
8887
- messageId: "nesting"
8888
- });
9027
+ const keyNode = node.key;
9028
+ if (isInvalidNestingSelector(keyNode)) {
9029
+ context.report({
9030
+ node: keyNode,
9031
+ messageId: "nesting"
9032
+ });
9033
+ }
8889
9034
  }
8890
9035
  };
8891
9036
  }
@@ -8915,87 +9060,89 @@ var init_no_invalid_token_paths = __esm({
8915
9060
  messages: {
8916
9061
  noInvalidTokenPaths: "`{{token}}` is an invalid token path."
8917
9062
  },
8918
- type: "suggestion",
9063
+ type: "problem",
8919
9064
  schema: []
8920
9065
  },
8921
9066
  defaultOptions: [],
8922
9067
  create(context) {
8923
- const handleLiteral = (node) => {
8924
- if (!isLiteral(node))
8925
- return;
8926
- sendReport(node);
8927
- };
8928
- const handleTemplateLiteral = (node) => {
8929
- if (!isTemplateLiteral(node))
9068
+ const invalidTokensCache2 = /* @__PURE__ */ new Map();
9069
+ const sendReport = (node, value) => {
9070
+ if (!value)
8930
9071
  return;
8931
- if (node.expressions.length > 0)
9072
+ let tokens = invalidTokensCache2.get(value);
9073
+ if (!tokens) {
9074
+ tokens = getInvalidTokens(value, context);
9075
+ invalidTokensCache2.set(value, tokens);
9076
+ }
9077
+ if (tokens.length === 0)
8932
9078
  return;
8933
- sendReport(node.quasis[0], node.quasis[0].value.raw);
9079
+ tokens.forEach((token) => {
9080
+ context.report({
9081
+ node,
9082
+ messageId: "noInvalidTokenPaths",
9083
+ data: { token }
9084
+ });
9085
+ });
8934
9086
  };
8935
- const sendReport = (node, _value) => {
8936
- const value = _value ?? node.value?.toString();
8937
- const tokens = getInvalidTokens(value, context);
8938
- if (!tokens)
9087
+ const handleLiteralOrTemplate = (node) => {
9088
+ if (!node)
8939
9089
  return;
8940
- if (tokens.length > 0) {
8941
- tokens.forEach((token) => {
8942
- context.report({
8943
- node,
8944
- messageId: "noInvalidTokenPaths",
8945
- data: { token }
8946
- });
8947
- });
9090
+ if (isLiteral(node)) {
9091
+ const value = node.value?.toString();
9092
+ sendReport(node, value);
9093
+ } else if (isTemplateLiteral(node) && node.expressions.length === 0) {
9094
+ const value = node.quasis[0].value.raw;
9095
+ sendReport(node.quasis[0], value);
8948
9096
  }
8949
9097
  };
8950
9098
  return {
8951
9099
  JSXAttribute(node) {
8952
- if (!node.value)
8953
- return;
8954
- if (!isPandaProp(node, context))
9100
+ if (!node.value || !isPandaProp(node, context))
8955
9101
  return;
8956
- handleLiteral(node.value);
8957
- if (!isJSXExpressionContainer(node.value))
8958
- return;
8959
- handleLiteral(node.value.expression);
8960
- handleTemplateLiteral(node.value.expression);
9102
+ if (isLiteral(node.value)) {
9103
+ handleLiteralOrTemplate(node.value);
9104
+ } else if (isJSXExpressionContainer(node.value)) {
9105
+ handleLiteralOrTemplate(node.value.expression);
9106
+ }
8961
9107
  },
8962
9108
  Property(node) {
8963
- if (!isIdentifier(node.key))
8964
- return;
8965
- if (!isNodeOfTypes([AST_NODE_TYPES2.Literal, AST_NODE_TYPES2.TemplateLiteral])(node.value))
8966
- return;
8967
- if (!isPandaAttribute(node, context))
9109
+ if (!isIdentifier(node.key) || !isNodeOfTypes([AST_NODE_TYPES2.Literal, AST_NODE_TYPES2.TemplateLiteral])(node.value) || !isPandaAttribute(node, context) || isRecipeVariant(node, context)) {
8968
9110
  return;
8969
- if (isRecipeVariant(node, context))
8970
- return;
8971
- handleLiteral(node.value);
8972
- handleTemplateLiteral(node.value);
9111
+ }
9112
+ handleLiteralOrTemplate(node.value);
8973
9113
  },
8974
9114
  TaggedTemplateExpression(node) {
8975
9115
  const caller = getTaggedTemplateCaller(node);
8976
- if (!caller)
8977
- return;
8978
- if (!isPandaIsh(caller, context))
9116
+ if (!caller || !isPandaIsh(caller, context))
8979
9117
  return;
8980
- const quasis = node.quasi.quasis[0];
8981
- const styles = quasis.value.raw;
8982
- const tokens = getInvalidTokens(styles, context);
8983
- if (!tokens)
8984
- return;
8985
- tokens.forEach((token, i, arr) => {
8986
- if (arr.indexOf(token) < i)
9118
+ const quasis = node.quasi.quasis;
9119
+ quasis.forEach((quasi) => {
9120
+ const styles = quasi.value.raw;
9121
+ if (!styles)
8987
9122
  return;
8988
- let index = styles.indexOf(token);
8989
- while (index !== -1) {
8990
- const start = quasis.range[0] + 1 + index;
8991
- const end = start + token.length;
8992
- context.report({
8993
- loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
8994
- messageId: "noInvalidTokenPaths",
8995
- data: { token }
8996
- });
8997
- index = styles.indexOf(token, index + 1);
9123
+ let tokens = invalidTokensCache2.get(styles);
9124
+ if (!tokens) {
9125
+ tokens = getInvalidTokens(styles, context);
9126
+ invalidTokensCache2.set(styles, tokens);
8998
9127
  }
9128
+ if (tokens.length === 0)
9129
+ return;
9130
+ tokens.forEach((token) => {
9131
+ let index = styles.indexOf(token);
9132
+ while (index !== -1) {
9133
+ const start = quasi.range[0] + index + 1;
9134
+ const end = start + token.length;
9135
+ context.report({
9136
+ loc: {
9137
+ start: context.sourceCode.getLocFromIndex(start),
9138
+ end: context.sourceCode.getLocFromIndex(end)
9139
+ },
9140
+ messageId: "noInvalidTokenPaths",
9141
+ data: { token }
9142
+ });
9143
+ index = styles.indexOf(token, index + token.length);
9144
+ }
9145
+ });
8999
9146
  });
9000
9147
  }
9001
9148
  };
@@ -9029,29 +9176,69 @@ var init_no_margin_properties = __esm({
9029
9176
  },
9030
9177
  defaultOptions: [],
9031
9178
  create(context) {
9032
- const getLonghand = (name2) => resolveLonghand(name2, context) ?? name2;
9179
+ const longhandCache = /* @__PURE__ */ new Map();
9180
+ const getLonghand = (name2) => {
9181
+ if (longhandCache.has(name2)) {
9182
+ return longhandCache.get(name2);
9183
+ }
9184
+ const longhand = resolveLonghand(name2, context) ?? name2;
9185
+ longhandCache.set(name2, longhand);
9186
+ return longhand;
9187
+ };
9188
+ const marginRegex = /margin/i;
9189
+ const isMarginProperty = (name2) => {
9190
+ const longhand = getLonghand(name2).toLowerCase();
9191
+ return marginRegex.test(longhand);
9192
+ };
9033
9193
  const sendReport = (node) => {
9034
- if (!getLonghand(node.name).toLowerCase().includes("margin"))
9194
+ if (!isMarginProperty(node.name))
9035
9195
  return;
9036
- return context.report({
9196
+ context.report({
9037
9197
  node,
9038
9198
  messageId: "noMargin"
9039
9199
  });
9040
9200
  };
9201
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
9202
+ const isCachedPandaProp = (node) => {
9203
+ if (pandaPropCache.has(node)) {
9204
+ return pandaPropCache.get(node);
9205
+ }
9206
+ const result = isPandaProp(node, context);
9207
+ pandaPropCache.set(node, result);
9208
+ return !!result;
9209
+ };
9210
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
9211
+ const isCachedPandaAttribute = (node) => {
9212
+ if (pandaAttributeCache.has(node)) {
9213
+ return pandaAttributeCache.get(node);
9214
+ }
9215
+ const result = isPandaAttribute(node, context);
9216
+ pandaAttributeCache.set(node, result);
9217
+ return !!result;
9218
+ };
9219
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
9220
+ const isCachedRecipeVariant = (node) => {
9221
+ if (recipeVariantCache.has(node)) {
9222
+ return recipeVariantCache.get(node);
9223
+ }
9224
+ const result = isRecipeVariant(node, context);
9225
+ recipeVariantCache.set(node, result);
9226
+ return !!result;
9227
+ };
9041
9228
  return {
9042
9229
  JSXAttribute(node) {
9043
9230
  if (!isJSXIdentifier(node.name))
9044
9231
  return;
9045
- if (!isPandaProp(node, context))
9232
+ if (!isCachedPandaProp(node))
9046
9233
  return;
9047
9234
  sendReport(node.name);
9048
9235
  },
9049
9236
  Property(node) {
9050
9237
  if (!isIdentifier(node.key))
9051
9238
  return;
9052
- if (!isPandaAttribute(node, context))
9239
+ if (!isCachedPandaAttribute(node))
9053
9240
  return;
9054
- if (isRecipeVariant(node, context))
9241
+ if (isCachedRecipeVariant(node))
9055
9242
  return;
9056
9243
  sendReport(node.key);
9057
9244
  }
@@ -9120,11 +9307,11 @@ var init_no_physical_properties = __esm({
9120
9307
  name: RULE_NAME11,
9121
9308
  meta: {
9122
9309
  docs: {
9123
- description: "Encourage the use of [logical properties](https://mdn.io/logical-properties-basic-concepts) over physical proeprties, to foster a responsive and adaptable user interface."
9310
+ description: "Encourage the use of logical properties over physical properties to foster a responsive and adaptable user interface."
9124
9311
  },
9125
9312
  messages: {
9126
- physical: "Use logical property of {{physical}} instead. Prefer `{{logical}}`",
9127
- replace: "Replace `{{physical}}` with `{{logical}}`"
9313
+ physical: "Use logical property instead of {{physical}}. Prefer `{{logical}}`.",
9314
+ replace: "Replace `{{physical}}` with `{{logical}}`."
9128
9315
  },
9129
9316
  type: "suggestion",
9130
9317
  hasSuggestions: true,
@@ -9132,17 +9319,53 @@ var init_no_physical_properties = __esm({
9132
9319
  },
9133
9320
  defaultOptions: [],
9134
9321
  create(context) {
9135
- const getLonghand = (name2) => resolveLonghand(name2, context) ?? name2;
9322
+ const longhandCache = /* @__PURE__ */ new Map();
9323
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
9324
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
9325
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
9326
+ const getLonghand = (name2) => {
9327
+ if (longhandCache.has(name2)) {
9328
+ return longhandCache.get(name2);
9329
+ }
9330
+ const longhand = resolveLonghand(name2, context) ?? name2;
9331
+ longhandCache.set(name2, longhand);
9332
+ return longhand;
9333
+ };
9334
+ const isCachedPandaProp = (node) => {
9335
+ if (pandaPropCache.has(node)) {
9336
+ return pandaPropCache.get(node);
9337
+ }
9338
+ const result = isPandaProp(node, context);
9339
+ pandaPropCache.set(node, result);
9340
+ return !!result;
9341
+ };
9342
+ const isCachedPandaAttribute = (node) => {
9343
+ if (pandaAttributeCache.has(node)) {
9344
+ return pandaAttributeCache.get(node);
9345
+ }
9346
+ const result = isPandaAttribute(node, context);
9347
+ pandaAttributeCache.set(node, result);
9348
+ return !!result;
9349
+ };
9350
+ const isCachedRecipeVariant = (node) => {
9351
+ if (recipeVariantCache.has(node)) {
9352
+ return recipeVariantCache.get(node);
9353
+ }
9354
+ const result = isRecipeVariant(node, context);
9355
+ recipeVariantCache.set(node, result);
9356
+ return !!result;
9357
+ };
9136
9358
  const sendReport = (node) => {
9137
- if (!(getLonghand(node.name) in physicalProperties))
9359
+ const longhandName = getLonghand(node.name);
9360
+ if (!(longhandName in physicalProperties))
9138
9361
  return;
9139
- const logical = physicalProperties[getLonghand(node.name)];
9140
- const longhand = resolveLonghand(node.name, context);
9141
- return context.report({
9362
+ const logical = physicalProperties[longhandName];
9363
+ const physicalName = `\`${node.name}\`${longhandName !== node.name ? ` (resolved to \`${longhandName}\`)` : ""}`;
9364
+ context.report({
9142
9365
  node,
9143
9366
  messageId: "physical",
9144
9367
  data: {
9145
- physical: `\`${node.name}\`${longhand ? ` - \`${longhand}\`` : ""}`,
9368
+ physical: physicalName,
9146
9369
  logical
9147
9370
  },
9148
9371
  suggest: [
@@ -9153,7 +9376,7 @@ var init_no_physical_properties = __esm({
9153
9376
  logical
9154
9377
  },
9155
9378
  fix: (fixer) => {
9156
- return fixer.replaceTextRange(node.range, logical);
9379
+ return fixer.replaceText(node, logical);
9157
9380
  }
9158
9381
  }
9159
9382
  ]
@@ -9163,16 +9386,16 @@ var init_no_physical_properties = __esm({
9163
9386
  JSXAttribute(node) {
9164
9387
  if (!isJSXIdentifier(node.name))
9165
9388
  return;
9166
- if (!isPandaProp(node, context))
9389
+ if (!isCachedPandaProp(node))
9167
9390
  return;
9168
9391
  sendReport(node.name);
9169
9392
  },
9170
9393
  Property(node) {
9171
9394
  if (!isIdentifier(node.key))
9172
9395
  return;
9173
- if (!isPandaAttribute(node, context))
9396
+ if (!isCachedPandaAttribute(node))
9174
9397
  return;
9175
- if (isRecipeVariant(node, context))
9398
+ if (isCachedRecipeVariant(node))
9176
9399
  return;
9177
9400
  sendReport(node.key);
9178
9401
  }
@@ -9197,19 +9420,46 @@ var init_no_property_renaming = __esm({
9197
9420
  name: RULE_NAME12,
9198
9421
  meta: {
9199
9422
  docs: {
9200
- description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
9423
+ description: "Ensure that properties for patterns or style props are not renamed, as it prevents proper tracking."
9201
9424
  },
9202
9425
  messages: {
9203
- noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute. Panada will not track this prop."
9426
+ noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute. Panda will not track this prop."
9204
9427
  },
9205
- type: "suggestion",
9428
+ type: "problem",
9206
9429
  schema: []
9207
9430
  },
9208
9431
  defaultOptions: [],
9209
9432
  create(context) {
9433
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
9434
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
9435
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
9436
+ const isCachedPandaProp = (node) => {
9437
+ if (pandaPropCache.has(node)) {
9438
+ return pandaPropCache.get(node);
9439
+ }
9440
+ const result = isPandaProp(node, context);
9441
+ pandaPropCache.set(node, result);
9442
+ return !!result;
9443
+ };
9444
+ const isCachedPandaAttribute = (node) => {
9445
+ if (pandaAttributeCache.has(node)) {
9446
+ return pandaAttributeCache.get(node);
9447
+ }
9448
+ const result = isPandaAttribute(node, context);
9449
+ pandaAttributeCache.set(node, result);
9450
+ return !!result;
9451
+ };
9452
+ const isCachedRecipeVariant = (node) => {
9453
+ if (recipeVariantCache.has(node)) {
9454
+ return recipeVariantCache.get(node);
9455
+ }
9456
+ const result = isRecipeVariant(node, context);
9457
+ recipeVariantCache.set(node, result);
9458
+ return !!result;
9459
+ };
9210
9460
  const sendReport = (node, expected, prop) => {
9211
- return context.report({
9212
- node: node.value,
9461
+ context.report({
9462
+ node,
9213
9463
  messageId: "noRenaming",
9214
9464
  data: {
9215
9465
  expected,
@@ -9219,10 +9469,9 @@ var init_no_property_renaming = __esm({
9219
9469
  };
9220
9470
  const handleReport = (node, value, attr) => {
9221
9471
  if (isIdentifier(value) && attr !== value.name) {
9222
- return sendReport(node, attr, value.name);
9223
- }
9224
- if (isMemberExpression(value) && isIdentifier(value.property) && attr !== value.property.name) {
9225
- return sendReport(node, attr, value.property.name);
9472
+ sendReport(node, attr, value.name);
9473
+ } else if (isMemberExpression(value) && isIdentifier(value.property) && attr !== value.property.name) {
9474
+ sendReport(node, attr, value.property.name);
9226
9475
  }
9227
9476
  };
9228
9477
  return {
@@ -9231,24 +9480,24 @@ var init_no_property_renaming = __esm({
9231
9480
  return;
9232
9481
  if (!isJSXExpressionContainer(node.value))
9233
9482
  return;
9234
- if (!isPandaProp(node, context))
9483
+ if (!isCachedPandaProp(node))
9235
9484
  return;
9236
9485
  const attr = node.name.name.toString();
9237
9486
  const expression = node.value.expression;
9238
- handleReport(node, expression, attr);
9487
+ handleReport(node.value, expression, attr);
9239
9488
  },
9240
9489
  Property(node) {
9241
9490
  if (!isIdentifier(node.key))
9242
9491
  return;
9243
9492
  if (!isIdentifier(node.value) && !isMemberExpression(node.value))
9244
9493
  return;
9245
- if (!isPandaAttribute(node, context))
9494
+ if (!isCachedPandaAttribute(node))
9246
9495
  return;
9247
- if (isRecipeVariant(node, context))
9496
+ if (isCachedRecipeVariant(node))
9248
9497
  return;
9249
- const attr = node.key.name.toString();
9498
+ const attr = node.key.name;
9250
9499
  const value = node.value;
9251
- handleReport(node, value, attr);
9500
+ handleReport(node.value, value, attr);
9252
9501
  }
9253
9502
  };
9254
9503
  }
@@ -9276,8 +9525,8 @@ var init_no_unsafe_token_fn_usage = __esm({
9276
9525
  description: "Prevent users from using the token function in situations where they could simply use the raw design token."
9277
9526
  },
9278
9527
  messages: {
9279
- noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
9280
- replace: "Replace token function with `{{safe}}`"
9528
+ noUnsafeTokenFnUsage: "Unnecessary token function usage. Prefer design token.",
9529
+ replace: "Replace token function with `{{safe}}`."
9281
9530
  },
9282
9531
  type: "suggestion",
9283
9532
  hasSuggestions: true,
@@ -9285,11 +9534,42 @@ var init_no_unsafe_token_fn_usage = __esm({
9285
9534
  },
9286
9535
  defaultOptions: [],
9287
9536
  create(context) {
9537
+ let tokenImportCache;
9538
+ const getCachedTokenImport = () => {
9539
+ if (tokenImportCache !== void 0) {
9540
+ return tokenImportCache;
9541
+ }
9542
+ tokenImportCache = getTokenImport(context);
9543
+ return tokenImportCache;
9544
+ };
9288
9545
  const isUnsafeCallExpression = (node) => {
9289
- const tkImport = getTokenImport(context);
9546
+ const tkImport = getCachedTokenImport();
9290
9547
  return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
9291
9548
  };
9292
9549
  const tokenWrap = (value) => value ? `token(${value})` : "";
9550
+ const isCompositeValue = (input) => {
9551
+ if (!input)
9552
+ return false;
9553
+ const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
9554
+ return !tokenRegex.test(input);
9555
+ };
9556
+ const sendReport = (node, value) => {
9557
+ const tkImports = extractTokens(value);
9558
+ if (!tkImports.length)
9559
+ return;
9560
+ const token = tkImports[0].replace(/^[^.]*\./, "");
9561
+ context.report({
9562
+ node,
9563
+ messageId: "noUnsafeTokenFnUsage",
9564
+ suggest: [
9565
+ {
9566
+ messageId: "replace",
9567
+ data: { safe: token },
9568
+ fix: (fixer) => fixer.replaceText(node, `'${token}'`)
9569
+ }
9570
+ ]
9571
+ });
9572
+ };
9293
9573
  const handleRuntimeFm = (node) => {
9294
9574
  if (!isCallExpression(node))
9295
9575
  return;
@@ -9297,17 +9577,12 @@ var init_no_unsafe_token_fn_usage = __esm({
9297
9577
  return;
9298
9578
  const value = node.arguments[0];
9299
9579
  if (isLiteral(value)) {
9300
- sendReport(node, tokenWrap(getArbitraryValue3(value.value?.toString() ?? "")));
9580
+ const val = getArbitraryValue3(value.value?.toString() ?? "");
9581
+ sendReport(node, tokenWrap(val));
9582
+ } else if (isTemplateLiteral(value) && value.expressions.length === 0) {
9583
+ const val = getArbitraryValue3(value.quasis[0].value.raw);
9584
+ sendReport(node, tokenWrap(val));
9301
9585
  }
9302
- if (isTemplateLiteral(value)) {
9303
- sendReport(node, tokenWrap(getArbitraryValue3(value.quasis[0].value.raw)));
9304
- }
9305
- };
9306
- const isCompositeValue = (input) => {
9307
- if (!input)
9308
- return;
9309
- const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
9310
- return !tokenRegex.test(input);
9311
9586
  };
9312
9587
  const handleLiteral = (node) => {
9313
9588
  if (!isLiteral(node))
@@ -9318,54 +9593,63 @@ var init_no_unsafe_token_fn_usage = __esm({
9318
9593
  sendReport(node, value);
9319
9594
  };
9320
9595
  const handleTemplateLiteral = (node) => {
9321
- if (!isTemplateLiteral(node))
9596
+ if (!isTemplateLiteral(node) || node.expressions.length > 0)
9322
9597
  return;
9323
- if (node.expressions.length > 0)
9324
- return;
9325
- sendReport(node, getArbitraryValue3(node.quasis[0].value.raw));
9598
+ const value = getArbitraryValue3(node.quasis[0].value.raw);
9599
+ sendReport(node, value);
9326
9600
  };
9327
- const sendReport = (node, value) => {
9328
- const tkImports = extractTokens(value);
9329
- if (!tkImports.length)
9330
- return;
9331
- const token = tkImports[0].replace(/^[^.]*\./, "");
9332
- return context.report({
9333
- node,
9334
- messageId: "noUnsafeTokenFnUsage",
9335
- suggest: [
9336
- {
9337
- messageId: "replace",
9338
- data: { safe: token },
9339
- fix: (fixer) => {
9340
- return fixer.replaceTextRange(node.range, `'${token}'`);
9341
- }
9342
- }
9343
- ]
9344
- });
9601
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
9602
+ const isCachedPandaProp = (node) => {
9603
+ if (pandaPropCache.has(node)) {
9604
+ return pandaPropCache.get(node);
9605
+ }
9606
+ const result = isPandaProp(node, context);
9607
+ pandaPropCache.set(node, result);
9608
+ return !!result;
9609
+ };
9610
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
9611
+ const isCachedPandaAttribute = (node) => {
9612
+ if (pandaAttributeCache.has(node)) {
9613
+ return pandaAttributeCache.get(node);
9614
+ }
9615
+ const result = isPandaAttribute(node, context);
9616
+ pandaAttributeCache.set(node, result);
9617
+ return !!result;
9618
+ };
9619
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
9620
+ const isCachedRecipeVariant = (node) => {
9621
+ if (recipeVariantCache.has(node)) {
9622
+ return recipeVariantCache.get(node);
9623
+ }
9624
+ const result = isRecipeVariant(node, context);
9625
+ recipeVariantCache.set(node, result);
9626
+ return !!result;
9345
9627
  };
9346
9628
  return {
9347
9629
  JSXAttribute(node) {
9348
9630
  if (!node.value)
9349
9631
  return;
9350
- if (!isPandaProp(node, context))
9632
+ if (!isCachedPandaProp(node))
9351
9633
  return;
9352
9634
  handleLiteral(node.value);
9353
- if (!isJSXExpressionContainer(node.value))
9354
- return;
9355
- handleLiteral(node.value.expression);
9356
- handleTemplateLiteral(node.value.expression);
9357
- handleRuntimeFm(node.value.expression);
9635
+ if (isJSXExpressionContainer(node.value)) {
9636
+ const expression = node.value.expression;
9637
+ handleLiteral(expression);
9638
+ handleTemplateLiteral(expression);
9639
+ handleRuntimeFm(expression);
9640
+ }
9358
9641
  },
9359
9642
  Property(node) {
9360
- if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
9643
+ if (!isCachedPandaAttribute(node))
9361
9644
  return;
9362
- if (!isPandaAttribute(node, context))
9645
+ if (isCachedRecipeVariant(node))
9363
9646
  return;
9364
- if (isRecipeVariant(node, context))
9365
- return;
9366
- handleRuntimeFm(node.value);
9367
- handleLiteral(node.value);
9368
- handleTemplateLiteral(node.value);
9647
+ const valueNode = node.value;
9648
+ if (isCallExpression(valueNode) || isLiteral(valueNode) || isTemplateLiteral(valueNode)) {
9649
+ handleRuntimeFm(valueNode);
9650
+ handleLiteral(valueNode);
9651
+ handleTemplateLiteral(valueNode);
9652
+ }
9369
9653
  }
9370
9654
  };
9371
9655
  }
@@ -9391,8 +9675,8 @@ var init_prefer_longhand_properties = __esm({
9391
9675
  description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
9392
9676
  },
9393
9677
  messages: {
9394
- longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
9395
- replace: "Replace `{{shorthand}}` with `{{longhand}}`"
9678
+ longhand: "Use longhand property instead of `{{shorthand}}`. Prefer `{{longhand}}`.",
9679
+ replace: "Replace `{{shorthand}}` with `{{longhand}}`."
9396
9680
  },
9397
9681
  type: "suggestion",
9398
9682
  hasSuggestions: true,
@@ -9400,15 +9684,51 @@ var init_prefer_longhand_properties = __esm({
9400
9684
  },
9401
9685
  defaultOptions: [],
9402
9686
  create(context) {
9687
+ const longhandCache = /* @__PURE__ */ new Map();
9688
+ const getLonghand = (name2) => {
9689
+ if (longhandCache.has(name2)) {
9690
+ return longhandCache.get(name2);
9691
+ }
9692
+ const longhand = resolveLonghand(name2, context);
9693
+ longhandCache.set(name2, longhand);
9694
+ return longhand;
9695
+ };
9696
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
9697
+ const isCachedPandaProp = (node) => {
9698
+ if (pandaPropCache.has(node)) {
9699
+ return pandaPropCache.get(node);
9700
+ }
9701
+ const result = isPandaProp(node, context);
9702
+ pandaPropCache.set(node, result);
9703
+ return !!result;
9704
+ };
9705
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
9706
+ const isCachedPandaAttribute = (node) => {
9707
+ if (pandaAttributeCache.has(node)) {
9708
+ return pandaAttributeCache.get(node);
9709
+ }
9710
+ const result = isPandaAttribute(node, context);
9711
+ pandaAttributeCache.set(node, result);
9712
+ return !!result;
9713
+ };
9714
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
9715
+ const isCachedRecipeVariant = (node) => {
9716
+ if (recipeVariantCache.has(node)) {
9717
+ return recipeVariantCache.get(node);
9718
+ }
9719
+ const result = isRecipeVariant(node, context);
9720
+ recipeVariantCache.set(node, result);
9721
+ return !!result;
9722
+ };
9403
9723
  const sendReport = (node) => {
9404
- const longhand = resolveLonghand(node.name, context);
9405
- if (!longhand)
9724
+ const longhand = getLonghand(node.name);
9725
+ if (!longhand || longhand === node.name)
9406
9726
  return;
9407
9727
  const data = {
9408
9728
  shorthand: node.name,
9409
9729
  longhand
9410
9730
  };
9411
- return context.report({
9731
+ context.report({
9412
9732
  node,
9413
9733
  messageId: "longhand",
9414
9734
  data,
@@ -9416,9 +9736,7 @@ var init_prefer_longhand_properties = __esm({
9416
9736
  {
9417
9737
  messageId: "replace",
9418
9738
  data,
9419
- fix: (fixer) => {
9420
- return fixer.replaceTextRange(node.range, longhand);
9421
- }
9739
+ fix: (fixer) => fixer.replaceText(node, longhand)
9422
9740
  }
9423
9741
  ]
9424
9742
  });
@@ -9427,16 +9745,16 @@ var init_prefer_longhand_properties = __esm({
9427
9745
  JSXAttribute(node) {
9428
9746
  if (!isJSXIdentifier(node.name))
9429
9747
  return;
9430
- if (!isPandaProp(node, context))
9748
+ if (!isCachedPandaProp(node))
9431
9749
  return;
9432
9750
  sendReport(node.name);
9433
9751
  },
9434
9752
  Property(node) {
9435
9753
  if (!isIdentifier(node.key))
9436
9754
  return;
9437
- if (!isPandaAttribute(node, context))
9755
+ if (!isCachedPandaAttribute(node))
9438
9756
  return;
9439
- if (isRecipeVariant(node, context))
9757
+ if (isCachedRecipeVariant(node))
9440
9758
  return;
9441
9759
  sendReport(node.key);
9442
9760
  }
@@ -9464,8 +9782,8 @@ var init_prefer_shorthand_properties = __esm({
9464
9782
  description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
9465
9783
  },
9466
9784
  messages: {
9467
- shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
9468
- replace: "Replace `{{longhand}}` with `{{shorthand}}`"
9785
+ shorthand: "Use shorthand property instead of `{{longhand}}`. Prefer `{{shorthand}}`.",
9786
+ replace: "Replace `{{longhand}}` with `{{shorthand}}`."
9469
9787
  },
9470
9788
  type: "suggestion",
9471
9789
  hasSuggestions: true,
@@ -9473,19 +9791,64 @@ var init_prefer_shorthand_properties = __esm({
9473
9791
  },
9474
9792
  defaultOptions: [],
9475
9793
  create(context) {
9794
+ const longhandCache = /* @__PURE__ */ new Map();
9795
+ const getLonghand = (name2) => {
9796
+ if (longhandCache.has(name2)) {
9797
+ return longhandCache.get(name2);
9798
+ }
9799
+ const longhand = resolveLonghand(name2, context);
9800
+ longhandCache.set(name2, longhand);
9801
+ return longhand;
9802
+ };
9803
+ const shorthandsCache = /* @__PURE__ */ new Map();
9804
+ const getShorthands = (name2) => {
9805
+ if (shorthandsCache.has(name2)) {
9806
+ return shorthandsCache.get(name2);
9807
+ }
9808
+ const shorthands = resolveShorthands(name2, context);
9809
+ shorthandsCache.set(name2, shorthands);
9810
+ return shorthands;
9811
+ };
9812
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
9813
+ const isCachedPandaProp = (node) => {
9814
+ if (pandaPropCache.has(node)) {
9815
+ return pandaPropCache.get(node);
9816
+ }
9817
+ const result = isPandaProp(node, context);
9818
+ pandaPropCache.set(node, result);
9819
+ return !!result;
9820
+ };
9821
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
9822
+ const isCachedPandaAttribute = (node) => {
9823
+ if (pandaAttributeCache.has(node)) {
9824
+ return pandaAttributeCache.get(node);
9825
+ }
9826
+ const result = isPandaAttribute(node, context);
9827
+ pandaAttributeCache.set(node, result);
9828
+ return !!result;
9829
+ };
9830
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
9831
+ const isCachedRecipeVariant = (node) => {
9832
+ if (recipeVariantCache.has(node)) {
9833
+ return recipeVariantCache.get(node);
9834
+ }
9835
+ const result = isRecipeVariant(node, context);
9836
+ recipeVariantCache.set(node, result);
9837
+ return !!result;
9838
+ };
9476
9839
  const sendReport = (node) => {
9477
- const longhand = resolveLonghand(node.name, context);
9840
+ const longhand = getLonghand(node.name);
9478
9841
  if (longhand)
9479
9842
  return;
9480
- const shorthands = resolveShorthands(node.name, context);
9481
- if (!shorthands)
9843
+ const shorthands = getShorthands(node.name);
9844
+ if (!shorthands || shorthands.length === 0)
9482
9845
  return;
9483
- const shorthand = shorthands.map((s) => `\`${s}\``)?.join(", ");
9846
+ const shorthandList = shorthands.map((s) => `\`${s}\``).join(", ");
9484
9847
  const data = {
9485
9848
  longhand: node.name,
9486
- shorthand
9849
+ shorthand: shorthandList
9487
9850
  };
9488
- return context.report({
9851
+ context.report({
9489
9852
  node,
9490
9853
  messageId: "shorthand",
9491
9854
  data,
@@ -9493,9 +9856,7 @@ var init_prefer_shorthand_properties = __esm({
9493
9856
  {
9494
9857
  messageId: "replace",
9495
9858
  data,
9496
- fix: (fixer) => {
9497
- return fixer.replaceTextRange(node.range, shorthands[0]);
9498
- }
9859
+ fix: (fixer) => fixer.replaceText(node, shorthands[0])
9499
9860
  }
9500
9861
  ]
9501
9862
  });
@@ -9504,16 +9865,16 @@ var init_prefer_shorthand_properties = __esm({
9504
9865
  JSXAttribute(node) {
9505
9866
  if (!isJSXIdentifier(node.name))
9506
9867
  return;
9507
- if (!isPandaProp(node, context))
9868
+ if (!isCachedPandaProp(node))
9508
9869
  return;
9509
9870
  sendReport(node.name);
9510
9871
  },
9511
9872
  Property(node) {
9512
9873
  if (!isIdentifier(node.key))
9513
9874
  return;
9514
- if (!isPandaAttribute(node, context))
9875
+ if (!isCachedPandaAttribute(node))
9515
9876
  return;
9516
- if (isRecipeVariant(node, context))
9877
+ if (isCachedRecipeVariant(node))
9517
9878
  return;
9518
9879
  sendReport(node.key);
9519
9880
  }
@@ -9650,8 +10011,8 @@ var init_prefer_atomic_properties = __esm({
9650
10011
  "src/rules/prefer-atomic-properties.ts"() {
9651
10012
  "use strict";
9652
10013
  init_esm_shims();
9653
- init_helpers();
9654
10014
  init_utils();
10015
+ init_helpers();
9655
10016
  init_composite_properties();
9656
10017
  init_nodes();
9657
10018
  RULE_NAME16 = "prefer-atomic-properties";
@@ -9662,26 +10023,69 @@ var init_prefer_atomic_properties = __esm({
9662
10023
  description: "Encourage the use of atomic properties instead of composite properties in the codebase."
9663
10024
  },
9664
10025
  messages: {
9665
- atomic: "Use atomic properties of `{{composite}}` instead. Prefer: \n{{atomics}}"
10026
+ atomic: "Use atomic properties instead of `{{composite}}`. Prefer: \n{{atomics}}"
9666
10027
  },
9667
10028
  type: "suggestion",
9668
10029
  schema: []
9669
10030
  },
9670
10031
  defaultOptions: [],
9671
10032
  create(context) {
10033
+ const longhandCache = /* @__PURE__ */ new Map();
10034
+ const getLonghand = (name2) => {
10035
+ if (longhandCache.has(name2)) {
10036
+ return longhandCache.get(name2);
10037
+ }
10038
+ const longhand = resolveLonghand(name2, context) ?? name2;
10039
+ longhandCache.set(name2, longhand);
10040
+ return longhand;
10041
+ };
10042
+ const compositePropertyCache = /* @__PURE__ */ new Map();
9672
10043
  const resolveCompositeProperty = (name2) => {
9673
- if (Object.hasOwn(compositeProperties, name2))
10044
+ if (compositePropertyCache.has(name2)) {
10045
+ return compositePropertyCache.get(name2);
10046
+ }
10047
+ if (Object.hasOwn(compositeProperties, name2)) {
10048
+ compositePropertyCache.set(name2, name2);
9674
10049
  return name2;
9675
- const longhand = resolveLonghand(name2, context) ?? name2;
9676
- if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
10050
+ }
10051
+ const longhand = getLonghand(name2);
10052
+ if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand)) {
10053
+ compositePropertyCache.set(name2, longhand);
9677
10054
  return longhand;
10055
+ }
10056
+ compositePropertyCache.set(name2, void 0);
10057
+ return void 0;
9678
10058
  };
9679
- const sendReport = (node) => {
9680
- const cmp = resolveCompositeProperty(node.name);
9681
- if (!cmp)
9682
- return;
9683
- const atomics = compositeProperties[cmp].map((name2) => `\`${name2}\``).join(",\n");
9684
- return context.report({
10059
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
10060
+ const isCachedPandaProp = (node) => {
10061
+ if (pandaPropCache.has(node)) {
10062
+ return pandaPropCache.get(node);
10063
+ }
10064
+ const result = isPandaProp(node, context);
10065
+ pandaPropCache.set(node, result);
10066
+ return !!result;
10067
+ };
10068
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
10069
+ const isCachedPandaAttribute = (node) => {
10070
+ if (pandaAttributeCache.has(node)) {
10071
+ return pandaAttributeCache.get(node);
10072
+ }
10073
+ const result = isPandaAttribute(node, context);
10074
+ pandaAttributeCache.set(node, result);
10075
+ return !!result;
10076
+ };
10077
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
10078
+ const isCachedRecipeVariant = (node) => {
10079
+ if (recipeVariantCache.has(node)) {
10080
+ return recipeVariantCache.get(node);
10081
+ }
10082
+ const result = isRecipeVariant(node, context);
10083
+ recipeVariantCache.set(node, result);
10084
+ return !!result;
10085
+ };
10086
+ const sendReport = (node, composite) => {
10087
+ const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(",\n");
10088
+ context.report({
9685
10089
  node,
9686
10090
  messageId: "atomic",
9687
10091
  data: {
@@ -9694,18 +10098,24 @@ var init_prefer_atomic_properties = __esm({
9694
10098
  JSXAttribute(node) {
9695
10099
  if (!isJSXIdentifier(node.name))
9696
10100
  return;
9697
- if (!isPandaProp(node, context))
10101
+ if (!isCachedPandaProp(node))
9698
10102
  return;
9699
- sendReport(node.name);
10103
+ const composite = resolveCompositeProperty(node.name.name);
10104
+ if (!composite)
10105
+ return;
10106
+ sendReport(node.name, composite);
9700
10107
  },
9701
10108
  Property(node) {
9702
10109
  if (!isIdentifier(node.key))
9703
10110
  return;
9704
- if (!isPandaAttribute(node, context))
10111
+ if (!isCachedPandaAttribute(node))
9705
10112
  return;
9706
- if (isRecipeVariant(node, context))
10113
+ if (isCachedRecipeVariant(node))
9707
10114
  return;
9708
- sendReport(node.key);
10115
+ const composite = resolveCompositeProperty(node.key.name);
10116
+ if (!composite)
10117
+ return;
10118
+ sendReport(node.key, composite);
9709
10119
  }
9710
10120
  };
9711
10121
  }
@@ -9732,28 +10142,69 @@ var init_prefer_composite_properties = __esm({
9732
10142
  description: "Encourage the use of composite properties instead of atomic properties in the codebase."
9733
10143
  },
9734
10144
  messages: {
9735
- composite: "Use composite property of `{{atomic}}` instead. \nPrefer: {{composite}}"
10145
+ composite: "Use composite property instead of `{{atomic}}`. Prefer: `{{composite}}`."
9736
10146
  },
9737
10147
  type: "suggestion",
9738
10148
  schema: []
9739
10149
  },
9740
10150
  defaultOptions: [],
9741
10151
  create(context) {
9742
- const resolveCompositeProperty = (name2) => {
10152
+ const longhandCache = /* @__PURE__ */ new Map();
10153
+ const getLonghand = (name2) => {
10154
+ if (longhandCache.has(name2)) {
10155
+ return longhandCache.get(name2);
10156
+ }
9743
10157
  const longhand = resolveLonghand(name2, context) ?? name2;
9744
- if (!isValidProperty(longhand, context))
9745
- return;
9746
- return Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
10158
+ longhandCache.set(name2, longhand);
10159
+ return longhand;
9747
10160
  };
9748
- const sendReport = (node) => {
9749
- const cmp = resolveCompositeProperty(node.name);
9750
- if (!cmp)
9751
- return;
9752
- return context.report({
10161
+ const compositePropertyCache = /* @__PURE__ */ new Map();
10162
+ const resolveCompositeProperty = (name2) => {
10163
+ if (compositePropertyCache.has(name2)) {
10164
+ return compositePropertyCache.get(name2);
10165
+ }
10166
+ const longhand = getLonghand(name2);
10167
+ if (!isValidProperty(longhand, context)) {
10168
+ compositePropertyCache.set(name2, void 0);
10169
+ return void 0;
10170
+ }
10171
+ const composite = Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
10172
+ compositePropertyCache.set(name2, composite);
10173
+ return composite;
10174
+ };
10175
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
10176
+ const isCachedPandaProp = (node) => {
10177
+ if (pandaPropCache.has(node)) {
10178
+ return pandaPropCache.get(node);
10179
+ }
10180
+ const result = isPandaProp(node, context);
10181
+ pandaPropCache.set(node, result);
10182
+ return !!result;
10183
+ };
10184
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
10185
+ const isCachedPandaAttribute = (node) => {
10186
+ if (pandaAttributeCache.has(node)) {
10187
+ return pandaAttributeCache.get(node);
10188
+ }
10189
+ const result = isPandaAttribute(node, context);
10190
+ pandaAttributeCache.set(node, result);
10191
+ return !!result;
10192
+ };
10193
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
10194
+ const isCachedRecipeVariant = (node) => {
10195
+ if (recipeVariantCache.has(node)) {
10196
+ return recipeVariantCache.get(node);
10197
+ }
10198
+ const result = isRecipeVariant(node, context);
10199
+ recipeVariantCache.set(node, result);
10200
+ return !!result;
10201
+ };
10202
+ const sendReport = (node, composite) => {
10203
+ context.report({
9753
10204
  node,
9754
10205
  messageId: "composite",
9755
10206
  data: {
9756
- composite: cmp,
10207
+ composite,
9757
10208
  atomic: node.name
9758
10209
  }
9759
10210
  });
@@ -9762,18 +10213,24 @@ var init_prefer_composite_properties = __esm({
9762
10213
  JSXAttribute(node) {
9763
10214
  if (!isJSXIdentifier(node.name))
9764
10215
  return;
9765
- if (!isPandaProp(node, context))
10216
+ if (!isCachedPandaProp(node))
9766
10217
  return;
9767
- sendReport(node.name);
10218
+ const composite = resolveCompositeProperty(node.name.name);
10219
+ if (!composite)
10220
+ return;
10221
+ sendReport(node.name, composite);
9768
10222
  },
9769
10223
  Property(node) {
9770
10224
  if (!isIdentifier(node.key))
9771
10225
  return;
9772
- if (!isPandaAttribute(node, context))
10226
+ if (!isCachedPandaAttribute(node))
9773
10227
  return;
9774
- if (isRecipeVariant(node, context))
10228
+ if (isCachedRecipeVariant(node))
9775
10229
  return;
9776
- sendReport(node.key);
10230
+ const composite = resolveCompositeProperty(node.key.name);
10231
+ if (!composite)
10232
+ return;
10233
+ sendReport(node.key, composite);
9777
10234
  }
9778
10235
  };
9779
10236
  }
@@ -9797,35 +10254,82 @@ var init_prefer_unified_property_style = __esm({
9797
10254
  name: RULE_NAME18,
9798
10255
  meta: {
9799
10256
  docs: {
9800
- description: "Discourage against mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results"
10257
+ description: "Discourage mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results."
9801
10258
  },
9802
10259
  messages: {
9803
- unify: "You're mixing atomic {{atomicProperties}} with composite property {{composite}}. \nPrefer atomic styling to mixing atomic and composite properties. \nRemove `{{composite}}` and use one or more of {{atomics}} instead"
10260
+ 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."
9804
10261
  },
9805
10262
  type: "suggestion",
9806
10263
  schema: []
9807
10264
  },
9808
10265
  defaultOptions: [],
9809
10266
  create(context) {
9810
- const getLonghand = (name2) => resolveLonghand(name2, context) ?? name2;
10267
+ const longhandCache = /* @__PURE__ */ new Map();
10268
+ const getLonghand = (name2) => {
10269
+ if (longhandCache.has(name2)) {
10270
+ return longhandCache.get(name2);
10271
+ }
10272
+ const longhand = resolveLonghand(name2, context) ?? name2;
10273
+ longhandCache.set(name2, longhand);
10274
+ return longhand;
10275
+ };
10276
+ const compositePropertyCache = /* @__PURE__ */ new Map();
9811
10277
  const resolveCompositeProperty = (name2) => {
9812
- if (name2 in compositeProperties)
10278
+ if (compositePropertyCache.has(name2)) {
10279
+ return compositePropertyCache.get(name2);
10280
+ }
10281
+ if (name2 in compositeProperties) {
10282
+ compositePropertyCache.set(name2, name2);
9813
10283
  return name2;
10284
+ }
9814
10285
  const longhand = getLonghand(name2);
9815
- if (isValidProperty(longhand, context) && longhand in compositeProperties)
10286
+ if (isValidProperty(longhand, context) && longhand in compositeProperties) {
10287
+ compositePropertyCache.set(name2, longhand);
9816
10288
  return longhand;
10289
+ }
10290
+ compositePropertyCache.set(name2, void 0);
10291
+ return void 0;
9817
10292
  };
9818
- const sendReport = (node, cmp, siblings) => {
9819
- const _atomicProperties = siblings.filter((prop) => compositeProperties[cmp].includes(getLonghand(prop))).map((prop) => `\`${prop}\``);
9820
- if (!_atomicProperties.length)
10293
+ const pandaPropCache = /* @__PURE__ */ new WeakMap();
10294
+ const isCachedPandaProp = (node) => {
10295
+ if (pandaPropCache.has(node)) {
10296
+ return pandaPropCache.get(node);
10297
+ }
10298
+ const result = isPandaProp(node, context);
10299
+ pandaPropCache.set(node, result);
10300
+ return !!result;
10301
+ };
10302
+ const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
10303
+ const isCachedPandaAttribute = (node) => {
10304
+ if (pandaAttributeCache.has(node)) {
10305
+ return pandaAttributeCache.get(node);
10306
+ }
10307
+ const result = isPandaAttribute(node, context);
10308
+ pandaAttributeCache.set(node, result);
10309
+ return !!result;
10310
+ };
10311
+ const recipeVariantCache = /* @__PURE__ */ new WeakMap();
10312
+ const isCachedRecipeVariant = (node) => {
10313
+ if (recipeVariantCache.has(node)) {
10314
+ return recipeVariantCache.get(node);
10315
+ }
10316
+ const result = isRecipeVariant(node, context);
10317
+ recipeVariantCache.set(node, result);
10318
+ return !!result;
10319
+ };
10320
+ const sendReport = (node, composite, siblings) => {
10321
+ const atomicPropertiesSet = new Set(
10322
+ siblings.filter((prop) => compositeProperties[composite].includes(getLonghand(prop)))
10323
+ );
10324
+ if (atomicPropertiesSet.size === 0)
9821
10325
  return;
9822
- const atomicProperties = _atomicProperties.join(", ") + (_atomicProperties.length === 1 ? " style" : " styles");
9823
- const atomics = compositeProperties[cmp].map((name2) => `\`${name2}\``).join(", ");
10326
+ const atomicProperties = Array.from(atomicPropertiesSet).map((prop) => `\`${prop}\``).join(", ");
10327
+ const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(", ");
9824
10328
  context.report({
9825
10329
  node,
9826
10330
  messageId: "unify",
9827
10331
  data: {
9828
- composite: cmp,
10332
+ composite,
9829
10333
  atomicProperties,
9830
10334
  atomics
9831
10335
  }
@@ -9835,30 +10339,30 @@ var init_prefer_unified_property_style = __esm({
9835
10339
  JSXAttribute(node) {
9836
10340
  if (!isJSXIdentifier(node.name))
9837
10341
  return;
9838
- if (!isPandaProp(node, context))
10342
+ if (!isCachedPandaProp(node))
9839
10343
  return;
9840
- const cmp = resolveCompositeProperty(node.name.name);
9841
- if (!cmp)
10344
+ const composite = resolveCompositeProperty(node.name.name);
10345
+ if (!composite)
9842
10346
  return;
9843
10347
  if (!isJSXOpeningElement(node.parent))
9844
10348
  return;
9845
10349
  const siblings = node.parent.attributes.map((attr) => attr.name.name);
9846
- sendReport(node, cmp, siblings);
10350
+ sendReport(node, composite, siblings);
9847
10351
  },
9848
10352
  Property(node) {
9849
10353
  if (!isIdentifier(node.key))
9850
10354
  return;
9851
- if (!isPandaAttribute(node, context))
10355
+ if (!isCachedPandaAttribute(node))
9852
10356
  return;
9853
- if (isRecipeVariant(node, context))
10357
+ if (isCachedRecipeVariant(node))
9854
10358
  return;
9855
- const cmp = resolveCompositeProperty(node.key.name);
9856
- if (!cmp)
10359
+ const composite = resolveCompositeProperty(node.key.name);
10360
+ if (!composite)
9857
10361
  return;
9858
10362
  if (!isObjectExpression(node.parent))
9859
10363
  return;
9860
- const siblings = node.parent.properties.map((prop) => isIdentifier(prop.key) && prop.key.name);
9861
- sendReport(node.key, cmp, siblings);
10364
+ const siblings = node.parent.properties.filter((prop) => prop.type === "Property").map((prop) => isIdentifier(prop.key) ? prop.key.name : "");
10365
+ sendReport(node.key, composite, siblings);
9862
10366
  }
9863
10367
  };
9864
10368
  }