@azu/eslint-plugin-panda-oxc 1.0.4 → 1.1.0

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.
@@ -0,0 +1,74 @@
1
+ // src/oxlint/create-panda-json.ts
2
+ import { loadConfig } from "@pandacss/config";
3
+ import { Generator } from "@pandacss/generator";
4
+ import fs from "fs";
5
+ import os from "os";
6
+ import path from "path";
7
+ async function buildPandaData(configPath) {
8
+ const configDir = path.dirname(configPath);
9
+ const conf = await loadConfig({ file: configPath, cwd: configDir });
10
+ const ctx = new Generator(conf);
11
+ const shorthandToLonghand = {};
12
+ const longhandToShorthands = {};
13
+ const shorthands = ctx.utility.getPropShorthandsMap();
14
+ for (const [key, values] of shorthands) {
15
+ longhandToShorthands[key] = values;
16
+ for (const v of values) {
17
+ shorthandToLonghand[v] = key;
18
+ }
19
+ }
20
+ const propToCategory = {};
21
+ for (const [prop, config] of Object.entries(ctx.utility.config)) {
22
+ propToCategory[prop] = typeof config?.values === "string" ? config.values : void 0;
23
+ }
24
+ const patternProps = {};
25
+ for (const detail of ctx.patterns.details) {
26
+ const props = Object.keys(detail.config.properties ?? {});
27
+ patternProps[detail.baseName] = props;
28
+ for (const jsxName of detail.jsx) {
29
+ patternProps[jsxName] = props;
30
+ }
31
+ }
32
+ const allTokenPaths = [];
33
+ const deprecatedTokenPaths = [];
34
+ for (const [tokenPath] of ctx.utility.tokens.view.values) {
35
+ allTokenPaths.push(tokenPath);
36
+ if (ctx.utility.tokens.isDeprecated(tokenPath)) {
37
+ deprecatedTokenPaths.push(tokenPath);
38
+ }
39
+ }
40
+ const pathMappings = (ctx.parserOptions?.tsOptions?.pathMappings ?? []).map(
41
+ (pm) => ({
42
+ pattern: pm.pattern.source,
43
+ paths: pm.paths
44
+ })
45
+ );
46
+ return {
47
+ jsxFactory: ctx.config.jsxFactory,
48
+ include: ctx.config.include ?? [],
49
+ exclude: ctx.config.exclude ?? [],
50
+ cwd: ctx.config.cwd ?? configDir,
51
+ importMap: ctx.imports.value,
52
+ jsxNames: ctx.jsx.names ?? [],
53
+ pathMappings,
54
+ allValidProps: Object.keys(ctx.utility.config),
55
+ shorthandToLonghand,
56
+ longhandToShorthands,
57
+ propToCategory,
58
+ patternProps,
59
+ allTokenPaths,
60
+ deprecatedTokenPaths
61
+ };
62
+ }
63
+ async function createPandaJSON(basedir, configRelativePath) {
64
+ const configPath = path.resolve(basedir, configRelativePath);
65
+ const data = await buildPandaData(configPath);
66
+ const jsonPath = path.join(os.tmpdir(), `panda-data-${process.pid}.json`);
67
+ fs.writeFileSync(jsonPath, JSON.stringify(data, null, 2));
68
+ return jsonPath;
69
+ }
70
+
71
+ export {
72
+ buildPandaData,
73
+ createPandaJSON
74
+ };
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
6
6
 
7
7
  // package.json
8
8
  var name = "@azu/eslint-plugin-panda-oxc";
9
- var version = "1.0.4";
9
+ var version = "1.1.0";
10
10
 
11
11
  // src/utils/index.ts
12
12
  var import_utils = require("@typescript-eslint/utils");
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ var name, version;
9
9
  var init_package = __esm({
10
10
  "package.json"() {
11
11
  name = "@azu/eslint-plugin-panda-oxc";
12
- version = "1.0.4";
12
+ version = "1.1.0";
13
13
  }
14
14
  });
15
15
 
@@ -24,16 +24,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/oxlint/generate-data.ts
27
+ var import_node_fs2 = __toESM(require("fs"));
28
+ var import_node_path2 = __toESM(require("path"));
29
+
30
+ // src/oxlint/create-panda-json.ts
27
31
  var import_config = require("@pandacss/config");
28
32
  var import_generator = require("@pandacss/generator");
29
33
  var import_node_fs = __toESM(require("fs"));
