@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.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.13";
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_) => {
@@ -8122,6 +8123,17 @@ var isPandaProp = (node, context) => {
8122
8123
  return;
8123
8124
  return true;
8124
8125
  };
8126
+ var isStyledProperty = (node, context, calleeName) => {
8127
+ if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key))
8128
+ return;
8129
+ if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName))
8130
+ return;
8131
+ if (isLiteral(node.key) && typeof node.key.value === "string" && !isValidProperty(node.key.value, context, calleeName))
8132
+ return;
8133
+ if (isTemplateLiteral(node.key) && !isValidProperty(node.key.quasis[0].value.raw, context, calleeName))
8134
+ return;
8135
+ return true;
8136
+ };
8125
8137
  var isInPandaFunction = (node, context) => {
8126
8138
  const callAncestor = getAncestor(isCallExpression, node);
8127
8139
  if (!callAncestor)
@@ -8137,17 +8149,9 @@ var isInPandaFunction = (node, context) => {
8137
8149
  return;
8138
8150
  if (!isPandaIsh(calleeName, context))
8139
8151
  return;
8140
- if (!isIdentifier(node.key))
8141
- return;
8142
- const attr = node.key.name;
8143
- if (!isValidProperty(attr, context, calleeName))
8144
- return;
8145
- return true;
8152
+ return calleeName;
8146
8153
  };
8147
- var isPandaAttribute = (node, context) => {
8148
- const callAncestor = getAncestor(isCallExpression, node);
8149
- if (callAncestor)
8150
- return isInPandaFunction(node, context);
8154
+ var isInJSXProp = (node, context) => {
8151
8155
  const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8152
8156
  const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8153
8157
  if (!jsxExprAncestor || !jsxAttrAncestor)
@@ -8158,6 +8162,16 @@ var isPandaAttribute = (node, context) => {
8158
8162
  return;
8159
8163
  return true;
8160
8164
  };
8165
+ var isPandaAttribute = (node, context) => {
8166
+ const callAncestor = getAncestor(isCallExpression, node);
8167
+ if (callAncestor) {
8168
+ const callee = isInPandaFunction(node, context);
8169
+ if (!callee)
8170
+ return;
8171
+ return isStyledProperty(node, context, callee);
8172
+ }
8173
+ return isInJSXProp(node, context);
8174
+ };
8161
8175
  var resolveLonghand = (name2, context) => {
8162
8176
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
8163
8177
  };
@@ -8580,13 +8594,148 @@ var rule6 = createRule({
8580
8594
  });
8581
8595
  var no_hardcoded_color_default = rule6;
8582
8596
 
8583
- // src/rules/no-invalid-token-paths.ts
8597
+ // src/rules/no-important.ts
8584
8598
  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";
8599
+ var import_shared2 = require("@pandacss/shared");
8600
+ var exclamationRegex = /\s*!$/;
8601
+ var importantRegex = /\s*!important\s*$/;
8602
+ var RULE_NAME7 = "no-important";
8588
8603
  var rule7 = createRule({
8589
8604
  name: RULE_NAME7,
8605
+ meta: {
8606
+ docs: {
8607
+ description: "Disallow usage of important keyword. Prioroitize specificity for a maintainable and predictable styling structure."
8608
+ },
8609
+ messages: {
8610
+ important: "Avoid using the !important keyword. Refactor your code to prioritize specificity for predictable styling.",
8611
+ remove: "Remove the `{{keyword}}` keyword."
8612
+ },
8613
+ type: "suggestion",
8614
+ hasSuggestions: true,
8615
+ schema: []
8616
+ },
8617
+ defaultOptions: [],
8618
+ create(context) {
8619
+ const removeQuotes = ([start, end]) => [start + 1, end - 1];
8620
+ const hasImportantKeyword = (_value) => {
8621
+ if (!_value)
8622
+ return false;
8623
+ const value = (0, import_shared2.getArbitraryValue)(_value);
8624
+ return exclamationRegex.test(value) || importantRegex.test(value);
8625
+ };
8626
+ const removeImportantKeyword = (input) => {
8627
+ if (exclamationRegex.test(input)) {
8628
+ return { fixed: input.replace(exclamationRegex, ""), keyword: "!" };
8629
+ } else if (importantRegex.test(input)) {
8630
+ return { fixed: input.replace(importantRegex, ""), keyword: "!important" };
8631
+ } else {
8632
+ return { fixed: input, keyword: null };
8633
+ }
8634
+ };
8635
+ const handleLiteral = (node) => {
8636
+ if (!isLiteral(node))
8637
+ return;
8638
+ if (!hasImportantKeyword(node.value?.toString()))
8639
+ return;
8640
+ sendReport(node);
8641
+ };
8642
+ const handleTemplateLiteral = (node) => {
8643
+ if (!isTemplateLiteral(node))
8644
+ return;
8645
+ if (node.expressions.length > 0)
8646
+ return;
8647
+ if (!hasImportantKeyword(node.quasis[0].value.raw))
8648
+ return;
8649
+ sendReport(node.quasis[0], node.quasis[0].value.raw);
8650
+ };
8651
+ const sendReport = (node, _value) => {
8652
+ const value = _value ?? node.value?.toString();
8653
+ const { keyword, fixed } = removeImportantKeyword(value);
8654
+ return context.report({
8655
+ node,
8656
+ messageId: "important",
8657
+ suggest: [
8658
+ {
8659
+ messageId: "remove",
8660
+ data: { keyword },
8661
+ fix: (fixer) => {
8662
+ return fixer.replaceTextRange(removeQuotes(node.range), fixed);
8663
+ }
8664
+ }
8665
+ ]
8666
+ });
8667
+ };
8668
+ return {
8669
+ JSXAttribute(node) {
8670
+ if (!node.value)
8671
+ return;
8672
+ if (!isPandaProp(node, context))
8673
+ return;
8674
+ handleLiteral(node.value);
8675
+ if (!isJSXExpressionContainer(node.value))
8676
+ return;
8677
+ handleLiteral(node.value.expression);
8678
+ handleTemplateLiteral(node.value.expression);
8679
+ },
8680
+ Property(node) {
8681
+ if (!isIdentifier(node.key))
8682
+ return;
8683
+ if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
8684
+ return;
8685
+ if (!isPandaAttribute(node, context))
8686
+ return;
8687
+ handleLiteral(node.value);
8688
+ handleTemplateLiteral(node.value);
8689
+ }
8690
+ };
8691
+ }
8692
+ });
8693
+ var no_important_default = rule7;
8694
+
8695
+ // src/rules/no-invalid-nesting.ts
8696
+ init_cjs_shims();
8697
+ var RULE_NAME8 = "no-invalid-nesting";
8698
+ var rule8 = createRule({
8699
+ name: RULE_NAME8,
8700
+ meta: {
8701
+ docs: {
8702
+ description: "Warn against invalid nesting. i.e. nested styles that don't contain the `&` character."
8703
+ },
8704
+ messages: {
8705
+ nesting: "Invalid style nesting. Nested styles must contain the `&` character."
8706
+ },
8707
+ type: "suggestion",
8708
+ schema: []
8709
+ },
8710
+ defaultOptions: [],
8711
+ create(context) {
8712
+ return {
8713
+ Property(node) {
8714
+ if (!isObjectExpression(node.value) || isIdentifier(node.key))
8715
+ return;
8716
+ if (!isInPandaFunction(node, context) && !isInJSXProp(node, context))
8717
+ return;
8718
+ const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
8719
+ const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
8720
+ if (invalidLiteral || invalidTemplateLiteral) {
8721
+ context.report({
8722
+ node: node.key,
8723
+ messageId: "nesting"
8724
+ });
8725
+ }
8726
+ }
8727
+ };
8728
+ }
8729
+ });
8730
+ var no_invalid_nesting_default = rule8;
8731
+
8732
+ // src/rules/no-invalid-token-paths.ts
8733
+ init_cjs_shims();
8734
+ var import_utils12 = require("@typescript-eslint/utils");
8735
+ var import_ast_utils2 = require("@typescript-eslint/utils/ast-utils");
8736
+ var RULE_NAME9 = "no-invalid-token-paths";
8737
+ var rule9 = createRule({
8738
+ name: RULE_NAME9,
8590
8739
  meta: {
8591
8740
  docs: {
8592
8741
  description: "Disallow the use of invalid token paths within token function syntax."
@@ -8639,7 +8788,7 @@ var rule7 = createRule({
8639
8788
  Property(node) {
8640
8789
  if (!isIdentifier(node.key))
8641
8790
  return;
8642
- if (!(0, import_ast_utils2.isNodeOfTypes)([import_utils10.AST_NODE_TYPES.Literal, import_utils10.AST_NODE_TYPES.TemplateLiteral])(node.value))
8791
+ if (!(0, import_ast_utils2.isNodeOfTypes)([import_utils12.AST_NODE_TYPES.Literal, import_utils12.AST_NODE_TYPES.TemplateLiteral])(node.value))
8643
8792
  return;
8644
8793
  if (!isPandaAttribute(node, context))
8645
8794
  return;
@@ -8686,13 +8835,13 @@ var rule7 = createRule({
8686
8835
  };
8687
8836
  }
8688
8837
  });
8689
- var no_invalid_token_paths_default = rule7;
8838
+ var no_invalid_token_paths_default = rule9;
8690
8839
 
8691
8840
  // src/rules/no-property-renaming.ts
8692
8841
  init_cjs_shims();
8693
- var RULE_NAME8 = "no-property-renaming";
8694
- var rule8 = createRule({
8695
- name: RULE_NAME8,
8842
+ var RULE_NAME10 = "no-property-renaming";
8843
+ var rule10 = createRule({
8844
+ name: RULE_NAME10,
8696
8845
  meta: {
8697
8846
  docs: {
8698
8847
  description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
@@ -8751,20 +8900,22 @@ var rule8 = createRule({
8751
8900
  };
8752
8901
  }
8753
8902
  });
8754
- var no_property_renaming_default = rule8;
8903
+ var no_property_renaming_default = rule10;
8755
8904
 
8756
- // src/rules/prefer-longhand-properties.ts
8905
+ // src/rules/no-unsafe-token-fn-usage.ts
8757
8906
  init_cjs_shims();
8758
- var RULE_NAME9 = "prefer-longhand-properties";
8759
- var rule9 = createRule({
8760
- name: RULE_NAME9,
8907
+ var import_utils15 = require("@typescript-eslint/utils");
8908
+ var import_shared3 = require("@pandacss/shared");
8909
+ var RULE_NAME11 = "no-unsafe-token-fn-usage";
8910
+ var rule11 = createRule({
8911
+ name: RULE_NAME11,
8761
8912
  meta: {
8762
8913
  docs: {
8763
- description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8914
+ description: "Prevent users from using the token function in situations where they could simply use the raw design token."
8764
8915
  },
8765
8916
  messages: {
8766
- longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
8767
- replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8917
+ noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8918
+ replace: "Replace token function with `{{safe}}`"
8768
8919
  },
8769
8920
  type: "suggestion",
8770
8921
  hasSuggestions: true,
@@ -8772,22 +8923,57 @@ var rule9 = createRule({
8772
8923
  },
8773
8924
  defaultOptions: [],
8774
8925
  create(context) {
8775
- const sendReport = (node, name2) => {
8776
- const longhand = resolveLonghand(name2, context);
8777
- const data = {
8778
- shorthand: name2,
8779
- longhand
8780
- };
8926
+ const isUnsafeCallExpression = (node) => {
8927
+ const tkImport = getTokenImport(context);
8928
+ return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
8929
+ };
8930
+ const tokenWrap = (value) => value ? `token(${value})` : "";
8931
+ const handleRuntimeFm = (node) => {
8932
+ if (!isCallExpression(node))
8933
+ return;
8934
+ if (!isUnsafeCallExpression(node))
8935
+ return;
8936
+ const value = node.arguments[0];
8937
+ if (isLiteral(value)) {
8938
+ sendReport(node, tokenWrap((0, import_shared3.getArbitraryValue)(value.value?.toString() ?? "")));
8939
+ }
8940
+ if (isTemplateLiteral(value)) {
8941
+ sendReport(node, tokenWrap((0, import_shared3.getArbitraryValue)(value.quasis[0].value.raw)));
8942
+ }
8943
+ };
8944
+ const isCompositeValue = (input) => {
8945
+ if (!input)
8946
+ return;
8947
+ const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
8948
+ return !tokenRegex.test(input);
8949
+ };
8950
+ const handleLiteral = (node) => {
8951
+ if (!isLiteral(node))
8952
+ return;
8953
+ const value = (0, import_shared3.getArbitraryValue)(node.value?.toString() ?? "");
8954
+ if (isCompositeValue(value))
8955
+ return;
8956
+ sendReport(node, value);
8957
+ };
8958
+ const handleTemplateLiteral = (node) => {
8959
+ if (!isTemplateLiteral(node))
8960
+ return;
8961
+ if (node.expressions.length > 0)
8962
+ return;
8963
+ sendReport(node, (0, import_shared3.getArbitraryValue)(node.quasis[0].value.raw));
8964
+ };
8965
+ const sendReport = (node, value) => {
8966
+ const tkImports = extractTokens(value);
8967
+ const token = tkImports[0].replace(/^[^.]*\./, "");
8781
8968
  return context.report({
8782
8969
  node,
8783
- messageId: "longhand",
8784
- data,
8970
+ messageId: "noUnsafeTokenFnUsage",
8785
8971
  suggest: [
8786
8972
  {
8787
8973
  messageId: "replace",
8788
- data,
8974
+ data: { safe: token },
8789
8975
  fix: (fixer) => {
8790
- return fixer.replaceTextRange(node.range, longhand);
8976
+ return fixer.replaceTextRange(node.range, `'${token}'`);
8791
8977
  }
8792
8978
  }
8793
8979
  ]
@@ -8795,42 +8981,43 @@ var rule9 = createRule({
8795
8981
  };
8796
8982
  return {
8797
8983
  JSXAttribute(node) {
8798
- if (!isJSXIdentifier(node.name))
8984
+ if (!node.value)
8799
8985
  return;
8800
8986
  if (!isPandaProp(node, context))
8801
8987
  return;
8802
- const longhand = resolveLonghand(node.name.name, context);
8803
- if (!longhand)
8988
+ handleLiteral(node.value);
8989
+ if (!isJSXExpressionContainer(node.value))
8804
8990
  return;
8805
- sendReport(node.name, node.name.name);
8991
+ handleLiteral(node.value.expression);
8992
+ handleTemplateLiteral(node.value.expression);
8993
+ handleRuntimeFm(node.value.expression);
8806
8994
  },
8807
8995
  Property(node) {
8808
- if (!isIdentifier(node.key))
8996
+ if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
8809
8997
  return;
8810
8998
  if (!isPandaAttribute(node, context))
8811
8999
  return;
8812
- const longhand = resolveLonghand(node.key.name, context);
8813
- if (!longhand)
8814
- return;
8815
- sendReport(node.key, node.key.name);
9000
+ handleRuntimeFm(node.value);
9001
+ handleLiteral(node.value);
9002
+ handleTemplateLiteral(node.value);
8816
9003
  }
8817
9004
  };
8818
9005
  }
8819
9006
  });
8820
- var prefer_longhand_properties_default = rule9;
9007
+ var no_unsafe_token_fn_usage_default = rule11;
8821
9008
 
8822
- // src/rules/prefer-shorthand-properties.ts
9009
+ // src/rules/prefer-longhand-properties.ts
8823
9010
  init_cjs_shims();
8824
- var RULE_NAME10 = "prefer-shorthand-properties";
8825
- var rule10 = createRule({
8826
- name: RULE_NAME10,
9011
+ var RULE_NAME12 = "prefer-longhand-properties";
9012
+ var rule12 = createRule({
9013
+ name: RULE_NAME12,
8827
9014
  meta: {
8828
9015
  docs: {
8829
- description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
9016
+ description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8830
9017
  },
8831
9018
  messages: {
8832
- shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
8833
- replace: "Replace `{{longhand}}` with `{{shorthand}}`"
9019
+ longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
9020
+ replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8834
9021
  },
8835
9022
  type: "suggestion",
8836
9023
  hasSuggestions: true,
@@ -8839,24 +9026,21 @@ var rule10 = createRule({
8839
9026
  defaultOptions: [],
8840
9027
  create(context) {
8841
9028
  const sendReport = (node, name2) => {
8842
- const shorthands = resolveShorthands(name2, context);
8843
- if (!shorthands)
8844
- return;
8845
- const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
9029
+ const longhand = resolveLonghand(name2, context);
8846
9030
  const data = {
8847
- longhand: name2,
8848
- shorthand
9031
+ shorthand: name2,
9032
+ longhand
8849
9033
  };
8850
9034
  return context.report({
8851
9035
  node,
8852
- messageId: "shorthand",
9036
+ messageId: "longhand",
8853
9037
  data,
8854
9038
  suggest: [
8855
9039
  {
8856
9040
  messageId: "replace",
8857
9041
  data,
8858
9042
  fix: (fixer) => {
8859
- return fixer.replaceTextRange(node.range, shorthands[0]);
9043
+ return fixer.replaceTextRange(node.range, longhand);
8860
9044
  }
8861
9045
  }
8862
9046
  ]
@@ -8869,7 +9053,7 @@ var rule10 = createRule({
8869
9053
  if (!isPandaProp(node, context))
8870
9054
  return;
8871
9055
  const longhand = resolveLonghand(node.name.name, context);
8872
- if (longhand)
9056
+ if (!longhand)
8873
9057
  return;
8874
9058
  sendReport(node.name, node.name.name);
8875
9059
  },
@@ -8879,28 +9063,27 @@ var rule10 = createRule({
8879
9063
  if (!isPandaAttribute(node, context))
8880
9064
  return;
8881
9065
  const longhand = resolveLonghand(node.key.name, context);
8882
- if (longhand)
9066
+ if (!longhand)
8883
9067
  return;
8884
9068
  sendReport(node.key, node.key.name);
8885
9069
  }
8886
9070
  };
8887
9071
  }
8888
9072
  });
8889
- var prefer_shorthand_properties_default = rule10;
9073
+ var prefer_longhand_properties_default = rule12;
8890
9074
 
8891
- // src/rules/no-unsafe-token-fn-usage.ts
9075
+ // src/rules/prefer-shorthand-properties.ts
8892
9076
  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,
9077
+ var RULE_NAME13 = "prefer-shorthand-properties";
9078
+ var rule13 = createRule({
9079
+ name: RULE_NAME13,
8897
9080
  meta: {
8898
9081
  docs: {
8899
- description: "Prevent users from using the token function in situations where they could simply use the raw design token."
9082
+ description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
8900
9083
  },
8901
9084
  messages: {
8902
- noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8903
- replace: "Replace token function with `{{safe}}`"
9085
+ shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
9086
+ replace: "Replace `{{longhand}}` with `{{shorthand}}`"
8904
9087
  },
8905
9088
  type: "suggestion",
8906
9089
  hasSuggestions: true,
@@ -8908,57 +9091,25 @@ var rule11 = createRule({
8908
9091
  },
8909
9092
  defaultOptions: [],
8910
9093
  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)
9094
+ const sendReport = (node, name2) => {
9095
+ const shorthands = resolveShorthands(name2, context);
9096
+ if (!shorthands)
8946
9097
  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(/^[^.]*\./, "");
9098
+ const shorthand = shorthands.map((s) => `\`${s}\``)?.join(", ");
9099
+ const data = {
9100
+ longhand: name2,
9101
+ shorthand
9102
+ };
8953
9103
  return context.report({
8954
9104
  node,
8955
- messageId: "noUnsafeTokenFnUsage",
9105
+ messageId: "shorthand",
9106
+ data,
8956
9107
  suggest: [
8957
9108
  {
8958
9109
  messageId: "replace",
8959
- data: { safe: token },
9110
+ data,
8960
9111
  fix: (fixer) => {
8961
- return fixer.replaceTextRange(node.range, `'${token}'`);
9112
+ return fixer.replaceTextRange(node.range, shorthands[0]);
8962
9113
  }
8963
9114
  }
8964
9115
  ]
@@ -8966,30 +9117,29 @@ var rule11 = createRule({
8966
9117
  };
8967
9118
  return {
8968
9119
  JSXAttribute(node) {
8969
- if (!node.value)
9120
+ if (!isJSXIdentifier(node.name))
8970
9121
  return;
8971
9122
  if (!isPandaProp(node, context))
8972
9123
  return;
8973
- handleLiteral(node.value);
8974
- if (!isJSXExpressionContainer(node.value))
9124
+ const longhand = resolveLonghand(node.name.name, context);
9125
+ if (longhand)
8975
9126
  return;
8976
- handleLiteral(node.value.expression);
8977
- handleTemplateLiteral(node.value.expression);
8978
- handleRuntimeFm(node.value.expression);
9127
+ sendReport(node.name, node.name.name);
8979
9128
  },
8980
9129
  Property(node) {
8981
- if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
9130
+ if (!isIdentifier(node.key))
8982
9131
  return;
8983
9132
  if (!isPandaAttribute(node, context))
8984
9133
  return;
8985
- handleRuntimeFm(node.value);
8986
- handleLiteral(node.value);
8987
- handleTemplateLiteral(node.value);
9134
+ const longhand = resolveLonghand(node.key.name, context);
9135
+ if (longhand)
9136
+ return;
9137
+ sendReport(node.key, node.key.name);
8988
9138
  }
8989
9139
  };
8990
9140
  }
8991
9141
  });
8992
- var no_unsafe_token_fn_usage_default = rule11;
9142
+ var prefer_shorthand_properties_default = rule13;
8993
9143
 
8994
9144
  // src/rules/prefer-atomic-properties.ts
8995
9145
  init_cjs_shims();
@@ -9109,9 +9259,9 @@ var compositeProperties = {
9109
9259
  };
9110
9260
 
9111
9261
  // src/rules/prefer-atomic-properties.ts
9112
- var RULE_NAME12 = "prefer-atomic-properties";
9113
- var rule12 = createRule({
9114
- name: RULE_NAME12,
9262
+ var RULE_NAME14 = "prefer-atomic-properties";
9263
+ var rule14 = createRule({
9264
+ name: RULE_NAME14,
9115
9265
  meta: {
9116
9266
  docs: {
9117
9267
  description: "Encourage the use of atomic properties instead of composite properties in the codebase."
@@ -9132,8 +9282,8 @@ var rule12 = createRule({
9132
9282
  return longhand;
9133
9283
  };
9134
9284
  const sendReport = (node, name2) => {
9135
- const cpd = resolveCompositeProperty(name2);
9136
- const atomics = compositeProperties[cpd].map((name3) => `\`${name3}\``).join(",\n");
9285
+ const cmp = resolveCompositeProperty(name2);
9286
+ const atomics = compositeProperties[cmp].map((name3) => `\`${name3}\``).join(",\n");
9137
9287
  return context.report({
9138
9288
  node,
9139
9289
  messageId: "atomic",
@@ -9149,8 +9299,8 @@ var rule12 = createRule({
9149
9299
  return;
9150
9300
  if (!isPandaProp(node, context))
9151
9301
  return;
9152
- const cpd = resolveCompositeProperty(node.name.name);
9153
- if (!cpd)
9302
+ const cmp = resolveCompositeProperty(node.name.name);
9303
+ if (!cmp)
9154
9304
  return;
9155
9305
  sendReport(node, node.name.name);
9156
9306
  },
@@ -9159,21 +9309,21 @@ var rule12 = createRule({
9159
9309
  return;
9160
9310
  if (!isPandaAttribute(node, context))
9161
9311
  return;
9162
- const cpd = resolveCompositeProperty(node.key.name);
9163
- if (!cpd)
9312
+ const cmp = resolveCompositeProperty(node.key.name);
9313
+ if (!cmp)
9164
9314
  return;
9165
9315
  sendReport(node.key, node.key.name);
9166
9316
  }
9167
9317
  };
9168
9318
  }
9169
9319
  });
9170
- var prefer_atomic_properties_default = rule12;
9320
+ var prefer_atomic_properties_default = rule14;
9171
9321
 
9172
9322
  // src/rules/prefer-composite-properties.ts
9173
9323
  init_cjs_shims();
9174
- var RULE_NAME13 = "prefer-composite-properties";
9175
- var rule13 = createRule({
9176
- name: RULE_NAME13,
9324
+ var RULE_NAME15 = "prefer-composite-properties";
9325
+ var rule15 = createRule({
9326
+ name: RULE_NAME15,
9177
9327
  meta: {
9178
9328
  docs: {
9179
9329
  description: "Encourage the use of composite properties instead of atomic properties in the codebase."
@@ -9227,7 +9377,80 @@ var rule13 = createRule({
9227
9377
  };
9228
9378
  }
9229
9379
  });
9230
- var prefer_composite_properties_default = rule13;
9380
+ var prefer_composite_properties_default = rule15;
9381
+
9382
+ // src/rules/prefer-unified-property-style.ts
9383
+ init_cjs_shims();
9384
+ var RULE_NAME16 = "prefer-unified-property-style";
9385
+ var rule16 = createRule({
9386
+ name: RULE_NAME16,
9387
+ meta: {
9388
+ docs: {
9389
+ description: "Discourage against mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results"
9390
+ },
9391
+ messages: {
9392
+ 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"
9393
+ },
9394
+ type: "suggestion",
9395
+ schema: []
9396
+ },
9397
+ defaultOptions: [],
9398
+ create(context) {
9399
+ const getLonghand = (name2) => resolveLonghand(name2, context) ?? name2;
9400
+ const resolveCompositeProperty = (name2) => {
9401
+ if (Object.hasOwn(compositeProperties, name2))
9402
+ return name2;
9403
+ const longhand = getLonghand(name2);
9404
+ if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
9405
+ return longhand;
9406
+ };
9407
+ const sendReport = (node, cmp, siblings) => {
9408
+ const _atomicProperties = siblings.filter((prop) => compositeProperties[cmp].includes(getLonghand(prop))).map((prop) => `\`${prop}\``);
9409
+ if (!_atomicProperties.length)
9410
+ return;
9411
+ const atomicProperties = _atomicProperties.join(", ") + (_atomicProperties.length === 1 ? " style" : " styles");
9412
+ const atomics = compositeProperties[cmp].map((name2) => `\`${name2}\``).join(", ");
9413
+ context.report({
9414
+ node,
9415
+ messageId: "unify",
9416
+ data: {
9417
+ composite: cmp,
9418
+ atomicProperties,
9419
+ atomics
9420
+ }
9421
+ });
9422
+ };
9423
+ return {
9424
+ JSXAttribute(node) {
9425
+ if (!isJSXIdentifier(node.name))
9426
+ return;
9427
+ if (!isPandaProp(node, context))
9428
+ return;
9429
+ const cmp = resolveCompositeProperty(node.name.name);
9430
+ if (!cmp)
9431
+ return;
9432
+ if (!isJSXOpeningElement(node.parent))
9433
+ return;
9434
+ const siblings = node.parent.attributes.map((attr) => attr.name.name);
9435
+ sendReport(node, cmp, siblings);
9436
+ },
9437
+ Property(node) {
9438
+ if (!isIdentifier(node.key))
9439
+ return;
9440
+ if (!isPandaAttribute(node, context))
9441
+ return;
9442
+ const cmp = resolveCompositeProperty(node.key.name);
9443
+ if (!cmp)
9444
+ return;
9445
+ if (!isObjectExpression(node.parent))
9446
+ return;
9447
+ const siblings = node.parent.properties.map((prop) => isIdentifier(prop.key) && prop.key.name);
9448
+ sendReport(node.key, cmp, siblings);
9449
+ }
9450
+ };
9451
+ }
9452
+ });
9453
+ var prefer_unified_property_style_default = rule16;
9231
9454
 
9232
9455
  // src/rules/index.ts
9233
9456
  var rules = {
@@ -9237,17 +9460,20 @@ var rules = {
9237
9460
  [RULE_NAME4]: no_dynamic_styling_default,
9238
9461
  [RULE_NAME5]: no_escape_hatch_default,
9239
9462
  [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,
9463
+ [RULE_NAME7]: no_important_default,
9464
+ [RULE_NAME9]: no_invalid_token_paths_default,
9465
+ [RULE_NAME8]: no_invalid_nesting_default,
9466
+ [RULE_NAME10]: no_property_renaming_default,
9244
9467
  [RULE_NAME11]: no_unsafe_token_fn_usage_default,
9245
- [RULE_NAME12]: prefer_atomic_properties_default,
9246
- [RULE_NAME13]: prefer_composite_properties_default
9468
+ [RULE_NAME12]: prefer_longhand_properties_default,
9469
+ [RULE_NAME13]: prefer_shorthand_properties_default,
9470
+ [RULE_NAME14]: prefer_atomic_properties_default,
9471
+ [RULE_NAME15]: prefer_composite_properties_default,
9472
+ [RULE_NAME16]: prefer_unified_property_style_default
9247
9473
  };
9248
9474
 
9249
9475
  // src/configs/all.ts
9250
- var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME7];
9476
+ var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME9];
9251
9477
  var allRules = Object.fromEntries(
9252
9478
  Object.entries(rules).map(([name2]) => {
9253
9479
  return [`@pandacss/${name2}`, errorRules.includes(name2) ? "error" : "warn"];
@@ -9271,8 +9497,10 @@ var recommended_default = {
9271
9497
  "@pandacss/no-config-function-in-source": "error",
9272
9498
  "@pandacss/no-debug": "warn",
9273
9499
  "@pandacss/no-dynamic-styling": "warn",
9500
+ "@pandacss/no-invalid-nesting": "error",
9501
+ "@pandacss/no-invalid-token-paths": "error",
9274
9502
  "@pandacss/no-property-renaming": "warn",
9275
- "@pandacss/no-invalid-token-paths": "error"
9503
+ "@pandacss/prefer-unified-property-style": "warn"
9276
9504
  }
9277
9505
  };
9278
9506