@pandacss/eslint-plugin 0.2.14 → 0.3.1

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.
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
 
30
- // ../node_modules/.pnpm/tsup@8.3.6_typescript@5.7.3/node_modules/tsup/assets/esm_shims.js
30
+ // ../node_modules/.pnpm/tsup@8.3.6_postcss@8.4.49_typescript@5.7.3/node_modules/tsup/assets/esm_shims.js
31
31
  var init_esm_shims = __esm({
32
- "../node_modules/.pnpm/tsup@8.3.6_typescript@5.7.3/node_modules/tsup/assets/esm_shims.js"() {
32
+ "../node_modules/.pnpm/tsup@8.3.6_postcss@8.4.49_typescript@5.7.3/node_modules/tsup/assets/esm_shims.js"() {
33
33
  "use strict";
34
34
  }
35
35
  });
package/dist/index.js CHANGED
@@ -28,10 +28,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // ../node_modules/.pnpm/tsup@8.3.6_typescript@5.7.3/node_modules/tsup/assets/cjs_shims.js
31
+ // ../node_modules/.pnpm/tsup@8.3.6_postcss@8.4.49_typescript@5.7.3/node_modules/tsup/assets/cjs_shims.js
32
32
  var getImportMetaUrl, importMetaUrl;
33
33
  var init_cjs_shims = __esm({
34
- "../node_modules/.pnpm/tsup@8.3.6_typescript@5.7.3/node_modules/tsup/assets/cjs_shims.js"() {
34
+ "../node_modules/.pnpm/tsup@8.3.6_postcss@8.4.49_typescript@5.7.3/node_modules/tsup/assets/cjs_shims.js"() {
35
35
  "use strict";
36
36
  getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
37
37
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -7884,7 +7884,7 @@ init_cjs_shims();
7884
7884
 
7885
7885
  // package.json
7886
7886
  var name = "@pandacss/eslint-plugin";
7887
- var version = "0.2.14";
7887
+ var version = "0.3.1";
7888
7888
 
7889
7889
  // src/configs/all.ts
7890
7890
  init_cjs_shims();
@@ -8003,6 +8003,10 @@ var isValidStyledProp = (node, context) => {
8003
8003
  var isPandaIsh = (name2, context) => {
8004
8004
  const imports = getImports(context);
8005
8005
  if (imports.length === 0) return false;
8006
+ const jsxFactory = syncAction("getJsxFactory", getSyncOpts(context));
8007
+ if (jsxFactory && name2 === jsxFactory) {
8008
+ return imports.some((imp) => imp.name === name2 || imp.alias === name2);
8009
+ }
8006
8010
  return syncAction("matchFile", getSyncOpts(context), name2, imports);
8007
8011
  };
8008
8012
  var findDeclaration = (name2, context) => {
@@ -8047,8 +8051,10 @@ var isPandaProp = (node, context) => {
8047
8051
  if (!isJSXMemberExpression(jsxAncestor.name) && !isJSXIdentifier(jsxAncestor.name)) return;
8048
8052
  const name2 = isJSXMemberExpression(jsxAncestor.name) ? jsxAncestor.name.object.name : jsxAncestor.name.name;
8049
8053
  const prop = node.name.name;
8050
- if (!isPandaIsh(name2, context) && !isLocalStyledFactory(jsxAncestor, context)) return;
8051
- if (typeof prop !== "string" || !isValidProperty(prop, context, name2)) return;
8054
+ const isPandaComponent = isPandaIsh(name2, context) || isLocalStyledFactory(jsxAncestor, context);
8055
+ if (!isPandaComponent) return;
8056
+ const patternName = isJSXMemberExpression(jsxAncestor.name) ? void 0 : name2;
8057
+ if (typeof prop !== "string" || !isValidProperty(prop, context, patternName)) return;
8052
8058
  return true;
8053
8059
  };
8054
8060
  var isStyledProperty = (node, context, calleeName) => {
package/dist/index.mjs CHANGED
@@ -3,14 +3,14 @@ import {
3
3
  __esm,
4
4
  __toESM,
5
5
  init_esm_shims
6
- } from "./chunk-KSIVUN3F.mjs";
6
+ } from "./chunk-Q5KKF6BL.mjs";
7
7
 
8
8
  // package.json
9
9
  var name, version;
10
10
  var init_package = __esm({
11
11
  "package.json"() {
12
12
  name = "@pandacss/eslint-plugin";
13
- version = "0.2.14";
13
+ version = "0.3.1";
14
14
  }
15
15
  });
16
16
 
@@ -8000,6 +8000,10 @@ var init_helpers = __esm({
8000
8000
  isPandaIsh = (name2, context) => {
8001
8001
  const imports = getImports(context);
8002
8002
  if (imports.length === 0) return false;
8003
+ const jsxFactory = syncAction("getJsxFactory", getSyncOpts(context));
8004
+ if (jsxFactory && name2 === jsxFactory) {
8005
+ return imports.some((imp) => imp.name === name2 || imp.alias === name2);
8006
+ }
8003
8007
  return syncAction("matchFile", getSyncOpts(context), name2, imports);
8004
8008
  };
8005
8009
  findDeclaration = (name2, context) => {
@@ -8044,8 +8048,10 @@ var init_helpers = __esm({
8044
8048
  if (!isJSXMemberExpression(jsxAncestor.name) && !isJSXIdentifier(jsxAncestor.name)) return;
8045
8049
  const name2 = isJSXMemberExpression(jsxAncestor.name) ? jsxAncestor.name.object.name : jsxAncestor.name.name;
8046
8050
  const prop = node.name.name;
8047
- if (!isPandaIsh(name2, context) && !isLocalStyledFactory(jsxAncestor, context)) return;
8048
- if (typeof prop !== "string" || !isValidProperty(prop, context, name2)) return;
8051
+ const isPandaComponent = isPandaIsh(name2, context) || isLocalStyledFactory(jsxAncestor, context);
8052
+ if (!isPandaComponent) return;
8053
+ const patternName = isJSXMemberExpression(jsxAncestor.name) ? void 0 : name2;
8054
+ if (typeof prop !== "string" || !isValidProperty(prop, context, patternName)) return;
8049
8055
  return true;
8050
8056
  };
8051
8057
  isStyledProperty = (node, context, calleeName) => {
@@ -35,7 +35,7 @@ __export(worker_exports, {
35
35
  runAsync: () => runAsync
36
36
  });
37
37
  module.exports = __toCommonJS(worker_exports);
38
- var import_node2 = require("@pandacss/node");
38
+ var import_generator2 = require("@pandacss/generator");
39
39
  var import_synckit = require("synckit");
40
40
 
41
41
  // ../node_modules/.pnpm/@pandacss+preset-base@0.40.1/node_modules/@pandacss/preset-base/dist/index.mjs
@@ -3951,44 +3951,49 @@ var fixtureDefaults = {
3951
3951
  serialized: (0, import_shared.stringifyJson)(config),
3952
3952
  deserialize: () => (0, import_shared.parseJson)((0, import_shared.stringifyJson)(config))
3953
3953
  };
3954
- var createContext = (userConfig) => {
3955
- const resolvedConfig = (0, import_config.mergeConfigs)([fixtureDefaults.config, panda_config_default, { importMap: "./panda" }]);
3956
- return new import_node.PandaContext({
3957
- ...fixtureDefaults,
3958
- config: resolvedConfig,
3959
- tsconfig: {
3960
- // @ts-expect-error
3961
- useInMemoryFileSystem: true
3962
- }
3963
- });
3954
+ var createGeneratorContext = (userConfig) => {
3955
+ const resolvedConfig = userConfig ? (0, import_config.mergeConfigs)([fixtureDefaults.config, userConfig]) : fixtureDefaults.config;
3956
+ return new import_generator.Generator({ ...fixtureDefaults, config: resolvedConfig });
3964
3957
  };
3965
3958
 
3966
3959
  // src/utils/worker.ts
3967
3960
  var import_ts_path = require("@pandacss/config/ts-path");
3968
3961
  var import_config3 = require("@pandacss/config");
3969
3962
  var import_path = __toESM(require("path"));
3963
+ var import_micromatch = __toESM(require("micromatch"));
3970
3964
  var contextCache = {};
3971
3965
  async function _getContext(configPath) {
3972
3966
  if (!configPath) throw new Error("Invalid config path");
3973
3967
  const cwd = import_path.default.dirname(configPath);
3974
- const ctx = await (0, import_node2.loadConfigAndCreateContext)({ configPath, cwd });
3968
+ const conf = await (0, import_config3.loadConfig)({ file: configPath, cwd });
3969
+ const ctx = new import_generator2.Generator(conf);
3975
3970
  return ctx;
3976
3971
  }
3977
3972
  async function getContext(opts) {
3978
3973
  if (process.env.NODE_ENV === "test") {
3979
- const ctx = createContext();
3980
- ctx.getFiles = () => ["App.tsx"];
3974
+ const ctx = createGeneratorContext({
3975
+ ...panda_config_default,
3976
+ include: ["**/*"],
3977
+ exclude: ["**/Invalid.tsx", "**/panda.config.ts"],
3978
+ importMap: "./panda",
3979
+ jsxFactory: "styled"
3980
+ });
3981
3981
  return ctx;
3982
3982
  } else {
3983
3983
  const configPath = (0, import_config3.findConfig)({ cwd: opts.configPath ?? opts.currentFile });
3984
+ const cwd = import_path.default.dirname(configPath);
3984
3985
  if (!contextCache[configPath]) {
3985
3986
  contextCache[configPath] = _getContext(configPath);
3986
3987
  }
3987
- return await contextCache[configPath];
3988
+ return contextCache[configPath];
3988
3989
  }
3989
3990
  }
3990
3991
  async function filterInvalidTokens(ctx, paths) {
3991
- return paths.filter((path2) => !ctx.utility.tokens.view.get(path2));
3992
+ const invalid = paths.filter((path2) => !ctx.utility.tokens.view.get(path2));
3993
+ if (invalid.length > 0) {
3994
+ console.error("filterInvalidTokens", { paths, invalid });
3995
+ }
3996
+ return invalid;
3992
3997
  }
3993
3998
  async function filterDeprecatedTokens(ctx, tokens3) {
3994
3999
  return tokens3.filter((token) => {
@@ -4009,31 +4014,35 @@ async function isColorAttribute(ctx, _attr) {
4009
4014
  const category = await getPropCategory(ctx, _attr);
4010
4015
  return category === "colors";
4011
4016
  }
4012
- var arePathsEqual = (path1, path2) => {
4013
- const normalizedPath1 = import_path.default.resolve(path1);
4014
- const normalizedPath2 = import_path.default.resolve(path2);
4015
- return normalizedPath1 === normalizedPath2;
4016
- };
4017
4017
  async function isValidFile(ctx, fileName) {
4018
- return ctx.getFiles().some((file) => arePathsEqual(file, fileName));
4018
+ const { include, exclude } = ctx.config;
4019
+ const cwd = ctx.config.cwd || process.cwd();
4020
+ const relativePath = import_path.default.isAbsolute(fileName) ? import_path.default.relative(cwd, fileName) : fileName;
4021
+ return import_micromatch.default.isMatch(relativePath, include, { ignore: exclude, dot: true });
4019
4022
  }
4020
4023
  async function resolveShorthands(ctx, name) {
4021
4024
  return ctx.utility.getPropShorthandsMap().get(name);
4022
4025
  }
4023
4026
  async function resolveLongHand(ctx, name) {
4024
4027
  const reverseShorthandsMap = /* @__PURE__ */ new Map();
4025
- for (const [key, values] of ctx.utility.getPropShorthandsMap()) {
4028
+ const shorthands = ctx.utility.getPropShorthandsMap();
4029
+ for (const [key, values] of shorthands) {
4026
4030
  for (const value of values) {
4027
4031
  reverseShorthandsMap.set(value, key);
4028
4032
  }
4029
4033
  }
4030
- return reverseShorthandsMap.get(name);
4034
+ const result = reverseShorthandsMap.get(name);
4035
+ return result;
4031
4036
  }
4032
4037
  async function isValidProperty(ctx, name, patternName) {
4033
- if (ctx.isValidProperty(name)) return true;
4034
- if (!patternName) return;
4038
+ const isValid = ctx.isValidProperty(name);
4039
+ if (isValid) return true;
4040
+ if (!patternName) return false;
4041
+ if (patternName === ctx.config.jsxFactory) {
4042
+ return false;
4043
+ }
4035
4044
  const pattern = ctx.patterns.details.find((p) => p.baseName === patternName || p.jsx.includes(patternName))?.config.properties;
4036
- if (!pattern) return;
4045
+ if (!pattern) return false;
4037
4046
  return Object.keys(pattern).includes(name);
4038
4047
  }
4039
4048
  async function matchFile(ctx, name, imports) {
@@ -4041,11 +4050,15 @@ async function matchFile(ctx, name, imports) {
4041
4050
  return file.match(name);
4042
4051
  }
4043
4052
  async function matchImports(ctx, result) {
4044
- return ctx.imports.match(result, (mod) => {
4053
+ const isMatch = ctx.imports.match(result, (mod) => {
4045
4054
  const { tsOptions } = ctx.parserOptions;
4046
4055
  if (!tsOptions?.pathMappings) return;
4047
4056
  return (0, import_ts_path.resolveTsPathPattern)(tsOptions.pathMappings, mod);
4048
4057
  });
4058
+ return isMatch;
4059
+ }
4060
+ async function getJsxFactory(ctx) {
4061
+ return ctx.config.jsxFactory;
4049
4062
  }
4050
4063
  async function runAsync(action, opts, ...args) {
4051
4064
  const ctx = await getContext(opts);
@@ -4070,6 +4083,8 @@ async function runAsync(action, opts, ...args) {
4070
4083
  return filterInvalidTokens(ctx, ...args);
4071
4084
  case "getPropCategory":
4072
4085
  return getPropCategory(ctx, ...args);
4086
+ case "getJsxFactory":
4087
+ return getJsxFactory(ctx);
4073
4088
  case "filterDeprecatedTokens":
4074
4089
  return filterDeprecatedTokens(ctx, ...args);
4075
4090
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "../chunk-KSIVUN3F.mjs";
3
+ } from "../chunk-Q5KKF6BL.mjs";
4
4
 
5
5
  // src/utils/worker.ts
6
6
  init_esm_shims();
7
- import { loadConfigAndCreateContext } from "@pandacss/node";
7
+ import { Generator as Generator2 } from "@pandacss/generator";
8
8
  import { runAsWorker } from "synckit";
9
9
 
10
10
  // ../fixture/src/index.ts
@@ -3936,16 +3936,9 @@ var fixtureDefaults = {
3936
3936
  serialized: stringifyJson(config),
3937
3937
  deserialize: () => parseJson(stringifyJson(config))
3938
3938
  };
3939
- var createContext = (userConfig) => {
3940
- const resolvedConfig = mergeConfigs([fixtureDefaults.config, panda_config_default, { importMap: "./panda" }]);
3941
- return new PandaContext({
3942
- ...fixtureDefaults,
3943
- config: resolvedConfig,
3944
- tsconfig: {
3945
- // @ts-expect-error
3946
- useInMemoryFileSystem: true
3947
- }
3948
- });
3939
+ var createGeneratorContext = (userConfig) => {
3940
+ const resolvedConfig = userConfig ? mergeConfigs([fixtureDefaults.config, userConfig]) : fixtureDefaults.config;
3941
+ return new Generator({ ...fixtureDefaults, config: resolvedConfig });
3949
3942
  };
3950
3943
 
3951
3944
  // ../fixture/src/layers.ts
@@ -3953,30 +3946,42 @@ init_esm_shims();
3953
3946
 
3954
3947
  // src/utils/worker.ts
3955
3948
  import { resolveTsPathPattern } from "@pandacss/config/ts-path";
3956
- import { findConfig } from "@pandacss/config";
3949
+ import { findConfig, loadConfig } from "@pandacss/config";
3957
3950
  import path from "path";
3951
+ import micromatch from "micromatch";
3958
3952
  var contextCache = {};
3959
3953
  async function _getContext(configPath) {
3960
3954
  if (!configPath) throw new Error("Invalid config path");
3961
3955
  const cwd = path.dirname(configPath);
3962
- const ctx = await loadConfigAndCreateContext({ configPath, cwd });
3956
+ const conf = await loadConfig({ file: configPath, cwd });
3957
+ const ctx = new Generator2(conf);
3963
3958
  return ctx;
3964
3959
  }
3965
3960
  async function getContext(opts) {
3966
3961
  if (process.env.NODE_ENV === "test") {
3967
- const ctx = createContext();
3968
- ctx.getFiles = () => ["App.tsx"];
3962
+ const ctx = createGeneratorContext({
3963
+ ...panda_config_default,
3964
+ include: ["**/*"],
3965
+ exclude: ["**/Invalid.tsx", "**/panda.config.ts"],
3966
+ importMap: "./panda",
3967
+ jsxFactory: "styled"
3968
+ });
3969
3969
  return ctx;
3970
3970
  } else {
3971
3971
  const configPath = findConfig({ cwd: opts.configPath ?? opts.currentFile });
3972
+ const cwd = path.dirname(configPath);
3972
3973
  if (!contextCache[configPath]) {
3973
3974
  contextCache[configPath] = _getContext(configPath);
3974
3975
  }
3975
- return await contextCache[configPath];
3976
+ return contextCache[configPath];
3976
3977
  }
3977
3978
  }
3978
3979
  async function filterInvalidTokens(ctx, paths) {
3979
- return paths.filter((path2) => !ctx.utility.tokens.view.get(path2));
3980
+ const invalid = paths.filter((path2) => !ctx.utility.tokens.view.get(path2));
3981
+ if (invalid.length > 0) {
3982
+ console.error("filterInvalidTokens", { paths, invalid });
3983
+ }
3984
+ return invalid;
3980
3985
  }
3981
3986
  async function filterDeprecatedTokens(ctx, tokens3) {
3982
3987
  return tokens3.filter((token) => {
@@ -3997,31 +4002,35 @@ async function isColorAttribute(ctx, _attr) {
3997
4002
  const category = await getPropCategory(ctx, _attr);
3998
4003
  return category === "colors";
3999
4004
  }
4000
- var arePathsEqual = (path1, path2) => {
4001
- const normalizedPath1 = path.resolve(path1);
4002
- const normalizedPath2 = path.resolve(path2);
4003
- return normalizedPath1 === normalizedPath2;
4004
- };
4005
4005
  async function isValidFile(ctx, fileName) {
4006
- return ctx.getFiles().some((file) => arePathsEqual(file, fileName));
4006
+ const { include, exclude } = ctx.config;
4007
+ const cwd = ctx.config.cwd || process.cwd();
4008
+ const relativePath = path.isAbsolute(fileName) ? path.relative(cwd, fileName) : fileName;
4009
+ return micromatch.isMatch(relativePath, include, { ignore: exclude, dot: true });
4007
4010
  }
4008
4011
  async function resolveShorthands(ctx, name) {
4009
4012
  return ctx.utility.getPropShorthandsMap().get(name);
4010
4013
  }
4011
4014
  async function resolveLongHand(ctx, name) {
4012
4015
  const reverseShorthandsMap = /* @__PURE__ */ new Map();
4013
- for (const [key, values] of ctx.utility.getPropShorthandsMap()) {
4016
+ const shorthands = ctx.utility.getPropShorthandsMap();
4017
+ for (const [key, values] of shorthands) {
4014
4018
  for (const value of values) {
4015
4019
  reverseShorthandsMap.set(value, key);
4016
4020
  }
4017
4021
  }
4018
- return reverseShorthandsMap.get(name);
4022
+ const result = reverseShorthandsMap.get(name);
4023
+ return result;
4019
4024
  }
4020
4025
  async function isValidProperty(ctx, name, patternName) {
4021
- if (ctx.isValidProperty(name)) return true;
4022
- if (!patternName) return;
4026
+ const isValid = ctx.isValidProperty(name);
4027
+ if (isValid) return true;
4028
+ if (!patternName) return false;
4029
+ if (patternName === ctx.config.jsxFactory) {
4030
+ return false;
4031
+ }
4023
4032
  const pattern = ctx.patterns.details.find((p) => p.baseName === patternName || p.jsx.includes(patternName))?.config.properties;
4024
- if (!pattern) return;
4033
+ if (!pattern) return false;
4025
4034
  return Object.keys(pattern).includes(name);
4026
4035
  }
4027
4036
  async function matchFile(ctx, name, imports) {
@@ -4029,11 +4038,15 @@ async function matchFile(ctx, name, imports) {
4029
4038
  return file.match(name);
4030
4039
  }
4031
4040
  async function matchImports(ctx, result) {
4032
- return ctx.imports.match(result, (mod) => {
4041
+ const isMatch = ctx.imports.match(result, (mod) => {
4033
4042
  const { tsOptions } = ctx.parserOptions;
4034
4043
  if (!tsOptions?.pathMappings) return;
4035
4044
  return resolveTsPathPattern(tsOptions.pathMappings, mod);
4036
4045
  });
4046
+ return isMatch;
4047
+ }
4048
+ async function getJsxFactory(ctx) {
4049
+ return ctx.config.jsxFactory;
4037
4050
  }
4038
4051
  async function runAsync(action, opts, ...args) {
4039
4052
  const ctx = await getContext(opts);
@@ -4058,6 +4071,8 @@ async function runAsync(action, opts, ...args) {
4058
4071
  return filterInvalidTokens(ctx, ...args);
4059
4072
  case "getPropCategory":
4060
4073
  return getPropCategory(ctx, ...args);
4074
+ case "getJsxFactory":
4075
+ return getJsxFactory(ctx);
4061
4076
  case "filterDeprecatedTokens":
4062
4077
  return filterDeprecatedTokens(ctx, ...args);
4063
4078
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "0.2.14",
3
+ "version": "0.3.1",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/index.js",
@@ -32,12 +32,14 @@
32
32
  "@pandacss/shared": "^0.53.2",
33
33
  "@typescript-eslint/utils": "^8.21.0",
34
34
  "hookable": "^5.5.3",
35
+ "micromatch": "^4.0.8",
35
36
  "synckit": "^0.9.0"
36
37
  },
37
38
  "peerDependencies": {
38
39
  "eslint": "*"
39
40
  },
40
41
  "devDependencies": {
42
+ "@types/micromatch": "^4.0.10",
41
43
  "typescript": "^5.7.2"
42
44
  },
43
45
  "scripts": {