@pandacss/eslint-plugin 0.1.9 → 0.1.11

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 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.1.9";
7960
+ var version = "0.1.11";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -8231,6 +8231,31 @@ var getTaggedTemplateCaller = (node) => {
8231
8231
  return node.tag.callee.name;
8232
8232
  }
8233
8233
  };
8234
+ function isRecipeVariant(node, context) {
8235
+ const caller = isInPandaFunction(node, context);
8236
+ if (!caller)
8237
+ return;
8238
+ const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
8239
+ if (!recipe)
8240
+ return;
8241
+ let currentNode = node;
8242
+ let length = 0;
8243
+ let styleObjectParent = null;
8244
+ while (currentNode) {
8245
+ const keyName = currentNode?.key?.name;
8246
+ if (keyName && ["base", "variants"].includes(keyName)) {
8247
+ styleObjectParent = keyName;
8248
+ }
8249
+ currentNode = currentNode.parent;
8250
+ if (!styleObjectParent)
8251
+ length++;
8252
+ }
8253
+ const isCvaCaller = caller === "cva";
8254
+ const requiredLength = isCvaCaller ? 2 : 4;
8255
+ const extraLength = styleObjectParent === "base" ? 0 : 4;
8256
+ if (length < requiredLength + extraLength)
8257
+ return true;
8258
+ }
8234
8259
 
8235
8260
  // src/rules/file-not-included.ts
8236
8261
  var RULE_NAME = "file-not-included";
