@pandacss/eslint-plugin 0.0.0-dev-20240209200922 → 0.0.0-dev-20240210071834

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 +119 -64
  2. package/dist/index.mjs +135 -70
  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.0-dev-20240209200922";
7960
+ var version = "0.0.0-dev-20240210071834";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -8123,6 +8123,17 @@ var isPandaProp = (node, context) => {
8123
8123
  return;
8124
8124
  return true;
8125
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
+ };
8126
8137
  var isInPandaFunction = (node, context) => {
8127
8138
  const callAncestor = getAncestor(isCallExpression, node);
8128
8139
  if (!callAncestor)
@@ -8138,17 +8149,9 @@ var isInPandaFunction = (node, context) => {
8138
8149
  return;
8139
8150
  if (!isPandaIsh(calleeName, context))
8140
8151
  return;
8141
- if (!isIdentifier(node.key))
8142
- return;
8143
- const attr = node.key.name;
8144
- if (!isValidProperty(attr, context, calleeName))
8145
- return;
8146
- return true;
8152
+ return calleeName;
8147
8153
  };
8148
- var isPandaAttribute = (node, context) => {
8149
- const callAncestor = getAncestor(isCallExpression, node);
8150
- if (callAncestor)
8151
- return isInPandaFunction(node, context);
8154
+ var isInJSXProp = (node, context) => {
8152
8155
  const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8153
8156
  const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8154
8157
  if (!jsxExprAncestor || !jsxAttrAncestor)
@@ -8159,6 +8162,16 @@ var isPandaAttribute = (node, context) => {
8159
8162
  return;
8160
8163
  return true;
8161
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
+ };
8162
8175
  var resolveLonghand = (name2, context) => {
8163
8176
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
8164
8177
  };
@@ -8583,6 +8596,7 @@ var no_hardcoded_color_default = rule6;
8583
8596
 
8584
8597
  // src/rules/no-important.ts
8585
8598
  init_cjs_shims();
8599
+ var import_shared2 = require("@pandacss/shared");
8586
8600
  var exclamationRegex = /\s*!$/;
8587
8601
  var importantRegex = /\s*!important\s*$/;
8588
8602
  var RULE_NAME7 = "no-important";
@@ -8603,9 +8617,10 @@ var rule7 = createRule({
8603
8617
  defaultOptions: [],
8604
8618
  create(context) {
8605
8619
  const removeQuotes = ([start, end]) => [start + 1, end - 1];
8606
- const hasImportantKeyword = (value) => {
8607
- if (!value)
8620
+ const hasImportantKeyword = (_value) => {
8621
+ if (!_value)
8608
8622
  return false;
8623
+ const value = (0, import_shared2.getArbitraryValue)(_value);
8609
8624
  return exclamationRegex.test(value) || importantRegex.test(value);
8610
8625
  };
8611
8626
  const removeImportantKeyword = (input) => {
@@ -8677,13 +8692,50 @@ var rule7 = createRule({
8677
8692
  });
8678
8693
  var no_important_default = rule7;
8679
8694
 
8680
- // src/rules/no-invalid-token-paths.ts
8695
+ // src/rules/no-invalid-nesting.ts
8681
8696
  init_cjs_shims();
8682
- var import_utils11 = require("@typescript-eslint/utils");
8683
- var import_ast_utils2 = require("@typescript-eslint/utils/ast-utils");
8684
- var RULE_NAME8 = "no-invalid-token-paths";
8697
+ var RULE_NAME8 = "no-invalid-nesting";
8685
8698
  var rule8 = createRule({
8686
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,
8687
8739
  meta: {
8688
8740
  docs: {
8689
8741
  description: "Disallow the use of invalid token paths within token function syntax."
@@ -8736,7 +8788,7 @@ var rule8 = createRule({
8736
8788
  Property(node) {
8737
8789
  if (!isIdentifier(node.key))
8738
8790
  return;
8739
- if (!(0, import_ast_utils2.isNodeOfTypes)([import_utils11.AST_NODE_TYPES.Literal, import_utils11.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))
8740
8792
  return;
8741
8793
  if (!isPandaAttribute(node, context))
8742
8794
  return;
@@ -8783,13 +8835,13 @@ var rule8 = createRule({
8783
8835
  };
8784
8836
  }
8785
8837
  });
8786
- var no_invalid_token_paths_default = rule8;
8838
+ var no_invalid_token_paths_default = rule9;
8787
8839
 
8788
8840
  // src/rules/no-property-renaming.ts
8789
8841
  init_cjs_shims();
8790
- var RULE_NAME9 = "no-property-renaming";
8791
- var rule9 = createRule({
8792
- name: RULE_NAME9,
8842
+ var RULE_NAME10 = "no-property-renaming";
8843
+ var rule10 = createRule({
8844
+ name: RULE_NAME10,
8793
8845
  meta: {
8794
8846
  docs: {
8795
8847
  description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
@@ -8848,14 +8900,15 @@ var rule9 = createRule({
8848
8900
  };
8849
8901
  }
8850
8902
  });
8851
- var no_property_renaming_default = rule9;
8903
+ var no_property_renaming_default = rule10;
8852
8904
 
8853
8905
  // src/rules/no-unsafe-token-fn-usage.ts
8854
8906
  init_cjs_shims();
8855
- var import_utils14 = require("@typescript-eslint/utils");
8856
- var RULE_NAME10 = "no-unsafe-token-fn-usage";
8857
- var rule10 = createRule({
8858
- name: RULE_NAME10,
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,
8859
8912
  meta: {
8860
8913
  docs: {
8861
8914
  description: "Prevent users from using the token function in situations where they could simply use the raw design token."
@@ -8882,10 +8935,10 @@ var rule10 = createRule({
8882
8935
  return;
8883
8936
  const value = node.arguments[0];
8884
8937
  if (isLiteral(value)) {
8885
- sendReport(node, tokenWrap(value.value?.toString()));
8938
+ sendReport(node, tokenWrap((0, import_shared3.getArbitraryValue)(value.value?.toString() ?? "")));
8886
8939
  }
8887
8940
  if (isTemplateLiteral(value)) {
8888
- sendReport(node, tokenWrap(value.quasis[0].value.raw));
8941
+ sendReport(node, tokenWrap((0, import_shared3.getArbitraryValue)(value.quasis[0].value.raw)));
8889
8942
  }
8890
8943
  };
8891
8944
  const isCompositeValue = (input) => {
@@ -8897,19 +8950,19 @@ var rule10 = createRule({
8897
8950
  const handleLiteral = (node) => {
8898
8951
  if (!isLiteral(node))
8899
8952
  return;
8900
- if (isCompositeValue(node.value?.toString()))
8953
+ const value = (0, import_shared3.getArbitraryValue)(node.value?.toString() ?? "");
8954
+ if (isCompositeValue(value))
8901
8955
  return;
8902
- sendReport(node);
8956
+ sendReport(node, value);
8903
8957
  };
8904
8958
  const handleTemplateLiteral = (node) => {
8905
8959
  if (!isTemplateLiteral(node))
8906
8960
  return;
8907
8961
  if (node.expressions.length > 0)
8908
8962
  return;
8909
- sendReport(node, node.quasis[0].value.raw);
8963
+ sendReport(node, (0, import_shared3.getArbitraryValue)(node.quasis[0].value.raw));
8910
8964
  };
8911
- const sendReport = (node, _value) => {
8912
- const value = _value ?? node.value?.toString();
8965
+ const sendReport = (node, value) => {
8913
8966
  const tkImports = extractTokens(value);
8914
8967
  const token = tkImports[0].replace(/^[^.]*\./, "");
8915
8968
  return context.report({
@@ -8951,13 +9004,13 @@ var rule10 = createRule({
8951
9004
  };
8952
9005
  }
8953
9006
  });
8954
- var no_unsafe_token_fn_usage_default = rule10;
9007
+ var no_unsafe_token_fn_usage_default = rule11;
8955
9008
 
8956
9009
  // src/rules/prefer-longhand-properties.ts
8957
9010
  init_cjs_shims();
8958
- var RULE_NAME11 = "prefer-longhand-properties";
8959
- var rule11 = createRule({
8960
- name: RULE_NAME11,
9011
+ var RULE_NAME12 = "prefer-longhand-properties";
9012
+ var rule12 = createRule({
9013
+ name: RULE_NAME12,
8961
9014
  meta: {
8962
9015
  docs: {
8963
9016
  description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
@@ -9017,13 +9070,13 @@ var rule11 = createRule({
9017
9070
  };
9018
9071
  }
9019
9072
  });
9020
- var prefer_longhand_properties_default = rule11;
9073
+ var prefer_longhand_properties_default = rule12;
9021
9074
 
9022
9075
  // src/rules/prefer-shorthand-properties.ts
9023
9076
  init_cjs_shims();
9024
- var RULE_NAME12 = "prefer-shorthand-properties";
9025
- var rule12 = createRule({
9026
- name: RULE_NAME12,
9077
+ var RULE_NAME13 = "prefer-shorthand-properties";
9078
+ var rule13 = createRule({
9079
+ name: RULE_NAME13,
9027
9080
  meta: {
9028
9081
  docs: {
9029
9082
  description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
@@ -9086,7 +9139,7 @@ var rule12 = createRule({
9086
9139
  };
9087
9140
  }
9088
9141
  });
9089
- var prefer_shorthand_properties_default = rule12;
9142
+ var prefer_shorthand_properties_default = rule13;
9090
9143
 
9091
9144
  // src/rules/prefer-atomic-properties.ts
9092
9145
  init_cjs_shims();
@@ -9206,9 +9259,9 @@ var compositeProperties = {
9206
9259
  };
9207
9260
 
9208
9261
  // src/rules/prefer-atomic-properties.ts
9209
- var RULE_NAME13 = "prefer-atomic-properties";
9210
- var rule13 = createRule({
9211
- name: RULE_NAME13,
9262
+ var RULE_NAME14 = "prefer-atomic-properties";
9263
+ var rule14 = createRule({
9264
+ name: RULE_NAME14,
9212
9265
  meta: {
9213
9266
  docs: {
9214
9267
  description: "Encourage the use of atomic properties instead of composite properties in the codebase."
@@ -9264,13 +9317,13 @@ var rule13 = createRule({
9264
9317
  };
9265
9318
  }
9266
9319
  });
9267
- var prefer_atomic_properties_default = rule13;
9320
+ var prefer_atomic_properties_default = rule14;
9268
9321
 
9269
9322
  // src/rules/prefer-composite-properties.ts
9270
9323
  init_cjs_shims();
9271
- var RULE_NAME14 = "prefer-composite-properties";
9272
- var rule14 = createRule({
9273
- name: RULE_NAME14,
9324
+ var RULE_NAME15 = "prefer-composite-properties";
9325
+ var rule15 = createRule({
9326
+ name: RULE_NAME15,
9274
9327
  meta: {
9275
9328
  docs: {
9276
9329
  description: "Encourage the use of composite properties instead of atomic properties in the codebase."
@@ -9324,13 +9377,13 @@ var rule14 = createRule({
9324
9377
  };
9325
9378
  }
9326
9379
  });
9327
- var prefer_composite_properties_default = rule14;
9380
+ var prefer_composite_properties_default = rule15;
9328
9381
 
9329
9382
  // src/rules/prefer-unified-property-style.ts
9330
9383
  init_cjs_shims();
9331
- var RULE_NAME15 = "prefer-unified-property-style";
9332
- var rule15 = createRule({
9333
- name: RULE_NAME15,
9384
+ var RULE_NAME16 = "prefer-unified-property-style";
9385
+ var rule16 = createRule({
9386
+ name: RULE_NAME16,
9334
9387
  meta: {
9335
9388
  docs: {
9336
9389
  description: "Discourage against mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results"
@@ -9397,7 +9450,7 @@ var rule15 = createRule({
9397
9450
  };
9398
9451
  }
9399
9452
  });
9400
- var prefer_unified_property_style_default = rule15;
9453
+ var prefer_unified_property_style_default = rule16;
9401
9454
 
9402
9455
  // src/rules/index.ts
9403
9456
  var rules = {
@@ -9408,18 +9461,19 @@ var rules = {
9408
9461
  [RULE_NAME5]: no_escape_hatch_default,
9409
9462
  [RULE_NAME6]: no_hardcoded_color_default,
9410
9463
  [RULE_NAME7]: no_important_default,
9411
- [RULE_NAME8]: no_invalid_token_paths_default,
9412
- [RULE_NAME9]: no_property_renaming_default,
9413
- [RULE_NAME10]: no_unsafe_token_fn_usage_default,
9414
- [RULE_NAME11]: prefer_longhand_properties_default,
9415
- [RULE_NAME12]: prefer_shorthand_properties_default,
9416
- [RULE_NAME13]: prefer_atomic_properties_default,
9417
- [RULE_NAME14]: prefer_composite_properties_default,
9418
- [RULE_NAME15]: prefer_unified_property_style_default
9464
+ [RULE_NAME9]: no_invalid_token_paths_default,
9465
+ [RULE_NAME8]: no_invalid_nesting_default,
9466
+ [RULE_NAME10]: no_property_renaming_default,
9467
+ [RULE_NAME11]: no_unsafe_token_fn_usage_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
9419
9473
  };
9420
9474
 
9421
9475
  // src/configs/all.ts
9422
- var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME8];
9476
+ var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME9];
9423
9477
  var allRules = Object.fromEntries(
9424
9478
  Object.entries(rules).map(([name2]) => {
9425
9479
  return [`@pandacss/${name2}`, errorRules.includes(name2) ? "error" : "warn"];
@@ -9443,6 +9497,7 @@ var recommended_default = {
9443
9497
  "@pandacss/no-config-function-in-source": "error",
9444
9498
  "@pandacss/no-debug": "warn",
9445
9499
  "@pandacss/no-dynamic-styling": "warn",
9500
+ "@pandacss/no-invalid-nesting": "error",
9446
9501
  "@pandacss/no-invalid-token-paths": "error",
9447
9502
  "@pandacss/no-property-renaming": "warn",
9448
9503
  "@pandacss/prefer-unified-property-style": "warn"
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.0-dev-20240209200922";
13
+ version = "0.0.0-dev-20240210071834";
14
14
  }
15
15
  });
16
16
 
@@ -7975,7 +7975,7 @@ var init_nodes = __esm({
7975
7975
  });
7976
7976
 
7977
7977
  // src/utils/helpers.ts
7978
- 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;
7979
7979
  var init_helpers = __esm({
7980
7980
  "src/utils/helpers.ts"() {
7981
7981
  "use strict";
@@ -8099,6 +8099,17 @@ var init_helpers = __esm({
8099
8099
  return;
8100
8100
  return true;
8101
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
+ };
8102
8113
  isInPandaFunction = (node, context) => {
8103
8114
  const callAncestor = getAncestor(isCallExpression, node);
8104
8115
  if (!callAncestor)
@@ -8114,17 +8125,9 @@ var init_helpers = __esm({
8114
8125
  return;
8115
8126
  if (!isPandaIsh(calleeName, context))
8116
8127
  return;
8117
- if (!isIdentifier(node.key))
8118
- return;
8119
- const attr = node.key.name;
8120
- if (!isValidProperty(attr, context, calleeName))
8121
- return;
8122
- return true;
8128
+ return calleeName;
8123
8129
  };
8124
- isPandaAttribute = (node, context) => {
8125
- const callAncestor = getAncestor(isCallExpression, node);
8126
- if (callAncestor)
8127
- return isInPandaFunction(node, context);
8130
+ isInJSXProp = (node, context) => {
8128
8131
  const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8129
8132
  const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8130
8133
  if (!jsxExprAncestor || !jsxAttrAncestor)
@@ -8135,6 +8138,16 @@ var init_helpers = __esm({
8135
8138
  return;
8136
8139
  return true;
8137
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
+ };
8138
8151
  resolveLonghand = (name2, context) => {
8139
8152
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
8140
8153
  };
@@ -8614,6 +8627,7 @@ var init_no_hardcoded_color = __esm({
8614
8627
  });
8615
8628
 
8616
8629
  // src/rules/no-important.ts
8630
+ import { getArbitraryValue as getArbitraryValue2 } from "@pandacss/shared";
8617
8631
  var exclamationRegex, importantRegex, RULE_NAME7, rule7, no_important_default;
8618
8632
  var init_no_important = __esm({
8619
8633
  "src/rules/no-important.ts"() {
@@ -8642,9 +8656,10 @@ var init_no_important = __esm({
8642
8656
  defaultOptions: [],
8643
8657
  create(context) {
8644
8658
  const removeQuotes = ([start, end]) => [start + 1, end - 1];
8645
- const hasImportantKeyword = (value) => {
8646
- if (!value)
8659
+ const hasImportantKeyword = (_value) => {
8660
+ if (!_value)
8647
8661
  return false;
8662
+ const value = getArbitraryValue2(_value);
8648
8663
  return exclamationRegex.test(value) || importantRegex.test(value);
8649
8664
  };
8650
8665
  const removeImportantKeyword = (input) => {
@@ -8718,10 +8733,56 @@ var init_no_important = __esm({
8718
8733
  }
8719
8734
  });
8720
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
+
8721
8782
  // src/rules/no-invalid-token-paths.ts
8722
8783
  import { AST_NODE_TYPES as AST_NODE_TYPES2 } from "@typescript-eslint/utils";
8723
8784
  import { isNodeOfTypes } from "@typescript-eslint/utils/ast-utils";
8724
- var RULE_NAME8, rule8, no_invalid_token_paths_default;
8785
+ var RULE_NAME9, rule9, no_invalid_token_paths_default;
8725
8786
  var init_no_invalid_token_paths = __esm({
8726
8787
  "src/rules/no-invalid-token-paths.ts"() {
8727
8788
  "use strict";
@@ -8729,9 +8790,9 @@ var init_no_invalid_token_paths = __esm({
8729
8790
  init_helpers();
8730
8791
  init_utils();
8731
8792
  init_nodes();
8732
- RULE_NAME8 = "no-invalid-token-paths";
8733
- rule8 = createRule({
8734
- name: RULE_NAME8,
8793
+ RULE_NAME9 = "no-invalid-token-paths";
8794
+ rule9 = createRule({
8795
+ name: RULE_NAME9,
8735
8796
  meta: {
8736
8797
  docs: {
8737
8798
  description: "Disallow the use of invalid token paths within token function syntax."
@@ -8831,12 +8892,12 @@ var init_no_invalid_token_paths = __esm({
8831
8892
  };
8832
8893
  }
8833
8894
  });
8834
- no_invalid_token_paths_default = rule8;
8895
+ no_invalid_token_paths_default = rule9;
8835
8896
  }
8836
8897
  });
8837
8898
 
8838
8899
  // src/rules/no-property-renaming.ts
8839
- var RULE_NAME9, rule9, no_property_renaming_default;
8900
+ var RULE_NAME10, rule10, no_property_renaming_default;
8840
8901
  var init_no_property_renaming = __esm({
8841
8902
  "src/rules/no-property-renaming.ts"() {
8842
8903
  "use strict";
@@ -8844,9 +8905,9 @@ var init_no_property_renaming = __esm({
8844
8905
  init_utils();
8845
8906
  init_helpers();
8846
8907
  init_nodes();
8847
- RULE_NAME9 = "no-property-renaming";
8848
- rule9 = createRule({
8849
- name: RULE_NAME9,
8908
+ RULE_NAME10 = "no-property-renaming";
8909
+ rule10 = createRule({
8910
+ name: RULE_NAME10,
8850
8911
  meta: {
8851
8912
  docs: {
8852
8913
  description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
@@ -8905,13 +8966,14 @@ var init_no_property_renaming = __esm({
8905
8966
  };
8906
8967
  }
8907
8968
  });
8908
- no_property_renaming_default = rule9;
8969
+ no_property_renaming_default = rule10;
8909
8970
  }
8910
8971
  });
8911
8972
 
8912
8973
  // src/rules/no-unsafe-token-fn-usage.ts
8913
8974
  import "@typescript-eslint/utils";
8914
- var RULE_NAME10, rule10, no_unsafe_token_fn_usage_default;
8975
+ import { getArbitraryValue as getArbitraryValue3 } from "@pandacss/shared";
8976
+ var RULE_NAME11, rule11, no_unsafe_token_fn_usage_default;
8915
8977
  var init_no_unsafe_token_fn_usage = __esm({
8916
8978
  "src/rules/no-unsafe-token-fn-usage.ts"() {
8917
8979
  "use strict";
@@ -8919,9 +8981,9 @@ var init_no_unsafe_token_fn_usage = __esm({
8919
8981
  init_helpers();
8920
8982
  init_utils();
8921
8983
  init_nodes();
8922
- RULE_NAME10 = "no-unsafe-token-fn-usage";
8923
- rule10 = createRule({
8924
- name: RULE_NAME10,
8984
+ RULE_NAME11 = "no-unsafe-token-fn-usage";
8985
+ rule11 = createRule({
8986
+ name: RULE_NAME11,
8925
8987
  meta: {
8926
8988
  docs: {
8927
8989
  description: "Prevent users from using the token function in situations where they could simply use the raw design token."
@@ -8948,10 +9010,10 @@ var init_no_unsafe_token_fn_usage = __esm({
8948
9010
  return;
8949
9011
  const value = node.arguments[0];
8950
9012
  if (isLiteral(value)) {
8951
- sendReport(node, tokenWrap(value.value?.toString()));
9013
+ sendReport(node, tokenWrap(getArbitraryValue3(value.value?.toString() ?? "")));
8952
9014
  }
8953
9015
  if (isTemplateLiteral(value)) {
8954
- sendReport(node, tokenWrap(value.quasis[0].value.raw));
9016
+ sendReport(node, tokenWrap(getArbitraryValue3(value.quasis[0].value.raw)));
8955
9017
  }
8956
9018
  };
8957
9019
  const isCompositeValue = (input) => {
@@ -8963,19 +9025,19 @@ var init_no_unsafe_token_fn_usage = __esm({
8963
9025
  const handleLiteral = (node) => {
8964
9026
  if (!isLiteral(node))
8965
9027
  return;
8966
- if (isCompositeValue(node.value?.toString()))
9028
+ const value = getArbitraryValue3(node.value?.toString() ?? "");
9029
+ if (isCompositeValue(value))
8967
9030
  return;
8968
- sendReport(node);
9031
+ sendReport(node, value);
8969
9032
  };
8970
9033
  const handleTemplateLiteral = (node) => {
8971
9034
  if (!isTemplateLiteral(node))
8972
9035
  return;
8973
9036
  if (node.expressions.length > 0)
8974
9037
  return;
8975
- sendReport(node, node.quasis[0].value.raw);
9038
+ sendReport(node, getArbitraryValue3(node.quasis[0].value.raw));
8976
9039
  };
8977
- const sendReport = (node, _value) => {
8978
- const value = _value ?? node.value?.toString();
9040
+ const sendReport = (node, value) => {
8979
9041
  const tkImports = extractTokens(value);
8980
9042
  const token = tkImports[0].replace(/^[^.]*\./, "");
8981
9043
  return context.report({
@@ -9017,12 +9079,12 @@ var init_no_unsafe_token_fn_usage = __esm({
9017
9079
  };
9018
9080
  }
9019
9081
  });
9020
- no_unsafe_token_fn_usage_default = rule10;
9082
+ no_unsafe_token_fn_usage_default = rule11;
9021
9083
  }
9022
9084
  });
9023
9085
 
9024
9086
  // src/rules/prefer-longhand-properties.ts
9025
- var RULE_NAME11, rule11, prefer_longhand_properties_default;
9087
+ var RULE_NAME12, rule12, prefer_longhand_properties_default;
9026
9088
  var init_prefer_longhand_properties = __esm({
9027
9089
  "src/rules/prefer-longhand-properties.ts"() {
9028
9090
  "use strict";
@@ -9030,9 +9092,9 @@ var init_prefer_longhand_properties = __esm({
9030
9092
  init_helpers();
9031
9093
  init_utils();
9032
9094
  init_nodes();
9033
- RULE_NAME11 = "prefer-longhand-properties";
9034
- rule11 = createRule({
9035
- name: RULE_NAME11,
9095
+ RULE_NAME12 = "prefer-longhand-properties";
9096
+ rule12 = createRule({
9097
+ name: RULE_NAME12,
9036
9098
  meta: {
9037
9099
  docs: {
9038
9100
  description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
@@ -9092,12 +9154,12 @@ var init_prefer_longhand_properties = __esm({
9092
9154
  };
9093
9155
  }
9094
9156
  });
9095
- prefer_longhand_properties_default = rule11;
9157
+ prefer_longhand_properties_default = rule12;
9096
9158
  }
9097
9159
  });
9098
9160
 
9099
9161
  // src/rules/prefer-shorthand-properties.ts
9100
- var RULE_NAME12, rule12, prefer_shorthand_properties_default;
9162
+ var RULE_NAME13, rule13, prefer_shorthand_properties_default;
9101
9163
  var init_prefer_shorthand_properties = __esm({
9102
9164
  "src/rules/prefer-shorthand-properties.ts"() {
9103
9165
  "use strict";
@@ -9105,9 +9167,9 @@ var init_prefer_shorthand_properties = __esm({
9105
9167
  init_helpers();
9106
9168
  init_utils();
9107
9169
  init_nodes();
9108
- RULE_NAME12 = "prefer-shorthand-properties";
9109
- rule12 = createRule({
9110
- name: RULE_NAME12,
9170
+ RULE_NAME13 = "prefer-shorthand-properties";
9171
+ rule13 = createRule({
9172
+ name: RULE_NAME13,
9111
9173
  meta: {
9112
9174
  docs: {
9113
9175
  description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
@@ -9170,7 +9232,7 @@ var init_prefer_shorthand_properties = __esm({
9170
9232
  };
9171
9233
  }
9172
9234
  });
9173
- prefer_shorthand_properties_default = rule12;
9235
+ prefer_shorthand_properties_default = rule13;
9174
9236
  }
9175
9237
  });
9176
9238
 
@@ -9295,7 +9357,7 @@ var init_composite_properties = __esm({
9295
9357
  });
9296
9358
 
9297
9359
  // src/rules/prefer-atomic-properties.ts
9298
- var RULE_NAME13, rule13, prefer_atomic_properties_default;
9360
+ var RULE_NAME14, rule14, prefer_atomic_properties_default;
9299
9361
  var init_prefer_atomic_properties = __esm({
9300
9362
  "src/rules/prefer-atomic-properties.ts"() {
9301
9363
  "use strict";
@@ -9304,9 +9366,9 @@ var init_prefer_atomic_properties = __esm({
9304
9366
  init_utils();
9305
9367
  init_composite_properties();
9306
9368
  init_nodes();
9307
- RULE_NAME13 = "prefer-atomic-properties";
9308
- rule13 = createRule({
9309
- name: RULE_NAME13,
9369
+ RULE_NAME14 = "prefer-atomic-properties";
9370
+ rule14 = createRule({
9371
+ name: RULE_NAME14,
9310
9372
  meta: {
9311
9373
  docs: {
9312
9374
  description: "Encourage the use of atomic properties instead of composite properties in the codebase."
@@ -9362,12 +9424,12 @@ var init_prefer_atomic_properties = __esm({
9362
9424
  };
9363
9425
  }
9364
9426
  });
9365
- prefer_atomic_properties_default = rule13;
9427
+ prefer_atomic_properties_default = rule14;
9366
9428
  }
9367
9429
  });
9368
9430
 
9369
9431
  // src/rules/prefer-composite-properties.ts
9370
- var RULE_NAME14, rule14, prefer_composite_properties_default;
9432
+ var RULE_NAME15, rule15, prefer_composite_properties_default;
9371
9433
  var init_prefer_composite_properties = __esm({
9372
9434
  "src/rules/prefer-composite-properties.ts"() {
9373
9435
  "use strict";
@@ -9376,9 +9438,9 @@ var init_prefer_composite_properties = __esm({
9376
9438
  init_utils();
9377
9439
  init_composite_properties();
9378
9440
  init_nodes();
9379
- RULE_NAME14 = "prefer-composite-properties";
9380
- rule14 = createRule({
9381
- name: RULE_NAME14,
9441
+ RULE_NAME15 = "prefer-composite-properties";
9442
+ rule15 = createRule({
9443
+ name: RULE_NAME15,
9382
9444
  meta: {
9383
9445
  docs: {
9384
9446
  description: "Encourage the use of composite properties instead of atomic properties in the codebase."
@@ -9432,12 +9494,12 @@ var init_prefer_composite_properties = __esm({
9432
9494
  };
9433
9495
  }
9434
9496
  });
9435
- prefer_composite_properties_default = rule14;
9497
+ prefer_composite_properties_default = rule15;
9436
9498
  }
9437
9499
  });
9438
9500
 
9439
9501
  // src/rules/prefer-unified-property-style.ts
9440
- var RULE_NAME15, rule15, prefer_unified_property_style_default;
9502
+ var RULE_NAME16, rule16, prefer_unified_property_style_default;
9441
9503
  var init_prefer_unified_property_style = __esm({
9442
9504
  "src/rules/prefer-unified-property-style.ts"() {
9443
9505
  "use strict";
@@ -9446,9 +9508,9 @@ var init_prefer_unified_property_style = __esm({
9446
9508
  init_utils();
9447
9509
  init_composite_properties();
9448
9510
  init_nodes();
9449
- RULE_NAME15 = "prefer-unified-property-style";
9450
- rule15 = createRule({
9451
- name: RULE_NAME15,
9511
+ RULE_NAME16 = "prefer-unified-property-style";
9512
+ rule16 = createRule({
9513
+ name: RULE_NAME16,
9452
9514
  meta: {
9453
9515
  docs: {
9454
9516
  description: "Discourage against mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results"
@@ -9515,7 +9577,7 @@ var init_prefer_unified_property_style = __esm({
9515
9577
  };
9516
9578
  }
9517
9579
  });
9518
- prefer_unified_property_style_default = rule15;
9580
+ prefer_unified_property_style_default = rule16;
9519
9581
  }
9520
9582
  });
9521
9583
 
@@ -9532,6 +9594,7 @@ var init_rules = __esm({
9532
9594
  init_no_escape_hatch();
9533
9595
  init_no_hardcoded_color();
9534
9596
  init_no_important();
9597
+ init_no_invalid_nesting();
9535
9598
  init_no_invalid_token_paths();
9536
9599
  init_no_property_renaming();
9537
9600
  init_no_unsafe_token_fn_usage();
@@ -9548,14 +9611,15 @@ var init_rules = __esm({
9548
9611
  [RULE_NAME5]: no_escape_hatch_default,
9549
9612
  [RULE_NAME6]: no_hardcoded_color_default,
9550
9613
  [RULE_NAME7]: no_important_default,
9551
- [RULE_NAME8]: no_invalid_token_paths_default,
9552
- [RULE_NAME9]: no_property_renaming_default,
9553
- [RULE_NAME10]: no_unsafe_token_fn_usage_default,
9554
- [RULE_NAME11]: prefer_longhand_properties_default,
9555
- [RULE_NAME12]: prefer_shorthand_properties_default,
9556
- [RULE_NAME13]: prefer_atomic_properties_default,
9557
- [RULE_NAME14]: prefer_composite_properties_default,
9558
- [RULE_NAME15]: prefer_unified_property_style_default
9614
+ [RULE_NAME9]: no_invalid_token_paths_default,
9615
+ [RULE_NAME8]: no_invalid_nesting_default,
9616
+ [RULE_NAME10]: no_property_renaming_default,
9617
+ [RULE_NAME11]: no_unsafe_token_fn_usage_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
9559
9623
  };
9560
9624
  }
9561
9625
  });
@@ -9570,7 +9634,7 @@ var init_all = __esm({
9570
9634
  init_file_not_included();
9571
9635
  init_no_config_function_in_source();
9572
9636
  init_no_invalid_token_paths();
9573
- errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME8];
9637
+ errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME9];
9574
9638
  allRules = Object.fromEntries(
9575
9639
  Object.entries(rules).map(([name2]) => {
9576
9640
  return [`@pandacss/${name2}`, errorRules.includes(name2) ? "error" : "warn"];
@@ -9600,6 +9664,7 @@ var init_recommended = __esm({
9600
9664
  "@pandacss/no-config-function-in-source": "error",
9601
9665
  "@pandacss/no-debug": "warn",
9602
9666
  "@pandacss/no-dynamic-styling": "warn",
9667
+ "@pandacss/no-invalid-nesting": "error",
9603
9668
  "@pandacss/no-invalid-token-paths": "error",
9604
9669
  "@pandacss/no-property-renaming": "warn",
9605
9670
  "@pandacss/prefer-unified-property-style": "warn"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.0.0-dev-20240209200922",
3
+ "version": "0.0.0-dev-20240210071834",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",