@pandacss/eslint-plugin 0.1.7 → 0.1.8

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.7";
7960
+ var version = "0.1.8";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -8754,23 +8754,50 @@ var rule8 = createRule({
8754
8754
  Property(node) {
8755
8755
  if (!isObjectExpression(node.value) || isIdentifier(node.key))
8756
8756
  return;
8757
- if (!isInPandaFunction(node, context) && !isInJSXProp(node, context))
8757
+ const caller = isInPandaFunction(node, context);
8758
+ if (!caller && !isInJSXProp(node, context))
8758
8759
  return;
8759
8760
  if (isStyledProperty(node, context))
8760
8761
  return;
8761
- const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8762
- const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8763
- if (invalidLiteral || invalidTemplateLiteral) {
8764
- context.report({
8765
- node: node.key,
8766
- messageId: "nesting"
8767
- });
8768
- }
8762
+ const invalidNesting = isInvalidNesting(node, context, caller);
8763
+ if (!invalidNesting)
8764
+ return;
8765
+ context.report({
8766
+ node: node.key,
8767
+ messageId: "nesting"
8768
+ });
8769
8769
  }
8770
8770
  };
8771
8771
  }
8772
8772
  });
8773
8773
  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
+ }
8774
8801
 
8775
8802
  // src/rules/no-invalid-token-paths.ts
8776
8803
  init_cjs_shims();
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.7";
13
+ version = "0.1.8";
14
14
  }
15
15
  });
16
16
 
@@ -8775,6 +8775,33 @@ var init_no_important = __esm({
8775
8775
  });
8776
8776
 
8777
8777
  // 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
+ }
8778
8805
  var RULE_NAME8, rule8, no_invalid_nesting_default;
8779
8806
  var init_no_invalid_nesting = __esm({
8780
8807
  "src/rules/no-invalid-nesting.ts"() {
@@ -8802,18 +8829,18 @@ var init_no_invalid_nesting = __esm({
8802
8829
  Property(node) {
8803
8830
  if (!isObjectExpression(node.value) || isIdentifier(node.key))
8804
8831
  return;
8805
- if (!isInPandaFunction(node, context) && !isInJSXProp(node, context))
8832
+ const caller = isInPandaFunction(node, context);
8833
+ if (!caller && !isInJSXProp(node, context))
8806
8834
  return;
8807
8835
  if (isStyledProperty(node, context))
8808
8836
  return;
8809
- const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8810
- const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8811
- if (invalidLiteral || invalidTemplateLiteral) {
8812
- context.report({
8813
- node: node.key,
8814
- messageId: "nesting"
8815
- });
8816
- }
8837
+ const invalidNesting = isInvalidNesting(node, context, caller);
8838
+ if (!invalidNesting)
8839
+ return;
8840
+ context.report({
8841
+ node: node.key,
8842
+ messageId: "nesting"
8843
+ });
8817
8844
  }
8818
8845
  };
8819
8846
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",