@pandacss/eslint-plugin 0.1.8 → 0.1.10

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.8";
7960
+ var version = "0.1.10";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -8078,12 +8078,16 @@ var isPandaIsh = (name2, context) => {
8078
8078
  return syncAction("matchFile", getSyncOpts(context), name2, imports);
8079
8079
  };
8080
8080
  var findDeclaration = (name2, context) => {
8081
- const scope = (0, import_scope_manager.analyze)(context.sourceCode.ast, {
8082
- sourceType: "module"
8083
- });
8084
- const decl = scope.variables.find((v) => v.name === name2)?.defs.find((d) => isIdentifier(d.name) && d.name.name === name2)?.node;
8085
- if (isVariableDeclarator(decl))
8086
- return decl;
8081
+ try {
8082
+ const scope = (0, import_scope_manager.analyze)(context.sourceCode.ast, {
8083
+ sourceType: "module"
8084
+ });
8085
+ const decl = scope.variables.find((v) => v.name === name2)?.defs.find((d) => isIdentifier(d.name) && d.name.name === name2)?.node;
8086
+ if (isVariableDeclarator(decl))
8087
+ return decl;
8088
+ } catch (error) {
8089
+ return;
8090
+ }
8087
8091
  };
8088
8092
  var isLocalStyledFactory = (node, context) => {
8089
8093
  if (!isJSXIdentifier(node.name))
@@ -8227,6 +8231,31 @@ var getTaggedTemplateCaller = (node) => {
8227
8231
  return node.tag.callee.name;
8228
8232
  }
8229
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
+ }
8230
8259
 
8231
8260
  // src/rules/file-not-included.ts
8232
8261
  var RULE_NAME = "file-not-included";
