@pandacss/eslint-plugin 0.1.2 → 0.1.3

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.1.2";
7960
+ var version = "0.1.3";
7961
7961
 
7962
7962
  // src/configs/all.ts
7963
7963
  init_cjs_shims();
@@ -8038,29 +8038,21 @@ var getImportSpecifiers = (context) => {
8038
8038
  });
8039
8039
  return specifiers;
8040
8040
  };
8041
+ var hasPkgImport = (context) => {
8042
+ const imports = _getImports(context);
8043
+ return imports.some(({ mod }) => mod === "@pandacss/dev");
8044
+ };
8045
+ var isPandaConfigFunction = (context, name2) => {
8046
+ const imports = _getImports(context);
8047
+ return imports.some(({ alias, mod }) => alias === name2 && mod === "@pandacss/dev");
8048
+ };
8041
8049
  var _getImports = (context) => {
8042
8050
  const specifiers = getImportSpecifiers(context);
8043
- specifiers.map(({ specifier, mod }) => ({
8051
+ const imports = specifiers.map(({ specifier, mod }) => ({
8044
8052
  name: specifier.imported.name,
8045
8053
  alias: specifier.local.name,
8046
8054
  mod
8047
8055
  }));
8048
- const imports = [];
8049
- context.sourceCode.ast.body.forEach((node) => {
8050
- if (!isImportDeclaration(node))
8051
- return;
8052
- const mod = node.source.value;
8053
- if (!mod)
8054
- return;
8055
- node.specifiers.forEach((specifier) => {
8056
- if (!isImportSpecifier(specifier))
8057
- return;
8058
- const name2 = specifier.imported.name;
8059
- const alias = specifier.local.name;
8060
- const result = { name: name2, alias, mod };
8061
- imports.push(result);
8062
- });
8063
- });
8064
8056
  return imports;
8065
8057
  };
8066
8058
  var getImports = (context) => {
@@ -8265,6 +8257,8 @@ var rule2 = createRule({
8265
8257
  },
8266
8258
  defaultOptions: [],
8267
8259
  create(context) {
8260
+ if (!hasPkgImport(context))
8261
+ return {};
8268
8262
  return {
8269
8263
  CallExpression(node) {
8270
8264
  if (!isValidFile(context))
@@ -8273,6 +8267,8 @@ var rule2 = createRule({
8273
8267
  return;
8274
8268
  if (!CONFIG_FUNCTIONS.includes(node.callee.name))
8275
8269
  return;
8270
+ if (!isPandaConfigFunction(context, node.callee.name))
8271
+ return;
8276
8272
  context.report({
8277
8273
  node,
8278
8274
  messageId: "configFunction",
@@ -9167,8 +9163,6 @@ var rule13 = createRule({
9167
9163
  handleRuntimeFm(node.value.expression);
9168
9164
  },
9169
9165
  Property(node) {
9170
- if (isLiteral(node.key) && node.key.value?.toString().startsWith("--"))
9171
- return;
9172
9166
  if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
9173
9167
  return;
9174
9168
  if (!isPandaAttribute(node, context))
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.1.2";
13
+ version = "0.1.3";
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, isStyledProperty, isInPandaFunction, isInJSXProp, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
7978
+ var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, hasPkgImport, isPandaConfigFunction, _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";
@@ -8014,29 +8014,21 @@ var init_helpers = __esm({
8014
8014
  });
8015
8015
  return specifiers;
8016
8016
  };
8017
+ hasPkgImport = (context) => {
8018
+ const imports = _getImports(context);
8019
+ return imports.some(({ mod }) => mod === "@pandacss/dev");
8020
+ };
8021
+ isPandaConfigFunction = (context, name2) => {
8022
+ const imports = _getImports(context);
8023
+ return imports.some(({ alias, mod }) => alias === name2 && mod === "@pandacss/dev");
8024
+ };
8017
8025
  _getImports = (context) => {
8018
8026
  const specifiers = getImportSpecifiers(context);
8019
- specifiers.map(({ specifier, mod }) => ({
8027
+ const imports = specifiers.map(({ specifier, mod }) => ({
8020
8028
  name: specifier.imported.name,
8021
8029
  alias: specifier.local.name,
8022
8030
  mod
8023
8031
  }));
8024
- const imports = [];
8025
- context.sourceCode.ast.body.forEach((node) => {
8026
- if (!isImportDeclaration(node))
8027
- return;
8028
- const mod = node.source.value;
8029
- if (!mod)
8030
- return;
8031
- node.specifiers.forEach((specifier) => {
8032
- if (!isImportSpecifier(specifier))
8033
- return;
8034
- const name2 = specifier.imported.name;
8035
- const alias = specifier.local.name;
8036
- const result = { name: name2, alias, mod };
8037
- imports.push(result);
8038
- });
8039
- });
8040
8032
  return imports;
8041
8033
  };
8042
8034
  getImports = (context) => {
@@ -8259,6 +8251,8 @@ var init_no_config_function_in_source = __esm({
8259
8251
  },
8260
8252
  defaultOptions: [],
8261
8253
  create(context) {
8254
+ if (!hasPkgImport(context))
8255
+ return {};
8262
8256
  return {
8263
8257
  CallExpression(node) {
8264
8258
  if (!isValidFile(context))
@@ -8267,6 +8261,8 @@ var init_no_config_function_in_source = __esm({
8267
8261
  return;
8268
8262
  if (!CONFIG_FUNCTIONS.includes(node.callee.name))
8269
8263
  return;
8264
+ if (!isPandaConfigFunction(context, node.callee.name))
8265
+ return;
8270
8266
  context.report({
8271
8267
  node,
8272
8268
  messageId: "configFunction",
@@ -9265,8 +9261,6 @@ var init_no_unsafe_token_fn_usage = __esm({
9265
9261
  handleRuntimeFm(node.value.expression);
9266
9262
  },
9267
9263
  Property(node) {
9268
- if (isLiteral(node.key) && node.key.value?.toString().startsWith("--"))
9269
- return;
9270
9264
  if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
9271
9265
  return;
9272
9266
  if (!isPandaAttribute(node, context))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",