@pandacss/eslint-plugin 0.0.11 → 0.0.12

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 +318 -142
  2. package/dist/index.mjs +352 -155
  3. package/package.json +1 -1
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.0.11";
7960
+ var version = "0.0.12";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -8004,6 +8004,7 @@ var isJSXIdentifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_
8004
8004
  var isCallExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.CallExpression);
8005
8005
  var isImportDeclaration = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ImportDeclaration);
8006
8006
  var isImportSpecifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ImportSpecifier);
8007
+ var isProperty = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Property);
8007
8008
 
8008
8009
  // src/utils/helpers.ts
8009
8010
  var getAncestor = (ofType, for_) => {
@@ -8580,13 +8581,111 @@ var rule6 = createRule({
8580
8581
  });
8581
8582
  var no_hardcoded_color_default = rule6;
8582
8583
 
8583
- // src/rules/no-invalid-token-paths.ts
8584
+ // src/rules/no-important.ts
8584
8585
  init_cjs_shims();
8585
- var import_utils10 = require("@typescript-eslint/utils");
8586
- var import_ast_utils2 = require("@typescript-eslint/utils/ast-utils");
8587
- var RULE_NAME7 = "no-invalid-token-paths";
8586
+ var import_shared2 = require("@pandacss/shared");
8587
+ var exclamationRegex = /\s*!$/;
8588
+ var importantRegex = /\s*!important\s*$/;
8589
+ var RULE_NAME7 = "no-important";
8588
8590
  var rule7 = createRule({
8589
8591
  name: RULE_NAME7,
8592
+ meta: {
8593
+ docs: {
8594
+ description: "Disallow usage of important keyword. Prioroitize specificity for a maintainable and predictable styling structure."
8595
+ },
8596
+ messages: {
8597
+ important: "Avoid using the !important keyword. Refactor your code to prioritize specificity for predictable styling.",
8598
+ remove: "Remove the `{{keyword}}` keyword."
8599
+ },
8600
+ type: "suggestion",
8601
+ hasSuggestions: true,
8602
+ schema: []
8603
+ },
8604
+ defaultOptions: [],
8605
+ create(context) {
8606
+ const removeQuotes = ([start, end]) => [start + 1, end - 1];
8607
+ const hasImportantKeyword = (_value) => {
8608
+ if (!_value)
8609
+ return false;
8610
+ const value = (0, import_shared2.getArbitraryValue)(_value);
8611
+ return exclamationRegex.test(value) || importantRegex.test(value);
8612
+ };
8613
+ const removeImportantKeyword = (input) => {
8614
+ if (exclamationRegex.test(input)) {
8615
+ return { fixed: input.replace(exclamationRegex, ""), keyword: "!" };
8616
+ } else if (importantRegex.test(input)) {
8617
+ return { fixed: input.replace(importantRegex, ""), keyword: "!important" };
8618
+ } else {
8619
+ return { fixed: input, keyword: null };
8620
+ }
8621
+ };
8622
+ const handleLiteral = (node) => {
8623
+ if (!isLiteral(node))
8624
+ return;
8625
+ if (!hasImportantKeyword(node.value?.toString()))
8626
+ return;
8627
+ sendReport(node);
8628
+ };
8629
+ const handleTemplateLiteral = (node) => {
8630
+ if (!isTemplateLiteral(node))
8631
+ return;
8632
+ if (node.expressions.length > 0)
8633
+ return;
8634
+ if (!hasImportantKeyword(node.quasis[0].value.raw))
8635
+ return;
8636
+ sendReport(node.quasis[0], node.quasis[0].value.raw);
8637
+ };
8638
+ const sendReport = (node, _value) => {
8639
+ const value = _value ?? node.value?.toString();
8640
+ const { keyword, fixed } = removeImportantKeyword(value);
8641
+ return context.report({
8642
+ node,
8643
+ messageId: "important",
8644
+ suggest: [
8645
+ {
8646
+ messageId: "remove",
8647
+ data: { keyword },
8648
+ fix: (fixer) => {
8649
+ return fixer.replaceTextRange(removeQuotes(node.range), fixed);
8650
+ }
8651
+ }
8652
+ ]
8653
+ });
8654
+ };
8655
+ return {
8656
+ JSXAttribute(node) {
8657
+ if (!node.value)
8658
+ return;
8659
+ if (!isPandaProp(node, context))
8660
+ return;
8661
+ handleLiteral(node.value);
8662
+ if (!isJSXExpressionContainer(node.value))
8663
+ return;
8664
+ handleLiteral(node.value.expression);
8665
+ handleTemplateLiteral(node.value.expression);
8666
+ },
8667
+ Property(node) {
8668
+ if (!isIdentifier(node.key))
8669
+ return;
8670
+ if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
8671
+ return;
8672
+ if (!isPandaAttribute(node, context))
8673
+ return;
8674
+ handleLiteral(node.value);
8675
+ handleTemplateLiteral(node.value);
8676
+ }
8677
+ };
8678
+ }
8679
+ });
8680
+ var no_important_default = rule7;
8681
+
8682
+ // src/rules/no-invalid-token-paths.ts
8683
+ init_cjs_shims();
8684
+ var import_utils11 = require("@typescript-eslint/utils");
8685
+ var import_ast_utils2 = require("@typescript-eslint/utils/ast-utils");
8686
+ var RULE_NAME8 = "no-invalid-token-paths";
8687
+ var rule8 = createRule({
8688
+ name: RULE_NAME8,
8590
8689
  meta: {
8591
8690
  docs: {
8592
8691
  description: "Disallow the use of invalid token paths within token function syntax."
@@ -8639,7 +8738,7 @@ var rule7 = createRule({
8639
8738
  Property(node) {
8640
8739
  if (!isIdentifier(node.key))
8641
8740
  return;
8642
- if (!(0, import_ast_utils2.isNodeOfTypes)([import_utils10.AST_NODE_TYPES.Literal, import_utils10.AST_NODE_TYPES.TemplateLiteral])(node.value))
8741
+ if (!(0, import_ast_utils2.isNodeOfTypes)([import_utils11.AST_NODE_TYPES.Literal, import_utils11.AST_NODE_TYPES.TemplateLiteral])(node.value))
8643
8742
  return;
8644
8743
  if (!isPandaAttribute(node, context))
8645
8744
  return;
@@ -8686,13 +8785,13 @@ var rule7 = createRule({
8686
8785
  };
8687
8786
  }
8688
8787
  });
8689
- var no_invalid_token_paths_default = rule7;
8788
+ var no_invalid_token_paths_default = rule8;
8690
8789
 
8691
8790
  // src/rules/no-property-renaming.ts
8692
8791
  init_cjs_shims();
8693
- var RULE_NAME8 = "no-property-renaming";
8694
- var rule8 = createRule({
8695
- name: RULE_NAME8,
8792
+ var RULE_NAME9 = "no-property-renaming";
8793
+ var rule9 = createRule({
8794
+ name: RULE_NAME9,
8696
8795
  meta: {
8697
8796
  docs: {
8698
8797
  description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
@@ -8751,20 +8850,22 @@ var rule8 = createRule({
8751
8850
  };
8752
8851
  }
8753
8852
  });
8754
- var no_property_renaming_default = rule8;
8853
+ var no_property_renaming_default = rule9;
8755
8854
 
8756
- // src/rules/prefer-longhand-properties.ts
8855
+ // src/rules/no-unsafe-token-fn-usage.ts
8757
8856
  init_cjs_shims();
8758
- var RULE_NAME9 = "prefer-longhand-properties";
8759
- var rule9 = createRule({
8760
- name: RULE_NAME9,
8857
+ var import_utils14 = require("@typescript-eslint/utils");
8858
+ var import_shared3 = require("@pandacss/shared");
8859
+ var RULE_NAME10 = "no-unsafe-token-fn-usage";
8860
+ var rule10 = createRule({
8861
+ name: RULE_NAME10,
8761
8862
  meta: {
8762
8863
  docs: {
8763
- description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8864
+ description: "Prevent users from using the token function in situations where they could simply use the raw design token."
8764
8865
  },
8765
8866
  messages: {
8766
- longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
8767
- replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8867
+ noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8868
+ replace: "Replace token function with `{{safe}}`"
8768
8869
  },
8769
8870
  type: "suggestion",
8770
8871
  hasSuggestions: true,
@@ -8772,22 +8873,57 @@ var rule9 = createRule({
8772
8873
  },
8773
8874
  defaultOptions: [],
8774
8875
  create(context) {
8775
- const sendReport = (node, name2) => {
8776
- const longhand = resolveLonghand(name2, context);
8777
- const data = {
8778
- shorthand: name2,
8779
- longhand
8780
- };
8876
+ const isUnsafeCallExpression = (node) => {
8877
+ const tkImport = getTokenImport(context);
8878
+ return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
8879
+ };
8880
+ const tokenWrap = (value) => value ? `token(${value})` : "";
8881
+ const handleRuntimeFm = (node) => {
8882
+ if (!isCallExpression(node))
8883
+ return;
8884
+ if (!isUnsafeCallExpression(node))
8885
+ return;
8886
+ const value = node.arguments[0];
8887
+ if (isLiteral(value)) {
8888
+ sendReport(node, tokenWrap((0, import_shared3.getArbitraryValue)(value.value?.toString() ?? "")));
8889
+ }
8890
+ if (isTemplateLiteral(value)) {
8891
+ sendReport(node, tokenWrap((0, import_shared3.getArbitraryValue)(value.quasis[0].value.raw)));
8892
+ }
8893
+ };
8894
+ const isCompositeValue = (input) => {
8895
+ if (!input)
8896
+ return;
8897
+ const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
8898
+ return !tokenRegex.test(input);
8899
+ };
8900
+ const handleLiteral = (node) => {
8901
+ if (!isLiteral(node))
8902
+ return;
8903
+ const value = (0, import_shared3.getArbitraryValue)(node.value?.toString() ?? "");
8904
+ if (isCompositeValue(value))
8905
+ return;
8906
+ sendReport(node, value);
8907
+ };
8908
+ const handleTemplateLiteral = (node) => {
8909
+ if (!isTemplateLiteral(node))
8910
+ return;
8911
+ if (node.expressions.length > 0)
8912
+ return;
8913
+ sendReport(node, (0, import_shared3.getArbitraryValue)(node.quasis[0].value.raw));
8914
+ };
8915
+ const sendReport = (node, value) => {
8916
+ const tkImports = extractTokens(value);
8917
+ const token = tkImports[0].replace(/^[^.]*\./, "");
8781
8918
  return context.report({
8782
8919
  node,
8783
- messageId: "longhand",
8784
- data,
8920
+ messageId: "noUnsafeTokenFnUsage",
8785
8921
  suggest: [
8786
8922
  {
8787
8923
  messageId: "replace",
8788
- data,
8924
+ data: { safe: token },
8789
8925
  fix: (fixer) => {
8790
- return fixer.replaceTextRange(node.range, longhand);
8926
+ return fixer.replaceTextRange(node.range, `'${token}'`);
8791
8927
  }
8792
8928
  }
8793
8929
  ]
@@ -8795,42 +8931,43 @@ var rule9 = createRule({
8795
8931
  };
8796
8932
  return {
8797
8933
  JSXAttribute(node) {
8798
- if (!isJSXIdentifier(node.name))
8934
+ if (!node.value)
8799
8935
  return;
8800
8936
  if (!isPandaProp(node, context))
8801
8937
  return;
8802
- const longhand = resolveLonghand(node.name.name, context);
8803
- if (!longhand)
8938
+ handleLiteral(node.value);
8939
+ if (!isJSXExpressionContainer(node.value))
8804
8940
  return;
8805
- sendReport(node.name, node.name.name);
8941
+ handleLiteral(node.value.expression);
8942
+ handleTemplateLiteral(node.value.expression);
8943
+ handleRuntimeFm(node.value.expression);
8806
8944
  },
8807
8945
  Property(node) {
8808
- if (!isIdentifier(node.key))
8946
+ if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
8809
8947
  return;
8810
8948
  if (!isPandaAttribute(node, context))
8811
8949
  return;
8812
- const longhand = resolveLonghand(node.key.name, context);
8813
- if (!longhand)
8814
- return;
8815
- sendReport(node.key, node.key.name);
8950
+ handleRuntimeFm(node.value);
8951
+ handleLiteral(node.value);
8952
+ handleTemplateLiteral(node.value);
8816
8953
  }
8817
8954
  };
8818
8955
  }
8819
8956
  });
8820
- var prefer_longhand_properties_default = rule9;
8957
+ var no_unsafe_token_fn_usage_default = rule10;
8821
8958
 
8822
- // src/rules/prefer-shorthand-properties.ts
8959
+ // src/rules/prefer-longhand-properties.ts
8823
8960
  init_cjs_shims();
8824
- var RULE_NAME10 = "prefer-shorthand-properties";
8825
- var rule10 = createRule({
8826
- name: RULE_NAME10,
8961
+ var RULE_NAME11 = "prefer-longhand-properties";
8962
+ var rule11 = createRule({
8963
+ name: RULE_NAME11,
8827
8964
  meta: {
8828
8965
  docs: {
8829
- description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
8966
+ description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8830
8967
  },
8831
8968
  messages: {
8832
- shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
8833
- replace: "Replace `{{longhand}}` with `{{shorthand}}`"
8969
+ longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
8970
+ replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8834
8971
  },
8835
8972
  type: "suggestion",
8836
8973
  hasSuggestions: true,
@@ -8839,24 +8976,21 @@ var rule10 = createRule({
8839
8976
  defaultOptions: [],
8840
8977
  create(context) {
8841
8978
  const sendReport = (node, name2) => {
8842
- const shorthands = resolveShorthands(name2, context);
8843
- if (!shorthands)
8844
- return;
8845
- const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
8979
+ const longhand = resolveLonghand(name2, context);
8846
8980
  const data = {
8847
- longhand: name2,
8848
- shorthand
8981
+ shorthand: name2,
8982
+ longhand
8849
8983
  };
8850
8984
  return context.report({
8851
8985
  node,
8852
- messageId: "shorthand",
8986
+ messageId: "longhand",
8853
8987
  data,
8854
8988
  suggest: [
8855
8989
  {
8856
8990
  messageId: "replace",
8857
8991
  data,
8858
8992
  fix: (fixer) => {
8859
- return fixer.replaceTextRange(node.range, shorthands[0]);
8993
+ return fixer.replaceTextRange(node.range, longhand);
8860
8994
  }
8861
8995
  }
8862
8996
  ]
@@ -8869,7 +9003,7 @@ var rule10 = createRule({
8869
9003
  if (!isPandaProp(node, context))
8870
9004
  return;
8871
9005
  const longhand = resolveLonghand(node.name.name, context);
8872
- if (longhand)
9006
+ if (!longhand)
8873
9007
  return;
8874
9008
  sendReport(node.name, node.name.name);
8875
9009
  },
@@ -8879,28 +9013,27 @@ var rule10 = createRule({
8879
9013
  if (!isPandaAttribute(node, context))
8880
9014
  return;
8881
9015
  const longhand = resolveLonghand(node.key.name, context);
8882
- if (longhand)
9016
+ if (!longhand)
8883
9017
  return;
8884
9018
  sendReport(node.key, node.key.name);
8885
9019
  }
8886
9020
  };
8887
9021
  }
8888
9022
  });
8889
- var prefer_shorthand_properties_default = rule10;
9023
+ var prefer_longhand_properties_default = rule11;
8890
9024
 
8891
- // src/rules/no-unsafe-token-fn-usage.ts
9025
+ // src/rules/prefer-shorthand-properties.ts
8892
9026
  init_cjs_shims();
8893
- var import_utils15 = require("@typescript-eslint/utils");
8894
- var RULE_NAME11 = "no-unsafe-token-fn-usage";
8895
- var rule11 = createRule({
8896
- name: RULE_NAME11,
9027
+ var RULE_NAME12 = "prefer-shorthand-properties";
9028
+ var rule12 = createRule({
9029
+ name: RULE_NAME12,
8897
9030
  meta: {
8898
9031
  docs: {
8899
- description: "Prevent users from using the token function in situations where they could simply use the raw design token."
9032
+ description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
8900
9033
  },
8901
9034
  messages: {
8902
- noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8903
- replace: "Replace token function with `{{safe}}`"
9035
+ shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
9036
+ replace: "Replace `{{longhand}}` with `{{shorthand}}`"
8904
9037
  },
8905
9038
  type: "suggestion",
8906
9039
  hasSuggestions: true,
@@ -8908,57 +9041,25 @@ var rule11 = createRule({
8908
9041
  },
8909
9042
  defaultOptions: [],
8910
9043
  create(context) {
8911
- const isUnsafeCallExpression = (node) => {
8912
- const tkImport = getTokenImport(context);
8913
- return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
8914
- };
8915
- const tokenWrap = (value) => value ? `token(${value})` : "";
8916
- const handleRuntimeFm = (node) => {
8917
- if (!isCallExpression(node))
8918
- return;
8919
- if (!isUnsafeCallExpression(node))
8920
- return;
8921
- const value = node.arguments[0];
8922
- if (isLiteral(value)) {
8923
- sendReport(node, tokenWrap(value.value?.toString()));
8924
- }
8925
- if (isTemplateLiteral(value)) {
8926
- sendReport(node, tokenWrap(value.quasis[0].value.raw));
8927
- }
8928
- };
8929
- const isCompositeValue = (input) => {
8930
- if (!input)
8931
- return;
8932
- const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
8933
- return !tokenRegex.test(input);
8934
- };
8935
- const handleLiteral = (node) => {
8936
- if (!isLiteral(node))
8937
- return;
8938
- if (isCompositeValue(node.value?.toString()))
8939
- return;
8940
- sendReport(node);
8941
- };
8942
- const handleTemplateLiteral = (node) => {
8943
- if (!isTemplateLiteral(node))
8944
- return;
8945
- if (node.expressions.length > 0)
9044
+ const sendReport = (node, name2) => {
9045
+ const shorthands = resolveShorthands(name2, context);
9046
+ if (!shorthands)
8946
9047
  return;
8947
- sendReport(node, node.quasis[0].value.raw);
8948
- };
8949
- const sendReport = (node, _value) => {
8950
- const value = _value ?? node.value?.toString();
8951
- const tkImports = extractTokens(value);
8952
- const token = tkImports[0].replace(/^[^.]*\./, "");
9048
+ const shorthand = shorthands.map((s) => `\`${s}\``)?.join(", ");
9049
+ const data = {
9050
+ longhand: name2,
9051
+ shorthand
9052
+ };
8953
9053
  return context.report({
8954
9054
  node,
8955
- messageId: "noUnsafeTokenFnUsage",
9055
+ messageId: "shorthand",
9056
+ data,
8956
9057
  suggest: [
8957
9058
  {
8958
9059
  messageId: "replace",
8959
- data: { safe: token },
9060
+ data,
8960
9061
  fix: (fixer) => {
8961
- return fixer.replaceTextRange(node.range, `'${token}'`);
9062
+ return fixer.replaceTextRange(node.range, shorthands[0]);
8962
9063
  }
8963
9064
  }
8964
9065
  ]
@@ -8966,30 +9067,29 @@ var rule11 = createRule({
8966
9067
  };
8967
9068
  return {
8968
9069
  JSXAttribute(node) {
8969
- if (!node.value)
9070
+ if (!isJSXIdentifier(node.name))
8970
9071
  return;
8971
9072
  if (!isPandaProp(node, context))
8972
9073
  return;
8973
- handleLiteral(node.value);
8974
- if (!isJSXExpressionContainer(node.value))
9074
+ const longhand = resolveLonghand(node.name.name, context);
9075
+ if (longhand)
8975
9076
  return;
8976
- handleLiteral(node.value.expression);
8977
- handleTemplateLiteral(node.value.expression);
8978
- handleRuntimeFm(node.value.expression);
9077
+ sendReport(node.name, node.name.name);
8979
9078
  },
8980
9079
  Property(node) {
8981
- if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
9080
+ if (!isIdentifier(node.key))
8982
9081
  return;
8983
9082
  if (!isPandaAttribute(node, context))
8984
9083
  return;
8985
- handleRuntimeFm(node.value);
8986
- handleLiteral(node.value);
8987
- handleTemplateLiteral(node.value);
9084
+ const longhand = resolveLonghand(node.key.name, context);
9085
+ if (longhand)
9086
+ return;
9087
+ sendReport(node.key, node.key.name);
8988
9088
  }
8989
9089
  };
8990
9090
  }
8991
9091
  });
8992
- var no_unsafe_token_fn_usage_default = rule11;
9092
+ var prefer_shorthand_properties_default = rule12;
8993
9093
 
8994
9094
  // src/rules/prefer-atomic-properties.ts
8995
9095
  init_cjs_shims();
@@ -9109,9 +9209,9 @@ var compositeProperties = {
9109
9209
  };
9110
9210
 
9111
9211
  // src/rules/prefer-atomic-properties.ts
9112
- var RULE_NAME12 = "prefer-atomic-properties";
9113
- var rule12 = createRule({
9114
- name: RULE_NAME12,
9212
+ var RULE_NAME13 = "prefer-atomic-properties";
9213
+ var rule13 = createRule({
9214
+ name: RULE_NAME13,
9115
9215
  meta: {
9116
9216
  docs: {
9117
9217
  description: "Encourage the use of atomic properties instead of composite properties in the codebase."
@@ -9132,8 +9232,8 @@ var rule12 = createRule({
9132
9232
  return longhand;
9133
9233
  };
9134
9234
  const sendReport = (node, name2) => {
9135
- const cpd = resolveCompositeProperty(name2);
9136
- const atomics = compositeProperties[cpd].map((name3) => `\`${name3}\``).join(",\n");
9235
+ const cmp = resolveCompositeProperty(name2);
9236
+ const atomics = compositeProperties[cmp].map((name3) => `\`${name3}\``).join(",\n");
9137
9237
  return context.report({
9138
9238
  node,
9139
9239
  messageId: "atomic",
@@ -9149,8 +9249,8 @@ var rule12 = createRule({
9149
9249
  return;
9150
9250
  if (!isPandaProp(node, context))
9151
9251
  return;
9152
- const cpd = resolveCompositeProperty(node.name.name);
9153
- if (!cpd)
9252
+ const cmp = resolveCompositeProperty(node.name.name);
9253
+ if (!cmp)
9154
9254
  return;
9155
9255
  sendReport(node, node.name.name);
9156
9256
  },
@@ -9159,21 +9259,21 @@ var rule12 = createRule({
9159
9259
  return;
9160
9260
  if (!isPandaAttribute(node, context))
9161
9261
  return;
9162
- const cpd = resolveCompositeProperty(node.key.name);
9163
- if (!cpd)
9262
+ const cmp = resolveCompositeProperty(node.key.name);
9263
+ if (!cmp)
9164
9264
  return;
9165
9265
  sendReport(node.key, node.key.name);
9166
9266
  }
9167
9267
  };
9168
9268
  }
9169
9269
  });
9170
- var prefer_atomic_properties_default = rule12;
9270
+ var prefer_atomic_properties_default = rule13;
9171
9271
 
9172
9272
  // src/rules/prefer-composite-properties.ts
9173
9273
  init_cjs_shims();
9174
- var RULE_NAME13 = "prefer-composite-properties";
9175
- var rule13 = createRule({
9176
- name: RULE_NAME13,
9274
+ var RULE_NAME14 = "prefer-composite-properties";
9275
+ var rule14 = createRule({
9276
+ name: RULE_NAME14,
9177
9277
  meta: {
9178
9278
  docs: {
9179
9279
  description: "Encourage the use of composite properties instead of atomic properties in the codebase."
@@ -9227,7 +9327,80 @@ var rule13 = createRule({
9227
9327
  };
9228
9328
  }
9229
9329
  });
9230
- var prefer_composite_properties_default = rule13;
9330
+ var prefer_composite_properties_default = rule14;
9331
+
9332
+ // src/rules/prefer-unified-property-style.ts
9333
+ init_cjs_shims();
9334
+ var RULE_NAME15 = "prefer-unified-property-style";
9335
+ var rule15 = createRule({
9336
+ name: RULE_NAME15,
9337
+ meta: {
9338
+ docs: {
9339
+ description: "Discourage against mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results"
9340
+ },
9341
+ messages: {
9342
+ 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"
9343
+ },
9344
+ type: "suggestion",
9345
+ schema: []
9346
+ },
9347
+ defaultOptions: [],
9348
+ create(context) {
9349
+ const getLonghand = (name2) => resolveLonghand(name2, context) ?? name2;
9350
+ const resolveCompositeProperty = (name2) => {
9351
+ if (Object.hasOwn(compositeProperties, name2))
9352
+ return name2;
9353
+ const longhand = getLonghand(name2);
9354
+ if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
9355
+ return longhand;
9356
+ };
9357
+ const sendReport = (node, cmp, siblings) => {
9358
+ const _atomicProperties = siblings.filter((prop) => compositeProperties[cmp].includes(getLonghand(prop))).map((prop) => `\`${prop}\``);
9359
+ if (!_atomicProperties.length)
9360
+ return;
9361
+ const atomicProperties = _atomicProperties.join(", ") + (_atomicProperties.length === 1 ? " style" : " styles");
9362
+ const atomics = compositeProperties[cmp].map((name2) => `\`${name2}\``).join(", ");
9363
+ context.report({
9364
+ node,
9365
+ messageId: "unify",
9366
+ data: {
9367
+ composite: cmp,
9368
+ atomicProperties,
9369
+ atomics
9370
+ }
9371
+ });
9372
+ };
9373
+ return {
9374
+ JSXAttribute(node) {
9375
+ if (!isJSXIdentifier(node.name))
9376
+ return;
9377
+ if (!isPandaProp(node, context))
9378
+ return;
9379
+ const cmp = resolveCompositeProperty(node.name.name);
9380
+ if (!cmp)
9381
+ return;
9382
+ if (!isJSXOpeningElement(node.parent))
9383
+ return;
9384
+ const siblings = node.parent.attributes.map((attr) => attr.name.name);
9385
+ sendReport(node, cmp, siblings);
9386
+ },
9387
+ Property(node) {
9388
+ if (!isIdentifier(node.key))
9389
+ return;
9390
+ if (!isPandaAttribute(node, context))
9391
+ return;
9392
+ const cmp = resolveCompositeProperty(node.key.name);
9393
+ if (!cmp)
9394
+ return;
9395
+ if (!isObjectExpression(node.parent))
9396
+ return;
9397
+ const siblings = node.parent.properties.map((prop) => isIdentifier(prop.key) && prop.key.name);
9398
+ sendReport(node.key, cmp, siblings);
9399
+ }
9400
+ };
9401
+ }
9402
+ });
9403
+ var prefer_unified_property_style_default = rule15;
9231
9404
 
9232
9405
  // src/rules/index.ts
9233
9406
  var rules = {
@@ -9237,17 +9410,19 @@ var rules = {
9237
9410
  [RULE_NAME4]: no_dynamic_styling_default,
9238
9411
  [RULE_NAME5]: no_escape_hatch_default,
9239
9412
  [RULE_NAME6]: no_hardcoded_color_default,
9240
- [RULE_NAME7]: no_invalid_token_paths_default,
9241
- [RULE_NAME8]: no_property_renaming_default,
9242
- [RULE_NAME9]: prefer_longhand_properties_default,
9243
- [RULE_NAME10]: prefer_shorthand_properties_default,
9244
- [RULE_NAME11]: no_unsafe_token_fn_usage_default,
9245
- [RULE_NAME12]: prefer_atomic_properties_default,
9246
- [RULE_NAME13]: prefer_composite_properties_default
9413
+ [RULE_NAME7]: no_important_default,
9414
+ [RULE_NAME8]: no_invalid_token_paths_default,
9415
+ [RULE_NAME9]: no_property_renaming_default,
9416
+ [RULE_NAME10]: no_unsafe_token_fn_usage_default,
9417
+ [RULE_NAME11]: prefer_longhand_properties_default,
9418
+ [RULE_NAME12]: prefer_shorthand_properties_default,
9419
+ [RULE_NAME13]: prefer_atomic_properties_default,
9420
+ [RULE_NAME14]: prefer_composite_properties_default,
9421
+ [RULE_NAME15]: prefer_unified_property_style_default
9247
9422
  };
9248
9423
 
9249
9424
  // src/configs/all.ts
9250
- var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME7];
9425
+ var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME8];
9251
9426
  var allRules = Object.fromEntries(
9252
9427
  Object.entries(rules).map(([name2]) => {
9253
9428
  return [`@pandacss/${name2}`, errorRules.includes(name2) ? "error" : "warn"];
@@ -9271,8 +9446,9 @@ var recommended_default = {
9271
9446
  "@pandacss/no-config-function-in-source": "error",
9272
9447
  "@pandacss/no-debug": "warn",
9273
9448
  "@pandacss/no-dynamic-styling": "warn",
9449
+ "@pandacss/no-invalid-token-paths": "error",
9274
9450
  "@pandacss/no-property-renaming": "warn",
9275
- "@pandacss/no-invalid-token-paths": "error"
9451
+ "@pandacss/prefer-unified-property-style": "warn"
9276
9452
  }
9277
9453
  };
9278
9454