@@ -8380,6 +8409,8 @@ var rule3 = createRule({
8380
8409
  return;
8381
8410
  if (!isPandaAttribute(node, context))
8382
8411
  return;
8412
+ if (isRecipeVariant(node, context))
8413
+ return;
8383
8414
  context.report({
8384
8415
  node: node.key,
8385
8416
  messageId: "debug",
@@ -8529,6 +8560,8 @@ var rule5 = createRule({
8529
8560
  return;
8530
8561
  if (!isPandaAttribute(node, context))
8531
8562
  return;
8563
+ if (isRecipeVariant(node, context))
8564
+ return;
8532
8565
  handleLiteral(node.value);
8533
8566
  handleTemplateLiteral(node.value);
8534
8567
  }
@@ -8616,6 +8649,8 @@ var rule6 = createRule({
8616
8649
  return;
8617
8650
  if (!isPandaAttribute(node, context))
8618
8651
  return;
8652
+ if (isRecipeVariant(node, context))
8653
+ return;
8619
8654
  if (!isColorAttribute(node.key.name, context))
8620
8655
  return;
8621
8656
  if (isTokenFn(node.value.value?.toString()))
@@ -8725,6 +8760,8 @@ var rule7 = createRule({
8725
8760
  return;
8726
8761
  if (!isPandaAttribute(node, context))
8727
8762
  return;
8763
+ if (isRecipeVariant(node, context))
8764
+ return;
8728
8765
  handleLiteral(node.value);
8729
8766
  handleTemplateLiteral(node.value);
8730
8767
  }
@@ -8757,10 +8794,13 @@ var rule8 = createRule({
8757
8794
  const caller = isInPandaFunction(node, context);
8758
8795
  if (!caller && !isInJSXProp(node, context))
8759
8796
  return;
8797
+ if (isRecipeVariant(node, context))
8798
+ return;
8760
8799
  if (isStyledProperty(node, context))
8761
8800
  return;
8762
- const invalidNesting = isInvalidNesting(node, context, caller);
8763
- if (!invalidNesting)
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
+ if (!(invalidLiteral || invalidTemplateLiteral))
8764
8804
  return;
8765
8805
  context.report({
8766
8806
  node: node.key,
@@ -8771,33 +8811,6 @@ var rule8 = createRule({
8771
8811
  }
8772
8812
  });
8773
8813
  var no_invalid_nesting_default = rule8;
8774
- function isInvalidNesting(node, context, caller) {
8775
- const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
8776
- if (!recipe)
8777
- return checkNode(node);
8778
- let currentNode = node;
8779
- let length = 0;
8780
- let styleObjectParent = null;
8781
- while (currentNode) {
8782
- if (currentNode.key && ["base", "variants"].includes(currentNode.key.name)) {
8783
- styleObjectParent = currentNode.key.name;
8784
- }
8785
- currentNode = currentNode.parent;
8786
- if (!styleObjectParent)
8787
- length++;
8788
- }
8789
- const requiredLength = caller === "cva" ? 2 : 4;
8790
- const extraLength = styleObjectParent === "base" ? 0 : 4;
8791
- if (length >= requiredLength + extraLength) {
8792
- return checkNode(node);
8793
- }
8794
- return false;
8795
- }
8796
- function checkNode(node) {
8797
- const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8798
- const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8799
- return invalidLiteral || invalidTemplateLiteral;
8800
- }
8801
8814
 
8802
8815
  // src/rules/no-invalid-token-paths.ts
8803
8816
  init_cjs_shims();
@@ -8864,6 +8877,8 @@ var rule9 = createRule({
8864
8877
  return;
8865
8878
  if (!isPandaAttribute(node, context))
8866
8879
  return;
8880
+ if (isRecipeVariant(node, context))
8881
+ return;
8867
8882
  handleLiteral(node.value);
8868
8883
  handleTemplateLiteral(node.value);
8869
8884
  },
@@ -8938,6 +8953,8 @@ var rule10 = createRule({
8938
8953
  return;
8939
8954
  if (!isPandaAttribute(node, context))
8940
8955
  return;
8956
+ if (isRecipeVariant(node, context))
8957
+ return;
8941
8958
  sendReport(node.key);
8942
8959
  }
8943
8960
  };
@@ -9043,6 +9060,8 @@ var rule11 = createRule({
9043
9060
  return;
9044
9061
  if (!isPandaAttribute(node, context))
9045
9062
  return;
9063
+ if (isRecipeVariant(node, context))
9064
+ return;
9046
9065
  sendReport(node.key);
9047
9066
  }
9048
9067
  };
@@ -9104,6 +9123,8 @@ var rule12 = createRule({
9104
9123
  return;
9105
9124
  if (!isPandaAttribute(node, context))
9106
9125
  return;
9126
+ if (isRecipeVariant(node, context))
9127
+ return;
9107
9128
  const attr = node.key.name.toString();
9108
9129
  const value = node.value;
9109
9130
  handleReport(node, value, attr);
@@ -9210,6 +9231,8 @@ var rule13 = createRule({
9210
9231
  return;
9211
9232
  if (!isPandaAttribute(node, context))
9212
9233
  return;
9234
+ if (isRecipeVariant(node, context))
9235
+ return;
9213
9236
  handleRuntimeFm(node.value);
9214
9237
  handleLiteral(node.value);
9215
9238
  handleTemplateLiteral(node.value);
@@ -9274,6 +9297,8 @@ var rule14 = createRule({
9274
9297
  return;
9275
9298
  if (!isPandaAttribute(node, context))
9276
9299
  return;
9300
+ if (isRecipeVariant(node, context))
9301
+ return;
9277
9302
  sendReport(node.key);
9278
9303
  }
9279
9304
  };
@@ -9340,6 +9365,8 @@ var rule15 = createRule({
9340
9365
  return;
9341
9366
  if (!isPandaAttribute(node, context))
9342
9367
  return;
9368
+ if (isRecipeVariant(node, context))
9369
+ return;
9343
9370
  sendReport(node.key);
9344
9371
  }
9345
9372
  };
@@ -9514,6 +9541,8 @@ var rule16 = createRule({
9514
9541
  return;
9515
9542
  if (!isPandaAttribute(node, context))
9516
9543
  return;
9544
+ if (isRecipeVariant(node, context))
9545
+ return;
9517
9546
  sendReport(node.key);
9518
9547
  }
9519
9548
  };
@@ -9570,6 +9599,8 @@ var rule17 = createRule({
9570
9599
  return;
9571
9600
  if (!isPandaAttribute(node, context))
9572
9601
  return;
9602
+ if (isRecipeVariant(node, context))
9603
+ return;
9573
9604
  sendReport(node.key);
9574
9605
  }
9575
9606
  };
@@ -9637,6 +9668,8 @@ var rule18 = createRule({
9637
9668
  return;
9638
9669
  if (!isPandaAttribute(node, context))
9639
9670
  return;
9671
+ if (isRecipeVariant(node, context))
9672
+ return;
9640
9673
  const cmp = resolveCompositeProperty(node.key.name);
9641
9674
  if (!cmp)
9642
9675
  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.8";
13
+ version = "0.1.10";
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"() {
@@ -8054,12 +8079,16 @@ var init_helpers = __esm({
8054
8079
  return syncAction("matchFile", getSyncOpts(context), name2, imports);
8055
8080
  };
8056
8081
  findDeclaration = (name2, context) => {
8057
- const scope = (0, import_scope_manager.analyze)(context.sourceCode.ast, {
8058
- sourceType: "module"
8059
- });
8060
- const decl = scope.variables.find((v) => v.name === name2)?.defs.find((d) => isIdentifier(d.name) && d.name.name === name2)?.node;
8061
- if (isVariableDeclarator(decl))
8062
- return decl;
8082
+ try {
8083
+ const scope = (0, import_scope_manager.analyze)(context.sourceCode.ast, {
8084
+ sourceType: "module"
8085
+ });
8086
+ const decl = scope.variables.find((v) => v.name === name2)?.defs.find((d) => isIdentifier(d.name) && d.name.name === name2)?.node;
8087
+ if (isVariableDeclarator(decl))
8088
+ return decl;
8089
+ } catch (error) {
8090
+ return;
8091
+ }
8063
8092
  };
8064
8093
  isLocalStyledFactory = (node, context) => {
8065
8094
  if (!isJSXIdentifier(node.name))
@@ -8383,6 +8412,8 @@ var init_no_debug = __esm({
8383
8412
  return;
8384
8413
  if (!isPandaAttribute(node, context))
8385
8414
  return;
8415
+ if (isRecipeVariant(node, context))
8416
+ return;
8386
8417
  context.report({
8387
8418
  node: node.key,
8388
8419
  messageId: "debug",
@@ -8550,6 +8581,8 @@ var init_no_escape_hatch = __esm({
8550
8581
  return;
8551
8582
  if (!isPandaAttribute(node, context))
8552
8583
  return;
8584
+ if (isRecipeVariant(node, context))
8585
+ return;
8553
8586
  handleLiteral(node.value);
8554
8587
  handleTemplateLiteral(node.value);
8555
8588
  }
@@ -8646,6 +8679,8 @@ var init_no_hardcoded_color = __esm({
8646
8679
  return;
8647
8680
  if (!isPandaAttribute(node, context))
8648
8681
  return;
8682
+ if (isRecipeVariant(node, context))
8683
+ return;
8649
8684
  if (!isColorAttribute(node.key.name, context))
8650
8685
  return;
8651
8686
  if (isTokenFn(node.value.value?.toString()))
@@ -8764,6 +8799,8 @@ var init_no_important = __esm({
8764
8799
  return;
8765
8800
  if (!isPandaAttribute(node, context))
8766
8801
  return;
8802
+ if (isRecipeVariant(node, context))
8803
+ return;
8767
8804
  handleLiteral(node.value);
8768
8805
  handleTemplateLiteral(node.value);
8769
8806
  }
@@ -8775,33 +8812,6 @@ var init_no_important = __esm({
8775
8812
  });
8776
8813
 
8777
8814
  // src/rules/no-invalid-nesting.ts
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
8815
  var RULE_NAME8, rule8, no_invalid_nesting_default;
8806
8816
  var init_no_invalid_nesting = __esm({
8807
8817
  "src/rules/no-invalid-nesting.ts"() {
@@ -8832,10 +8842,13 @@ var init_no_invalid_nesting = __esm({
8832
8842
  const caller = isInPandaFunction(node, context);
8833
8843
  if (!caller && !isInJSXProp(node, context))
8834
8844
  return;
8845
+ if (isRecipeVariant(node, context))
8846
+ return;
8835
8847
  if (isStyledProperty(node, context))
8836
8848
  return;
8837
- const invalidNesting = isInvalidNesting(node, context, caller);
8838
- if (!invalidNesting)
8849
+ const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8850
+ const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8851
+ if (!(invalidLiteral || invalidTemplateLiteral))
8839
8852
  return;
8840
8853
  context.report({
8841
8854
  node: node.key,
@@ -8921,6 +8934,8 @@ var init_no_invalid_token_paths = __esm({
8921
8934
  return;
8922
8935
  if (!isPandaAttribute(node, context))
8923
8936
  return;
8937
+ if (isRecipeVariant(node, context))
8938
+ return;
8924
8939
  handleLiteral(node.value);
8925
8940
  handleTemplateLiteral(node.value);
8926
8941
  },
@@ -9004,6 +9019,8 @@ var init_no_margin_properties = __esm({
9004
9019
  return;
9005
9020
  if (!isPandaAttribute(node, context))
9006
9021
  return;
9022
+ if (isRecipeVariant(node, context))
9023
+ return;
9007
9024
  sendReport(node.key);
9008
9025
  }
9009
9026
  };
@@ -9123,6 +9140,8 @@ var init_no_physical_properties = __esm({
9123
9140
  return;
9124
9141
  if (!isPandaAttribute(node, context))
9125
9142
  return;
9143
+ if (isRecipeVariant(node, context))
9144
+ return;
9126
9145
  sendReport(node.key);
9127
9146
  }
9128
9147
  };
@@ -9193,6 +9212,8 @@ var init_no_property_renaming = __esm({
9193
9212
  return;
9194
9213
  if (!isPandaAttribute(node, context))
9195
9214
  return;
9215
+ if (isRecipeVariant(node, context))
9216
+ return;
9196
9217
  const attr = node.key.name.toString();
9197
9218
  const value = node.value;
9198
9219
  handleReport(node, value, attr);
@@ -9308,6 +9329,8 @@ var init_no_unsafe_token_fn_usage = __esm({
9308
9329
  return;
9309
9330
  if (!isPandaAttribute(node, context))
9310
9331
  return;
9332
+ if (isRecipeVariant(node, context))
9333
+ return;
9311
9334
  handleRuntimeFm(node.value);
9312
9335
  handleLiteral(node.value);
9313
9336
  handleTemplateLiteral(node.value);
@@ -9381,6 +9404,8 @@ var init_prefer_longhand_properties = __esm({
9381
9404
  return;
9382
9405
  if (!isPandaAttribute(node, context))
9383
9406
  return;
9407
+ if (isRecipeVariant(node, context))
9408
+ return;
9384
9409
  sendReport(node.key);
9385
9410
  }
9386
9411
  };
@@ -9456,6 +9481,8 @@ var init_prefer_shorthand_properties = __esm({
9456
9481
  return;
9457
9482
  if (!isPandaAttribute(node, context))
9458
9483
  return;
9484
+ if (isRecipeVariant(node, context))
9485
+ return;
9459
9486
  sendReport(node.key);
9460
9487
  }
9461
9488
  };
@@ -9644,6 +9671,8 @@ var init_prefer_atomic_properties = __esm({
9644
9671
  return;
9645
9672
  if (!isPandaAttribute(node, context))
9646
9673
  return;
9674
+ if (isRecipeVariant(node, context))
9675
+ return;
9647
9676
  sendReport(node.key);
9648
9677
  }
9649
9678
  };
@@ -9710,6 +9739,8 @@ var init_prefer_composite_properties = __esm({
9710
9739
  return;
9711
9740
  if (!isPandaAttribute(node, context))
9712
9741
  return;
9742
+ if (isRecipeVariant(node, context))
9743
+ return;
9713
9744
  sendReport(node.key);
9714
9745
  }
9715
9746
  };
@@ -9787,6 +9818,8 @@ var init_prefer_unified_property_style = __esm({
9787
9818
  return;
9788
9819
  if (!isPandaAttribute(node, context))
9789
9820
  return;
9821
+ if (isRecipeVariant(node, context))
9822
+ return;
9790
9823
  const cmp = resolveCompositeProperty(node.key.name);
9791
9824
  if (!cmp)
9792
9825
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",