@pandacss/eslint-plugin 0.0.11 → 0.0.13

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.
Files changed (3) hide show
  1. package/dist/index.js +379 -151
  2. package/dist/index.mjs +424 -165
  3. package/package.json +1 -1
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.0.11";
13
+ version = "0.0.13";
14
14
  }
15
15
  });
16
16
 
@@ -7950,7 +7950,7 @@ var require_dist3 = __commonJS({
7950
7950
  // src/utils/nodes.ts
7951
7951
  import { isNodeOfType } from "@typescript-eslint/utils/ast-utils";
7952
7952
  import { AST_NODE_TYPES } from "@typescript-eslint/utils";
7953
- var isIdentifier, isLiteral, isTemplateLiteral, isObjectExpression, isMemberExpression, isVariableDeclarator, isVariableDeclaration, isJSXMemberExpression, isJSXOpeningElement, isJSXExpressionContainer, isJSXAttribute, isJSXIdentifier, isCallExpression, isImportDeclaration, isImportSpecifier;
7953
+ var isIdentifier, isLiteral, isTemplateLiteral, isObjectExpression, isMemberExpression, isVariableDeclarator, isVariableDeclaration, isJSXMemberExpression, isJSXOpeningElement, isJSXExpressionContainer, isJSXAttribute, isJSXIdentifier, isCallExpression, isImportDeclaration, isImportSpecifier, isProperty;
7954
7954
  var init_nodes = __esm({
7955
7955
  "src/utils/nodes.ts"() {
7956
7956
  "use strict";
@@ -7970,11 +7970,12 @@ var init_nodes = __esm({
7970
7970
  isCallExpression = isNodeOfType(AST_NODE_TYPES.CallExpression);
7971
7971
  isImportDeclaration = isNodeOfType(AST_NODE_TYPES.ImportDeclaration);
7972
7972
  isImportSpecifier = isNodeOfType(AST_NODE_TYPES.ImportSpecifier);
7973
+ isProperty = isNodeOfType(AST_NODE_TYPES.Property);
7973
7974
  }
7974
7975
  });
7975
7976
 
7976
7977
  // src/utils/helpers.ts
7977
- var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isInPandaFunction, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
7978
+ var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isStyledProperty, isInPandaFunction, isInJSXProp, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
7978
7979
  var init_helpers = __esm({
7979
7980
  "src/utils/helpers.ts"() {
7980
7981
  "use strict";
@@ -8098,6 +8099,17 @@ var init_helpers = __esm({
8098
8099
  return;
8099
8100
  return true;
8100
8101
  };
8102
+ isStyledProperty = (node, context, calleeName) => {
8103
+ if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key))
8104
+ return;
8105
+ if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName))
8106
+ return;
8107
+ if (isLiteral(node.key) && typeof node.key.value === "string" && !isValidProperty(node.key.value, context, calleeName))
8108
+ return;
8109
+ if (isTemplateLiteral(node.key) && !isValidProperty(node.key.quasis[0].value.raw, context, calleeName))
8110
+ return;
8111
+ return true;
8112
+ };
8101
8113
  isInPandaFunction = (node, context) => {
8102
8114
  const callAncestor = getAncestor(isCallExpression, node);
8103
8115
  if (!callAncestor)
@@ -8113,17 +8125,9 @@ var init_helpers = __esm({
8113
8125
  return;
8114
8126
  if (!isPandaIsh(calleeName, context))
8115
8127
  return;
8116
- if (!isIdentifier(node.key))
8117
- return;
8118
- const attr = node.key.name;
8119
- if (!isValidProperty(attr, context, calleeName))
8120
- return;
8121
- return true;
8128
+ return calleeName;
8122
8129
  };
8123
- isPandaAttribute = (node, context) => {
8124
- const callAncestor = getAncestor(isCallExpression, node);
8125
- if (callAncestor)
8126
- return isInPandaFunction(node, context);
8130
+ isInJSXProp = (node, context) => {
8127
8131
  const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8128
8132
  const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8129
8133
  if (!jsxExprAncestor || !jsxAttrAncestor)
@@ -8134,6 +8138,16 @@ var init_helpers = __esm({
8134
8138
  return;
8135
8139
  return true;
8136
8140
  };
8141
+ isPandaAttribute = (node, context) => {
8142
+ const callAncestor = getAncestor(isCallExpression, node);
8143
+ if (callAncestor) {
8144
+ const callee = isInPandaFunction(node, context);
8145
+ if (!callee)
8146
+ return;
8147
+ return isStyledProperty(node, context, callee);
8148
+ }
8149
+ return isInJSXProp(node, context);
8150
+ };
8137
8151
  resolveLonghand = (name2, context) => {
8138
8152
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
8139
8153
  };
@@ -8612,10 +8626,163 @@ var init_no_hardcoded_color = __esm({
8612
8626
  }
8613
8627
  });
8614
8628
 
8629
+ // src/rules/no-important.ts
8630
+ import { getArbitraryValue as getArbitraryValue2 } from "@pandacss/shared";
8631
+ var exclamationRegex, importantRegex, RULE_NAME7, rule7, no_important_default;
8632
+ var init_no_important = __esm({
8633
+ "src/rules/no-important.ts"() {
8634
+ "use strict";
8635
+ init_esm_shims();
8636
+ init_helpers();
8637
+ init_utils();
8638
+ init_nodes();
8639
+ exclamationRegex = /\s*!$/;
8640
+ importantRegex = /\s*!important\s*$/;
8641
+ RULE_NAME7 = "no-important";
8642
+ rule7 = createRule({
8643
+ name: RULE_NAME7,
8644
+ meta: {
8645
+ docs: {
8646
+ description: "Disallow usage of important keyword. Prioroitize specificity for a maintainable and predictable styling structure."
8647
+ },
8648
+ messages: {
8649
+ important: "Avoid using the !important keyword. Refactor your code to prioritize specificity for predictable styling.",
8650
+ remove: "Remove the `{{keyword}}` keyword."
8651
+ },
8652
+ type: "suggestion",
8653
+ hasSuggestions: true,
8654
+ schema: []
8655
+ },
8656
+ defaultOptions: [],
8657
+ create(context) {
8658
+ const removeQuotes = ([start, end]) => [start + 1, end - 1];
8659
+ const hasImportantKeyword = (_value) => {
8660
+ if (!_value)
8661
+ return false;
8662
+ const value = getArbitraryValue2(_value);
8663
+ return exclamationRegex.test(value) || importantRegex.test(value);
8664
+ };
8665
+ const removeImportantKeyword = (input) => {
8666
+ if (exclamationRegex.test(input)) {
8667
+ return { fixed: input.replace(exclamationRegex, ""), keyword: "!" };
8668
+ } else if (importantRegex.test(input)) {
8669
+ return { fixed: input.replace(importantRegex, ""), keyword: "!important" };
8670
+ } else {
8671
+ return { fixed: input, keyword: null };
8672
+ }
8673
+ };
8674
+ const handleLiteral = (node) => {
8675
+ if (!isLiteral(node))
8676
+ return;
8677
+ if (!hasImportantKeyword(node.value?.toString()))
8678
+ return;
8679
+ sendReport(node);
8680
+ };
8681
+ const handleTemplateLiteral = (node) => {
8682
+ if (!isTemplateLiteral(node))
8683
+ return;
8684
+ if (node.expressions.length > 0)
8685
+ return;
8686
+ if (!hasImportantKeyword(node.quasis[0].value.raw))
8687
+ return;
8688
+ sendReport(node.quasis[0], node.quasis[0].value.raw);
8689
+ };
8690
+ const sendReport = (node, _value) => {
8691
+ const value = _value ?? node.value?.toString();
8692
+ const { keyword, fixed } = removeImportantKeyword(value);
8693
+ return context.report({
8694
+ node,
8695
+ messageId: "important",
8696
+ suggest: [
8697
+ {
8698
+ messageId: "remove",
8699
+ data: { keyword },
8700
+ fix: (fixer) => {
8701
+ return fixer.replaceTextRange(removeQuotes(node.range), fixed);
8702
+ }
8703
+ }
8704
+ ]
8705
+ });
8706
+ };
8707
+ return {
8708
+ JSXAttribute(node) {
8709
+ if (!node.value)
8710
+ return;
8711
+ if (!isPandaProp(node, context))
8712
+ return;
8713
+ handleLiteral(node.value);
8714
+ if (!isJSXExpressionContainer(node.value))
8715
+ return;
8716
+ handleLiteral(node.value.expression);
8717
+ handleTemplateLiteral(node.value.expression);
8718
+ },
8719
+ Property(node) {
8720
+ if (!isIdentifier(node.key))
8721
+ return;
8722
+ if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
8723
+ return;
8724
+ if (!isPandaAttribute(node, context))
8725
+ return;
8726
+ handleLiteral(node.value);
8727
+ handleTemplateLiteral(node.value);
8728
+ }
8729
+ };
8730
+ }
8731
+ });
8732
+ no_important_default = rule7;
8733
+ }
8734
+ });
8735
+
8736
+ // src/rules/no-invalid-nesting.ts
8737
+ var RULE_NAME8, rule8, no_invalid_nesting_default;
8738
+ var init_no_invalid_nesting = __esm({
8739
+ "src/rules/no-invalid-nesting.ts"() {
8740
+ "use strict";
8741
+ init_esm_shims();
8742
+ init_nodes();
8743
+ init_utils();
8744
+ init_helpers();
8745
+ RULE_NAME8 = "no-invalid-nesting";
8746
+ rule8 = createRule({
8747
+ name: RULE_NAME8,
8748
+ meta: {
8749
+ docs: {
8750
+ description: "Warn against invalid nesting. i.e. nested styles that don't contain the `&` character."
8751
+ },
8752
+ messages: {
8753
+ nesting: "Invalid style nesting. Nested styles must contain the `&` character."
8754
+ },
8755
+ type: "suggestion",
8756
+ schema: []
8757
+ },
8758
+ defaultOptions: [],
8759
+ create(context) {
8760
+ return {
8761
+ Property(node) {
8762
+ if (!isObjectExpression(node.value) || isIdentifier(node.key))
8763
+ return;
8764
+ if (!isInPandaFunction(node, context) && !isInJSXProp(node, context))
8765
+ return;
8766
+ const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8767
+ const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8768
+ if (invalidLiteral || invalidTemplateLiteral) {
8769
+ context.report({
8770
+ node: node.key,
8771
+ messageId: "nesting"
8772
+ });
8773
+ }
8774
+ }
8775
+ };
8776
+ }
8777
+ });
8778
+ no_invalid_nesting_default = rule8;
8779
+ }
8780
+ });
8781
+
8615
8782
  // src/rules/no-invalid-token-paths.ts
8616
8783
  import { AST_NODE_TYPES as AST_NODE_TYPES2 } from "@typescript-eslint/utils";
8617
8784
  import { isNodeOfTypes } from "@typescript-eslint/utils/ast-utils";
8618
- var RULE_NAME7, rule7, no_invalid_token_paths_default;
8785
+ var RULE_NAME9, rule9, no_invalid_token_paths_default;
8619
8786
  var init_no_invalid_token_paths = __esm({
8620
8787
  "src/rules/no-invalid-token-paths.ts"() {
8621
8788
  "use strict";
@@ -8623,9 +8790,9 @@ var init_no_invalid_token_paths = __esm({
8623
8790
  init_helpers();
8624
8791
  init_utils();
8625
8792
  init_nodes();
8626
- RULE_NAME7 = "no-invalid-token-paths";
8627
- rule7 = createRule({
8628
- name: RULE_NAME7,
8793
+ RULE_NAME9 = "no-invalid-token-paths";
8794
+ rule9 = createRule({
8795
+ name: RULE_NAME9,
8629
8796
  meta: {
8630
8797
  docs: {
8631
8798
  description: "Disallow the use of invalid token paths within token function syntax."
@@ -8725,12 +8892,12 @@ var init_no_invalid_token_paths = __esm({
8725
8892
  };
8726
8893
  }
8727
8894
  });
8728
- no_invalid_token_paths_default = rule7;
8895
+ no_invalid_token_paths_default = rule9;
8729
8896
  }
8730
8897
  });
8731
8898
 
8732
8899
  // src/rules/no-property-renaming.ts
8733
- var RULE_NAME8, rule8, no_property_renaming_default;
8900
+ var RULE_NAME10, rule10, no_property_renaming_default;
8734
8901
  var init_no_property_renaming = __esm({
8735
8902
  "src/rules/no-property-renaming.ts"() {
8736
8903
  "use strict";
@@ -8738,9 +8905,9 @@ var init_no_property_renaming = __esm({
8738
8905
  init_utils();
8739
8906
  init_helpers();
8740
8907
  init_nodes();
8741
- RULE_NAME8 = "no-property-renaming";
8742
- rule8 = createRule({
8743
- name: RULE_NAME8,
8908
+ RULE_NAME10 = "no-property-renaming";
8909
+ rule10 = createRule({
8910
+ name: RULE_NAME10,
8744
8911
  meta: {
8745
8912
  docs: {
8746
8913
  description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
@@ -8799,29 +8966,31 @@ var init_no_property_renaming = __esm({
8799
8966
  };
8800
8967
  }
8801
8968
  });
8802
- no_property_renaming_default = rule8;
8969
+ no_property_renaming_default = rule10;
8803
8970
  }
8804
8971
  });
8805
8972
 
8806
- // src/rules/prefer-longhand-properties.ts
8807
- var RULE_NAME9, rule9, prefer_longhand_properties_default;
8808
- var init_prefer_longhand_properties = __esm({
8809
- "src/rules/prefer-longhand-properties.ts"() {
8973
+ // src/rules/no-unsafe-token-fn-usage.ts
8974
+ import "@typescript-eslint/utils";
8975
+ import { getArbitraryValue as getArbitraryValue3 } from "@pandacss/shared";
8976
+ var RULE_NAME11, rule11, no_unsafe_token_fn_usage_default;
8977
+ var init_no_unsafe_token_fn_usage = __esm({
8978
+ "src/rules/no-unsafe-token-fn-usage.ts"() {
8810
8979
  "use strict";
8811
8980
  init_esm_shims();
8812
8981
  init_helpers();
8813
8982
  init_utils();
8814
8983
  init_nodes();
8815
- RULE_NAME9 = "prefer-longhand-properties";
8816
- rule9 = createRule({
8817
- name: RULE_NAME9,
8984
+ RULE_NAME11 = "no-unsafe-token-fn-usage";
8985
+ rule11 = createRule({
8986
+ name: RULE_NAME11,
8818
8987
  meta: {
8819
8988
  docs: {
8820
- description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8989
+ description: "Prevent users from using the token function in situations where they could simply use the raw design token."
8821
8990
  },
8822
8991
  messages: {
8823
- longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
8824
- replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8992
+ noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8993
+ replace: "Replace token function with `{{safe}}`"
8825
8994
  },
8826
8995
  type: "suggestion",
8827
8996
  hasSuggestions: true,
@@ -8829,22 +8998,57 @@ var init_prefer_longhand_properties = __esm({
8829
8998
  },
8830
8999
  defaultOptions: [],
8831
9000
  create(context) {
8832
- const sendReport = (node, name2) => {
8833
- const longhand = resolveLonghand(name2, context);
8834
- const data = {
8835
- shorthand: name2,
8836
- longhand
8837
- };
9001
+ const isUnsafeCallExpression = (node) => {
9002
+ const tkImport = getTokenImport(context);
9003
+ return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
9004
+ };
9005
+ const tokenWrap = (value) => value ? `token(${value})` : "";
9006
+ const handleRuntimeFm = (node) => {
9007
+ if (!isCallExpression(node))
9008
+ return;
9009
+ if (!isUnsafeCallExpression(node))
9010
+ return;
9011
+ const value = node.arguments[0];
9012
+ if (isLiteral(value)) {
9013
+ sendReport(node, tokenWrap(getArbitraryValue3(value.value?.toString() ?? "")));
9014
+ }
9015
+ if (isTemplateLiteral(value)) {
9016
+ sendReport(node, tokenWrap(getArbitraryValue3(value.quasis[0].value.raw)));
9017
+ }
9018
+ };
9019
+ const isCompositeValue = (input) => {
9020
+ if (!input)
9021
+ return;
9022
+ const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
9023
+ return !tokenRegex.test(input);
9024
+ };
9025
+ const handleLiteral = (node) => {
9026
+ if (!isLiteral(node))
9027
+ return;
9028
+ const value = getArbitraryValue3(node.value?.toString() ?? "");
9029
+ if (isCompositeValue(value))
9030
+ return;
9031
+ sendReport(node, value);
9032
+ };
9033
+ const handleTemplateLiteral = (node) => {
9034
+ if (!isTemplateLiteral(node))
9035
+ return;
9036
+ if (node.expressions.length > 0)
9037
+ return;
9038
+ sendReport(node, getArbitraryValue3(node.quasis[0].value.raw));
9039
+ };
9040
+ const sendReport = (node, value) => {
9041
+ const tkImports = extractTokens(value);
9042
+ const token = tkImports[0].replace(/^[^.]*\./, "");
8838
9043
  return context.report({
8839
9044
  node,
8840
- messageId: "longhand",
8841
- data,
9045
+ messageId: "noUnsafeTokenFnUsage",
8842
9046
  suggest: [
8843
9047
  {
8844
9048
  messageId: "replace",
8845
- data,
9049
+ data: { safe: token },
8846
9050
  fix: (fixer) => {
8847
- return fixer.replaceTextRange(node.range, longhand);
9051
+ return fixer.replaceTextRange(node.range, `'${token}'`);
8848
9052
  }
8849
9053
  }
8850
9054
  ]
@@ -8852,51 +9056,52 @@ var init_prefer_longhand_properties = __esm({
8852
9056
  };
8853
9057
  return {
8854
9058
  JSXAttribute(node) {
8855
- if (!isJSXIdentifier(node.name))
9059
+ if (!node.value)
8856
9060
  return;
8857
9061
  if (!isPandaProp(node, context))
8858
9062
  return;
8859
- const longhand = resolveLonghand(node.name.name, context);
8860
- if (!longhand)
9063
+ handleLiteral(node.value);
9064
+ if (!isJSXExpressionContainer(node.value))
8861
9065
  return;
8862
- sendReport(node.name, node.name.name);
9066
+ handleLiteral(node.value.expression);
9067
+ handleTemplateLiteral(node.value.expression);
9068
+ handleRuntimeFm(node.value.expression);
8863
9069
  },
8864
9070
  Property(node) {
8865
- if (!isIdentifier(node.key))
9071
+ if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
8866
9072
  return;
8867
9073
  if (!isPandaAttribute(node, context))
8868
9074
  return;
8869
- const longhand = resolveLonghand(node.key.name, context);
8870
- if (!longhand)
8871
- return;
8872
- sendReport(node.key, node.key.name);
9075
+ handleRuntimeFm(node.value);
9076
+ handleLiteral(node.value);
9077
+ handleTemplateLiteral(node.value);
8873
9078
  }
8874
9079
  };
8875
9080
  }
8876
9081
  });
8877
- prefer_longhand_properties_default = rule9;
9082
+ no_unsafe_token_fn_usage_default = rule11;
8878
9083
  }
8879
9084
  });
8880
9085
 
8881
- // src/rules/prefer-shorthand-properties.ts
8882
- var RULE_NAME10, rule10, prefer_shorthand_properties_default;
8883
- var init_prefer_shorthand_properties = __esm({
8884
- "src/rules/prefer-shorthand-properties.ts"() {
9086
+ // src/rules/prefer-longhand-properties.ts
9087
+ var RULE_NAME12, rule12, prefer_longhand_properties_default;
9088
+ var init_prefer_longhand_properties = __esm({
9089
+ "src/rules/prefer-longhand-properties.ts"() {
8885
9090
  "use strict";
8886
9091
  init_esm_shims();
8887
9092
  init_helpers();
8888
9093
  init_utils();
8889
9094
  init_nodes();
8890
- RULE_NAME10 = "prefer-shorthand-properties";
8891
- rule10 = createRule({
8892
- name: RULE_NAME10,
9095
+ RULE_NAME12 = "prefer-longhand-properties";
9096
+ rule12 = createRule({
9097
+ name: RULE_NAME12,
8893
9098
  meta: {
8894
9099
  docs: {
8895
- description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
9100
+ description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8896
9101
  },
8897
9102
  messages: {
8898
- shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
8899
- replace: "Replace `{{longhand}}` with `{{shorthand}}`"
9103
+ longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
9104
+ replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8900
9105
  },
8901
9106
  type: "suggestion",
8902
9107
  hasSuggestions: true,
@@ -8905,24 +9110,21 @@ var init_prefer_shorthand_properties = __esm({
8905
9110
  defaultOptions: [],
8906
9111
  create(context) {
8907
9112
  const sendReport = (node, name2) => {
8908
- const shorthands = resolveShorthands(name2, context);
8909
- if (!shorthands)
8910
- return;
8911
- const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
9113
+ const longhand = resolveLonghand(name2, context);
8912
9114
  const data = {
8913
- longhand: name2,
8914
- shorthand
9115
+ shorthand: name2,
9116
+ longhand
8915
9117
  };
8916
9118
  return context.report({
8917
9119
  node,
8918
- messageId: "shorthand",
9120
+ messageId: "longhand",
8919
9121
  data,
8920
9122
  suggest: [
8921
9123
  {
8922
9124
  messageId: "replace",
8923
9125
  data,
8924
9126
  fix: (fixer) => {
8925
- return fixer.replaceTextRange(node.range, shorthands[0]);
9127
+ return fixer.replaceTextRange(node.range, longhand);
8926
9128
  }
8927
9129
  }
8928
9130
  ]
@@ -8935,7 +9137,7 @@ var init_prefer_shorthand_properties = __esm({
8935
9137
  if (!isPandaProp(node, context))
8936
9138
  return;
8937
9139
  const longhand = resolveLonghand(node.name.name, context);
8938
- if (longhand)
9140
+ if (!longhand)
8939
9141
  return;
8940
9142
  sendReport(node.name, node.name.name);
8941
9143
  },
@@ -8945,37 +9147,36 @@ var init_prefer_shorthand_properties = __esm({
8945
9147
  if (!isPandaAttribute(node, context))
8946
9148
  return;
8947
9149
  const longhand = resolveLonghand(node.key.name, context);
8948
- if (longhand)
9150
+ if (!longhand)
8949
9151
  return;
8950
9152
  sendReport(node.key, node.key.name);
8951
9153
  }
8952
9154
  };
8953
9155
  }
8954
9156
  });
8955
- prefer_shorthand_properties_default = rule10;
9157
+ prefer_longhand_properties_default = rule12;
8956
9158
  }
8957
9159
  });
8958
9160
 
8959
- // src/rules/no-unsafe-token-fn-usage.ts
8960
- import "@typescript-eslint/utils";
8961
- var RULE_NAME11, rule11, no_unsafe_token_fn_usage_default;
8962
- var init_no_unsafe_token_fn_usage = __esm({
8963
- "src/rules/no-unsafe-token-fn-usage.ts"() {
9161
+ // src/rules/prefer-shorthand-properties.ts
9162
+ var RULE_NAME13, rule13, prefer_shorthand_properties_default;
9163
+ var init_prefer_shorthand_properties = __esm({
9164
+ "src/rules/prefer-shorthand-properties.ts"() {
8964
9165
  "use strict";
8965
9166
  init_esm_shims();
8966
9167
  init_helpers();
8967
9168
  init_utils();
8968
9169
  init_nodes();
8969
- RULE_NAME11 = "no-unsafe-token-fn-usage";
8970
- rule11 = createRule({
8971
- name: RULE_NAME11,
9170
+ RULE_NAME13 = "prefer-shorthand-properties";
9171
+ rule13 = createRule({
9172
+ name: RULE_NAME13,
8972
9173
  meta: {
8973
9174
  docs: {
8974
- description: "Prevent users from using the token function in situations where they could simply use the raw design token."
9175
+ description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
8975
9176
  },
8976
9177
  messages: {
8977
- noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8978
- replace: "Replace token function with `{{safe}}`"
9178
+ shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
9179
+ replace: "Replace `{{longhand}}` with `{{shorthand}}`"
8979
9180
  },
8980
9181
  type: "suggestion",
8981
9182
  hasSuggestions: true,
@@ -8983,57 +9184,25 @@ var init_no_unsafe_token_fn_usage = __esm({
8983
9184
  },
8984
9185
  defaultOptions: [],
8985
9186
  create(context) {
8986
- const isUnsafeCallExpression = (node) => {
8987
- const tkImport = getTokenImport(context);
8988
- return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
8989
- };
8990
- const tokenWrap = (value) => value ? `token(${value})` : "";
8991
- const handleRuntimeFm = (node) => {
8992
- if (!isCallExpression(node))
8993
- return;
8994
- if (!isUnsafeCallExpression(node))
8995
- return;
8996
- const value = node.arguments[0];
8997
- if (isLiteral(value)) {
8998
- sendReport(node, tokenWrap(value.value?.toString()));
8999
- }
9000
- if (isTemplateLiteral(value)) {
9001
- sendReport(node, tokenWrap(value.quasis[0].value.raw));
9002
- }
9003
- };
9004
- const isCompositeValue = (input) => {
9005
- if (!input)
9006
- return;
9007
- const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
9008
- return !tokenRegex.test(input);
9009
- };
9010
- const handleLiteral = (node) => {
9011
- if (!isLiteral(node))
9012
- return;
9013
- if (isCompositeValue(node.value?.toString()))
9014
- return;
9015
- sendReport(node);
9016
- };
9017
- const handleTemplateLiteral = (node) => {
9018
- if (!isTemplateLiteral(node))
9019
- return;
9020
- if (node.expressions.length > 0)
9187
+ const sendReport = (node, name2) => {
9188
+ const shorthands = resolveShorthands(name2, context);
9189
+ if (!shorthands)
9021
9190
  return;
9022
- sendReport(node, node.quasis[0].value.raw);
9023
- };
9024
- const sendReport = (node, _value) => {
9025
- const value = _value ?? node.value?.toString();
9026
- const tkImports = extractTokens(value);
9027
- const token = tkImports[0].replace(/^[^.]*\./, "");
9191
+ const shorthand = shorthands.map((s) => `\`${s}\``)?.join(", ");
9192
+ const data = {
9193
+ longhand: name2,
9194
+ shorthand
9195
+ };
9028
9196
  return context.report({
9029
9197
  node,
9030
- messageId: "noUnsafeTokenFnUsage",
9198
+ messageId: "shorthand",
9199
+ data,
9031
9200
  suggest: [
9032
9201
  {
9033
9202
  messageId: "replace",
9034
- data: { safe: token },
9203
+ data,
9035
9204
  fix: (fixer) => {
9036
- return fixer.replaceTextRange(node.range, `'${token}'`);
9205
+ return fixer.replaceTextRange(node.range, shorthands[0]);
9037
9206
  }
9038
9207
  }
9039
9208
  ]
@@ -9041,30 +9210,29 @@ var init_no_unsafe_token_fn_usage = __esm({
9041
9210
  };
9042
9211
  return {
9043
9212
  JSXAttribute(node) {
9044
- if (!node.value)
9213
+ if (!isJSXIdentifier(node.name))
9045
9214
  return;
9046
9215
  if (!isPandaProp(node, context))
9047
9216
  return;
9048
- handleLiteral(node.value);
9049
- if (!isJSXExpressionContainer(node.value))
9217
+ const longhand = resolveLonghand(node.name.name, context);
9218
+ if (longhand)
9050
9219
  return;
9051
- handleLiteral(node.value.expression);
9052
- handleTemplateLiteral(node.value.expression);
9053
- handleRuntimeFm(node.value.expression);
9220
+ sendReport(node.name, node.name.name);
9054
9221
  },
9055
9222
  Property(node) {
9056
- if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
9223
+ if (!isIdentifier(node.key))
9057
9224
  return;
9058
9225
  if (!isPandaAttribute(node, context))
9059
9226
  return;
9060
- handleRuntimeFm(node.value);
9061
- handleLiteral(node.value);
9062
- handleTemplateLiteral(node.value);
9227
+ const longhand = resolveLonghand(node.key.name, context);
9228
+ if (longhand)
9229
+ return;
9230
+ sendReport(node.key, node.key.name);
9063
9231
  }
9064
9232
  };
9065
9233
  }
9066
9234
  });
9067
- no_unsafe_token_fn_usage_default = rule11;
9235
+ prefer_shorthand_properties_default = rule13;
9068
9236
  }
9069
9237
  });
9070
9238
 
@@ -9189,7 +9357,7 @@ var init_composite_properties = __esm({
9189
9357
  });
9190
9358
 
9191
9359
  // src/rules/prefer-atomic-properties.ts
9192
- var RULE_NAME12, rule12, prefer_atomic_properties_default;
9360
+ var RULE_NAME14, rule14, prefer_atomic_properties_default;
9193
9361
  var init_prefer_atomic_properties = __esm({
9194
9362
  "src/rules/prefer-atomic-properties.ts"() {
9195
9363
  "use strict";
@@ -9198,9 +9366,9 @@ var init_prefer_atomic_properties = __esm({
9198
9366
  init_utils();
9199
9367
  init_composite_properties();
9200
9368
  init_nodes();
9201
- RULE_NAME12 = "prefer-atomic-properties";
9202
- rule12 = createRule({
9203
- name: RULE_NAME12,
9369
+ RULE_NAME14 = "prefer-atomic-properties";
9370
+ rule14 = createRule({
9371
+ name: RULE_NAME14,
9204
9372
  meta: {
9205
9373
  docs: {
9206
9374
  description: "Encourage the use of atomic properties instead of composite properties in the codebase."
@@ -9221,8 +9389,8 @@ var init_prefer_atomic_properties = __esm({
9221
9389
  return longhand;
9222
9390
  };
9223
9391
  const sendReport = (node, name2) => {
9224
- const cpd = resolveCompositeProperty(name2);
9225
- const atomics = compositeProperties[cpd].map((name3) => `\`${name3}\``).join(",\n");
9392
+ const cmp = resolveCompositeProperty(name2);
9393
+ const atomics = compositeProperties[cmp].map((name3) => `\`${name3}\``).join(",\n");
9226
9394
  return context.report({
9227
9395
  node,
9228
9396
  messageId: "atomic",
@@ -9238,8 +9406,8 @@ var init_prefer_atomic_properties = __esm({
9238
9406
  return;
9239
9407
  if (!isPandaProp(node, context))
9240
9408
  return;
9241
- const cpd = resolveCompositeProperty(node.name.name);
9242
- if (!cpd)
9409
+ const cmp = resolveCompositeProperty(node.name.name);
9410
+ if (!cmp)
9243
9411
  return;
9244
9412
  sendReport(node, node.name.name);
9245
9413
  },
@@ -9248,20 +9416,20 @@ var init_prefer_atomic_properties = __esm({
9248
9416
  return;
9249
9417
  if (!isPandaAttribute(node, context))
9250
9418
  return;
9251
- const cpd = resolveCompositeProperty(node.key.name);
9252
- if (!cpd)
9419
+ const cmp = resolveCompositeProperty(node.key.name);
9420
+ if (!cmp)
9253
9421
  return;
9254
9422
  sendReport(node.key, node.key.name);
9255
9423
  }
9256
9424
  };
9257
9425
  }
9258
9426
  });
9259
- prefer_atomic_properties_default = rule12;
9427
+ prefer_atomic_properties_default = rule14;
9260
9428
  }
9261
9429
  });
9262
9430
 
9263
9431
  // src/rules/prefer-composite-properties.ts
9264
- var RULE_NAME13, rule13, prefer_composite_properties_default;
9432
+ var RULE_NAME15, rule15, prefer_composite_properties_default;
9265
9433
  var init_prefer_composite_properties = __esm({
9266
9434
  "src/rules/prefer-composite-properties.ts"() {
9267
9435
  "use strict";
@@ -9270,9 +9438,9 @@ var init_prefer_composite_properties = __esm({
9270
9438
  init_utils();
9271
9439
  init_composite_properties();
9272
9440
  init_nodes();
9273
- RULE_NAME13 = "prefer-composite-properties";
9274
- rule13 = createRule({
9275
- name: RULE_NAME13,
9441
+ RULE_NAME15 = "prefer-composite-properties";
9442
+ rule15 = createRule({
9443
+ name: RULE_NAME15,
9276
9444
  meta: {
9277
9445
  docs: {
9278
9446
  description: "Encourage the use of composite properties instead of atomic properties in the codebase."
@@ -9326,7 +9494,90 @@ var init_prefer_composite_properties = __esm({
9326
9494
  };
9327
9495
  }
9328
9496
  });
9329
- prefer_composite_properties_default = rule13;
9497
+ prefer_composite_properties_default = rule15;
9498
+ }
9499
+ });
9500
+
9501
+ // src/rules/prefer-unified-property-style.ts
9502
+ var RULE_NAME16, rule16, prefer_unified_property_style_default;
9503
+ var init_prefer_unified_property_style = __esm({
9504
+ "src/rules/prefer-unified-property-style.ts"() {
9505
+ "use strict";
9506
+ init_esm_shims();
9507
+ init_helpers();
9508
+ init_utils();
9509
+ init_composite_properties();
9510
+ init_nodes();
9511
+ RULE_NAME16 = "prefer-unified-property-style";
9512
+ rule16 = createRule({
9513
+ name: RULE_NAME16,
9514
+ meta: {
9515
+ docs: {
9516
+ description: "Discourage against mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results"
9517
+ },
9518
+ messages: {
9519
+ 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"
9520
+ },
9521
+ type: "suggestion",
9522
+ schema: []
9523
+ },
9524
+ defaultOptions: [],
9525
+ create(context) {
9526
+ const getLonghand = (name2) => resolveLonghand(name2, context) ?? name2;
9527
+ const resolveCompositeProperty = (name2) => {
9528
+ if (Object.hasOwn(compositeProperties, name2))
9529
+ return name2;
9530
+ const longhand = getLonghand(name2);
9531
+ if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
9532
+ return longhand;
9533
+ };
9534
+ const sendReport = (node, cmp, siblings) => {
9535
+ const _atomicProperties = siblings.filter((prop) => compositeProperties[cmp].includes(getLonghand(prop))).map((prop) => `\`${prop}\``);
9536
+ if (!_atomicProperties.length)
9537
+ return;
9538
+ const atomicProperties = _atomicProperties.join(", ") + (_atomicProperties.length === 1 ? " style" : " styles");
9539
+ const atomics = compositeProperties[cmp].map((name2) => `\`${name2}\``).join(", ");
9540
+ context.report({
9541
+ node,
9542
+ messageId: "unify",
9543
+ data: {
9544
+ composite: cmp,
9545
+ atomicProperties,
9546
+ atomics
9547
+ }
9548
+ });
9549
+ };
9550
+ return {
9551
+ JSXAttribute(node) {
9552
+ if (!isJSXIdentifier(node.name))
9553
+ return;
9554
+ if (!isPandaProp(node, context))
9555
+ return;
9556
+ const cmp = resolveCompositeProperty(node.name.name);
9557
+ if (!cmp)
9558
+ return;
9559
+ if (!isJSXOpeningElement(node.parent))
9560
+ return;
9561
+ const siblings = node.parent.attributes.map((attr) => attr.name.name);
9562
+ sendReport(node, cmp, siblings);
9563
+ },
9564
+ Property(node) {
9565
+ if (!isIdentifier(node.key))
9566
+ return;
9567
+ if (!isPandaAttribute(node, context))
9568
+ return;
9569
+ const cmp = resolveCompositeProperty(node.key.name);
9570
+ if (!cmp)
9571
+ return;
9572
+ if (!isObjectExpression(node.parent))
9573
+ return;
9574
+ const siblings = node.parent.properties.map((prop) => isIdentifier(prop.key) && prop.key.name);
9575
+ sendReport(node.key, cmp, siblings);
9576
+ }
9577
+ };
9578
+ }
9579
+ });
9580
+ prefer_unified_property_style_default = rule16;
9330
9581
  }
9331
9582
  });
9332
9583
 
@@ -9342,13 +9593,16 @@ var init_rules = __esm({
9342
9593
  init_no_dynamic_styling();
9343
9594
  init_no_escape_hatch();
9344
9595
  init_no_hardcoded_color();
9596
+ init_no_important();
9597
+ init_no_invalid_nesting();
9345
9598
  init_no_invalid_token_paths();
9346
9599
  init_no_property_renaming();
9600
+ init_no_unsafe_token_fn_usage();
9347
9601
  init_prefer_longhand_properties();
9348
9602
  init_prefer_shorthand_properties();
9349
- init_no_unsafe_token_fn_usage();
9350
9603
  init_prefer_atomic_properties();
9351
9604
  init_prefer_composite_properties();
9605
+ init_prefer_unified_property_style();
9352
9606
  rules = {
9353
9607
  [RULE_NAME]: file_not_included_default,
9354
9608
  [RULE_NAME2]: no_config_function_in_source_default,
@@ -9356,13 +9610,16 @@ var init_rules = __esm({
9356
9610
  [RULE_NAME4]: no_dynamic_styling_default,
9357
9611
  [RULE_NAME5]: no_escape_hatch_default,
9358
9612
  [RULE_NAME6]: no_hardcoded_color_default,
9359
- [RULE_NAME7]: no_invalid_token_paths_default,
9360
- [RULE_NAME8]: no_property_renaming_default,
9361
- [RULE_NAME9]: prefer_longhand_properties_default,
9362
- [RULE_NAME10]: prefer_shorthand_properties_default,
9613
+ [RULE_NAME7]: no_important_default,
9614
+ [RULE_NAME9]: no_invalid_token_paths_default,
9615
+ [RULE_NAME8]: no_invalid_nesting_default,
9616
+ [RULE_NAME10]: no_property_renaming_default,
9363
9617
  [RULE_NAME11]: no_unsafe_token_fn_usage_default,
9364
- [RULE_NAME12]: prefer_atomic_properties_default,
9365
- [RULE_NAME13]: prefer_composite_properties_default
9618
+ [RULE_NAME12]: prefer_longhand_properties_default,
9619
+ [RULE_NAME13]: prefer_shorthand_properties_default,
9620
+ [RULE_NAME14]: prefer_atomic_properties_default,
9621
+ [RULE_NAME15]: prefer_composite_properties_default,
9622
+ [RULE_NAME16]: prefer_unified_property_style_default
9366
9623
  };
9367
9624
  }
9368
9625
  });
@@ -9377,7 +9634,7 @@ var init_all = __esm({
9377
9634
  init_file_not_included();
9378
9635
  init_no_config_function_in_source();
9379
9636
  init_no_invalid_token_paths();
9380
- errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME7];
9637
+ errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME9];
9381
9638
  allRules = Object.fromEntries(
9382
9639
  Object.entries(rules).map(([name2]) => {
9383
9640
  return [`@pandacss/${name2}`, errorRules.includes(name2) ? "error" : "warn"];
@@ -9407,8 +9664,10 @@ var init_recommended = __esm({
9407
9664
  "@pandacss/no-config-function-in-source": "error",
9408
9665
  "@pandacss/no-debug": "warn",
9409
9666
  "@pandacss/no-dynamic-styling": "warn",
9667
+ "@pandacss/no-invalid-nesting": "error",
9668
+ "@pandacss/no-invalid-token-paths": "error",
9410
9669
  "@pandacss/no-property-renaming": "warn",
9411
- "@pandacss/no-invalid-token-paths": "error"
9670
+ "@pandacss/prefer-unified-property-style": "warn"
9412
9671
  }
9413
9672
  };
9414
9673
  }