@pandacss/eslint-plugin 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7957,7 +7957,7 @@ init_cjs_shims();
7957
7957
 
7958
7958
  // package.json
7959
7959
  var name = "@pandacss/eslint-plugin";
7960
- var version = "0.0.9";
7960
+ var version = "0.0.10";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -8161,8 +8161,8 @@ var isPandaAttribute = (node, context) => {
8161
8161
  var resolveLonghand = (name2, context) => {
8162
8162
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
8163
8163
  };
8164
- var resolveShorthand = (name2, context) => {
8165
- return syncAction("resolveShorthand", getSyncOpts(context), name2);
8164
+ var resolveShorthands = (name2, context) => {
8165
+ return syncAction("resolveShorthands", getSyncOpts(context), name2);
8166
8166
  };
8167
8167
  var isColorAttribute = (attr, context) => {
8168
8168
  return syncAction("isColorAttribute", getSyncOpts(context), attr);
@@ -8755,12 +8755,12 @@ var no_property_renaming_default = rule8;
8755
8755
 
8756
8756
  // src/rules/prefer-longhand-properties.ts
8757
8757
  init_cjs_shims();
8758
- var RULE_NAME9 = "no-shorthand-prop";
8758
+ var RULE_NAME9 = "prefer-longhand-properties";
8759
8759
  var rule9 = createRule({
8760
8760
  name: RULE_NAME9,
8761
8761
  meta: {
8762
8762
  docs: {
8763
- description: "Discourage the use of shorthand properties and promote the preference for longhand CSS properties in the codebase."
8763
+ description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8764
8764
  },
8765
8765
  messages: {
8766
8766
  longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
@@ -8819,12 +8819,81 @@ var rule9 = createRule({
8819
8819
  });
8820
8820
  var prefer_longhand_properties_default = rule9;
8821
8821
 
8822
- // src/rules/no-unsafe-token-fn-usage.ts
8822
+ // src/rules/prefer-shorthand-properties.ts
8823
8823
  init_cjs_shims();
8824
- var import_utils14 = require("@typescript-eslint/utils");
8825
- var RULE_NAME10 = "no-unsafe-token-fn-usage";
8824
+ var RULE_NAME10 = "prefer-shorthand-properties";
8826
8825
  var rule10 = createRule({
8827
8826
  name: RULE_NAME10,
8827
+ meta: {
8828
+ docs: {
8829
+ description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
8830
+ },
8831
+ messages: {
8832
+ shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
8833
+ replace: "Replace `{{longhand}}` with `{{shorthand}}`"
8834
+ },
8835
+ type: "suggestion",
8836
+ hasSuggestions: true,
8837
+ schema: []
8838
+ },
8839
+ defaultOptions: [],
8840
+ create(context) {
8841
+ const sendReport = (node, name2) => {
8842
+ const shorthands = resolveShorthands(name2, context);
8843
+ if (!shorthands)
8844
+ return;
8845
+ const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
8846
+ const data = {
8847
+ longhand: name2,
8848
+ shorthand
8849
+ };
8850
+ return context.report({
8851
+ node,
8852
+ messageId: "shorthand",
8853
+ data,
8854
+ suggest: [
8855
+ {
8856
+ messageId: "replace",
8857
+ data,
8858
+ fix: (fixer) => {
8859
+ return fixer.replaceTextRange(node.range, shorthands[0]);
8860
+ }
8861
+ }
8862
+ ]
8863
+ });
8864
+ };
8865
+ return {
8866
+ JSXAttribute(node) {
8867
+ if (!isJSXIdentifier(node.name))
8868
+ return;
8869
+ if (!isPandaProp(node, context))
8870
+ return;
8871
+ const longhand = resolveLonghand(node.name.name, context);
8872
+ if (longhand)
8873
+ return;
8874
+ sendReport(node.name, node.name.name);
8875
+ },
8876
+ Property(node) {
8877
+ if (!isIdentifier(node.key))
8878
+ return;
8879
+ if (!isPandaAttribute(node, context))
8880
+ return;
8881
+ const longhand = resolveLonghand(node.key.name, context);
8882
+ if (longhand)
8883
+ return;
8884
+ sendReport(node.key, node.key.name);
8885
+ }
8886
+ };
8887
+ }
8888
+ });
8889
+ var prefer_shorthand_properties_default = rule10;
8890
+
8891
+ // src/rules/no-unsafe-token-fn-usage.ts
8892
+ 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,
8828
8897
  meta: {
8829
8898
  docs: {
8830
8899
  description: "Prevent users from using the token function in situations where they could simply use the raw design token."
@@ -8920,7 +8989,7 @@ var rule10 = createRule({
8920
8989
  };
8921
8990
  }
8922
8991
  });
8923
- var no_unsafe_token_fn_usage_default = rule10;
8992
+ var no_unsafe_token_fn_usage_default = rule11;
8924
8993
 
8925
8994
  // src/rules/prefer-atomic-properties.ts
8926
8995
  init_cjs_shims();
@@ -9040,9 +9109,9 @@ var compositeProperties = {
9040
9109
  };
9041
9110
 
9042
9111
  // src/rules/prefer-atomic-properties.ts
9043
- var RULE_NAME11 = "prefer-atomic-properties";
9044
- var rule11 = createRule({
9045
- name: RULE_NAME11,
9112
+ var RULE_NAME12 = "prefer-atomic-properties";
9113
+ var rule12 = createRule({
9114
+ name: RULE_NAME12,
9046
9115
  meta: {
9047
9116
  docs: {
9048
9117
  description: "Encourage the use of atomic properties instead of composite shorthand properties in the codebase."
@@ -9058,7 +9127,7 @@ var rule11 = createRule({
9058
9127
  const resolveCompositeProperty = (name2) => {
9059
9128
  if (Object.hasOwn(compositeProperties, name2))
9060
9129
  return name2;
9061
- const longhand = resolveShorthand(name2, context);
9130
+ const longhand = resolveLonghand(name2, context) ?? name2;
9062
9131
  if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
9063
9132
  return longhand;
9064
9133
  };
@@ -9098,7 +9167,7 @@ var rule11 = createRule({
9098
9167
  };
9099
9168
  }
9100
9169
  });
9101
- var prefer_atomic_properties_default = rule11;
9170
+ var prefer_atomic_properties_default = rule12;
9102
9171
 
9103
9172
  // src/rules/index.ts
9104
9173
  var rules = {
@@ -9111,8 +9180,9 @@ var rules = {
9111
9180
  [RULE_NAME7]: no_invalid_token_paths_default,
9112
9181
  [RULE_NAME8]: no_property_renaming_default,
9113
9182
  [RULE_NAME9]: prefer_longhand_properties_default,
9114
- [RULE_NAME10]: no_unsafe_token_fn_usage_default,
9115
- [RULE_NAME11]: prefer_atomic_properties_default
9183
+ [RULE_NAME10]: prefer_shorthand_properties_default,
9184
+ [RULE_NAME11]: no_unsafe_token_fn_usage_default,
9185
+ [RULE_NAME12]: prefer_atomic_properties_default
9116
9186
  };
9117
9187
 
9118
9188
  // src/configs/all.ts
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.9";
13
+ version = "0.0.10";
14
14
  }
15
15
  });
16
16
 
@@ -7974,7 +7974,7 @@ var init_nodes = __esm({
7974
7974
  });
7975
7975
 
7976
7976
  // 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, resolveShorthand, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
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
7978
  var init_helpers = __esm({
7979
7979
  "src/utils/helpers.ts"() {
7980
7980
  "use strict";
@@ -8137,8 +8137,8 @@ var init_helpers = __esm({
8137
8137
  resolveLonghand = (name2, context) => {
8138
8138
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
8139
8139
  };
8140
- resolveShorthand = (name2, context) => {
8141
- return syncAction("resolveShorthand", getSyncOpts(context), name2);
8140
+ resolveShorthands = (name2, context) => {
8141
+ return syncAction("resolveShorthands", getSyncOpts(context), name2);
8142
8142
  };
8143
8143
  isColorAttribute = (attr, context) => {
8144
8144
  return syncAction("isColorAttribute", getSyncOpts(context), attr);
@@ -8812,12 +8812,12 @@ var init_prefer_longhand_properties = __esm({
8812
8812
  init_helpers();
8813
8813
  init_utils();
8814
8814
  init_nodes();
8815
- RULE_NAME9 = "no-shorthand-prop";
8815
+ RULE_NAME9 = "prefer-longhand-properties";
8816
8816
  rule9 = createRule({
8817
8817
  name: RULE_NAME9,
8818
8818
  meta: {
8819
8819
  docs: {
8820
- description: "Discourage the use of shorthand properties and promote the preference for longhand CSS properties in the codebase."
8820
+ description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
8821
8821
  },
8822
8822
  messages: {
8823
8823
  longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
@@ -8878,9 +8878,87 @@ var init_prefer_longhand_properties = __esm({
8878
8878
  }
8879
8879
  });
8880
8880
 
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"() {
8885
+ "use strict";
8886
+ init_esm_shims();
8887
+ init_helpers();
8888
+ init_utils();
8889
+ init_nodes();
8890
+ RULE_NAME10 = "prefer-shorthand-properties";
8891
+ rule10 = createRule({
8892
+ name: RULE_NAME10,
8893
+ meta: {
8894
+ docs: {
8895
+ description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
8896
+ },
8897
+ messages: {
8898
+ shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
8899
+ replace: "Replace `{{longhand}}` with `{{shorthand}}`"
8900
+ },
8901
+ type: "suggestion",
8902
+ hasSuggestions: true,
8903
+ schema: []
8904
+ },
8905
+ defaultOptions: [],
8906
+ create(context) {
8907
+ const sendReport = (node, name2) => {
8908
+ const shorthands = resolveShorthands(name2, context);
8909
+ if (!shorthands)
8910
+ return;
8911
+ const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
8912
+ const data = {
8913
+ longhand: name2,
8914
+ shorthand
8915
+ };
8916
+ return context.report({
8917
+ node,
8918
+ messageId: "shorthand",
8919
+ data,
8920
+ suggest: [
8921
+ {
8922
+ messageId: "replace",
8923
+ data,
8924
+ fix: (fixer) => {
8925
+ return fixer.replaceTextRange(node.range, shorthands[0]);
8926
+ }
8927
+ }
8928
+ ]
8929
+ });
8930
+ };
8931
+ return {
8932
+ JSXAttribute(node) {
8933
+ if (!isJSXIdentifier(node.name))
8934
+ return;
8935
+ if (!isPandaProp(node, context))
8936
+ return;
8937
+ const longhand = resolveLonghand(node.name.name, context);
8938
+ if (longhand)
8939
+ return;
8940
+ sendReport(node.name, node.name.name);
8941
+ },
8942
+ Property(node) {
8943
+ if (!isIdentifier(node.key))
8944
+ return;
8945
+ if (!isPandaAttribute(node, context))
8946
+ return;
8947
+ const longhand = resolveLonghand(node.key.name, context);
8948
+ if (longhand)
8949
+ return;
8950
+ sendReport(node.key, node.key.name);
8951
+ }
8952
+ };
8953
+ }
8954
+ });
8955
+ prefer_shorthand_properties_default = rule10;
8956
+ }
8957
+ });
8958
+
8881
8959
  // src/rules/no-unsafe-token-fn-usage.ts
8882
8960
  import "@typescript-eslint/utils";
8883
- var RULE_NAME10, rule10, no_unsafe_token_fn_usage_default;
8961
+ var RULE_NAME11, rule11, no_unsafe_token_fn_usage_default;
8884
8962
  var init_no_unsafe_token_fn_usage = __esm({
8885
8963
  "src/rules/no-unsafe-token-fn-usage.ts"() {
8886
8964
  "use strict";
@@ -8888,9 +8966,9 @@ var init_no_unsafe_token_fn_usage = __esm({
8888
8966
  init_helpers();
8889
8967
  init_utils();
8890
8968
  init_nodes();
8891
- RULE_NAME10 = "no-unsafe-token-fn-usage";
8892
- rule10 = createRule({
8893
- name: RULE_NAME10,
8969
+ RULE_NAME11 = "no-unsafe-token-fn-usage";
8970
+ rule11 = createRule({
8971
+ name: RULE_NAME11,
8894
8972
  meta: {
8895
8973
  docs: {
8896
8974
  description: "Prevent users from using the token function in situations where they could simply use the raw design token."
@@ -8986,7 +9064,7 @@ var init_no_unsafe_token_fn_usage = __esm({
8986
9064
  };
8987
9065
  }
8988
9066
  });
8989
- no_unsafe_token_fn_usage_default = rule10;
9067
+ no_unsafe_token_fn_usage_default = rule11;
8990
9068
  }
8991
9069
  });
8992
9070
 
@@ -9111,7 +9189,7 @@ var init_composite_properties = __esm({
9111
9189
  });
9112
9190
 
9113
9191
  // src/rules/prefer-atomic-properties.ts
9114
- var RULE_NAME11, rule11, prefer_atomic_properties_default;
9192
+ var RULE_NAME12, rule12, prefer_atomic_properties_default;
9115
9193
  var init_prefer_atomic_properties = __esm({
9116
9194
  "src/rules/prefer-atomic-properties.ts"() {
9117
9195
  "use strict";
@@ -9120,9 +9198,9 @@ var init_prefer_atomic_properties = __esm({
9120
9198
  init_utils();
9121
9199
  init_composite_properties();
9122
9200
  init_nodes();
9123
- RULE_NAME11 = "prefer-atomic-properties";
9124
- rule11 = createRule({
9125
- name: RULE_NAME11,
9201
+ RULE_NAME12 = "prefer-atomic-properties";
9202
+ rule12 = createRule({
9203
+ name: RULE_NAME12,
9126
9204
  meta: {
9127
9205
  docs: {
9128
9206
  description: "Encourage the use of atomic properties instead of composite shorthand properties in the codebase."
@@ -9138,7 +9216,7 @@ var init_prefer_atomic_properties = __esm({
9138
9216
  const resolveCompositeProperty = (name2) => {
9139
9217
  if (Object.hasOwn(compositeProperties, name2))
9140
9218
  return name2;
9141
- const longhand = resolveShorthand(name2, context);
9219
+ const longhand = resolveLonghand(name2, context) ?? name2;
9142
9220
  if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
9143
9221
  return longhand;
9144
9222
  };
@@ -9178,7 +9256,7 @@ var init_prefer_atomic_properties = __esm({
9178
9256
  };
9179
9257
  }
9180
9258
  });
9181
- prefer_atomic_properties_default = rule11;
9259
+ prefer_atomic_properties_default = rule12;
9182
9260
  }
9183
9261
  });
9184
9262
 
@@ -9197,6 +9275,7 @@ var init_rules = __esm({
9197
9275
  init_no_invalid_token_paths();
9198
9276
  init_no_property_renaming();
9199
9277
  init_prefer_longhand_properties();
9278
+ init_prefer_shorthand_properties();
9200
9279
  init_no_unsafe_token_fn_usage();
9201
9280
  init_prefer_atomic_properties();
9202
9281
  rules = {
@@ -9209,8 +9288,9 @@ var init_rules = __esm({
9209
9288
  [RULE_NAME7]: no_invalid_token_paths_default,
9210
9289
  [RULE_NAME8]: no_property_renaming_default,
9211
9290
  [RULE_NAME9]: prefer_longhand_properties_default,
9212
- [RULE_NAME10]: no_unsafe_token_fn_usage_default,
9213
- [RULE_NAME11]: prefer_atomic_properties_default
9291
+ [RULE_NAME10]: prefer_shorthand_properties_default,
9292
+ [RULE_NAME11]: no_unsafe_token_fn_usage_default,
9293
+ [RULE_NAME12]: prefer_atomic_properties_default
9214
9294
  };
9215
9295
  }
9216
9296
  });
@@ -3548,8 +3548,9 @@ async function isConfigFile(fileName) {
3548
3548
  async function isValidFile(ctx, fileName) {
3549
3549
  return ctx.getFiles().includes(fileName);
3550
3550
  }
3551
- async function resolveShorthand(ctx, name) {
3552
- return ctx.utility.resolveShorthand(name);
3551
+ async function resolveShorthands(ctx, name) {
3552
+ console.log("name", name, ctx.utility.getPropShorthandsMap().get(name));
3553
+ return ctx.utility.getPropShorthandsMap().get(name);
3553
3554
  }
3554
3555
  async function resolveLongHand(ctx, name) {
3555
3556
  const reverseShorthandsMap = /* @__PURE__ */ new Map();
@@ -3593,8 +3594,8 @@ async function runAsync(action, opts, ...args) {
3593
3594
  return isValidProperty(ctx, ...args);
3594
3595
  case "resolveLongHand":
3595
3596
  return resolveLongHand(ctx, ...args);
3596
- case "resolveShorthand":
3597
- return resolveShorthand(ctx, ...args);
3597
+ case "resolveShorthands":
3598
+ return resolveShorthands(ctx, ...args);
3598
3599
  case "isConfigFile":
3599
3600
  return isConfigFile(opts.currentFile);
3600
3601
  case "isValidFile":
@@ -3532,8 +3532,9 @@ async function isConfigFile(fileName) {
3532
3532
  async function isValidFile(ctx, fileName) {
3533
3533
  return ctx.getFiles().includes(fileName);
3534
3534
  }
3535
- async function resolveShorthand(ctx, name) {
3536
- return ctx.utility.resolveShorthand(name);
3535
+ async function resolveShorthands(ctx, name) {
3536
+ console.log("name", name, ctx.utility.getPropShorthandsMap().get(name));
3537
+ return ctx.utility.getPropShorthandsMap().get(name);
3537
3538
  }
3538
3539
  async function resolveLongHand(ctx, name) {
3539
3540
  const reverseShorthandsMap = /* @__PURE__ */ new Map();
@@ -3577,8 +3578,8 @@ async function runAsync(action, opts, ...args) {
3577
3578
  return isValidProperty(ctx, ...args);
3578
3579
  case "resolveLongHand":
3579
3580
  return resolveLongHand(ctx, ...args);
3580
- case "resolveShorthand":
3581
- return resolveShorthand(ctx, ...args);
3581
+ case "resolveShorthands":
3582
+ return resolveShorthands(ctx, ...args);
3582
3583
  case "isConfigFile":
3583
3584
  return isConfigFile(opts.currentFile);
3584
3585
  case "isValidFile":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",