34
+ var import_node_os = __toESM(require("os"));
30
35
  var import_node_path = __toESM(require("path"));
31
- async function main() {
32
- const args = process.argv.slice(2);
33
- const configArg = args[0];
34
- const outputArg = args[1] ?? "panda-data.json";
35
- const cwd = process.cwd();
36
- const configPath = configArg ? import_node_path.default.resolve(cwd, configArg) : (0, import_config.findConfig)({ cwd });
36
+ async function buildPandaData(configPath) {
37
37
  const configDir = import_node_path.default.dirname(configPath);
38
38
  const conf = await (0, import_config.loadConfig)({ file: configPath, cwd: configDir });
39
39
  const ctx = new import_generator.Generator(conf);
@@ -72,7 +72,7 @@ async function main() {
72
72
  paths: pm.paths
73
73
  })
74
74
  );
75
- const data = {
75
+ return {
76
76
  jsxFactory: ctx.config.jsxFactory,
77
77
  include: ctx.config.include ?? [],
78
78
  exclude: ctx.config.exclude ?? [],
@@ -88,12 +88,25 @@ async function main() {
88
88
  allTokenPaths,
89
89
  deprecatedTokenPaths
90
90
  };
91
- const outputPath = import_node_path.default.resolve(cwd, outputArg);
92
- import_node_fs.default.writeFileSync(outputPath, JSON.stringify(data, null, 2));
93
- console.log(`Generated panda-data.json at ${outputPath}`);
94
- console.log(` Valid properties: ${data.allValidProps.length}`);
95
- console.log(` Token paths: ${allTokenPaths.length}`);
96
- console.log(` Deprecated tokens: ${deprecatedTokenPaths.length}`);
91
+ }
92
+
93
+ // src/oxlint/generate-data.ts
94
+ var import_config2 = require("@pandacss/config");
95
+ async function main() {
96
+ const args = process.argv.slice(2);
97
+ const configArg = args[0];
98
+ const outputArg = args[1] ?? "panda-data.json";
99
+ const cwd = process.cwd();
100
+ const configPath = configArg ? import_node_path2.default.resolve(cwd, configArg) : (0, import_config2.findConfig)({ cwd });
101
+ const data = await buildPandaData(configPath);
102
+ const outputPath = import_node_path2.default.resolve(cwd, outputArg);
103
+ import_node_fs2.default.writeFileSync(outputPath, JSON.stringify(data, null, 2));
104
+ if (process.env.DEBUG?.includes("eslint-plugin-panda-oxc")) {
105
+ console.log(`Generated panda-data.json at ${outputPath}`);
106
+ console.log(` Valid properties: ${data.allValidProps.length}`);
107
+ console.log(` Token paths: ${data.allTokenPaths.length}`);
108
+ console.log(` Deprecated tokens: ${data.deprecatedTokenPaths.length}`);
109
+ }
97
110
  }
98
111
  main().catch((err) => {
99
112
  console.error(err);
@@ -1,77 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import "../chunk-XIZSR54U.mjs";
2
+ import {
3
+ buildPandaData
4
+ } from "../chunk-YUAYYV3V.mjs";
3
5
 
4
6
  // src/oxlint/generate-data.ts
5
- import { findConfig, loadConfig } from "@pandacss/config";
6
- import { Generator } from "@pandacss/generator";
7
7
  import fs from "fs";
8
8
  import path from "path";
9
+ import { findConfig } from "@pandacss/config";
9
10
  async function main() {
10
11
  const args = process.argv.slice(2);
11
12
  const configArg = args[0];
12
13
  const outputArg = args[1] ?? "panda-data.json";
13
14
  const cwd = process.cwd();
14
15
  const configPath = configArg ? path.resolve(cwd, configArg) : findConfig({ cwd });
15
- const configDir = path.dirname(configPath);
16
- const conf = await loadConfig({ file: configPath, cwd: configDir });
17
- const ctx = new Generator(conf);
18
- const shorthandToLonghand = {};
19
- const longhandToShorthands = {};
20
- const shorthands = ctx.utility.getPropShorthandsMap();
21
- for (const [key, values] of shorthands) {
22
- longhandToShorthands[key] = values;
23
- for (const v of values) {
24
- shorthandToLonghand[v] = key;
25
- }
26
- }
27
- const propToCategory = {};
28
- for (const [prop, config] of Object.entries(ctx.utility.config)) {
29
- propToCategory[prop] = typeof config?.values === "string" ? config.values : void 0;
30
- }
31
- const patternProps = {};
32
- for (const detail of ctx.patterns.details) {
33
- const props = Object.keys(detail.config.properties ?? {});
34
- patternProps[detail.baseName] = props;
35
- for (const jsxName of detail.jsx) {
36
- patternProps[jsxName] = props;
37
- }
38
- }
39
- const allTokenPaths = [];
40
- const deprecatedTokenPaths = [];
41
- for (const [tokenPath] of ctx.utility.tokens.view.values) {
42
- allTokenPaths.push(tokenPath);
43
- if (ctx.utility.tokens.isDeprecated(tokenPath)) {
44
- deprecatedTokenPaths.push(tokenPath);
45
- }
46
- }
47
- const pathMappings = (ctx.parserOptions?.tsOptions?.pathMappings ?? []).map(
48
- (pm) => ({
49
- pattern: pm.pattern.source,
50
- paths: pm.paths
51
- })
52
- );
53
- const data = {
54
- jsxFactory: ctx.config.jsxFactory,
55
- include: ctx.config.include ?? [],
56
- exclude: ctx.config.exclude ?? [],
57
- cwd: ctx.config.cwd ?? configDir,
58
- importMap: ctx.imports.value,
59
- jsxNames: ctx.jsx.names ?? [],
60
- pathMappings,
61
- allValidProps: Object.keys(ctx.utility.config),
62
- shorthandToLonghand,
63
- longhandToShorthands,
64
- propToCategory,
65
- patternProps,
66
- allTokenPaths,
67
- deprecatedTokenPaths
68
- };
16
+ const data = await buildPandaData(configPath);
69
17
  const outputPath = path.resolve(cwd, outputArg);
70
18
  fs.writeFileSync(outputPath, JSON.stringify(data, null, 2));
71
- console.log(`Generated panda-data.json at ${outputPath}`);
72
- console.log(` Valid properties: ${data.allValidProps.length}`);
73
- console.log(` Token paths: ${allTokenPaths.length}`);
74
- console.log(` Deprecated tokens: ${deprecatedTokenPaths.length}`);
19
+ if (process.env.DEBUG?.includes("eslint-plugin-panda-oxc")) {
20
+ console.log(`Generated panda-data.json at ${outputPath}`);
21
+ console.log(` Valid properties: ${data.allValidProps.length}`);
22
+ console.log(` Token paths: ${data.allTokenPaths.length}`);
23
+ console.log(` Deprecated tokens: ${data.deprecatedTokenPaths.length}`);
24
+ }
75
25
  }
76
26
  main().catch((err) => {
77
27
  console.error(err);
package/dist/oxlint.js CHANGED
@@ -30,42 +30,89 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/oxlint.ts
31
31
  var oxlint_exports = {};
32
32
  __export(oxlint_exports, {
33
+ createPandaJSON: () => createPandaJSON,
33
34
  default: () => oxlint_default
34
35
  });
35
36
  module.exports = __toCommonJS(oxlint_exports);
36
37
 
37
- // src/oxlint/context.ts
38
- var import_node_child_process = require("child_process");
38
+ // src/oxlint/create-panda-json.ts
39
+ var import_config = require("@pandacss/config");
40
+ var import_generator = require("@pandacss/generator");
39
41
  var import_node_fs = __toESM(require("fs"));
40
42
  var import_node_os = __toESM(require("os"));
41
43
  var import_node_path = __toESM(require("path"));
42
- var cached;
43
- var generatedJsonPath;
44
- function generateData(configPath) {
45
- const jsonPath = import_node_path.default.join(import_node_os.default.tmpdir(), `panda-data-${process.pid}.json`);
46
- const generateScript = import_node_path.default.resolve(__dirname, "oxlint", "generate-data.mjs");
47
- const script = import_node_fs.default.existsSync(generateScript) ? generateScript : import_node_path.default.resolve(__dirname, "oxlint", "generate-data.js");
48
- (0, import_node_child_process.execSync)(`node ${script} ${configPath} ${jsonPath}`, {
49
- stdio: "inherit",
50
- cwd: import_node_path.default.dirname(configPath)
51
- });
52
- generatedJsonPath = jsonPath;
53
- process.on("exit", cleanup);
54
- return jsonPath;
55
- }
56
- function cleanup() {
57
- if (generatedJsonPath) {
58
- try {
59
- import_node_fs.default.unlinkSync(generatedJsonPath);
60
- } catch {
44
+ async function buildPandaData(configPath) {
45
+ const configDir = import_node_path.default.dirname(configPath);
46
+ const conf = await (0, import_config.loadConfig)({ file: configPath, cwd: configDir });
47
+ const ctx = new import_generator.Generator(conf);
48
+ const shorthandToLonghand = {};
49
+ const longhandToShorthands = {};
50
+ const shorthands = ctx.utility.getPropShorthandsMap();
51
+ for (const [key, values] of shorthands) {
52
+ longhandToShorthands[key] = values;
53
+ for (const v of values) {
54
+ shorthandToLonghand[v] = key;
55
+ }
56
+ }
57
+ const propToCategory = {};
58
+ for (const [prop, config] of Object.entries(ctx.utility.config)) {
59
+ propToCategory[prop] = typeof config?.values === "string" ? config.values : void 0;
60
+ }
61
+ const patternProps = {};
62
+ for (const detail of ctx.patterns.details) {
63
+ const props = Object.keys(detail.config.properties ?? {});
64
+ patternProps[detail.baseName] = props;
65
+ for (const jsxName of detail.jsx) {
66
+ patternProps[jsxName] = props;
67
+ }
68
+ }
69
+ const allTokenPaths = [];
70
+ const deprecatedTokenPaths = [];
71
+ for (const [tokenPath] of ctx.utility.tokens.view.values) {
72
+ allTokenPaths.push(tokenPath);
73
+ if (ctx.utility.tokens.isDeprecated(tokenPath)) {
74
+ deprecatedTokenPaths.push(tokenPath);
61
75
  }
62
76
  }
77
+ const pathMappings = (ctx.parserOptions?.tsOptions?.pathMappings ?? []).map(
78
+ (pm) => ({
79
+ pattern: pm.pattern.source,
80
+ paths: pm.paths
81
+ })
82
+ );
83
+ return {
84
+ jsxFactory: ctx.config.jsxFactory,
85
+ include: ctx.config.include ?? [],
86
+ exclude: ctx.config.exclude ?? [],
87
+ cwd: ctx.config.cwd ?? configDir,
88
+ importMap: ctx.imports.value,
89
+ jsxNames: ctx.jsx.names ?? [],
90
+ pathMappings,
91
+ allValidProps: Object.keys(ctx.utility.config),
92
+ shorthandToLonghand,
93
+ longhandToShorthands,
94
+ propToCategory,
95
+ patternProps,
96
+ allTokenPaths,
97
+ deprecatedTokenPaths
98
+ };
99
+ }
100
+ async function createPandaJSON(basedir, configRelativePath) {
101
+ const configPath = import_node_path.default.resolve(basedir, configRelativePath);
102
+ const data = await buildPandaData(configPath);
103
+ const jsonPath = import_node_path.default.join(import_node_os.default.tmpdir(), `panda-data-${process.pid}.json`);
104
+ import_node_fs.default.writeFileSync(jsonPath, JSON.stringify(data, null, 2));
105
+ return jsonPath;
63
106
  }
64
- function loadPandaData(configPath) {
107
+
108
+ // src/oxlint/context.ts
109
+ var import_node_fs2 = __toESM(require("fs"));
110
+ var import_node_path2 = __toESM(require("path"));
111
+ var cached;
112
+ function loadPandaData(jsonPath) {
65
113
  if (cached) return cached;
66
- const absConfigPath = import_node_path.default.isAbsolute(configPath) ? configPath : import_node_path.default.resolve(process.cwd(), configPath);
67
- const jsonPath = generateData(absConfigPath);
68
- const raw = JSON.parse(import_node_fs.default.readFileSync(jsonPath, "utf-8"));
114
+ const absJsonPath = import_node_path2.default.isAbsolute(jsonPath) ? jsonPath : import_node_path2.default.resolve(process.cwd(), jsonPath);
115
+ const raw = JSON.parse(import_node_fs2.default.readFileSync(absJsonPath, "utf-8"));
69
116
  const pathMappings = (raw.pathMappings ?? []).map((pm) => ({
70
117
  pattern: new RegExp(typeof pm.pattern === "string" ? pm.pattern : pm.pattern.source),
71
118
  paths: pm.paths
@@ -153,7 +200,7 @@ function matchImport(result, data) {
153
200
 
154
201
  // src/oxlint/helpers.ts
155
202
  var import_micromatch = __toESM(require("micromatch"));
156
- var import_node_path2 = __toESM(require("path"));
203
+ var import_node_path3 = __toESM(require("path"));
157
204
  function buildFileState(ast, data) {
158
205
  const allImports = [];
159
206
  for (const node of ast.body) {
@@ -192,7 +239,7 @@ function buildFileState(ast, data) {
192
239
  return { pandaImports, allImports, localStyledComponents };
193
240
  }
194
241
  function isValidFile(data, fileName) {
195
- const relativePath = import_node_path2.default.isAbsolute(fileName) ? import_node_path2.default.relative(data.cwd, fileName) : fileName;
242
+ const relativePath = import_node_path3.default.isAbsolute(fileName) ? import_node_path3.default.relative(data.cwd, fileName) : fileName;
196
243
  return import_micromatch.default.isMatch(relativePath, data.include, { ignore: data.exclude, dot: true });
197
244
  }
198
245
  function getAncestor(ofType, node) {
@@ -1992,3 +2039,7 @@ var plugin = {
1992
2039
  }
1993
2040
  };
1994
2041
  var oxlint_default = plugin;
2042
+ // Annotate the CommonJS export names for ESM import in node:
2043
+ 0 && (module.exports = {
2044
+ createPandaJSON
2045
+ });
package/dist/oxlint.mjs CHANGED
@@ -1,39 +1,15 @@
1
1
  import {
2
- __dirname
3
- } from "./chunk-XIZSR54U.mjs";
2
+ createPandaJSON
3
+ } from "./chunk-YUAYYV3V.mjs";
4
4
 
5
5
  // src/oxlint/context.ts
6
- import { execSync } from "child_process";
7
6
  import fs from "fs";
8
- import os from "os";
9
7
  import path from "path";
10
8
  var cached;
11
- var generatedJsonPath;
12
- function generateData(configPath) {
13
- const jsonPath = path.join(os.tmpdir(), `panda-data-${process.pid}.json`);
14
- const generateScript = path.resolve(__dirname, "oxlint", "generate-data.mjs");
15
- const script = fs.existsSync(generateScript) ? generateScript : path.resolve(__dirname, "oxlint", "generate-data.js");
16
- execSync(`node ${script} ${configPath} ${jsonPath}`, {
17
- stdio: "inherit",
18
- cwd: path.dirname(configPath)
19
- });
20
- generatedJsonPath = jsonPath;
21
- process.on("exit", cleanup);
22
- return jsonPath;
23
- }
24
- function cleanup() {
25
- if (generatedJsonPath) {
26
- try {
27
- fs.unlinkSync(generatedJsonPath);
28
- } catch {
29
- }
30
- }
31
- }
32
- function loadPandaData(configPath) {
9
+ function loadPandaData(jsonPath) {
33
10
  if (cached) return cached;
34
- const absConfigPath = path.isAbsolute(configPath) ? configPath : path.resolve(process.cwd(), configPath);
35
- const jsonPath = generateData(absConfigPath);
36
- const raw = JSON.parse(fs.readFileSync(jsonPath, "utf-8"));
11
+ const absJsonPath = path.isAbsolute(jsonPath) ? jsonPath : path.resolve(process.cwd(), jsonPath);
12
+ const raw = JSON.parse(fs.readFileSync(absJsonPath, "utf-8"));
37
13
  const pathMappings = (raw.pathMappings ?? []).map((pm) => ({
38
14
  pattern: new RegExp(typeof pm.pattern === "string" ? pm.pattern : pm.pattern.source),
39
15
  paths: pm.paths
@@ -1961,5 +1937,6 @@ var plugin = {
1961
1937
  };
1962
1938
  var oxlint_default = plugin;
1963
1939
  export {
1940
+ createPandaJSON,
1964
1941
  oxlint_default as default
1965
1942
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azu/eslint-plugin-panda-oxc",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Eslint plugin for Panda CSS",
5
5
  "author": "Abraham Aremu <anubra266@gmail.com>",
6
6
  "main": "dist/oxlint.js",
@@ -1,10 +0,0 @@
1
- // ../node_modules/.pnpm/tsup@8.5.1_postcss@8.4.49_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js
2
- import path from "path";
3
- import { fileURLToPath } from "url";
4
- var getFilename = () => fileURLToPath(import.meta.url);
5
- var getDirname = () => path.dirname(getFilename());
6
- var __dirname = /* @__PURE__ */ getDirname();
7
-
8
- export {
9
- __dirname
10
- };