@pandacss/eslint-plugin 0.0.5 → 0.0.8

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.5";
7960
+ var version = "0.0.8";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -7992,6 +7992,7 @@ var import_utils2 = require("@typescript-eslint/utils");
7992
7992
  var isIdentifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Identifier);
7993
7993
  var isLiteral = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Literal);
7994
7994
  var isTemplateLiteral = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.TemplateLiteral);
7995
+ var isObjectExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ObjectExpression);
7995
7996
  var isMemberExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.MemberExpression);
7996
7997
  var isVariableDeclarator = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.VariableDeclarator);
7997
7998
  var isVariableDeclaration = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.VariableDeclaration);
@@ -8099,17 +8100,14 @@ var isLocalStyledFactory = (node, context) => {
8099
8100
  var isValidFile = (context) => {
8100
8101
  return syncAction("isValidFile", getSyncOpts(context));
8101
8102
  };
8102
- var isValidProperty = (name2, context) => {
8103
- return syncAction("isValidProperty", getSyncOpts(context), name2);
8103
+ var isValidProperty = (name2, context, calleName) => {
8104
+ return syncAction("isValidProperty", getSyncOpts(context), name2, calleName);
8104
8105
  };
8105
8106
  var isPandaImport = (node, context) => {
8106
8107
  const imports = getImports(context);
8107
8108
  return imports.some((imp) => imp.mod === node.source.value);
8108
8109
  };
8109
8110
  var isPandaProp = (node, context) => {
8110
- const prop = node.name.name;
8111
- if (typeof prop !== "string" || !isValidProperty(prop, context))
8112
- return;
8113
8111
  const jsxAncestor = getAncestor(isJSXOpeningElement, node);
8114
8112
  if (!jsxAncestor)
8115
8113
  return;
@@ -8119,33 +8117,46 @@ var isPandaProp = (node, context) => {
8119
8117
  return;
8120
8118
  if (!isPandaIsh(jsxAncestor.name.name, context) && !isLocalStyledFactory(jsxAncestor, context))
8121
8119
  return;
8120
+ const prop = node.name.name;
8121
+ if (typeof prop !== "string" || !isValidProperty(prop, context, jsxAncestor.name.name))
8122
+ return;
8122
8123
  return true;
8123
8124
  };
8124
- var isPandaAttribute = (node, context) => {
8125
+ var isInPandaFunction = (node, context) => {
8125
8126
  const callAncestor = getAncestor(isCallExpression, node);
8126
- if (!callAncestor) {
8127
- const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8128
- const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8129
- if (!jsxExprAncestor || !jsxAttrAncestor)
8130
- return;
8131
- if (!isPandaProp(jsxAttrAncestor, context))
8132
- return;
8133
- if (!isValidStyledProp(jsxAttrAncestor.name, context))
8134
- return;
8135
- return true;
8136
- }
8137
- if (!isIdentifier(node.key))
8138
- return;
8139
- const attr = node.key.name;
8140
- if (!isValidProperty(attr, context))
8127
+ if (!callAncestor)
8141
8128
  return;
8129
+ let calleeName;
8142
8130
  if (isIdentifier(callAncestor.callee)) {
8143
- return isPandaIsh(callAncestor.callee.name, context);
8131
+ calleeName = callAncestor.callee.name;
8144
8132
  }
8145
8133
  if (isMemberExpression(callAncestor.callee) && isIdentifier(callAncestor.callee.object)) {
8146
- return isPandaIsh(callAncestor.callee.object.name, context);
8134
+ calleeName = callAncestor.callee.object.name;
8147
8135
  }
8148
- return;
8136
+ if (!calleeName)
8137
+ return;
8138
+ if (!isPandaIsh(calleeName, context))
8139
+ 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;
8146
+ };
8147
+ var isPandaAttribute = (node, context) => {
8148
+ const callAncestor = getAncestor(isCallExpression, node);
8149
+ if (callAncestor)
8150
+ return isInPandaFunction(node, context);
8151
+ const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8152
+ const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8153
+ if (!jsxExprAncestor || !jsxAttrAncestor)
8154
+ return;
8155
+ if (!isPandaProp(jsxAttrAncestor, context))
8156
+ return;
8157
+ if (!isValidStyledProp(jsxAttrAncestor.name, context))
8158
+ return;
8159
+ return true;
8149
8160
  };
8150
8161
  var resolveLonghand = (name2, context) => {
8151
8162
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
@@ -8230,10 +8241,11 @@ var rule2 = createRule({
8230
8241
  description: "Prohibit the use of config functions outside the Panda config."
8231
8242
  },
8232
8243
  messages: {
8233
- configFunction: "Remove `{{name}}` usage. Config functions should only be used in panda config"
8244
+ configFunction: "Unnecessary`{{name}}` call. \nConfig functions should only be used in panda config.",
8245
+ delete: "Delete `{{name}}` call."
8234
8246
  },
8235
8247
  type: "suggestion",
8236
- fixable: "code",
8248
+ hasSuggestions: true,
8237
8249
  schema: []
8238
8250
  },
8239
8251
  defaultOptions: [],
@@ -8252,16 +8264,24 @@ var rule2 = createRule({
8252
8264
  data: {
8253
8265
  name: node.callee.name
8254
8266
  },
8255
- fix(fixer) {
8256
- const declaration = getAncestor(isVariableDeclaration, node);
8257
- const importSpec = getImportSpecifiers(context).find(
8258
- (s) => isIdentifier(node.callee) && s.specifier.local.name === node.callee.name
8259
- );
8260
- return [
8261
- fixer.remove(declaration ?? node),
8262
- importSpec?.specifier ? fixer.remove(importSpec?.specifier) : {}
8263
- ];
8264
- }
8267
+ suggest: [
8268
+ {
8269
+ messageId: "delete",
8270
+ data: {
8271
+ name: node.callee.name
8272
+ },
8273
+ fix(fixer) {
8274
+ const declaration = getAncestor(isVariableDeclaration, node);
8275
+ const importSpec = getImportSpecifiers(context).find(
8276
+ (s) => isIdentifier(node.callee) && s.specifier.local.name === node.callee.name
8277
+ );
8278
+ return [
8279
+ fixer.remove(declaration ?? node),
8280
+ importSpec?.specifier ? fixer.remove(importSpec?.specifier) : {}
8281
+ ];
8282
+ }
8283
+ }
8284
+ ]
8265
8285
  });
8266
8286
  }
8267
8287
  };
@@ -8295,10 +8315,12 @@ var rule3 = createRule({
8295
8315
  description: "Disallow the inclusion of the debug attribute when shipping code to the production environment."
8296
8316
  },
8297
8317
  messages: {
8298
- debug: "Remove the debug utility."
8318
+ debug: "Unnecessary debug utility.",
8319
+ prop: "Remove the debug prop.",
8320
+ property: "Remove the debug property."
8299
8321
  },
8300
8322
  type: "suggestion",
8301
- fixable: "code",
8323
+ hasSuggestions: true,
8302
8324
  schema: []
8303
8325
  },
8304
8326
  defaultOptions: [],
@@ -8312,7 +8334,12 @@ var rule3 = createRule({
8312
8334
  context.report({
8313
8335
  node,
8314
8336
  messageId: "debug",
8315
- fix: (fixer) => fixer.remove(node)
8337
+ suggest: [
8338
+ {
8339
+ messageId: "prop",
8340
+ fix: (fixer) => fixer.remove(node)
8341
+ }
8342
+ ]
8316
8343
  });
8317
8344
  },
8318
8345
  Property(node) {
@@ -8323,7 +8350,12 @@ var rule3 = createRule({
8323
8350
  context.report({
8324
8351
  node: node.key,
8325
8352
  messageId: "debug",
8326
- fix: (fixer) => fixer.removeRange([node.range[0], node.range[1] + 1])
8353
+ suggest: [
8354
+ {
8355
+ messageId: "property",
8356
+ fix: (fixer) => fixer.removeRange([node.range[0], node.range[1] + 1])
8357
+ }
8358
+ ]
8327
8359
  });
8328
8360
  }
8329
8361
  };
@@ -8338,7 +8370,7 @@ var rule4 = createRule({
8338
8370
  name: RULE_NAME4,
8339
8371
  meta: {
8340
8372
  docs: {
8341
- description: "Ensure user doesn't use dynamic styling at any point. Prefer to use static styles, leverage css variables or recipes for known dynamic styles."
8373
+ description: "Ensure user doesn't use dynamic styling at any point. \nPrefer to use static styles, leverage css variables or recipes for known dynamic styles."
8342
8374
  },
8343
8375
  messages: {
8344
8376
  dynamic: "Remove dynamic value. Prefer static styles"
@@ -8358,6 +8390,8 @@ var rule4 = createRule({
8358
8390
  return;
8359
8391
  if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
8360
8392
  return;
8393
+ if (isObjectExpression(node.value))
8394
+ return;
8361
8395
  if (!isPandaProp(node, context))
8362
8396
  return;
8363
8397
  context.report({
@@ -8372,6 +8406,8 @@ var rule4 = createRule({
8372
8406
  return;
8373
8407
  if (isTemplateLiteral(node.value) && node.value.expressions.length === 0)
8374
8408
  return;
8409
+ if (isObjectExpression(node.value))
8410
+ return;
8375
8411
  if (!isPandaAttribute(node, context))
8376
8412
  return;
8377
8413
  context.report({
@@ -8395,10 +8431,11 @@ var rule5 = createRule({
8395
8431
  description: "Prohibit the use of escape hatch syntax in the code."
8396
8432
  },
8397
8433
  messages: {
8398
- escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. Define a corresponding token in your design system for better consistency and maintainability."
8434
+ escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. \nDefine a corresponding token in your design system for better consistency and maintainability.",
8435
+ remove: "Remove the square brackets (`[]`)."
8399
8436
  },
8400
8437
  type: "suggestion",
8401
- fixable: "code",
8438
+ hasSuggestions: true,
8402
8439
  schema: []
8403
8440
  },
8404
8441
  defaultOptions: [],
@@ -8430,9 +8467,14 @@ var rule5 = createRule({
8430
8467
  return context.report({
8431
8468
  node,
8432
8469
  messageId: "escapeHatch",
8433
- fix: (fixer) => {
8434
- return fixer.replaceTextRange(removeQuotes(node.range), (0, import_shared.getArbitraryValue)(value));
8435
- }
8470
+ suggest: [
8471
+ {
8472
+ messageId: "remove",
8473
+ fix: (fixer) => {
8474
+ return fixer.replaceTextRange(removeQuotes(node.range), (0, import_shared.getArbitraryValue)(value));
8475
+ }
8476
+ }
8477
+ ]
8436
8478
  });
8437
8479
  };
8438
8480
  return {
@@ -8653,7 +8695,7 @@ var rule8 = createRule({
8653
8695
  name: RULE_NAME8,
8654
8696
  meta: {
8655
8697
  docs: {
8656
- description: "Ensure user does not rename a property for a pattern or style prop. It doesn't get tracked."
8698
+ description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
8657
8699
  },
8658
8700
  messages: {
8659
8701
  noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute. Panada will not track this prop."
@@ -8679,7 +8721,7 @@ var rule8 = createRule({
8679
8721
  return;
8680
8722
  if (!isJSXExpressionContainer(node.value))
8681
8723
  return;
8682
- if (!isPandaProp(node.name, context))
8724
+ if (!isPandaProp(node, context))
8683
8725
  return;
8684
8726
  const attr = node.name.name.toString();
8685
8727
  const expression = node.value.expression;
@@ -8721,26 +8763,34 @@ var rule9 = createRule({
8721
8763
  description: "Discourage the use of shorthand properties and promote the preference for longhand CSS properties in the codebase."
8722
8764
  },
8723
8765
  messages: {
8724
- longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`"
8766
+ longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
8767
+ replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8725
8768
  },
8726
8769
  type: "suggestion",
8727
- fixable: "code",
8770
+ hasSuggestions: true,
8728
8771
  schema: []
8729
8772
  },
8730
8773
  defaultOptions: [],
8731
8774
  create(context) {
8732
8775
  const sendReport = (node, name2) => {
8733
8776
  const longhand = resolveLonghand(name2, context);
8777
+ const data = {
8778
+ shorthand: name2,
8779
+ longhand
8780
+ };
8734
8781
  return context.report({
8735
8782
  node,
8736
8783
  messageId: "longhand",
8737
- data: {
8738
- shorthand: name2,
8739
- longhand
8740
- },
8741
- fix: (fixer) => {
8742
- return fixer.replaceTextRange(node.range, longhand);
8743
- }
8784
+ data,
8785
+ suggest: [
8786
+ {
8787
+ messageId: "replace",
8788
+ data,
8789
+ fix: (fixer) => {
8790
+ return fixer.replaceTextRange(node.range, longhand);
8791
+ }
8792
+ }
8793
+ ]
8744
8794
  });
8745
8795
  };
8746
8796
  return {
@@ -8780,10 +8830,11 @@ var rule10 = createRule({
8780
8830
  description: "Prevent users from using the token function in situations where they could simply use the raw design token."
8781
8831
  },
8782
8832
  messages: {
8783
- noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token"
8833
+ noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8834
+ replace: "Replace token function with `{{safe}}`"
8784
8835
  },
8785
8836
  type: "suggestion",
8786
- fixable: "code",
8837
+ hasSuggestions: true,
8787
8838
  schema: []
8788
8839
  },
8789
8840
  defaultOptions: [],
@@ -8833,9 +8884,15 @@ var rule10 = createRule({
8833
8884
  return context.report({
8834
8885
  node,
8835
8886
  messageId: "noUnsafeTokenFnUsage",
8836
- fix: (fixer) => {
8837
- return fixer.replaceTextRange(node.range, `'${token}'`);
8838
- }
8887
+ suggest: [
8888
+ {
8889
+ messageId: "replace",
8890
+ data: { safe: token },
8891
+ fix: (fixer) => {
8892
+ return fixer.replaceTextRange(node.range, `'${token}'`);
8893
+ }
8894
+ }
8895
+ ]
8839
8896
  });
8840
8897
  };
8841
8898
  return {
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.5";
13
+ version = "0.0.8";
14
14
  }
15
15
  });
16
16
 
@@ -7950,7 +7950,7 @@ var require_dist3 = __commonJS({
7950
7950
  // src/utils/nodes.ts
7951
7951
  import { isNodeOfType } from "@typescript-eslint/utils/ast-utils";
7952
7952
  import { AST_NODE_TYPES } from "@typescript-eslint/utils";
7953
- var isIdentifier, isLiteral, isTemplateLiteral, isMemberExpression, isVariableDeclarator, isVariableDeclaration, isJSXMemberExpression, isJSXOpeningElement, isJSXExpressionContainer, isJSXAttribute, isJSXIdentifier, isCallExpression, isImportDeclaration, isImportSpecifier;
7953
+ var isIdentifier, isLiteral, isTemplateLiteral, isObjectExpression, isMemberExpression, isVariableDeclarator, isVariableDeclaration, isJSXMemberExpression, isJSXOpeningElement, isJSXExpressionContainer, isJSXAttribute, isJSXIdentifier, isCallExpression, isImportDeclaration, isImportSpecifier;
7954
7954
  var init_nodes = __esm({
7955
7955
  "src/utils/nodes.ts"() {
7956
7956
  "use strict";
@@ -7958,6 +7958,7 @@ var init_nodes = __esm({
7958
7958
  isIdentifier = isNodeOfType(AST_NODE_TYPES.Identifier);
7959
7959
  isLiteral = isNodeOfType(AST_NODE_TYPES.Literal);
7960
7960
  isTemplateLiteral = isNodeOfType(AST_NODE_TYPES.TemplateLiteral);
7961
+ isObjectExpression = isNodeOfType(AST_NODE_TYPES.ObjectExpression);
7961
7962
  isMemberExpression = isNodeOfType(AST_NODE_TYPES.MemberExpression);
7962
7963
  isVariableDeclarator = isNodeOfType(AST_NODE_TYPES.VariableDeclarator);
7963
7964
  isVariableDeclaration = isNodeOfType(AST_NODE_TYPES.VariableDeclaration);
@@ -7973,7 +7974,7 @@ var init_nodes = __esm({
7973
7974
  });
7974
7975
 
7975
7976
  // src/utils/helpers.ts
7976
- var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, 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, resolveShorthand, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
7977
7978
  var init_helpers = __esm({
7978
7979
  "src/utils/helpers.ts"() {
7979
7980
  "use strict";
@@ -8075,17 +8076,14 @@ var init_helpers = __esm({
8075
8076
  isValidFile = (context) => {
8076
8077
  return syncAction("isValidFile", getSyncOpts(context));
8077
8078
  };
8078
- isValidProperty = (name2, context) => {
8079
- return syncAction("isValidProperty", getSyncOpts(context), name2);
8079
+ isValidProperty = (name2, context, calleName) => {
8080
+ return syncAction("isValidProperty", getSyncOpts(context), name2, calleName);
8080
8081
  };
8081
8082
  isPandaImport = (node, context) => {
8082
8083
  const imports = getImports(context);
8083
8084
  return imports.some((imp) => imp.mod === node.source.value);
8084
8085
  };
8085
8086
  isPandaProp = (node, context) => {
8086
- const prop = node.name.name;
8087
- if (typeof prop !== "string" || !isValidProperty(prop, context))
8088
- return;
8089
8087
  const jsxAncestor = getAncestor(isJSXOpeningElement, node);
8090
8088
  if (!jsxAncestor)
8091
8089
  return;
@@ -8095,33 +8093,46 @@ var init_helpers = __esm({
8095
8093
  return;
8096
8094
  if (!isPandaIsh(jsxAncestor.name.name, context) && !isLocalStyledFactory(jsxAncestor, context))
8097
8095
  return;
8096
+ const prop = node.name.name;
8097
+ if (typeof prop !== "string" || !isValidProperty(prop, context, jsxAncestor.name.name))
8098
+ return;
8098
8099
  return true;
8099
8100
  };
8100
- isPandaAttribute = (node, context) => {
8101
+ isInPandaFunction = (node, context) => {
8101
8102
  const callAncestor = getAncestor(isCallExpression, node);
8102
- if (!callAncestor) {
8103
- const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8104
- const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8105
- if (!jsxExprAncestor || !jsxAttrAncestor)
8106
- return;
8107
- if (!isPandaProp(jsxAttrAncestor, context))
8108
- return;
8109
- if (!isValidStyledProp(jsxAttrAncestor.name, context))
8110
- return;
8111
- return true;
8112
- }
8113
- if (!isIdentifier(node.key))
8114
- return;
8115
- const attr = node.key.name;
8116
- if (!isValidProperty(attr, context))
8103
+ if (!callAncestor)
8117
8104
  return;
8105
+ let calleeName;
8118
8106
  if (isIdentifier(callAncestor.callee)) {
8119
- return isPandaIsh(callAncestor.callee.name, context);
8107
+ calleeName = callAncestor.callee.name;
8120
8108
  }
8121
8109
  if (isMemberExpression(callAncestor.callee) && isIdentifier(callAncestor.callee.object)) {
8122
- return isPandaIsh(callAncestor.callee.object.name, context);
8110
+ calleeName = callAncestor.callee.object.name;
8123
8111
  }
8124
- return;
8112
+ if (!calleeName)
8113
+ return;
8114
+ if (!isPandaIsh(calleeName, context))
8115
+ return;
8116
+ if (!isIdentifier(node.key))
8117
+ return;
8118
+ const attr = node.key.name;
8119
+ if (!isValidProperty(attr, context, calleeName))
8120
+ return;
8121
+ return true;
8122
+ };
8123
+ isPandaAttribute = (node, context) => {
8124
+ const callAncestor = getAncestor(isCallExpression, node);
8125
+ if (callAncestor)
8126
+ return isInPandaFunction(node, context);
8127
+ const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
8128
+ const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
8129
+ if (!jsxExprAncestor || !jsxAttrAncestor)
8130
+ return;
8131
+ if (!isPandaProp(jsxAttrAncestor, context))
8132
+ return;
8133
+ if (!isValidStyledProp(jsxAttrAncestor.name, context))
8134
+ return;
8135
+ return true;
8125
8136
  };
8126
8137
  resolveLonghand = (name2, context) => {
8127
8138
  return syncAction("resolveLongHand", getSyncOpts(context), name2);
@@ -8224,10 +8235,11 @@ var init_no_config_function_in_source = __esm({
8224
8235
  description: "Prohibit the use of config functions outside the Panda config."
8225
8236
  },
8226
8237
  messages: {
8227
- configFunction: "Remove `{{name}}` usage. Config functions should only be used in panda config"
8238
+ configFunction: "Unnecessary`{{name}}` call. \nConfig functions should only be used in panda config.",
8239
+ delete: "Delete `{{name}}` call."
8228
8240
  },
8229
8241
  type: "suggestion",
8230
- fixable: "code",
8242
+ hasSuggestions: true,
8231
8243
  schema: []
8232
8244
  },
8233
8245
  defaultOptions: [],
@@ -8246,16 +8258,24 @@ var init_no_config_function_in_source = __esm({
8246
8258
  data: {
8247
8259
  name: node.callee.name
8248
8260
  },
8249
- fix(fixer) {
8250
- const declaration = getAncestor(isVariableDeclaration, node);
8251
- const importSpec = getImportSpecifiers(context).find(
8252
- (s) => isIdentifier(node.callee) && s.specifier.local.name === node.callee.name
8253
- );
8254
- return [
8255
- fixer.remove(declaration ?? node),
8256
- importSpec?.specifier ? fixer.remove(importSpec?.specifier) : {}
8257
- ];
8258
- }
8261
+ suggest: [
8262
+ {
8263
+ messageId: "delete",
8264
+ data: {
8265
+ name: node.callee.name
8266
+ },
8267
+ fix(fixer) {
8268
+ const declaration = getAncestor(isVariableDeclaration, node);
8269
+ const importSpec = getImportSpecifiers(context).find(
8270
+ (s) => isIdentifier(node.callee) && s.specifier.local.name === node.callee.name
8271
+ );
8272
+ return [
8273
+ fixer.remove(declaration ?? node),
8274
+ importSpec?.specifier ? fixer.remove(importSpec?.specifier) : {}
8275
+ ];
8276
+ }
8277
+ }
8278
+ ]
8259
8279
  });
8260
8280
  }
8261
8281
  };
@@ -8298,10 +8318,12 @@ var init_no_debug = __esm({
8298
8318
  description: "Disallow the inclusion of the debug attribute when shipping code to the production environment."
8299
8319
  },
8300
8320
  messages: {
8301
- debug: "Remove the debug utility."
8321
+ debug: "Unnecessary debug utility.",
8322
+ prop: "Remove the debug prop.",
8323
+ property: "Remove the debug property."
8302
8324
  },
8303
8325
  type: "suggestion",
8304
- fixable: "code",
8326
+ hasSuggestions: true,
8305
8327
  schema: []
8306
8328
  },
8307
8329
  defaultOptions: [],
@@ -8315,7 +8337,12 @@ var init_no_debug = __esm({
8315
8337
  context.report({
8316
8338
  node,
8317
8339
  messageId: "debug",
8318
- fix: (fixer) => fixer.remove(node)
8340
+ suggest: [
8341
+ {
8342
+ messageId: "prop",
8343
+ fix: (fixer) => fixer.remove(node)
8344
+ }
8345
+ ]
8319
8346
  });
8320
8347
  },
8321
8348
  Property(node) {
@@ -8326,7 +8353,12 @@ var init_no_debug = __esm({
8326
8353
  context.report({
8327
8354
  node: node.key,
8328
8355
  messageId: "debug",
8329
- fix: (fixer) => fixer.removeRange([node.range[0], node.range[1] + 1])
8356
+ suggest: [
8357
+ {
8358
+ messageId: "property",
8359
+ fix: (fixer) => fixer.removeRange([node.range[0], node.range[1] + 1])
8360
+ }
8361
+ ]
8330
8362
  });
8331
8363
  }
8332
8364
  };
@@ -8350,7 +8382,7 @@ var init_no_dynamic_styling = __esm({
8350
8382
  name: RULE_NAME4,
8351
8383
  meta: {
8352
8384
  docs: {
8353
- description: "Ensure user doesn't use dynamic styling at any point. Prefer to use static styles, leverage css variables or recipes for known dynamic styles."
8385
+ description: "Ensure user doesn't use dynamic styling at any point. \nPrefer to use static styles, leverage css variables or recipes for known dynamic styles."
8354
8386
  },
8355
8387
  messages: {
8356
8388
  dynamic: "Remove dynamic value. Prefer static styles"
@@ -8370,6 +8402,8 @@ var init_no_dynamic_styling = __esm({
8370
8402
  return;
8371
8403
  if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
8372
8404
  return;
8405
+ if (isObjectExpression(node.value))
8406
+ return;
8373
8407
  if (!isPandaProp(node, context))
8374
8408
  return;
8375
8409
  context.report({
@@ -8384,6 +8418,8 @@ var init_no_dynamic_styling = __esm({
8384
8418
  return;
8385
8419
  if (isTemplateLiteral(node.value) && node.value.expressions.length === 0)
8386
8420
  return;
8421
+ if (isObjectExpression(node.value))
8422
+ return;
8387
8423
  if (!isPandaAttribute(node, context))
8388
8424
  return;
8389
8425
  context.report({
@@ -8416,10 +8452,11 @@ var init_no_escape_hatch = __esm({
8416
8452
  description: "Prohibit the use of escape hatch syntax in the code."
8417
8453
  },
8418
8454
  messages: {
8419
- escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. Define a corresponding token in your design system for better consistency and maintainability."
8455
+ escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. \nDefine a corresponding token in your design system for better consistency and maintainability.",
8456
+ remove: "Remove the square brackets (`[]`)."
8420
8457
  },
8421
8458
  type: "suggestion",
8422
- fixable: "code",
8459
+ hasSuggestions: true,
8423
8460
  schema: []
8424
8461
  },
8425
8462
  defaultOptions: [],
@@ -8451,9 +8488,14 @@ var init_no_escape_hatch = __esm({
8451
8488
  return context.report({
8452
8489
  node,
8453
8490
  messageId: "escapeHatch",
8454
- fix: (fixer) => {
8455
- return fixer.replaceTextRange(removeQuotes(node.range), getArbitraryValue(value));
8456
- }
8491
+ suggest: [
8492
+ {
8493
+ messageId: "remove",
8494
+ fix: (fixer) => {
8495
+ return fixer.replaceTextRange(removeQuotes(node.range), getArbitraryValue(value));
8496
+ }
8497
+ }
8498
+ ]
8457
8499
  });
8458
8500
  };
8459
8501
  return {
@@ -8701,7 +8743,7 @@ var init_no_property_renaming = __esm({
8701
8743
  name: RULE_NAME8,
8702
8744
  meta: {
8703
8745
  docs: {
8704
- description: "Ensure user does not rename a property for a pattern or style prop. It doesn't get tracked."
8746
+ description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
8705
8747
  },
8706
8748
  messages: {
8707
8749
  noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute. Panada will not track this prop."
@@ -8727,7 +8769,7 @@ var init_no_property_renaming = __esm({
8727
8769
  return;
8728
8770
  if (!isJSXExpressionContainer(node.value))
8729
8771
  return;
8730
- if (!isPandaProp(node.name, context))
8772
+ if (!isPandaProp(node, context))
8731
8773
  return;
8732
8774
  const attr = node.name.name.toString();
8733
8775
  const expression = node.value.expression;
@@ -8778,26 +8820,34 @@ var init_no_shorthand_prop = __esm({
8778
8820
  description: "Discourage the use of shorthand properties and promote the preference for longhand CSS properties in the codebase."
8779
8821
  },
8780
8822
  messages: {
8781
- longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`"
8823
+ longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
8824
+ replace: "Replace `{{shorthand}}` with `{{longhand}}`"
8782
8825
  },
8783
8826
  type: "suggestion",
8784
- fixable: "code",
8827
+ hasSuggestions: true,
8785
8828
  schema: []
8786
8829
  },
8787
8830
  defaultOptions: [],
8788
8831
  create(context) {
8789
8832
  const sendReport = (node, name2) => {
8790
8833
  const longhand = resolveLonghand(name2, context);
8834
+ const data = {
8835
+ shorthand: name2,
8836
+ longhand
8837
+ };
8791
8838
  return context.report({
8792
8839
  node,
8793
8840
  messageId: "longhand",
8794
- data: {
8795
- shorthand: name2,
8796
- longhand
8797
- },
8798
- fix: (fixer) => {
8799
- return fixer.replaceTextRange(node.range, longhand);
8800
- }
8841
+ data,
8842
+ suggest: [
8843
+ {
8844
+ messageId: "replace",
8845
+ data,
8846
+ fix: (fixer) => {
8847
+ return fixer.replaceTextRange(node.range, longhand);
8848
+ }
8849
+ }
8850
+ ]
8801
8851
  });
8802
8852
  };
8803
8853
  return {
@@ -8846,10 +8896,11 @@ var init_no_unsafe_token_fn_usage = __esm({
8846
8896
  description: "Prevent users from using the token function in situations where they could simply use the raw design token."
8847
8897
  },
8848
8898
  messages: {
8849
- noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token"
8899
+ noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
8900
+ replace: "Replace token function with `{{safe}}`"
8850
8901
  },
8851
8902
  type: "suggestion",
8852
- fixable: "code",
8903
+ hasSuggestions: true,
8853
8904
  schema: []
8854
8905
  },
8855
8906
  defaultOptions: [],
@@ -8899,9 +8950,15 @@ var init_no_unsafe_token_fn_usage = __esm({
8899
8950
  return context.report({
8900
8951
  node,
8901
8952
  messageId: "noUnsafeTokenFnUsage",
8902
- fix: (fixer) => {
8903
- return fixer.replaceTextRange(node.range, `'${token}'`);
8904
- }
8953
+ suggest: [
8954
+ {
8955
+ messageId: "replace",
8956
+ data: { safe: token },
8957
+ fix: (fixer) => {
8958
+ return fixer.replaceTextRange(node.range, `'${token}'`);
8959
+ }
8960
+ }
8961
+ ]
8905
8962
  });
8906
8963
  };
8907
8964
  return {
@@ -3390,6 +3390,7 @@ var createContext = (userConfig) => {
3390
3390
  var import_ts_path = require("@pandacss/config/ts-path");
3391
3391
  var import_config3 = require("@pandacss/config");
3392
3392
  var import_path = __toESM(require("path"));
3393
+ var import_fs = __toESM(require("fs"));
3393
3394
  var promise;
3394
3395
  var configPath;
3395
3396
  async function _getContext(configPath2) {
@@ -3401,6 +3402,7 @@ async function _getContext(configPath2) {
3401
3402
  }
3402
3403
  async function getContext(opts) {
3403
3404
  if (process.env.NODE_ENV === "test") {
3405
+ configPath = opts.configPath;
3404
3406
  const ctx = createContext({ importMap: "./panda" });
3405
3407
  ctx.getFiles = () => ["App.tsx"];
3406
3408
  return ctx;
@@ -3410,6 +3412,27 @@ async function getContext(opts) {
3410
3412
  return await promise;
3411
3413
  }
3412
3414
  }
3415
+ async function getExtendWarnings() {
3416
+ if (!configPath)
3417
+ return [];
3418
+ const cwd = import_path.default.dirname(configPath);
3419
+ const { config: config2 } = await (0, import_config3.bundleConfig)({ cwd, file: configPath });
3420
+ if (!config2.presets || config2.presets.length === 0)
3421
+ return [];
3422
+ if (config2.eject)
3423
+ return [];
3424
+ const warnings = /* @__PURE__ */ new Set();
3425
+ if (config2.theme && !config2.theme.extend) {
3426
+ warnings.add("theme");
3427
+ }
3428
+ if (config2.conditions && !config2.conditions.extend) {
3429
+ warnings.add("conditions");
3430
+ }
3431
+ if (config2.patterns && !config2.patterns.extend) {
3432
+ warnings.add("patterns");
3433
+ }
3434
+ return Array.from(warnings);
3435
+ }
3413
3436
  async function filterInvalidTokenz(ctx, paths) {
3414
3437
  return paths.filter((path2) => !ctx.utility.tokens.get(path2));
3415
3438
  }
@@ -3422,6 +3445,14 @@ async function isColorAttribute(ctx, _attr) {
3422
3445
  const attrConfig = ctx.utility.config[attr];
3423
3446
  return attrConfig?.values === "colors";
3424
3447
  }
3448
+ var arePathsEqual = (path1, path2) => {
3449
+ const stats1 = import_fs.default.statSync(path1);
3450
+ const stats2 = import_fs.default.statSync(path2);
3451
+ return stats1.dev === stats2.dev && stats1.ino === stats2.ino;
3452
+ };
3453
+ async function isConfigFile(fileName) {
3454
+ return arePathsEqual(configPath, fileName);
3455
+ }
3425
3456
  async function isValidFile(ctx, fileName) {
3426
3457
  return ctx.getFiles().includes(fileName);
3427
3458
  }
@@ -3437,8 +3468,15 @@ async function resolveLongHand(ctx, name) {
3437
3468
  }
3438
3469
  return reverseShorthandsMap.get(name);
3439
3470
  }
3440
- async function isValidProperty(ctx, name) {
3441
- return ctx.isValidProperty(name);
3471
+ async function isValidProperty(ctx, name, patternName) {
3472
+ if (ctx.isValidProperty(name))
3473
+ return true;
3474
+ if (!patternName)
3475
+ return;
3476
+ const pattern = ctx.patterns.details.find((p) => p.baseName === patternName || p.jsx.includes(patternName))?.config.properties;
3477
+ if (!pattern)
3478
+ return;
3479
+ return Object.keys(pattern).includes(name);
3442
3480
  }
3443
3481
  async function matchFile(ctx, name, imports) {
3444
3482
  const file = ctx.imports.file(imports);
@@ -3465,6 +3503,8 @@ async function runAsync(action, opts, ...args) {
3465
3503
  return resolveLongHand(ctx, ...args);
3466
3504
  case "resolveShorthand":
3467
3505
  return resolveShorthand(ctx, ...args);
3506
+ case "isConfigFile":
3507
+ return isConfigFile(opts.currentFile);
3468
3508
  case "isValidFile":
3469
3509
  return isValidFile(ctx, opts.currentFile);
3470
3510
  case "isColorAttribute":
@@ -3473,6 +3513,8 @@ async function runAsync(action, opts, ...args) {
3473
3513
  return isColorToken(ctx, ...args);
3474
3514
  case "filterInvalidTokenz":
3475
3515
  return filterInvalidTokenz(ctx, ...args);
3516
+ case "getExtendWarnings":
3517
+ return getExtendWarnings();
3476
3518
  }
3477
3519
  }
3478
3520
  function run(action, opts, ...args) {
@@ -3372,8 +3372,9 @@ init_esm_shims();
3372
3372
 
3373
3373
  // src/utils/worker.ts
3374
3374
  import { resolveTsPathPattern } from "@pandacss/config/ts-path";
3375
- import { findConfig } from "@pandacss/config";
3375
+ import { findConfig, bundleConfig } from "@pandacss/config";
3376
3376
  import path from "path";
3377
+ import fs from "fs";
3377
3378
  var promise;
3378
3379
  var configPath;
3379
3380
  async function _getContext(configPath2) {
@@ -3385,6 +3386,7 @@ async function _getContext(configPath2) {
3385
3386
  }
3386
3387
  async function getContext(opts) {
3387
3388
  if (process.env.NODE_ENV === "test") {
3389
+ configPath = opts.configPath;
3388
3390
  const ctx = createContext({ importMap: "./panda" });
3389
3391
  ctx.getFiles = () => ["App.tsx"];
3390
3392
  return ctx;
@@ -3394,6 +3396,27 @@ async function getContext(opts) {
3394
3396
  return await promise;
3395
3397
  }
3396
3398
  }
3399
+ async function getExtendWarnings() {
3400
+ if (!configPath)
3401
+ return [];
3402
+ const cwd = path.dirname(configPath);
3403
+ const { config: config2 } = await bundleConfig({ cwd, file: configPath });
3404
+ if (!config2.presets || config2.presets.length === 0)
3405
+ return [];
3406
+ if (config2.eject)
3407
+ return [];
3408
+ const warnings = /* @__PURE__ */ new Set();
3409
+ if (config2.theme && !config2.theme.extend) {
3410
+ warnings.add("theme");
3411
+ }
3412
+ if (config2.conditions && !config2.conditions.extend) {
3413
+ warnings.add("conditions");
3414
+ }
3415
+ if (config2.patterns && !config2.patterns.extend) {
3416
+ warnings.add("patterns");
3417
+ }
3418
+ return Array.from(warnings);
3419
+ }
3397
3420
  async function filterInvalidTokenz(ctx, paths) {
3398
3421
  return paths.filter((path2) => !ctx.utility.tokens.get(path2));
3399
3422
  }
@@ -3406,6 +3429,14 @@ async function isColorAttribute(ctx, _attr) {
3406
3429
  const attrConfig = ctx.utility.config[attr];
3407
3430
  return attrConfig?.values === "colors";
3408
3431
  }
3432
+ var arePathsEqual = (path1, path2) => {
3433
+ const stats1 = fs.statSync(path1);
3434
+ const stats2 = fs.statSync(path2);
3435
+ return stats1.dev === stats2.dev && stats1.ino === stats2.ino;
3436
+ };
3437
+ async function isConfigFile(fileName) {
3438
+ return arePathsEqual(configPath, fileName);
3439
+ }
3409
3440
  async function isValidFile(ctx, fileName) {
3410
3441
  return ctx.getFiles().includes(fileName);
3411
3442
  }
@@ -3421,8 +3452,15 @@ async function resolveLongHand(ctx, name) {
3421
3452
  }
3422
3453
  return reverseShorthandsMap.get(name);
3423
3454
  }
3424
- async function isValidProperty(ctx, name) {
3425
- return ctx.isValidProperty(name);
3455
+ async function isValidProperty(ctx, name, patternName) {
3456
+ if (ctx.isValidProperty(name))
3457
+ return true;
3458
+ if (!patternName)
3459
+ return;
3460
+ const pattern = ctx.patterns.details.find((p) => p.baseName === patternName || p.jsx.includes(patternName))?.config.properties;
3461
+ if (!pattern)
3462
+ return;
3463
+ return Object.keys(pattern).includes(name);
3426
3464
  }
3427
3465
  async function matchFile(ctx, name, imports) {
3428
3466
  const file = ctx.imports.file(imports);
@@ -3449,6 +3487,8 @@ async function runAsync(action, opts, ...args) {
3449
3487
  return resolveLongHand(ctx, ...args);
3450
3488
  case "resolveShorthand":
3451
3489
  return resolveShorthand(ctx, ...args);
3490
+ case "isConfigFile":
3491
+ return isConfigFile(opts.currentFile);
3452
3492
  case "isValidFile":
3453
3493
  return isValidFile(ctx, opts.currentFile);
3454
3494
  case "isColorAttribute":
@@ -3457,6 +3497,8 @@ async function runAsync(action, opts, ...args) {
3457
3497
  return isColorToken(ctx, ...args);
3458
3498
  case "filterInvalidTokenz":
3459
3499
  return filterInvalidTokenz(ctx, ...args);
3500
+ case "getExtendWarnings":
3501
+ return getExtendWarnings();
3460
3502
  }
3461
3503
  }
3462
3504
  function run(action, opts, ...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.0.5",
3
+ "version": "0.0.8",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",
@@ -26,10 +26,10 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@pandacss/config": "^0.28.0",
30
- "@pandacss/generator": "^0.28.0",
31
- "@pandacss/node": "^0.28.0",
32
- "@pandacss/shared": "^0.28.0",
29
+ "@pandacss/config": "^0.29.1",
30
+ "@pandacss/generator": "^0.29.1",
31
+ "@pandacss/node": "^0.29.1",
32
+ "@pandacss/shared": "^0.29.1",
33
33
  "@typescript-eslint/utils": "^6.19.1",
34
34
  "hookable": "^5.5.3",
35
35
  "synckit": "^0.9.0"