@@ -8384,6 +8409,8 @@ var rule3 = createRule({
8384
8409
  return;
8385
8410
  if (!isPandaAttribute(node, context))
8386
8411
  return;
8412
+ if (isRecipeVariant(node, context))
8413
+ return;
8387
8414
  context.report({
8388
8415
  node: node.key,
8389
8416
  messageId: "debug",
@@ -8410,7 +8437,9 @@ var rule4 = createRule({
8410
8437
  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."
8411
8438
  },
8412
8439
  messages: {
8413
- dynamic: "Remove dynamic value. Prefer static styles"
8440
+ dynamic: "Remove dynamic value. Prefer static styles",
8441
+ dynamicProperty: "Remove dynamic property. Prefer static style property",
8442
+ dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition"
8414
8443
  },
8415
8444
  type: "suggestion",
8416
8445
  schema: []
@@ -8436,6 +8465,14 @@ var rule4 = createRule({
8436
8465
  messageId: "dynamic"
8437
8466
  });
8438
8467
  },
8468
+ "Property[computed=true]"(node) {
8469
+ if (!isInPandaFunction(node, context))
8470
+ return;
8471
+ context.report({
8472
+ node: node.key,
8473
+ messageId: isRecipeVariant(node, context) ? "dynamicRecipeVariant" : "dynamicProperty"
8474
+ });
8475
+ },
8439
8476
  Property(node) {
8440
8477
  if (!isIdentifier(node.key))
8441
8478
  return;
@@ -8533,6 +8570,8 @@ var rule5 = createRule({
8533
8570
  return;
8534
8571
  if (!isPandaAttribute(node, context))
8535
8572
  return;
8573
+ if (isRecipeVariant(node, context))
8574
+ return;
8536
8575
  handleLiteral(node.value);
8537
8576
  handleTemplateLiteral(node.value);
8538
8577
  }
@@ -8620,6 +8659,8 @@ var rule6 = createRule({
8620
8659
  return;
8621
8660
  if (!isPandaAttribute(node, context))
8622
8661
  return;
8662
+ if (isRecipeVariant(node, context))
8663
+ return;
8623
8664
  if (!isColorAttribute(node.key.name, context))
8624
8665
  return;
8625
8666
  if (isTokenFn(node.value.value?.toString()))
@@ -8729,6 +8770,8 @@ var rule7 = createRule({
8729
8770
  return;
8730
8771
  if (!isPandaAttribute(node, context))
8731
8772
  return;
8773
+ if (isRecipeVariant(node, context))
8774
+ return;
8732
8775
  handleLiteral(node.value);
8733
8776
  handleTemplateLiteral(node.value);
8734
8777
  }
@@ -8761,10 +8804,13 @@ var rule8 = createRule({
8761
8804
  const caller = isInPandaFunction(node, context);
8762
8805
  if (!caller && !isInJSXProp(node, context))
8763
8806
  return;
8807
+ if (isRecipeVariant(node, context))
8808
+ return;
8764
8809
  if (isStyledProperty(node, context))
8765
8810
  return;
8766
- const invalidNesting = isInvalidNesting(node, context, caller);
8767
- if (!invalidNesting)
8811
+ const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8812
+ const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8813
+ if (!(invalidLiteral || invalidTemplateLiteral))
8768
8814
  return;
8769
8815
  context.report({
8770
8816
  node: node.key,
@@ -8775,33 +8821,6 @@ var rule8 = createRule({
8775
8821
  }
8776
8822
  });
8777
8823
  var no_invalid_nesting_default = rule8;
8778
- function isInvalidNesting(node, context, caller) {
8779
- const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
8780
- if (!recipe)
8781
- return checkNode(node);
8782
- let currentNode = node;
8783
- let length = 0;
8784
- let styleObjectParent = null;
8785
- while (currentNode) {
8786
- if (currentNode.key && ["base", "variants"].includes(currentNode.key.name)) {
8787
- styleObjectParent = currentNode.key.name;
8788
- }
8789
- currentNode = currentNode.parent;
8790
- if (!styleObjectParent)
8791
- length++;
8792
- }
8793
- const requiredLength = caller === "cva" ? 2 : 4;
8794
- const extraLength = styleObjectParent === "base" ? 0 : 4;
8795
- if (length >= requiredLength + extraLength) {
8796
- return checkNode(node);
8797
- }
8798
- return false;
8799
- }
8800
- function checkNode(node) {
8801
- const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8802
- const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8803
- return invalidLiteral || invalidTemplateLiteral;
8804
- }
8805
8824
 
8806
8825
  // src/rules/no-invalid-token-paths.ts
8807
8826
  init_cjs_shims();
@@ -8868,6 +8887,8 @@ var rule9 = createRule({
8868
8887
  return;
8869
8888
  if (!isPandaAttribute(node, context))
8870
8889
  return;
8890
+ if (isRecipeVariant(node, context))
8891
+ return;
8871
8892
  handleLiteral(node.value);
8872
8893
  handleTemplateLiteral(node.value);
8873
8894
  },
@@ -8942,6 +8963,8 @@ var rule10 = createRule({
8942
8963
  return;
8943
8964
  if (!isPandaAttribute(node, context))
8944
8965
  return;
8966
+ if (isRecipeVariant(node, context))
8967
+ return;
8945
8968
  sendReport(node.key);
8946
8969
  }
8947
8970
  };
@@ -9047,6 +9070,8 @@ var rule11 = createRule({
9047
9070
  return;
9048
9071
  if (!isPandaAttribute(node, context))
9049
9072
  return;
9073
+ if (isRecipeVariant(node, context))
9074
+ return;
9050
9075
  sendReport(node.key);
9051
9076
  }
9052
9077
  };
@@ -9108,6 +9133,8 @@ var rule12 = createRule({
9108
9133
  return;
9109
9134
  if (!isPandaAttribute(node, context))
9110
9135
  return;
9136
+ if (isRecipeVariant(node, context))
9137
+ return;
9111
9138
  const attr = node.key.name.toString();
9112
9139
  const value = node.value;
9113
9140
  handleReport(node, value, attr);
@@ -9214,6 +9241,8 @@ var rule13 = createRule({
9214
9241
  return;
9215
9242
  if (!isPandaAttribute(node, context))
9216
9243
  return;
9244
+ if (isRecipeVariant(node, context))
9245
+ return;
9217
9246
  handleRuntimeFm(node.value);
9218
9247
  handleLiteral(node.value);
9219
9248
  handleTemplateLiteral(node.value);
@@ -9278,6 +9307,8 @@ var rule14 = createRule({
9278
9307
  return;
9279
9308
  if (!isPandaAttribute(node, context))
9280
9309
  return;
9310
+ if (isRecipeVariant(node, context))
9311
+ return;
9281
9312
  sendReport(node.key);
9282
9313
  }
9283
9314
  };
@@ -9344,6 +9375,8 @@ var rule15 = createRule({
9344
9375
  return;
9345
9376
  if (!isPandaAttribute(node, context))
9346
9377
  return;
9378
+ if (isRecipeVariant(node, context))
9379
+ return;
9347
9380
  sendReport(node.key);
9348
9381
  }
9349
9382
  };
@@ -9518,6 +9551,8 @@ var rule16 = createRule({
9518
9551
  return;
9519
9552
  if (!isPandaAttribute(node, context))
9520
9553
  return;
9554
+ if (isRecipeVariant(node, context))
9555
+ return;
9521
9556
  sendReport(node.key);
9522
9557
  }
9523
9558
  };
@@ -9574,6 +9609,8 @@ var rule17 = createRule({
9574
9609
  return;
9575
9610
  if (!isPandaAttribute(node, context))
9576
9611
  return;
9612
+ if (isRecipeVariant(node, context))
9613
+ return;
9577
9614
  sendReport(node.key);
9578
9615
  }
9579
9616
  };
@@ -9641,6 +9678,8 @@ var rule18 = createRule({
9641
9678
  return;
9642
9679
  if (!isPandaAttribute(node, context))
9643
9680
  return;
9681
+ if (isRecipeVariant(node, context))
9682
+ return;
9644
9683
  const cmp = resolveCompositeProperty(node.key.name);
9645
9684
  if (!cmp)
9646
9685
  return;
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.9";
13
+ version = "0.1.11";
14
14
  }
15
15
  });
16
16
 
@@ -7982,6 +7982,31 @@ var init_nodes = __esm({
7982
7982
  });
7983
7983
 
7984
7984
  // src/utils/helpers.ts
7985
+ function isRecipeVariant(node, context) {
7986
+ const caller = isInPandaFunction(node, context);
7987
+ if (!caller)
7988
+ return;
7989
+ const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
7990
+ if (!recipe)
7991
+ return;
7992
+ let currentNode = node;
7993
+ let length = 0;
7994
+ let styleObjectParent = null;
7995
+ while (currentNode) {
7996
+ const keyName = currentNode?.key?.name;
7997
+ if (keyName && ["base", "variants"].includes(keyName)) {
7998
+ styleObjectParent = keyName;
7999
+ }
8000
+ currentNode = currentNode.parent;
8001
+ if (!styleObjectParent)
8002
+ length++;
8003
+ }
8004
+ const isCvaCaller = caller === "cva";
8005
+ const requiredLength = isCvaCaller ? 2 : 4;
8006
+ const extraLength = styleObjectParent === "base" ? 0 : 4;
8007
+ if (length < requiredLength + extraLength)
8008
+ return true;
8009
+ }
7985
8010
  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;
7986
8011
  var init_helpers = __esm({
7987
8012
  "src/utils/helpers.ts"() {
@@ -8387,6 +8412,8 @@ var init_no_debug = __esm({
8387
8412
  return;
8388
8413
  if (!isPandaAttribute(node, context))
8389
8414
  return;
8415
+ if (isRecipeVariant(node, context))
8416
+ return;
8390
8417
  context.report({
8391
8418
  node: node.key,
8392
8419
  messageId: "debug",
@@ -8422,7 +8449,9 @@ var init_no_dynamic_styling = __esm({
8422
8449
  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."
8423
8450
  },
8424
8451
  messages: {
8425
- dynamic: "Remove dynamic value. Prefer static styles"
8452
+ dynamic: "Remove dynamic value. Prefer static styles",
8453
+ dynamicProperty: "Remove dynamic property. Prefer static style property",
8454
+ dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition"
8426
8455
  },
8427
8456
  type: "suggestion",
8428
8457
  schema: []
@@ -8448,6 +8477,14 @@ var init_no_dynamic_styling = __esm({
8448
8477
  messageId: "dynamic"
8449
8478
  });
8450
8479
  },
8480
+ "Property[computed=true]"(node) {
8481
+ if (!isInPandaFunction(node, context))
8482
+ return;
8483
+ context.report({
8484
+ node: node.key,
8485
+ messageId: isRecipeVariant(node, context) ? "dynamicRecipeVariant" : "dynamicProperty"
8486
+ });
8487
+ },
8451
8488
  Property(node) {
8452
8489
  if (!isIdentifier(node.key))
8453
8490
  return;
@@ -8554,6 +8591,8 @@ var init_no_escape_hatch = __esm({
8554
8591
  return;
8555
8592
  if (!isPandaAttribute(node, context))
8556
8593
  return;
8594
+ if (isRecipeVariant(node, context))
8595
+ return;
8557
8596
  handleLiteral(node.value);
8558
8597
  handleTemplateLiteral(node.value);
8559
8598
  }
@@ -8650,6 +8689,8 @@ var init_no_hardcoded_color = __esm({
8650
8689
  return;
8651
8690
  if (!isPandaAttribute(node, context))
8652
8691
  return;
8692
+ if (isRecipeVariant(node, context))
8693
+ return;
8653
8694
  if (!isColorAttribute(node.key.name, context))
8654
8695
  return;
8655
8696
  if (isTokenFn(node.value.value?.toString()))
@@ -8768,6 +8809,8 @@ var init_no_important = __esm({
8768
8809
  return;
8769
8810
  if (!isPandaAttribute(node, context))
8770
8811
  return;
8812
+ if (isRecipeVariant(node, context))
8813
+ return;
8771
8814
  handleLiteral(node.value);
8772
8815
  handleTemplateLiteral(node.value);
8773
8816
  }
@@ -8779,33 +8822,6 @@ var init_no_important = __esm({
8779
8822
  });
8780
8823
 
8781
8824
  // src/rules/no-invalid-nesting.ts
8782
- function isInvalidNesting(node, context, caller) {
8783
- const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
8784
- if (!recipe)
8785
- return checkNode(node);
8786
- let currentNode = node;
8787
- let length = 0;
8788
- let styleObjectParent = null;
8789
- while (currentNode) {
8790
- if (currentNode.key && ["base", "variants"].includes(currentNode.key.name)) {
8791
- styleObjectParent = currentNode.key.name;
8792
- }
8793
- currentNode = currentNode.parent;
8794
- if (!styleObjectParent)
8795
- length++;
8796
- }
8797
- const requiredLength = caller === "cva" ? 2 : 4;
8798
- const extraLength = styleObjectParent === "base" ? 0 : 4;
8799
- if (length >= requiredLength + extraLength) {
8800
- return checkNode(node);
8801
- }
8802
- return false;
8803
- }
8804
- function checkNode(node) {
8805
- const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8806
- const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8807
- return invalidLiteral || invalidTemplateLiteral;
8808
- }
8809
8825
  var RULE_NAME8, rule8, no_invalid_nesting_default;
8810
8826
  var init_no_invalid_nesting = __esm({
8811
8827
  "src/rules/no-invalid-nesting.ts"() {
@@ -8836,10 +8852,13 @@ var init_no_invalid_nesting = __esm({
8836
8852
  const caller = isInPandaFunction(node, context);
8837
8853
  if (!caller && !isInJSXProp(node, context))
8838
8854
  return;
8855
+ if (isRecipeVariant(node, context))
8856
+ return;
8839
8857
  if (isStyledProperty(node, context))
8840
8858
  return;
8841
- const invalidNesting = isInvalidNesting(node, context, caller);
8842
- if (!invalidNesting)
8859
+ const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8860
+ const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8861
+ if (!(invalidLiteral || invalidTemplateLiteral))
8843
8862
  return;
8844
8863
  context.report({
8845
8864
  node: node.key,
@@ -8925,6 +8944,8 @@ var init_no_invalid_token_paths = __esm({
8925
8944
  return;
8926
8945
  if (!isPandaAttribute(node, context))
8927
8946
  return;
8947
+ if (isRecipeVariant(node, context))
8948
+ return;
8928
8949
  handleLiteral(node.value);
8929
8950
  handleTemplateLiteral(node.value);
8930
8951
  },
@@ -9008,6 +9029,8 @@ var init_no_margin_properties = __esm({
9008
9029
  return;
9009
9030
  if (!isPandaAttribute(node, context))
9010
9031
  return;
9032
+ if (isRecipeVariant(node, context))
9033
+ return;
9011
9034
  sendReport(node.key);
9012
9035
  }
9013
9036
  };
@@ -9127,6 +9150,8 @@ var init_no_physical_properties = __esm({
9127
9150
  return;
9128
9151
  if (!isPandaAttribute(node, context))
9129
9152
  return;
9153
+ if (isRecipeVariant(node, context))
9154
+ return;
9130
9155
  sendReport(node.key);
9131
9156
  }
9132
9157
  };
@@ -9197,6 +9222,8 @@ var init_no_property_renaming = __esm({
9197
9222
  return;
9198
9223
  if (!isPandaAttribute(node, context))
9199
9224
  return;
9225
+ if (isRecipeVariant(node, context))
9226
+ return;
9200
9227
  const attr = node.key.name.toString();
9201
9228
  const value = node.value;
9202
9229
  handleReport(node, value, attr);
@@ -9312,6 +9339,8 @@ var init_no_unsafe_token_fn_usage = __esm({
9312
9339
  return;
9313
9340
  if (!isPandaAttribute(node, context))
9314
9341
  return;
9342
+ if (isRecipeVariant(node, context))
9343
+ return;
9315
9344
  handleRuntimeFm(node.value);
9316
9345
  handleLiteral(node.value);
9317
9346
  handleTemplateLiteral(node.value);
@@ -9385,6 +9414,8 @@ var init_prefer_longhand_properties = __esm({
9385
9414
  return;
9386
9415
  if (!isPandaAttribute(node, context))
9387
9416
  return;
9417
+ if (isRecipeVariant(node, context))
9418
+ return;
9388
9419
  sendReport(node.key);
9389
9420
  }
9390
9421
  };
@@ -9460,6 +9491,8 @@ var init_prefer_shorthand_properties = __esm({
9460
9491
  return;
9461
9492
  if (!isPandaAttribute(node, context))
9462
9493
  return;
9494
+ if (isRecipeVariant(node, context))
9495
+ return;
9463
9496
  sendReport(node.key);
9464
9497
  }
9465
9498
  };
@@ -9648,6 +9681,8 @@ var init_prefer_atomic_properties = __esm({
9648
9681
  return;
9649
9682
  if (!isPandaAttribute(node, context))
9650
9683
  return;
9684
+ if (isRecipeVariant(node, context))
9685
+ return;
9651
9686
  sendReport(node.key);
9652
9687
  }
9653
9688
  };
@@ -9714,6 +9749,8 @@ var init_prefer_composite_properties = __esm({
9714
9749
  return;
9715
9750
  if (!isPandaAttribute(node, context))
9716
9751
  return;
9752
+ if (isRecipeVariant(node, context))
9753
+ return;
9717
9754
  sendReport(node.key);
9718
9755
  }
9719
9756
  };
@@ -9791,6 +9828,8 @@ var init_prefer_unified_property_style = __esm({
9791
9828
  return;
9792
9829
  if (!isPandaAttribute(node, context))
9793
9830
  return;
9831
+ if (isRecipeVariant(node, context))
9832
+ return;
9794
9833
  const cmp = resolveCompositeProperty(node.key.name);
9795
9834
  if (!cmp)
9796
9835
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",