@pandacss/eslint-plugin 0.3.2 → 2.0.0-beta.11

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
@@ -1,2541 +1,155 @@
1
- "use strict";
2
-
3
- // ../node_modules/.pnpm/tsup@8.3.6_postcss@8.5.6_typescript@5.7.3/node_modules/tsup/assets/cjs_shims.js
4
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
5
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
6
-
7
- // package.json
8
- var name = "@pandacss/eslint-plugin";
9
- var version = "0.3.2";
10
-
11
- // src/utils/index.ts
12
- var import_utils = require("@typescript-eslint/utils");
13
- var import_synckit = require("synckit");
14
- var import_node_path = require("path");
15
- var import_node_url = require("url");
16
-
17
- // src/utils/cache.ts
18
- var import_scope_manager = require("@typescript-eslint/scope-manager");
19
- var cache = {
20
- imports: null,
21
- scopeAnalysis: null
22
- };
23
- var numRulesRunning = 0;
24
- var resetMicrotaskScheduled = false;
25
- function ruleStarted() {
26
- numRulesRunning++;
27
- if (!resetMicrotaskScheduled) {
28
- queueMicrotask(resetCacheMicrotask);
29
- resetMicrotaskScheduled = true;
30
- }
31
- }
32
- function ruleFinished() {
33
- numRulesRunning--;
34
- if (numRulesRunning === 0) {
35
- resetCache();
36
- }
37
- }
38
- function resetCache() {
39
- cache.imports = null;
40
- cache.scopeAnalysis = null;
41
- }
42
- function resetCacheMicrotask() {
43
- resetCache();
44
- numRulesRunning = 0;
45
- resetMicrotaskScheduled = false;
46
- }
47
-
48
- // src/utils/index.ts
49
- var _createRule = import_utils.ESLintUtils.RuleCreator(
50
- (name2) => `https://github.com/chakra-ui/eslint-plugin-panda/blob/main/docs/rules/${name2}.md`
51
- );
52
- var createRule = (...args) => {
53
- const rule20 = _createRule(...args);
54
- const originalCreate = rule20.create;
55
- rule20.create = (context) => {
56
- ruleStarted();
57
- const visitor = originalCreate(context);
58
- const existingExit = visitor["Program:exit"];
59
- if (existingExit) {
60
- visitor["Program:exit"] = (node) => {
61
- existingExit(node);
62
- ruleFinished();
63
- };
64
- } else {
65
- visitor["Program:exit"] = (_node) => ruleFinished();
66
- }
67
- return visitor;
68
- };
69
- return rule20;
70
- };
71
- var isBase = process.env.NODE_ENV !== "test" || importMetaUrl.includes("/dist/index");
72
- var distDir = (0, import_node_url.fileURLToPath)(new URL(isBase ? "./" : "../../dist", importMetaUrl));
73
- var _syncAction = (0, import_synckit.createSyncFn)((0, import_node_path.join)(distDir, "utils/worker.mjs"));
74
- var syncAction = (...args) => {
75
- try {
76
- return _syncAction(...args);
77
- } catch (error) {
78
- console.error("syncAction error:", error);
79
- return void 0;
80
- }
81
- };
82
-
83
- // src/utils/helpers.ts
84
- var import_scope_manager2 = require("@typescript-eslint/scope-manager");
85
-
86
- // src/utils/nodes.ts
87
- var import_ast_utils = require("@typescript-eslint/utils/ast-utils");
88
- var import_utils2 = require("@typescript-eslint/utils");
89
- var isIdentifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Identifier);
90
- var isLiteral = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Literal);
91
- var isTemplateLiteral = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.TemplateLiteral);
92
- var isArrayExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ArrayExpression);
93
- var isObjectExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ObjectExpression);
94
- var isMemberExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.MemberExpression);
95
- var isVariableDeclarator = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.VariableDeclarator);
96
- var isVariableDeclaration = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.VariableDeclaration);
97
- var isJSXMemberExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.JSXMemberExpression);
98
- var isJSXOpeningElement = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.JSXOpeningElement);
99
- var isJSXExpressionContainer = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.JSXExpressionContainer);
100
- var isJSXAttribute = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.JSXAttribute);
101
- var isJSXIdentifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.JSXIdentifier);
102
- var isCallExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.CallExpression);
103
- var isImportDeclaration = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ImportDeclaration);
104
- var isImportSpecifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ImportSpecifier);
105
- var isProperty = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Property);
106
-
107
- // src/utils/helpers.ts
108
- var getAncestor = (ofType, for_) => {
109
- let current = for_.parent;
110
- while (current) {
111
- if (ofType(current)) return current;
112
- current = current.parent;
113
- }
114
- return;
115
- };
116
- var getSyncOpts = (context) => {
1
+ import {
2
+ FileInspector,
3
+ Linter,
4
+ ProjectCache,
5
+ bindRules,
6
+ byteToIndex,
7
+ collectStrings,
8
+ consistentPropertyStyleRuleName,
9
+ createConsistentPropertyStyleRule,
10
+ createExtractionDiagnosticsRule,
11
+ createFileNotIncludedRule,
12
+ createNoDebugRule,
13
+ createNoDeprecatedRule,
14
+ createNoImportantRule,
15
+ createNoInvalidNestingRule,
16
+ createNoInvalidTokenPathsRule,
17
+ createNoMarginPropertiesRule,
18
+ createNoPhysicalPropertiesRule,
19
+ createNoPrimitiveTokenRule,
20
+ createNoShorthandLonghandMixRule,
21
+ createPandaPlugin,
22
+ createPreferTextStyleRule,
23
+ createPreferTokenRule,
24
+ extractionDiagnosticsRuleName,
25
+ fileNotIncludedRuleName,
26
+ getContextFilename,
27
+ getContextSource,
28
+ getSourceText,
29
+ loadPandaProject,
30
+ noDebugRuleName,
31
+ noDeprecatedRuleName,
32
+ noImportantRuleName,
33
+ noInvalidNestingRuleName,
34
+ noInvalidTokenPathsRuleName,
35
+ noMarginPropertiesRuleName,
36
+ noPhysicalPropertiesRuleName,
37
+ noPrimitiveTokenRuleName,
38
+ noShorthandLonghandMixRuleName,
39
+ pluginMeta,
40
+ preferTextStyleRuleName,
41
+ preferTokenRuleName,
42
+ projectCacheKey,
43
+ reportDiagnostics,
44
+ reportPrimitiveTokenViolations,
45
+ reportTokenViolations,
46
+ resolvePandaSettings,
47
+ sourceCacheKey,
48
+ toEslintLoc
49
+ } from "./chunk-QIP545JU.js";
50
+
51
+ // src/core/range-index.ts
52
+ var RangeIndex = class {
53
+ #items;
54
+ constructor(items) {
55
+ this.#items = [...items].sort((a, b) => a.span.start - b.span.start || a.span.end - b.span.end);
56
+ }
57
+ at(offset) {
58
+ return this.#items.find((item) => item.span.start <= offset && offset <= item.span.end);
59
+ }
60
+ enclosing(span) {
61
+ return this.#items.find((item) => item.span.start <= span.start && item.span.end >= span.end);
62
+ }
63
+ exact(span) {
64
+ return this.#items.find((item) => item.span.start === span.start && item.span.end === span.end);
65
+ }
66
+ all() {
67
+ return this.#items;
68
+ }
69
+ };
70
+
71
+ // src/configs.ts
72
+ var PLUGIN_NAMESPACE = "@pandacss";
73
+ var DEFAULT_FILES = ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"];
74
+ var RECOMMENDED_RULES = {
75
+ [extractionDiagnosticsRuleName]: "warn",
76
+ [fileNotIncludedRuleName]: "error",
77
+ [noInvalidTokenPathsRuleName]: "error",
78
+ [noInvalidNestingRuleName]: "error",
79
+ [noDeprecatedRuleName]: "warn",
80
+ [noDebugRuleName]: "warn",
81
+ // Default to flagging hardcoded colors only (the old `no-hardcoded-color`);
82
+ // widen with `categories` to enforce other token categories.
83
+ [preferTokenRuleName]: ["warn", { categories: ["colors"] }]
84
+ };
85
+ async function recommended(options = {}) {
86
+ const { linter, project } = await loadPandaProject(options);
87
+ const rules = bindRules(linter, project);
88
+ const plugin = { meta: pluginMeta, rules };
117
89
  return {
118
- currentFile: context.filename,
119
- configPath: context.settings["@pandacss/configPath"]
90
+ files: options.files ?? DEFAULT_FILES,
91
+ plugins: { [PLUGIN_NAMESPACE]: plugin },
92
+ rules: Object.fromEntries(
93
+ Object.entries(RECOMMENDED_RULES).map(([id, severity]) => [`${PLUGIN_NAMESPACE}/${id}`, severity])
94
+ ),
95
+ ...options.configPath ? { settings: { panda: { configPath: options.configPath } } } : {}
120
96
  };
121
- };
122
- var getImportSpecifiers = (context) => {
123
- const specifiers = [];
124
- context.sourceCode?.ast.body.forEach((node) => {
125
- if (!isImportDeclaration(node)) return;
126
- const mod = node.source.value;
127
- if (!mod) return;
128
- node.specifiers.forEach((specifier) => {
129
- if (!isImportSpecifier(specifier)) return;
130
- specifiers.push({ specifier, mod });
131
- });
132
- });
133
- return specifiers;
134
- };
135
- var hasPkgImport = (context) => {
136
- const imports = _getImports(context);
137
- return imports.some(({ mod }) => mod === "@pandacss/dev");
138
- };
139
- var isPandaConfigFunction = (context, name2) => {
140
- const imports = _getImports(context);
141
- return imports.some(({ alias, mod }) => alias === name2 && mod === "@pandacss/dev");
142
- };
143
- var _getImports = (context) => {
144
- const specifiers = getImportSpecifiers(context);
145
- const imports = specifiers.map(({ specifier, mod }) => ({
146
- name: specifier.imported.name,
147
- alias: specifier.local.name,
148
- mod
149
- }));
150
- return imports;
151
- };
152
- var getImports = (context) => {
153
- if (cache.imports) {
154
- return cache.imports;
155
- }
156
- const imports = _getImports(context);
157
- const filteredImports = imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
158
- cache.imports = filteredImports;
159
- return filteredImports;
160
- };
161
- var isValidStyledProp = (node, context) => {
162
- return isJSXIdentifier(node) && isValidProperty(node.name, context);
163
- };
164
- var isPandaIsh = (name2, context) => {
165
- const imports = getImports(context);
166
- if (imports.length === 0) return false;
167
- const jsxFactory = syncAction("getJsxFactory", getSyncOpts(context));
168
- if (jsxFactory && name2 === jsxFactory) {
169
- return imports.some((imp) => imp.name === name2 || imp.alias === name2);
170
- }
171
- return syncAction("matchFile", getSyncOpts(context), name2, imports);
172
- };
173
- var findDeclaration = (name2, context) => {
174
- try {
175
- const src = context.sourceCode;
176
- if (!src) {
177
- console.warn("\u26A0\uFE0F ESLint's sourceCode is not available. Ensure that the rule is invoked with valid code.");
178
- return void 0;
179
- }
180
- let scope;
181
- if (cache.scopeAnalysis) {
182
- scope = cache.scopeAnalysis;
183
- } else {
184
- scope = (0, import_scope_manager2.analyze)(src.ast, {
185
- sourceType: "module"
186
- });
187
- cache.scopeAnalysis = scope;
188
- }
189
- const decl = scope.variables.find((v) => v.name === name2)?.defs.find((d) => isIdentifier(d.name) && d.name.name === name2)?.node;
190
- if (isVariableDeclarator(decl)) return decl;
191
- } catch (error) {
192
- console.error("Error in findDeclaration:", error);
193
- return void 0;
194
- }
195
- };
196
- var isLocalStyledFactory = (node, context) => {
197
- if (!isJSXIdentifier(node.name)) return;
198
- const decl = findDeclaration(node.name.name, context);
199
- if (!decl) return;
200
- if (!isCallExpression(decl.init)) return;
201
- if (!isIdentifier(decl.init.callee)) return;
202
- if (!isPandaIsh(decl.init.callee.name, context)) return;
203
- return true;
204
- };
205
- var isValidFile = (context) => {
206
- return syncAction("isValidFile", getSyncOpts(context));
207
- };
208
- var isValidProperty = (name2, context, calleName) => {
209
- return syncAction("isValidProperty", getSyncOpts(context), name2, calleName);
210
- };
211
- var isPandaImport = (node, context) => {
212
- const imports = getImports(context);
213
- return imports.some((imp) => imp.mod === node.source.value);
214
- };
215
- var isPandaProp = (node, context) => {
216
- const jsxAncestor = getAncestor(isJSXOpeningElement, node);
217
- if (!jsxAncestor) return;
218
- if (!isJSXMemberExpression(jsxAncestor.name) && !isJSXIdentifier(jsxAncestor.name)) return;
219
- const name2 = isJSXMemberExpression(jsxAncestor.name) ? jsxAncestor.name.object.name : jsxAncestor.name.name;
220
- const prop = node.name.name;
221
- const isPandaComponent = isPandaIsh(name2, context) || isLocalStyledFactory(jsxAncestor, context);
222
- if (!isPandaComponent) return;
223
- const patternName = isJSXMemberExpression(jsxAncestor.name) ? void 0 : name2;
224
- if (typeof prop !== "string" || !isValidProperty(prop, context, patternName)) return;
225
- return true;
226
- };
227
- var isStyledProperty = (node, context, calleeName) => {
228
- if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key)) return;
229
- if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName)) return;
230
- if (isLiteral(node.key) && typeof node.key.value === "string" && !isValidProperty(node.key.value, context, calleeName))
231
- return;
232
- if (isTemplateLiteral(node.key) && !isValidProperty(node.key.quasis[0].value.raw, context, calleeName)) return;
233
- return true;
234
- };
235
- var isInPandaFunction = (node, context) => {
236
- const callAncestor = getAncestor(isCallExpression, node);
237
- if (!callAncestor) return;
238
- let calleeName;
239
- if (isIdentifier(callAncestor.callee)) {
240
- calleeName = callAncestor.callee.name;
241
- }
242
- if (isMemberExpression(callAncestor.callee) && isIdentifier(callAncestor.callee.object)) {
243
- calleeName = callAncestor.callee.object.name;
244
- }
245
- if (!calleeName) return;
246
- if (!isPandaIsh(calleeName, context)) return;
247
- return calleeName;
248
- };
249
- var isInJSXProp = (node, context) => {
250
- const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
251
- const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
252
- if (!jsxExprAncestor || !jsxAttrAncestor) return;
253
- if (!isPandaProp(jsxAttrAncestor, context)) return;
254
- if (typeof jsxAttrAncestor.name === "string") return;
255
- if (!isValidStyledProp(jsxAttrAncestor.name, context)) return;
256
- return true;
257
- };
258
- var isPandaAttribute = (node, context) => {
259
- const callAncestor = getAncestor(isCallExpression, node);
260
- if (callAncestor) {
261
- const callee = isInPandaFunction(node, context);
262
- if (!callee) return;
263
- return isStyledProperty(node, context, callee);
264
- }
265
- return isInJSXProp(node, context) && isStyledProperty(node, context);
266
- };
267
- var resolveLonghand = (name2, context) => {
268
- return syncAction("resolveLongHand", getSyncOpts(context), name2);
269
- };
270
- var resolveShorthands = (name2, context) => {
271
- return syncAction("resolveShorthands", getSyncOpts(context), name2);
272
- };
273
- var isColorAttribute = (attr, context) => {
274
- return syncAction("isColorAttribute", getSyncOpts(context), attr);
275
- };
276
- var isColorToken = (value, context) => {
277
- if (!value) return;
278
- return syncAction("isColorToken", getSyncOpts(context), value);
279
- };
280
- var extractTokens = (value) => {
281
- const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{\r\n}]+)\}/g;
282
- const matches = [];
283
- let match;
284
- while ((match = regex.exec(value)) !== null) {
285
- const tokenFromFirstSyntax = match[1] || match[2] || match[3];
286
- const tokensFromSecondSyntax = match[4] && match[4].match(/(\w+\.\w+(\.\w+)?)/g);
287
- if (tokenFromFirstSyntax) {
288
- matches.push(tokenFromFirstSyntax);
289
- }
290
- if (tokensFromSecondSyntax) {
291
- matches.push(...tokensFromSecondSyntax);
292
- }
293
- }
294
- return matches.filter(Boolean);
295
- };
296
- var invalidTokensCache = /* @__PURE__ */ new Map();
297
- var getInvalidTokens = (value, context) => {
298
- if (invalidTokensCache.has(value)) {
299
- return invalidTokensCache.get(value);
300
- }
301
- const tokens = extractTokens(value);
302
- if (!tokens.length) return [];
303
- const invalidTokens = syncAction("filterInvalidTokens", getSyncOpts(context), tokens);
304
- invalidTokensCache.set(value, invalidTokens);
305
- return invalidTokens;
306
- };
307
- var deprecatedTokensCache = /* @__PURE__ */ new Map();
308
- var getDeprecatedTokens = (prop, value, context) => {
309
- if (deprecatedTokensCache.has(value)) {
310
- return deprecatedTokensCache.get(value);
311
- }
312
- const propCategory = syncAction("getPropCategory", getSyncOpts(context), prop);
313
- const tokens = extractTokens(value);
314
- if (!propCategory && !tokens.length) return [];
315
- const values = tokens.length ? tokens : [{ category: propCategory, value: value.split("/")[0] }];
316
- const deprecatedTokens = syncAction("filterDeprecatedTokens", getSyncOpts(context), values);
317
- deprecatedTokensCache.set(value, deprecatedTokens);
318
- return deprecatedTokens;
319
- };
320
- var getTokenImport = (context) => {
321
- const imports = _getImports(context);
322
- return imports.find((imp) => imp.name === "token");
323
- };
324
- var getTaggedTemplateCaller = (node) => {
325
- if (isIdentifier(node.tag)) {
326
- return node.tag.name;
327
- }
328
- if (isMemberExpression(node.tag)) {
329
- if (!isIdentifier(node.tag.object)) return;
330
- return node.tag.object.name;
331
- }
332
- if (isCallExpression(node.tag)) {
333
- if (!isIdentifier(node.tag.callee)) return;
334
- return node.tag.callee.name;
335
- }
336
- };
337
- function isRecipeVariant(node, context) {
338
- const caller = isInPandaFunction(node, context);
339
- if (!caller) return;
340
- const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
341
- if (!recipe) return;
342
- let currentNode = node;
343
- let length = 0;
344
- let styleObjectParent = null;
345
- while (currentNode) {
346
- const keyName = currentNode?.key?.name;
347
- if (keyName && ["base", "variants"].includes(keyName)) {
348
- styleObjectParent = keyName;
349
- }
350
- currentNode = currentNode.parent;
351
- if (!styleObjectParent) length++;
352
- }
353
- const isCvaCaller = caller === "cva";
354
- const requiredLength = isCvaCaller ? 2 : 4;
355
- const extraLength = styleObjectParent === "base" ? 0 : 4;
356
- if (length < requiredLength + extraLength) return true;
357
97
  }
358
-
359
- // src/rules/file-not-included.ts
360
- var import_utils4 = require("@typescript-eslint/utils");
361
- var RULE_NAME = "file-not-included";
362
- var rule = createRule({
363
- name: RULE_NAME,
364
- meta: {
365
- docs: {
366
- description: "Disallow the use of Panda CSS in files that are not included in the specified Panda CSS `include` config."
367
- },
368
- messages: {
369
- include: "The use of Panda CSS is not allowed in this file. Please ensure the file is included in the Panda CSS `include` configuration."
370
- },
371
- type: "problem",
372
- schema: []
373
- },
374
- defaultOptions: [],
375
- create(context) {
376
- const isFileIncluded = isValidFile(context);
377
- if (isFileIncluded) {
378
- return {};
379
- }
380
- let hasReported = false;
381
- return {
382
- ImportDeclaration(node) {
383
- if (hasReported) return;
384
- if (!isPandaImport(node, context)) return;
385
- context.report({
386
- node,
387
- messageId: "include"
388
- });
389
- hasReported = true;
390
- }
391
- };
392
- }
393
- });
394
- var file_not_included_default = rule;
395
-
396
- // src/rules/no-config-function-in-source.ts
397
- var import_utils6 = require("@typescript-eslint/utils");
398
- var RULE_NAME2 = "no-config-function-in-source";
399
- var CONFIG_FUNCTIONS = /* @__PURE__ */ new Set([
400
- "defineConfig",
401
- "defineRecipe",
402
- "defineSlotRecipe",
403
- "defineParts",
404
- "definePattern",
405
- "definePreset",
406
- "defineKeyframes",
407
- "defineGlobalStyles",
408
- "defineUtility",
409
- "defineTextStyles",
410
- "defineLayerStyles",
411
- "defineStyles",
412
- "defineTokens",
413
- "defineSemanticTokens"
414
- ]);
415
- var rule2 = createRule({
416
- name: RULE_NAME2,
417
- meta: {
418
- docs: {
419
- description: "Prohibit the use of config functions outside the Panda config file."
420
- },
421
- messages: {
422
- configFunction: "Unnecessary `{{name}}` call. Config functions should only be used in the Panda config file.",
423
- delete: "Delete `{{name}}` call."
424
- },
425
- type: "problem",
426
- hasSuggestions: true,
427
- schema: []
428
- },
429
- defaultOptions: [],
430
- create(context) {
431
- if (!hasPkgImport(context)) {
432
- return {};
433
- }
434
- const isPandaFile = isValidFile(context);
435
- if (!isPandaFile) {
436
- return {};
437
- }
438
- return {
439
- CallExpression(node) {
440
- if (!isIdentifier(node.callee)) return;
441
- const functionName = node.callee.name;
442
- if (!CONFIG_FUNCTIONS.has(functionName)) return;
443
- if (!isPandaConfigFunction(context, functionName)) return;
444
- context.report({
445
- node,
446
- messageId: "configFunction",
447
- data: {
448
- name: functionName
449
- },
450
- suggest: [
451
- {
452
- messageId: "delete",
453
- data: {
454
- name: functionName
455
- },
456
- fix(fixer) {
457
- const declaration = getAncestor(isVariableDeclaration, node);
458
- const importSpecifiers = getImportSpecifiers(context);
459
- const importSpec = importSpecifiers.find((s) => s.specifier.local.name === functionName);
460
- const fixes = [];
461
- if (declaration) {
462
- fixes.push(fixer.remove(declaration));
463
- } else {
464
- fixes.push(fixer.remove(node));
465
- }
466
- if (importSpec?.specifier) {
467
- fixes.push(fixer.remove(importSpec.specifier));
468
- }
469
- return fixes;
470
- }
471
- }
472
- ]
473
- });
474
- }
475
- };
476
- }
477
- });
478
- var no_config_function_in_source_default = rule2;
479
-
480
- // src/rules/no-debug.ts
481
- var import_utils8 = require("@typescript-eslint/utils");
482
- var RULE_NAME3 = "no-debug";
483
- var rule3 = createRule({
484
- name: RULE_NAME3,
485
- meta: {
486
- docs: {
487
- description: "Disallow the inclusion of the debug attribute when shipping code to the production environment."
488
- },
489
- messages: {
490
- debug: "Unnecessary debug utility.",
491
- prop: "Remove the debug prop.",
492
- property: "Remove the debug property."
493
- },
494
- type: "problem",
495
- hasSuggestions: true,
496
- schema: []
497
- },
498
- defaultOptions: [],
499
- create(context) {
500
- return {
501
- 'JSXAttribute[name.name="debug"]'(node) {
502
- if (!isPandaProp(node, context)) return;
503
- context.report({
504
- node,
505
- messageId: "debug",
506
- suggest: [
507
- {
508
- messageId: "prop",
509
- fix: (fixer) => fixer.remove(node)
510
- }
511
- ]
512
- });
513
- },
514
- 'Property[key.name="debug"]'(node) {
515
- if (!isPandaAttribute(node, context)) return;
516
- if (isRecipeVariant(node, context)) return;
517
- context.report({
518
- node: node.key,
519
- messageId: "debug",
520
- suggest: [
521
- {
522
- messageId: "property",
523
- fix: (fixer) => fixer.removeRange([node.range[0], node.range[1] + 1])
524
- }
525
- ]
526
- });
527
- }
528
- };
529
- }
530
- });
531
- var no_debug_default = rule3;
532
-
533
- // src/rules/no-deprecated-tokens.ts
534
- var import_utils10 = require("@typescript-eslint/utils");
535
- var import_ast_utils2 = require("@typescript-eslint/utils/ast-utils");
536
- var RULE_NAME4 = "no-deprecated-tokens";
537
- var rule4 = createRule({
538
- name: RULE_NAME4,
539
- meta: {
540
- docs: {
541
- description: "Disallow the use of deprecated tokens within token function syntax."
542
- },
543
- messages: {
544
- noDeprecatedTokenPaths: "`{{token}}` is a deprecated token.",
545
- noDeprecatedTokens: "`{{token}}` is a deprecated {{category}} token."
546
- },
547
- type: "problem",
548
- schema: []
549
- },
550
- defaultOptions: [],
551
- create(context) {
552
- const deprecatedTokensCache2 = /* @__PURE__ */ new Map();
553
- const sendReport = (prop, node, value) => {
554
- if (!value) return;
555
- let tokens = deprecatedTokensCache2.get(value);
556
- if (!tokens) {
557
- tokens = getDeprecatedTokens(prop, value, context);
558
- deprecatedTokensCache2.set(value, tokens);
559
- }
560
- if (tokens.length === 0) return;
561
- tokens.forEach((token) => {
562
- context.report({
563
- node,
564
- messageId: typeof token === "string" ? "noDeprecatedTokenPaths" : "noDeprecatedTokens",
565
- data: {
566
- token: typeof token === "string" ? token : token.value,
567
- category: typeof token === "string" ? void 0 : token.category
568
- }
569
- });
570
- });
571
- };
572
- const handleLiteralOrTemplate = (prop, node) => {
573
- if (!node) return;
574
- if (isLiteral(node)) {
575
- const value = node.value?.toString();
576
- sendReport(prop, node, value);
577
- } else if (isTemplateLiteral(node) && node.expressions.length === 0) {
578
- const value = node.quasis[0].value.raw;
579
- sendReport(prop, node.quasis[0], value);
580
- }
581
- };
582
- return {
583
- JSXAttribute(node) {
584
- if (!node.value || !isPandaProp(node, context)) return;
585
- const prop = node.name.name;
586
- if (isLiteral(node.value)) {
587
- handleLiteralOrTemplate(prop, node.value);
588
- } else if (isJSXExpressionContainer(node.value)) {
589
- handleLiteralOrTemplate(prop, node.value.expression);
590
- }
591
- },
592
- Property(node) {
593
- if (!isIdentifier(node.key) || !(0, import_ast_utils2.isNodeOfTypes)([import_utils10.AST_NODE_TYPES.Literal, import_utils10.AST_NODE_TYPES.TemplateLiteral])(node.value) || !isPandaAttribute(node, context) || isRecipeVariant(node, context)) {
594
- return;
595
- }
596
- const prop = node.key.name;
597
- handleLiteralOrTemplate(prop, node.value);
598
- },
599
- TaggedTemplateExpression(node) {
600
- const caller = getTaggedTemplateCaller(node);
601
- if (!caller || !isPandaIsh(caller, context)) return;
602
- const quasis = node.quasi.quasis;
603
- quasis.forEach((quasi) => {
604
- const styles = quasi.value.raw;
605
- if (!styles) return;
606
- let tokens = deprecatedTokensCache2.get(styles);
607
- if (!tokens) {
608
- tokens = getDeprecatedTokens("", styles, context);
609
- deprecatedTokensCache2.set(styles, tokens);
610
- }
611
- if (tokens.length === 0) return;
612
- tokens.forEach((token) => {
613
- const tokenValue = typeof token === "string" ? token : token.value;
614
- let index = styles.indexOf(tokenValue);
615
- while (index !== -1) {
616
- const start = quasi.range[0] + index + 1;
617
- const end = start + tokenValue.length;
618
- context.report({
619
- loc: {
620
- start: context.sourceCode.getLocFromIndex(start),
621
- end: context.sourceCode.getLocFromIndex(end)
622
- },
623
- messageId: typeof token === "string" ? "noDeprecatedTokenPaths" : "noDeprecatedTokens",
624
- data: {
625
- token: tokenValue,
626
- category: typeof token === "string" ? void 0 : token.category
627
- }
628
- });
629
- index = styles.indexOf(tokenValue, index + tokenValue.length);
630
- }
631
- });
632
- });
633
- }
634
- };
635
- }
636
- });
637
- var no_deprecated_tokens_default = rule4;
638
-
639
- // src/rules/no-dynamic-styling.ts
640
- var import_utils11 = require("@typescript-eslint/utils");
641
- var RULE_NAME5 = "no-dynamic-styling";
642
- var rule5 = createRule({
643
- name: RULE_NAME5,
644
- meta: {
645
- docs: {
646
- description: "Ensure users don't use dynamic styling. Prefer static styles, leverage CSS variables, or recipes for known dynamic styles."
647
- },
648
- messages: {
649
- dynamic: "Remove dynamic value. Prefer static styles.",
650
- dynamicProperty: "Remove dynamic property. Prefer static style property.",
651
- dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition."
652
- },
653
- type: "problem",
654
- schema: []
655
- },
656
- defaultOptions: [],
657
- create(context) {
658
- function isStaticValue(node) {
659
- if (!node) return false;
660
- if (isLiteral(node)) return true;
661
- if (isTemplateLiteral(node) && node.expressions.length === 0) return true;
662
- if (isObjectExpression(node)) return true;
663
- return false;
664
- }
665
- function checkArrayElements(array) {
666
- array.elements.forEach((element) => {
667
- if (!element) return;
668
- if (isStaticValue(element)) return;
669
- context.report({
670
- node: element,
671
- messageId: "dynamic"
672
- });
673
- });
674
- }
675
- return {
676
- // JSX Attributes
677
- JSXAttribute(node) {
678
- if (!node.value) return;
679
- if (isLiteral(node.value)) return;
680
- if (!isPandaProp(node, context)) return;
681
- if (isJSXExpressionContainer(node.value)) {
682
- const expr = node.value.expression;
683
- if (isStaticValue(expr)) return;
684
- if (isArrayExpression(expr)) {
685
- checkArrayElements(expr);
686
- return;
687
- }
688
- }
689
- context.report({
690
- node: node.value,
691
- messageId: "dynamic"
692
- });
693
- },
694
- // Dynamic properties with computed keys
695
- "Property[computed=true]": (node) => {
696
- if (!isInPandaFunction(node, context)) return;
697
- context.report({
698
- node: node.key,
699
- messageId: isRecipeVariant(node, context) ? "dynamicRecipeVariant" : "dynamicProperty"
700
- });
701
- },
702
- // Object Properties
703
- Property(node) {
704
- if (!isIdentifier(node.key)) return;
705
- if (!isPandaAttribute(node, context)) return;
706
- if (isRecipeVariant(node, context)) return;
707
- if (isStaticValue(node.value)) return;
708
- if (isArrayExpression(node.value)) {
709
- checkArrayElements(node.value);
710
- return;
711
- }
712
- context.report({
713
- node: node.value,
714
- messageId: "dynamic"
715
- });
716
- }
717
- };
718
- }
719
- });
720
- var no_dynamic_styling_default = rule5;
721
-
722
- // src/rules/no-escape-hatch.ts
723
- var import_shared = require("@pandacss/shared");
724
- var import_utils14 = require("@typescript-eslint/utils");
725
- var RULE_NAME6 = "no-escape-hatch";
726
- var rule6 = createRule({
727
- name: RULE_NAME6,
728
- meta: {
729
- docs: {
730
- description: "Prohibit the use of escape hatch syntax in the code."
731
- },
732
- messages: {
733
- escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. Define a corresponding token in your design system for better consistency and maintainability.",
734
- remove: "Remove the square brackets (`[]`)."
735
- },
736
- type: "problem",
737
- hasSuggestions: true,
738
- schema: []
739
- },
740
- defaultOptions: [],
741
- create(context) {
742
- const removeBrackets = (range) => {
743
- const [start, end] = range;
744
- return [start + 1, end - 1];
745
- };
746
- const hasEscapeHatch = (value) => {
747
- if (!value) return false;
748
- if (!value.includes("[")) return false;
749
- return (0, import_shared.getArbitraryValue)(value) !== value.trim();
750
- };
751
- const handleNodeValue = (node, value) => {
752
- if (!hasEscapeHatch(value)) return;
753
- context.report({
754
- node,
755
- messageId: "escapeHatch",
756
- suggest: [
757
- {
758
- messageId: "remove",
759
- fix: (fixer) => {
760
- return fixer.replaceTextRange(removeBrackets(node.range), (0, import_shared.getArbitraryValue)(value));
761
- }
762
- }
763
- ]
764
- });
765
- };
766
- return {
767
- JSXAttribute(node) {
768
- if (!node.value) return;
769
- if (!isPandaProp(node, context)) return;
770
- const { value } = node;
771
- if (isLiteral(value)) {
772
- const val = value.value?.toString() ?? "";
773
- handleNodeValue(value, val);
774
- } else if (isJSXExpressionContainer(value)) {
775
- const expr = value.expression;
776
- if (isLiteral(expr)) {
777
- const val = expr.value?.toString() ?? "";
778
- handleNodeValue(expr, val);
779
- } else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
780
- const val = expr.quasis[0].value.raw;
781
- handleNodeValue(expr.quasis[0], val);
782
- }
783
- }
784
- },
785
- Property(node) {
786
- if (!isIdentifier(node.key)) return;
787
- if (!isPandaAttribute(node, context)) return;
788
- if (isRecipeVariant(node, context)) return;
789
- const value = node.value;
790
- if (isLiteral(value)) {
791
- const val = value.value?.toString() ?? "";
792
- handleNodeValue(value, val);
793
- } else if (isTemplateLiteral(value) && value.expressions.length === 0) {
794
- const val = value.quasis[0].value.raw;
795
- handleNodeValue(value.quasis[0], val);
796
- }
797
- }
798
- };
799
- }
800
- });
801
- var no_escape_hatch_default = rule6;
802
-
803
- // src/rules/no-hardcoded-color.ts
804
- var import_utils16 = require("@typescript-eslint/utils");
805
- var RULE_NAME7 = "no-hardcoded-color";
806
- var rule7 = createRule({
807
- name: RULE_NAME7,
808
- meta: {
809
- docs: {
810
- description: "Enforce the exclusive use of design tokens as values for colors within the codebase."
811
- },
812
- messages: {
813
- invalidColor: "`{{color}}` is not a valid color token."
814
- },
815
- type: "problem",
816
- schema: [
817
- {
818
- type: "object",
819
- properties: {
820
- noOpacity: {
821
- type: "boolean"
822
- },
823
- whitelist: {
824
- type: "array",
825
- items: {
826
- type: "string",
827
- minLength: 0
828
- },
829
- uniqueItems: true
830
- }
831
- },
832
- additionalProperties: false
833
- }
834
- ]
835
- },
836
- defaultOptions: [
837
- {
838
- noOpacity: false,
839
- whitelist: []
840
- }
841
- ],
842
- create(context) {
843
- const noOpacity = context.options[0]?.noOpacity;
844
- const whitelist = context.options[0]?.whitelist ?? [];
845
- const colorTokenCache = new Map(whitelist?.map((item) => [item, true]));
846
- const colorAttributeCache = /* @__PURE__ */ new Map();
847
- const isColorToken2 = (token) => {
848
- if (colorTokenCache.has(token)) {
849
- return colorTokenCache.get(token);
850
- }
851
- const result = isColorToken(token, context);
852
- colorTokenCache.set(token, result);
853
- return !!result;
854
- };
855
- const isColorAttribute2 = (attribute) => {
856
- if (colorAttributeCache.has(attribute)) {
857
- return colorAttributeCache.get(attribute);
858
- }
859
- const result = isColorAttribute(attribute, context);
860
- colorAttributeCache.set(attribute, result);
861
- return result;
862
- };
863
- const isTokenFunctionUsed = (value) => {
864
- if (!value) return false;
865
- const tokens = extractTokens(value);
866
- return tokens.length > 0;
867
- };
868
- const isCssVariable = (value) => {
869
- if (!value) return false;
870
- return value.trim().startsWith("var(");
871
- };
872
- const isValidColorToken = (value) => {
873
- if (!value) return false;
874
- const [colorToken, opacity] = value.split("/");
875
- const hasOpacity = opacity !== void 0 && opacity.length > 0;
876
- const isValidToken = isColorToken2(colorToken);
877
- return noOpacity ? isValidToken && !hasOpacity : isValidToken;
878
- };
879
- const reportInvalidColor = (node, color) => {
880
- context.report({
881
- node,
882
- messageId: "invalidColor",
883
- data: {
884
- color
885
- }
886
- });
887
- };
888
- const checkColorValue = (node, value, attributeName) => {
889
- if (!isColorAttribute2(attributeName)) return;
890
- if (isTokenFunctionUsed(value)) return;
891
- if (isCssVariable(value)) return;
892
- if (isValidColorToken(value)) return;
893
- reportInvalidColor(node, value);
894
- };
895
- return {
896
- JSXAttribute(node) {
897
- if (!isJSXIdentifier(node.name)) return;
898
- if (!isPandaProp(node, context) || !node.value) return;
899
- const attributeName = node.name.name;
900
- const valueNode = node.value;
901
- if (isLiteral(valueNode)) {
902
- const value = valueNode.value?.toString() || "";
903
- checkColorValue(valueNode, value, attributeName);
904
- } else if (isJSXExpressionContainer(valueNode)) {
905
- const expression = valueNode.expression;
906
- if (isLiteral(expression)) {
907
- const value = expression.value?.toString() || "";
908
- checkColorValue(expression, value, attributeName);
909
- } else if (isTemplateLiteral(expression) && expression.expressions.length === 0) {
910
- const value = expression.quasis[0].value.raw;
911
- checkColorValue(expression.quasis[0], value, attributeName);
912
- }
913
- }
914
- },
915
- Property(node) {
916
- if (!isIdentifier(node.key)) return;
917
- if (!isPandaAttribute(node, context)) return;
918
- if (isRecipeVariant(node, context)) return;
919
- const attributeName = node.key.name;
920
- const valueNode = node.value;
921
- if (isLiteral(valueNode)) {
922
- const value = valueNode.value?.toString() || "";
923
- checkColorValue(valueNode, value, attributeName);
924
- } else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
925
- const value = valueNode.quasis[0].value.raw;
926
- checkColorValue(valueNode.quasis[0], value, attributeName);
927
- }
928
- }
929
- };
930
- }
931
- });
932
- var no_hardcoded_color_default = rule7;
933
-
934
- // src/rules/no-important.ts
935
- var import_shared2 = require("@pandacss/shared");
936
- var import_utils18 = require("@typescript-eslint/utils");
937
- var exclamationRegex = /\s*!$/;
938
- var importantRegex = /\s*!important\s*$/;
939
- var RULE_NAME8 = "no-important";
940
- var rule8 = createRule({
941
- name: RULE_NAME8,
942
- meta: {
943
- docs: {
944
- description: "Disallow usage of !important keyword. Prioritize specificity for a maintainable and predictable styling structure."
945
- },
946
- messages: {
947
- important: "Avoid using the {{keyword}} keyword. Refactor your code to prioritize specificity for predictable styling.",
948
- remove: "Remove the `{{keyword}}` keyword."
949
- },
950
- type: "problem",
951
- hasSuggestions: true,
952
- schema: []
953
- },
954
- defaultOptions: [],
955
- create(context) {
956
- const removeQuotes = (range) => {
957
- const [start, end] = range;
958
- return [start + 1, end - 1];
959
- };
960
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
961
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
962
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
963
- const isCachedPandaProp = (node) => {
964
- if (pandaPropCache.has(node)) {
965
- return pandaPropCache.get(node);
966
- }
967
- const result = isPandaProp(node, context);
968
- pandaPropCache.set(node, result);
969
- return !!result;
970
- };
971
- const isCachedPandaAttribute = (node) => {
972
- if (pandaAttributeCache.has(node)) {
973
- return pandaAttributeCache.get(node);
974
- }
975
- const result = isPandaAttribute(node, context);
976
- pandaAttributeCache.set(node, result);
977
- return !!result;
978
- };
979
- const isCachedRecipeVariant = (node) => {
980
- if (recipeVariantCache.has(node)) {
981
- return recipeVariantCache.get(node);
982
- }
983
- const result = isRecipeVariant(node, context);
984
- recipeVariantCache.set(node, result);
985
- return !!result;
986
- };
987
- const hasImportantKeyword = (value) => {
988
- if (!value) return false;
989
- const arbitraryValue = (0, import_shared2.getArbitraryValue)(value);
990
- return exclamationRegex.test(arbitraryValue) || importantRegex.test(arbitraryValue);
991
- };
992
- const removeImportantKeyword = (input) => {
993
- if (importantRegex.test(input)) {
994
- return { fixed: input.replace(importantRegex, "").trimEnd(), keyword: "!important" };
995
- } else if (exclamationRegex.test(input)) {
996
- return { fixed: input.replace(exclamationRegex, "").trimEnd(), keyword: "!" };
997
- } else {
998
- return { fixed: input, keyword: null };
999
- }
1000
- };
1001
- const handleNodeValue = (node, value) => {
1002
- if (!hasImportantKeyword(value)) return;
1003
- const { fixed, keyword } = removeImportantKeyword(value);
1004
- context.report({
1005
- node,
1006
- messageId: "important",
1007
- data: { keyword },
1008
- suggest: [
1009
- {
1010
- messageId: "remove",
1011
- data: { keyword },
1012
- fix: (fixer) => {
1013
- return fixer.replaceTextRange(removeQuotes(node.range), fixed);
1014
- }
1015
- }
1016
- ]
1017
- });
1018
- };
1019
- return {
1020
- // JSX Attributes
1021
- JSXAttribute(node) {
1022
- if (!node.value) return;
1023
- if (!isCachedPandaProp(node)) return;
1024
- const valueNode = node.value;
1025
- if (isLiteral(valueNode)) {
1026
- const val = valueNode.value?.toString() ?? "";
1027
- handleNodeValue(valueNode, val);
1028
- } else if (isJSXExpressionContainer(valueNode)) {
1029
- const expr = valueNode.expression;
1030
- if (isLiteral(expr)) {
1031
- const val = expr.value?.toString() ?? "";
1032
- handleNodeValue(expr, val);
1033
- } else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
1034
- const val = expr.quasis[0].value.raw;
1035
- handleNodeValue(expr.quasis[0], val);
1036
- }
1037
- }
1038
- },
1039
- // Object Properties
1040
- Property(node) {
1041
- if (!isIdentifier(node.key)) return;
1042
- if (!isCachedPandaAttribute(node)) return;
1043
- if (isCachedRecipeVariant(node)) return;
1044
- const valueNode = node.value;
1045
- if (isLiteral(valueNode)) {
1046
- const val = valueNode.value?.toString() ?? "";
1047
- handleNodeValue(valueNode, val);
1048
- } else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
1049
- const val = valueNode.quasis[0].value.raw;
1050
- handleNodeValue(valueNode.quasis[0], val);
1051
- }
1052
- }
1053
- };
1054
- }
1055
- });
1056
- var no_important_default = rule8;
1057
-
1058
- // src/rules/no-invalid-nesting.ts
1059
- var import_utils20 = require("@typescript-eslint/utils");
1060
- var RULE_NAME9 = "no-invalid-nesting";
1061
- var rule9 = createRule({
1062
- name: RULE_NAME9,
1063
- meta: {
1064
- docs: {
1065
- description: "Warn against invalid nesting. Nested styles must contain the `&` character."
1066
- },
1067
- messages: {
1068
- nesting: "Invalid style nesting. Nested styles must contain the `&` character."
1069
- },
1070
- type: "problem",
1071
- schema: []
1072
- },
1073
- defaultOptions: [],
1074
- create(context) {
1075
- const pandaFunctionCache = /* @__PURE__ */ new WeakMap();
1076
- const jsxPropCache = /* @__PURE__ */ new WeakMap();
1077
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
1078
- const styledPropertyCache = /* @__PURE__ */ new WeakMap();
1079
- const isCachedInPandaFunction = (node) => {
1080
- if (pandaFunctionCache.has(node)) {
1081
- return pandaFunctionCache.get(node);
1082
- }
1083
- const result = !!isInPandaFunction(node, context);
1084
- pandaFunctionCache.set(node, result);
1085
- return !!result;
1086
- };
1087
- const isCachedInJSXProp = (node) => {
1088
- if (jsxPropCache.has(node)) {
1089
- return jsxPropCache.get(node);
1090
- }
1091
- const result = isInJSXProp(node, context);
1092
- jsxPropCache.set(node, result);
1093
- return !!result;
1094
- };
1095
- const isCachedRecipeVariant = (node) => {
1096
- if (recipeVariantCache.has(node)) {
1097
- return recipeVariantCache.get(node);
1098
- }
1099
- const result = isRecipeVariant(node, context);
1100
- recipeVariantCache.set(node, result);
1101
- return !!result;
1102
- };
1103
- const isCachedStyledProperty = (node) => {
1104
- if (styledPropertyCache.has(node)) {
1105
- return styledPropertyCache.get(node);
1106
- }
1107
- const result = isStyledProperty(node, context);
1108
- styledPropertyCache.set(node, result);
1109
- return !!result;
1110
- };
1111
- const isInvalidNestingSelector = (node) => {
1112
- if (isLiteral(node) && typeof node.value === "string") {
1113
- return !node.value.includes("&");
1114
- } else if (isTemplateLiteral(node) && node.expressions.length === 0) {
1115
- return !node.quasis[0].value.raw.includes("&");
1116
- }
1117
- return false;
1118
- };
1119
- return {
1120
- // Use AST selector to target Property nodes with non-Identifier keys whose value is an ObjectExpression
1121
- 'Property[key.type!=/Identifier/][value.type="ObjectExpression"]'(node) {
1122
- const inPandaFunction = isCachedInPandaFunction(node);
1123
- const inJSXProp = isCachedInJSXProp(node);
1124
- if (!inPandaFunction && !inJSXProp) return;
1125
- if (isCachedRecipeVariant(node)) return;
1126
- if (isCachedStyledProperty(node)) return;
1127
- const keyNode = node.key;
1128
- if (isInvalidNestingSelector(keyNode)) {
1129
- context.report({
1130
- node: keyNode,
1131
- messageId: "nesting"
1132
- });
1133
- }
1134
- }
1135
- };
1136
- }
1137
- });
1138
- var no_invalid_nesting_default = rule9;
1139
-
1140
- // src/rules/no-invalid-token-paths.ts
1141
- var import_utils22 = require("@typescript-eslint/utils");
1142
- var import_ast_utils3 = require("@typescript-eslint/utils/ast-utils");
1143
- var RULE_NAME10 = "no-invalid-token-paths";
1144
- var rule10 = createRule({
1145
- name: RULE_NAME10,
1146
- meta: {
1147
- docs: {
1148
- description: "Disallow the use of invalid token paths within token function syntax."
1149
- },
1150
- messages: {
1151
- noInvalidTokenPaths: "`{{token}}` is an invalid token path."
1152
- },
1153
- type: "problem",
1154
- schema: []
1155
- },
1156
- defaultOptions: [],
1157
- create(context) {
1158
- const invalidTokensCache2 = /* @__PURE__ */ new Map();
1159
- const sendReport = (node, value) => {
1160
- if (!value) return;
1161
- let tokens = invalidTokensCache2.get(value);
1162
- if (!tokens) {
1163
- tokens = getInvalidTokens(value, context);
1164
- invalidTokensCache2.set(value, tokens);
1165
- }
1166
- if (tokens.length === 0) return;
1167
- tokens.forEach((token) => {
1168
- context.report({
1169
- node,
1170
- messageId: "noInvalidTokenPaths",
1171
- data: { token }
1172
- });
1173
- });
1174
- };
1175
- const handleLiteralOrTemplate = (node) => {
1176
- if (!node) return;
1177
- if (isLiteral(node)) {
1178
- const value = node.value?.toString();
1179
- sendReport(node, value);
1180
- } else if (isTemplateLiteral(node) && node.expressions.length === 0) {
1181
- const value = node.quasis[0].value.raw;
1182
- sendReport(node.quasis[0], value);
1183
- }
1184
- };
1185
- return {
1186
- JSXAttribute(node) {
1187
- if (!node.value || !isPandaProp(node, context)) return;
1188
- if (isLiteral(node.value)) {
1189
- handleLiteralOrTemplate(node.value);
1190
- } else if (isJSXExpressionContainer(node.value)) {
1191
- handleLiteralOrTemplate(node.value.expression);
1192
- }
1193
- },
1194
- Property(node) {
1195
- if (!isIdentifier(node.key) || !(0, import_ast_utils3.isNodeOfTypes)([import_utils22.AST_NODE_TYPES.Literal, import_utils22.AST_NODE_TYPES.TemplateLiteral])(node.value) || !isPandaAttribute(node, context) || isRecipeVariant(node, context)) {
1196
- return;
1197
- }
1198
- handleLiteralOrTemplate(node.value);
1199
- },
1200
- TaggedTemplateExpression(node) {
1201
- const caller = getTaggedTemplateCaller(node);
1202
- if (!caller || !isPandaIsh(caller, context)) return;
1203
- const quasis = node.quasi.quasis;
1204
- quasis.forEach((quasi) => {
1205
- const styles = quasi.value.raw;
1206
- if (!styles) return;
1207
- let tokens = invalidTokensCache2.get(styles);
1208
- if (!tokens) {
1209
- tokens = getInvalidTokens(styles, context);
1210
- invalidTokensCache2.set(styles, tokens);
1211
- }
1212
- if (tokens.length === 0) return;
1213
- tokens.forEach((token) => {
1214
- let index = styles.indexOf(token);
1215
- while (index !== -1) {
1216
- const start = quasi.range[0] + index + 1;
1217
- const end = start + token.length;
1218
- context.report({
1219
- loc: {
1220
- start: context.sourceCode.getLocFromIndex(start),
1221
- end: context.sourceCode.getLocFromIndex(end)
1222
- },
1223
- messageId: "noInvalidTokenPaths",
1224
- data: { token }
1225
- });
1226
- index = styles.indexOf(token, index + token.length);
1227
- }
1228
- });
1229
- });
1230
- }
1231
- };
1232
- }
1233
- });
1234
- var no_invalid_token_paths_default = rule10;
1235
-
1236
- // src/rules/no-margin-properties.ts
1237
- var RULE_NAME11 = "no-margin-properties";
1238
- var rule11 = createRule({
1239
- name: RULE_NAME11,
1240
- meta: {
1241
- docs: {
1242
- description: "Discourage using margin properties for spacing; prefer defining spacing in parent elements with `flex` or `grid` using the `gap` property for a more resilient layout. Margins make components less reusable in other contexts."
1243
- },
1244
- messages: {
1245
- noMargin: "Use flex or grid with the `gap` property to define spacing in parent elements for a more resilient layout."
1246
- },
1247
- type: "suggestion",
1248
- schema: [
1249
- {
1250
- type: "object",
1251
- properties: {
1252
- whitelist: {
1253
- type: "array",
1254
- items: {
1255
- type: "string",
1256
- minLength: 0
1257
- },
1258
- uniqueItems: true
1259
- }
1260
- },
1261
- additionalProperties: false
1262
- }
1263
- ]
1264
- },
1265
- defaultOptions: [
1266
- {
1267
- whitelist: []
1268
- }
1269
- ],
1270
- create(context) {
1271
- const whitelist = context.options[0]?.whitelist ?? [];
1272
- const longhandCache = /* @__PURE__ */ new Map();
1273
- const getLonghand = (name2) => {
1274
- if (longhandCache.has(name2)) {
1275
- return longhandCache.get(name2);
1276
- }
1277
- const longhand = resolveLonghand(name2, context) ?? name2;
1278
- longhandCache.set(name2, longhand);
1279
- return longhand;
1280
- };
1281
- const marginRegex = /margin/i;
1282
- const isMarginProperty = (name2) => {
1283
- const longhand = getLonghand(name2).toLowerCase();
1284
- return marginRegex.test(longhand);
1285
- };
1286
- const sendReport = (node) => {
1287
- if (whitelist.includes(node.name)) return;
1288
- if (!isMarginProperty(node.name)) return;
1289
- context.report({
1290
- node,
1291
- messageId: "noMargin"
1292
- });
1293
- };
1294
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
1295
- const isCachedPandaProp = (node) => {
1296
- if (pandaPropCache.has(node)) {
1297
- return pandaPropCache.get(node);
1298
- }
1299
- const result = isPandaProp(node, context);
1300
- pandaPropCache.set(node, result);
1301
- return !!result;
1302
- };
1303
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
1304
- const isCachedPandaAttribute = (node) => {
1305
- if (pandaAttributeCache.has(node)) {
1306
- return pandaAttributeCache.get(node);
1307
- }
1308
- const result = isPandaAttribute(node, context);
1309
- pandaAttributeCache.set(node, result);
1310
- return !!result;
1311
- };
1312
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
1313
- const isCachedRecipeVariant = (node) => {
1314
- if (recipeVariantCache.has(node)) {
1315
- return recipeVariantCache.get(node);
1316
- }
1317
- const result = isRecipeVariant(node, context);
1318
- recipeVariantCache.set(node, result);
1319
- return !!result;
1320
- };
1321
- return {
1322
- JSXAttribute(node) {
1323
- if (!isJSXIdentifier(node.name)) return;
1324
- if (!isCachedPandaProp(node)) return;
1325
- sendReport(node.name);
1326
- },
1327
- Property(node) {
1328
- if (!isIdentifier(node.key)) return;
1329
- if (!isCachedPandaAttribute(node)) return;
1330
- if (isCachedRecipeVariant(node)) return;
1331
- sendReport(node.key);
1332
- }
1333
- };
1334
- }
1335
- });
1336
- var no_margin_properties_default = rule11;
1337
-
1338
- // src/utils/physical-properties.ts
1339
- var physicalProperties = {
1340
- borderBottom: "borderBlockEnd",
1341
- borderBottomColor: "borderBlockEndColor",
1342
- borderBottomStyle: "borderBlockEndStyle",
1343
- borderBottomWidth: "borderBlockEndWidth",
1344
- borderTop: "borderBlockStart",
1345
- borderTopColor: "borderBlockStartColor",
1346
- borderTopStyle: "borderBlockStartStyle",
1347
- borderTopWidth: "borderBlockStartWidth",
1348
- borderRight: "borderInlineEnd",
1349
- borderRightColor: "borderInlineEndColor",
1350
- borderRightStyle: "borderInlineEndStyle",
1351
- borderRightWidth: "borderInlineEndWidth",
1352
- borderLeft: "borderInlineStart",
1353
- borderLeftColor: "borderInlineStartColor",
1354
- borderLeftStyle: "borderInlineStartStyle",
1355
- borderLeftWidth: "borderInlineStartWidth",
1356
- borderTopLeftRadius: "borderStartStartRadius",
1357
- borderBottomLeftRadius: "borderEndStartRadius",
1358
- borderTopRightRadius: "borderStartEndRadius",
1359
- borderBottomRightRadius: "borderEndEndRadius",
1360
- marginBottom: "marginBlockEnd",
1361
- marginTop: "marginBlockStart",
1362
- marginRight: "marginInlineEnd",
1363
- marginLeft: "marginInlineStart",
1364
- paddingBottom: "paddingBlockEnd",
1365
- paddingTop: "paddingBlockStart",
1366
- paddingRight: "paddingInlineEnd",
1367
- paddingLeft: "paddingInlineStart",
1368
- left: "insetInlineStart",
1369
- right: "insetInlineEnd",
1370
- top: "insetBlockStart",
1371
- bottom: "insetBlockEnd"
1372
- };
1373
- var physicalPropertyValues = {
1374
- // text-align physical values mapped to logical values
1375
- textAlign: {
1376
- left: "start",
1377
- right: "end"
1378
- }
1379
- };
1380
-
1381
- // src/rules/no-physical-properties.ts
1382
- var RULE_NAME12 = "no-physical-properties";
1383
- var MESSAGES = {
1384
- physical: "Use logical property instead of {{physical}}. Prefer `{{logical}}`.",
1385
- physicalValue: "Use logical value instead of {{physical}}. Prefer `{{logical}}`.",
1386
- replace: "Replace `{{physical}}` with `{{logical}}`."
1387
- };
1388
- var PropertyCache = class {
1389
- longhandCache = /* @__PURE__ */ new Map();
1390
- pandaPropCache = /* @__PURE__ */ new WeakMap();
1391
- pandaAttributeCache = /* @__PURE__ */ new WeakMap();
1392
- recipeVariantCache = /* @__PURE__ */ new WeakMap();
1393
- getLonghand(name2, context) {
1394
- if (this.longhandCache.has(name2)) {
1395
- return this.longhandCache.get(name2);
1396
- }
1397
- const longhand = resolveLonghand(name2, context) ?? name2;
1398
- this.longhandCache.set(name2, longhand);
1399
- return longhand;
1400
- }
1401
- isPandaProp(node, context) {
1402
- if (this.pandaPropCache.has(node)) {
1403
- return this.pandaPropCache.get(node);
1404
- }
1405
- const result = isPandaProp(node, context);
1406
- this.pandaPropCache.set(node, result);
1407
- return !!result;
1408
- }
1409
- isPandaAttribute(node, context) {
1410
- if (this.pandaAttributeCache.has(node)) {
1411
- return this.pandaAttributeCache.get(node);
1412
- }
1413
- const result = isPandaAttribute(node, context);
1414
- this.pandaAttributeCache.set(node, result);
1415
- return !!result;
1416
- }
1417
- isRecipeVariant(node, context) {
1418
- if (this.recipeVariantCache.has(node)) {
1419
- return this.recipeVariantCache.get(node);
1420
- }
1421
- const result = isRecipeVariant(node, context);
1422
- this.recipeVariantCache.set(node, result);
1423
- return !!result;
1424
- }
1425
- };
1426
- var extractStringLiteralValue = (valueNode) => {
1427
- if (isLiteral(valueNode) && typeof valueNode.value === "string") {
1428
- return valueNode.value;
1429
- }
1430
- if (isJSXExpressionContainer(valueNode) && isLiteral(valueNode.expression) && typeof valueNode.expression.value === "string") {
1431
- return valueNode.expression.value;
1432
- }
1433
- return null;
1434
- };
1435
- var createPropertyReport = (node, longhandName, logical, context) => {
1436
- const physicalName = `\`${node.name}\`${longhandName !== node.name ? ` (resolved to \`${longhandName}\`)` : ""}`;
1437
- context.report({
1438
- node,
1439
- messageId: "physical",
1440
- data: { physical: physicalName, logical },
1441
- suggest: [
1442
- {
1443
- messageId: "replace",
1444
- data: { physical: node.name, logical },
1445
- fix: (fixer) => fixer.replaceText(node, logical)
1446
- }
1447
- ]
1448
- });
1449
- };
1450
- var createValueReport = (valueNode, valueText, logical, context) => {
1451
- context.report({
1452
- node: valueNode,
1453
- messageId: "physicalValue",
1454
- data: { physical: `"${valueText}"`, logical: `"${logical}"` },
1455
- suggest: [
1456
- {
1457
- messageId: "replace",
1458
- data: { physical: `"${valueText}"`, logical: `"${logical}"` },
1459
- fix: (fixer) => {
1460
- if (isLiteral(valueNode)) {
1461
- return fixer.replaceText(valueNode, `"${logical}"`);
1462
- }
1463
- if (isJSXExpressionContainer(valueNode) && isLiteral(valueNode.expression)) {
1464
- return fixer.replaceText(valueNode.expression, `"${logical}"`);
1465
- }
1466
- return null;
1467
- }
1468
- }
1469
- ]
1470
- });
1471
- };
1472
- var rule12 = createRule({
1473
- name: RULE_NAME12,
1474
- meta: {
1475
- docs: {
1476
- description: "Encourage the use of logical properties over physical properties to foster a responsive and adaptable user interface."
1477
- },
1478
- messages: MESSAGES,
1479
- type: "suggestion",
1480
- hasSuggestions: true,
1481
- schema: [
1482
- {
1483
- type: "object",
1484
- properties: {
1485
- whitelist: {
1486
- type: "array",
1487
- items: {
1488
- type: "string",
1489
- minLength: 0
1490
- },
1491
- uniqueItems: true
1492
- }
1493
- },
1494
- additionalProperties: false
1495
- }
1496
- ]
1497
- },
1498
- defaultOptions: [{ whitelist: [] }],
1499
- create(context) {
1500
- const whitelist = context.options[0]?.whitelist ?? [];
1501
- const cache2 = new PropertyCache();
1502
- const checkPropertyName = (node) => {
1503
- if (whitelist.includes(node.name)) return;
1504
- const longhandName = cache2.getLonghand(node.name, context);
1505
- if (!(longhandName in physicalProperties)) return;
1506
- const logical = physicalProperties[longhandName];
1507
- createPropertyReport(node, longhandName, logical, context);
1508
- };
1509
- const checkPropertyValue = (keyNode, valueNode) => {
1510
- const propName = keyNode.name;
1511
- if (!(propName in physicalPropertyValues)) return false;
1512
- const valueText = extractStringLiteralValue(valueNode);
1513
- if (valueText === null) return false;
1514
- const valueMap = physicalPropertyValues[propName];
1515
- if (!valueMap[valueText]) return false;
1516
- createValueReport(valueNode, valueText, valueMap[valueText], context);
1517
- return true;
1518
- };
1519
- return {
1520
- JSXAttribute(node) {
1521
- if (!isJSXIdentifier(node.name)) return;
1522
- if (!cache2.isPandaProp(node, context)) return;
1523
- checkPropertyName(node.name);
1524
- if (node.value) {
1525
- checkPropertyValue(node.name, node.value);
1526
- }
1527
- },
1528
- Property(node) {
1529
- if (!isIdentifier(node.key)) return;
1530
- if (!cache2.isPandaAttribute(node, context)) return;
1531
- if (cache2.isRecipeVariant(node, context)) return;
1532
- checkPropertyName(node.key);
1533
- if (node.value) {
1534
- checkPropertyValue(node.key, node.value);
1535
- }
1536
- }
1537
- };
1538
- }
1539
- });
1540
- var no_physical_properties_default = rule12;
1541
-
1542
- // src/rules/no-property-renaming.ts
1543
- var RULE_NAME13 = "no-property-renaming";
1544
- var rule13 = createRule({
1545
- name: RULE_NAME13,
1546
- meta: {
1547
- docs: {
1548
- description: "Ensure that properties for patterns or style props are not renamed, as it prevents proper tracking."
1549
- },
1550
- messages: {
1551
- noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute. Panda will not track this prop."
1552
- },
1553
- type: "problem",
1554
- schema: []
1555
- },
1556
- defaultOptions: [],
1557
- create(context) {
1558
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
1559
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
1560
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
1561
- const isCachedPandaProp = (node) => {
1562
- if (pandaPropCache.has(node)) {
1563
- return pandaPropCache.get(node);
1564
- }
1565
- const result = isPandaProp(node, context);
1566
- pandaPropCache.set(node, result);
1567
- return !!result;
1568
- };
1569
- const isCachedPandaAttribute = (node) => {
1570
- if (pandaAttributeCache.has(node)) {
1571
- return pandaAttributeCache.get(node);
1572
- }
1573
- const result = isPandaAttribute(node, context);
1574
- pandaAttributeCache.set(node, result);
1575
- return !!result;
1576
- };
1577
- const isCachedRecipeVariant = (node) => {
1578
- if (recipeVariantCache.has(node)) {
1579
- return recipeVariantCache.get(node);
1580
- }
1581
- const result = isRecipeVariant(node, context);
1582
- recipeVariantCache.set(node, result);
1583
- return !!result;
1584
- };
1585
- const sendReport = (node, expected, prop) => {
1586
- context.report({
1587
- node,
1588
- messageId: "noRenaming",
1589
- data: {
1590
- expected,
1591
- prop
1592
- }
1593
- });
1594
- };
1595
- const handleReport = (node, value, attr) => {
1596
- if (isIdentifier(value) && attr !== value.name) {
1597
- sendReport(node, attr, value.name);
1598
- } else if (isMemberExpression(value) && isIdentifier(value.property) && attr !== value.property.name) {
1599
- sendReport(node, attr, value.property.name);
1600
- }
1601
- };
1602
- return {
1603
- JSXAttribute(node) {
1604
- if (!node.value) return;
1605
- if (!isJSXExpressionContainer(node.value)) return;
1606
- if (!isCachedPandaProp(node)) return;
1607
- const attr = node.name.name.toString();
1608
- const expression = node.value.expression;
1609
- handleReport(node.value, expression, attr);
1610
- },
1611
- Property(node) {
1612
- if (!isIdentifier(node.key)) return;
1613
- if (!isIdentifier(node.value) && !isMemberExpression(node.value)) return;
1614
- if (!isCachedPandaAttribute(node)) return;
1615
- if (isCachedRecipeVariant(node)) return;
1616
- const attr = node.key.name;
1617
- const value = node.value;
1618
- handleReport(node.value, value, attr);
1619
- }
1620
- };
1621
- }
1622
- });
1623
- var no_property_renaming_default = rule13;
1624
-
1625
- // src/rules/no-unsafe-token-fn-usage.ts
1626
- var import_utils27 = require("@typescript-eslint/utils");
1627
- var import_shared3 = require("@pandacss/shared");
1628
- var RULE_NAME14 = "no-unsafe-token-fn-usage";
1629
- var rule14 = createRule({
1630
- name: RULE_NAME14,
1631
- meta: {
1632
- docs: {
1633
- description: "Prevent users from using the token function in situations where they could simply use the raw design token."
1634
- },
1635
- messages: {
1636
- noUnsafeTokenFnUsage: "Unnecessary token function usage. Prefer design token.",
1637
- replace: "Replace token function with `{{safe}}`."
1638
- },
1639
- type: "suggestion",
1640
- hasSuggestions: true,
1641
- schema: []
1642
- },
1643
- defaultOptions: [],
1644
- create(context) {
1645
- let tokenImportCache;
1646
- const getCachedTokenImport = () => {
1647
- if (tokenImportCache !== void 0) {
1648
- return tokenImportCache;
1649
- }
1650
- tokenImportCache = getTokenImport(context);
1651
- return tokenImportCache;
1652
- };
1653
- const isUnsafeCallExpression = (node) => {
1654
- const tkImport = getCachedTokenImport();
1655
- return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
1656
- };
1657
- const tokenWrap = (value) => value ? `token(${value})` : "";
1658
- const isCompositeValue = (input) => {
1659
- if (!input) return false;
1660
- const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
1661
- return !tokenRegex.test(input);
1662
- };
1663
- const sendReport = (node, value) => {
1664
- const tkImports = extractTokens(value);
1665
- if (!tkImports.length) return;
1666
- const token = tkImports[0].replace(/^[^.]*\./, "");
1667
- context.report({
1668
- node,
1669
- messageId: "noUnsafeTokenFnUsage",
1670
- suggest: [
1671
- {
1672
- messageId: "replace",
1673
- data: { safe: token },
1674
- fix: (fixer) => fixer.replaceText(node, `'${token}'`)
1675
- }
1676
- ]
1677
- });
1678
- };
1679
- const handleRuntimeFn = (node) => {
1680
- if (!isCallExpression(node)) return;
1681
- if (!isUnsafeCallExpression(node)) return;
1682
- const value = node.arguments[0];
1683
- if (isLiteral(value)) {
1684
- const val = (0, import_shared3.getArbitraryValue)(value.value?.toString() ?? "");
1685
- sendReport(node, tokenWrap(val));
1686
- } else if (isTemplateLiteral(value) && value.expressions.length === 0) {
1687
- const val = (0, import_shared3.getArbitraryValue)(value.quasis[0].value.raw);
1688
- sendReport(node, tokenWrap(val));
1689
- }
1690
- };
1691
- const handleLiteral = (node) => {
1692
- if (!isLiteral(node)) return;
1693
- const value = (0, import_shared3.getArbitraryValue)(node.value?.toString() ?? "");
1694
- if (isCompositeValue(value)) return;
1695
- sendReport(node, value);
1696
- };
1697
- const handleTemplateLiteral = (node) => {
1698
- if (!isTemplateLiteral(node) || node.expressions.length > 0) return;
1699
- const value = (0, import_shared3.getArbitraryValue)(node.quasis[0].value.raw);
1700
- if (isCompositeValue(value)) return;
1701
- sendReport(node, value);
1702
- };
1703
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
1704
- const isCachedPandaProp = (node) => {
1705
- if (pandaPropCache.has(node)) {
1706
- return pandaPropCache.get(node);
1707
- }
1708
- const result = isPandaProp(node, context);
1709
- pandaPropCache.set(node, result);
1710
- return !!result;
1711
- };
1712
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
1713
- const isCachedPandaAttribute = (node) => {
1714
- if (pandaAttributeCache.has(node)) {
1715
- return pandaAttributeCache.get(node);
1716
- }
1717
- const result = isPandaAttribute(node, context);
1718
- pandaAttributeCache.set(node, result);
1719
- return !!result;
1720
- };
1721
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
1722
- const isCachedRecipeVariant = (node) => {
1723
- if (recipeVariantCache.has(node)) {
1724
- return recipeVariantCache.get(node);
1725
- }
1726
- const result = isRecipeVariant(node, context);
1727
- recipeVariantCache.set(node, result);
1728
- return !!result;
1729
- };
1730
- return {
1731
- JSXAttribute(node) {
1732
- if (!node.value) return;
1733
- if (!isCachedPandaProp(node)) return;
1734
- handleLiteral(node.value);
1735
- if (isJSXExpressionContainer(node.value)) {
1736
- const expression = node.value.expression;
1737
- handleLiteral(expression);
1738
- handleTemplateLiteral(expression);
1739
- handleRuntimeFn(expression);
1740
- }
1741
- },
1742
- Property(node) {
1743
- if (!isCachedPandaAttribute(node)) return;
1744
- if (isCachedRecipeVariant(node)) return;
1745
- const valueNode = node.value;
1746
- if (isCallExpression(valueNode) || isLiteral(valueNode) || isTemplateLiteral(valueNode)) {
1747
- handleRuntimeFn(valueNode);
1748
- handleLiteral(valueNode);
1749
- handleTemplateLiteral(valueNode);
1750
- }
1751
- }
1752
- };
1753
- }
1754
- });
1755
- var no_unsafe_token_fn_usage_default = rule14;
1756
-
1757
- // src/rules/prefer-longhand-properties.ts
1758
- var RULE_NAME15 = "prefer-longhand-properties";
1759
- var rule15 = createRule({
1760
- name: RULE_NAME15,
1761
- meta: {
1762
- docs: {
1763
- description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
1764
- },
1765
- messages: {
1766
- longhand: "Use longhand property instead of `{{shorthand}}`. Prefer `{{longhand}}`.",
1767
- replace: "Replace `{{shorthand}}` with `{{longhand}}`."
1768
- },
1769
- type: "suggestion",
1770
- hasSuggestions: true,
1771
- schema: [
1772
- {
1773
- type: "object",
1774
- properties: {
1775
- whitelist: {
1776
- type: "array",
1777
- items: {
1778
- type: "string",
1779
- minLength: 0
1780
- },
1781
- uniqueItems: true
1782
- }
1783
- },
1784
- additionalProperties: false
1785
- }
1786
- ]
1787
- },
1788
- defaultOptions: [
1789
- {
1790
- whitelist: []
1791
- }
1792
- ],
1793
- create(context) {
1794
- const whitelist = context.options[0]?.whitelist ?? [];
1795
- const longhandCache = /* @__PURE__ */ new Map();
1796
- const getLonghand = (name2) => {
1797
- if (longhandCache.has(name2)) {
1798
- return longhandCache.get(name2);
1799
- }
1800
- const longhand = resolveLonghand(name2, context);
1801
- longhandCache.set(name2, longhand);
1802
- return longhand;
1803
- };
1804
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
1805
- const isCachedPandaProp = (node) => {
1806
- if (pandaPropCache.has(node)) {
1807
- return pandaPropCache.get(node);
1808
- }
1809
- const result = isPandaProp(node, context);
1810
- pandaPropCache.set(node, result);
1811
- return !!result;
1812
- };
1813
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
1814
- const isCachedPandaAttribute = (node) => {
1815
- if (pandaAttributeCache.has(node)) {
1816
- return pandaAttributeCache.get(node);
1817
- }
1818
- const result = isPandaAttribute(node, context);
1819
- pandaAttributeCache.set(node, result);
1820
- return !!result;
1821
- };
1822
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
1823
- const isCachedRecipeVariant = (node) => {
1824
- if (recipeVariantCache.has(node)) {
1825
- return recipeVariantCache.get(node);
1826
- }
1827
- const result = isRecipeVariant(node, context);
1828
- recipeVariantCache.set(node, result);
1829
- return !!result;
1830
- };
1831
- const sendReport = (node) => {
1832
- if (whitelist.includes(node.name)) return;
1833
- const longhand = getLonghand(node.name);
1834
- if (!longhand || longhand === node.name) return;
1835
- const data = {
1836
- shorthand: node.name,
1837
- longhand
1838
- };
1839
- context.report({
1840
- node,
1841
- messageId: "longhand",
1842
- data,
1843
- suggest: [
1844
- {
1845
- messageId: "replace",
1846
- data,
1847
- fix: (fixer) => fixer.replaceText(node, longhand)
1848
- }
1849
- ]
1850
- });
1851
- };
1852
- return {
1853
- JSXAttribute(node) {
1854
- if (!isJSXIdentifier(node.name)) return;
1855
- if (!isCachedPandaProp(node)) return;
1856
- sendReport(node.name);
1857
- },
1858
- Property(node) {
1859
- if (!isIdentifier(node.key)) return;
1860
- if (!isCachedPandaAttribute(node)) return;
1861
- if (isCachedRecipeVariant(node)) return;
1862
- sendReport(node.key);
1863
- }
1864
- };
1865
- }
1866
- });
1867
- var prefer_longhand_properties_default = rule15;
1868
-
1869
- // src/rules/prefer-shorthand-properties.ts
1870
- var RULE_NAME16 = "prefer-shorthand-properties";
1871
- var rule16 = createRule({
1872
- name: RULE_NAME16,
1873
- meta: {
1874
- docs: {
1875
- description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
1876
- },
1877
- messages: {
1878
- shorthand: "Use shorthand property instead of `{{longhand}}`. Prefer `{{shorthand}}`.",
1879
- replace: "Replace `{{longhand}}` with `{{shorthand}}`."
1880
- },
1881
- type: "suggestion",
1882
- hasSuggestions: true,
1883
- schema: [
1884
- {
1885
- type: "object",
1886
- properties: {
1887
- whitelist: {
1888
- type: "array",
1889
- items: {
1890
- type: "string",
1891
- minLength: 0
1892
- },
1893
- uniqueItems: true
1894
- }
1895
- },
1896
- additionalProperties: false
1897
- }
1898
- ]
1899
- },
1900
- defaultOptions: [
1901
- {
1902
- whitelist: []
1903
- }
1904
- ],
1905
- create(context) {
1906
- const whitelist = context.options[0]?.whitelist ?? [];
1907
- const longhandCache = /* @__PURE__ */ new Map();
1908
- const getLonghand = (name2) => {
1909
- if (longhandCache.has(name2)) {
1910
- return longhandCache.get(name2);
1911
- }
1912
- const longhand = resolveLonghand(name2, context);
1913
- longhandCache.set(name2, longhand);
1914
- return longhand;
1915
- };
1916
- const shorthandsCache = /* @__PURE__ */ new Map();
1917
- const getShorthands = (name2) => {
1918
- if (shorthandsCache.has(name2)) {
1919
- return shorthandsCache.get(name2);
1920
- }
1921
- const shorthands = resolveShorthands(name2, context);
1922
- shorthandsCache.set(name2, shorthands);
1923
- return shorthands;
1924
- };
1925
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
1926
- const isCachedPandaProp = (node) => {
1927
- if (pandaPropCache.has(node)) {
1928
- return pandaPropCache.get(node);
1929
- }
1930
- const result = isPandaProp(node, context);
1931
- pandaPropCache.set(node, result);
1932
- return !!result;
1933
- };
1934
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
1935
- const isCachedPandaAttribute = (node) => {
1936
- if (pandaAttributeCache.has(node)) {
1937
- return pandaAttributeCache.get(node);
1938
- }
1939
- const result = isPandaAttribute(node, context);
1940
- pandaAttributeCache.set(node, result);
1941
- return !!result;
1942
- };
1943
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
1944
- const isCachedRecipeVariant = (node) => {
1945
- if (recipeVariantCache.has(node)) {
1946
- return recipeVariantCache.get(node);
1947
- }
1948
- const result = isRecipeVariant(node, context);
1949
- recipeVariantCache.set(node, result);
1950
- return !!result;
1951
- };
1952
- const sendReport = (node) => {
1953
- if (whitelist.includes(node.name)) return;
1954
- const longhand = getLonghand(node.name);
1955
- if (longhand) return;
1956
- const shorthands = getShorthands(node.name);
1957
- if (!shorthands || shorthands.length === 0) return;
1958
- const shorthandList = shorthands.map((s) => `\`${s}\``).join(", ");
1959
- const data = {
1960
- longhand: node.name,
1961
- shorthand: shorthandList
1962
- };
1963
- context.report({
1964
- node,
1965
- messageId: "shorthand",
1966
- data,
1967
- suggest: [
1968
- {
1969
- messageId: "replace",
1970
- data,
1971
- fix: (fixer) => fixer.replaceText(node, shorthands[0])
1972
- }
1973
- ]
1974
- });
1975
- };
1976
- return {
1977
- JSXAttribute(node) {
1978
- if (!isJSXIdentifier(node.name)) return;
1979
- if (!isCachedPandaProp(node)) return;
1980
- sendReport(node.name);
1981
- },
1982
- Property(node) {
1983
- if (!isIdentifier(node.key)) return;
1984
- if (!isCachedPandaAttribute(node)) return;
1985
- if (isCachedRecipeVariant(node)) return;
1986
- sendReport(node.key);
1987
- }
1988
- };
1989
- }
1990
- });
1991
- var prefer_shorthand_properties_default = rule16;
1992
-
1993
- // src/utils/composite-properties.ts
1994
- var compositeProperties = {
1995
- animation: [
1996
- "animationName",
1997
- "animationDuration",
1998
- "animationTimingFunction",
1999
- "animationDelay",
2000
- "animationIterationCount",
2001
- "animationDirection",
2002
- "animationFillMode",
2003
- "animationPlayState"
2004
- ],
2005
- background: [
2006
- "backgroundImage",
2007
- "backgroundPosition",
2008
- "backgroundSize",
2009
- "backgroundRepeat",
2010
- "backgroundAttachment",
2011
- "backgroundOrigin",
2012
- "backgroundClip",
2013
- "backgroundColor"
2014
- ],
2015
- backgroundPosition: ["backgroundPositionX", "backgroundPositionY"],
2016
- border: ["borderWidth", "borderStyle", "borderColor"],
2017
- borderBlock: ["borderBlockWidth", "borderBlockStyle", "borderBlockColor"],
2018
- borderBlockColor: ["borderBlockStartColor", "borderBlockEndColor"],
2019
- borderBlockEnd: ["borderBlockEndWidth", "borderBlockEndStyle", "borderBlockEndColor"],
2020
- borderBlockStart: ["borderBlockStartWidth", "borderBlockStartStyle", "borderBlockStartColor"],
2021
- borderBlockStyle: ["borderBlockStartStyle", "borderBlockEndStyle"],
2022
- borderBlockWidth: ["borderBlockStartWidth", "borderBlockEndWidth"],
2023
- borderBottom: ["borderBottomWidth", "borderBottomStyle", "borderBottomColor"],
2024
- borderColor: ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"],
2025
- borderImage: ["borderImageSource", "borderImageSlice", "borderImageWidth", "borderImageOutset", "borderImageRepeat"],
2026
- borderInline: ["borderInlineWidth", "borderInlineStyle", "borderInlineColor"],
2027
- borderInlineColor: ["borderInlineStartColor", "borderInlineEndColor"],
2028
- borderInlineEnd: ["borderInlineEndWidth", "borderInlineEndStyle", "borderInlineEndColor"],
2029
- borderInlineStart: ["borderInlineStartWidth", "borderInlineStartStyle", "borderInlineStartColor"],
2030
- borderInlineStyle: ["borderInlineStartStyle", "borderInlineEndStyle"],
2031
- borderInlineWidth: ["borderInlineStartWidth", "borderInlineEndWidth"],
2032
- borderLeft: ["borderLeftWidth", "borderLeftStyle", "borderLeftColor"],
2033
- borderRadius: ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomRightRadius", "borderBottomLeftRadius"],
2034
- borderRight: ["borderRightWidth", "borderRightStyle", "borderRightColor"],
2035
- borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
2036
- borderTop: ["borderTopWidth", "borderTopStyle", "borderTopColor"],
2037
- borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
2038
- columnRule: ["columnRuleWidth", "columnRuleStyle", "columnRuleColor"],
2039
- columns: ["columnWidth", "columnCount"],
2040
- container: ["contain", "content"],
2041
- containIntrinsicSize: ["containIntrinsicSizeInline", "containIntrinsicSizeBlock"],
2042
- cue: ["cueBefore", "cueAfter"],
2043
- flex: ["flexGrow", "flexShrink", "flexBasis"],
2044
- flexFlow: ["flexDirection", "flexWrap"],
2045
- font: [
2046
- "fontStyle",
2047
- "fontVariantCaps",
2048
- "fontVariantEastAsian",
2049
- "fontVariantLigatures",
2050
- "fontVariantNumeric",
2051
- "fontVariantPosition",
2052
- "fontWeight",
2053
- "fontStretch",
2054
- "fontSize",
2055
- "lineHeight",
2056
- "fontFamily"
2057
- ],
2058
- fontSynthesis: ["fontSynthesisWeight", "fontSynthesisStyle", "fontSynthesisSmallCaps"],
2059
- fontVariant: [
2060
- "fontVariantCaps",
2061
- "fontVariantEastAsian",
2062
- "fontVariantLigatures",
2063
- "fontVariantNumeric",
2064
- "fontVariantPosition"
2065
- ],
2066
- gap: ["columnGap", "rowGap"],
2067
- grid: [
2068
- "gridTemplateColumns",
2069
- "gridTemplateRows",
2070
- "gridTemplateAreas",
2071
- "gridAutoColumns",
2072
- "gridAutoRows",
2073
- "gridAutoFlow"
2074
- ],
2075
- gridArea: ["gridRowStart", "gridColumnStart", "gridRowEnd", "gridColumnEnd"],
2076
- gridColumn: ["gridColumnStart", "gridColumnEnd"],
2077
- gridGap: ["gridColumnGap", "gridRowGap"],
2078
- gridRow: ["gridRowStart", "gridRowEnd"],
2079
- gridTemplate: ["gridTemplateColumns", "gridTemplateRows", "gridTemplateAreas"],
2080
- inset: ["top", "right", "bottom", "left"],
2081
- insetBlock: ["insetBlockStart", "insetBlockEnd"],
2082
- insetInline: ["insetInlineStart", "insetInlineEnd"],
2083
- listStyle: ["listStyleType", "listStylePosition", "listStyleImage"],
2084
- margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
2085
- marginBlock: ["marginBlockStart", "marginBlockEnd"],
2086
- marginInline: ["marginInlineStart", "marginInlineEnd"],
2087
- mask: ["maskImage", "maskMode", "maskRepeat", "maskPosition", "maskClip", "maskOrigin", "maskSize", "maskComposite"],
2088
- maskBorder: [
2089
- "maskBorderSource",
2090
- "maskBorderMode",
2091
- "maskBorderSlice",
2092
- "maskBorderWidth",
2093
- "maskBorderOutset",
2094
- "maskBorderRepeat"
2095
- ],
2096
- offset: ["offsetPosition", "offsetPath", "offsetDistance", "offsetRotate", "offsetAnchor"],
2097
- outline: ["outlineWidth", "outlineStyle", "outlineColor"],
2098
- overflow: ["overflowX", "overflowY"],
2099
- padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
2100
- paddingBlock: ["paddingBlockStart", "paddingBlockEnd"],
2101
- paddingInline: ["paddingInlineStart", "paddingInlineEnd"],
2102
- pause: ["pauseBefore", "pauseAfter"],
2103
- placeContent: ["alignContent", "justifyContent"],
2104
- placeItems: ["alignItems", "justifyItems"],
2105
- placeSelf: ["alignSelf", "justifySelf"],
2106
- rest: ["restBefore", "restAfter"],
2107
- scrollMargin: ["scrollMarginTop", "scrollMarginRight", "scrollMarginBottom", "scrollMarginLeft"],
2108
- scrollMarginBlock: ["scrollMarginBlockStart", "scrollMarginBlockEnd"],
2109
- scrollMarginInline: ["scrollMarginInlineStart", "scrollMarginInlineEnd"],
2110
- scrollPadding: ["scrollPaddingTop", "scrollPaddingRight", "scrollPaddingBottom", "scrollPaddingLeft"],
2111
- scrollPaddingBlock: ["scrollPaddingBlockStart", "scrollPaddingBlockEnd"],
2112
- scrollPaddingInline: ["scrollPaddingInlineStart", "scrollPaddingInlineEnd"],
2113
- scrollSnapMargin: ["scrollSnapMarginTop", "scrollSnapMarginRight", "scrollSnapMarginBottom", "scrollSnapMarginLeft"],
2114
- scrollSnapMarginBlock: ["scrollSnapMarginBlockStart", "scrollSnapMarginBlockEnd"],
2115
- scrollSnapMarginInline: ["scrollSnapMarginInlineStart", "scrollSnapMarginInlineEnd"],
2116
- scrollTimeline: ["scrollTimelineSource", "scrollTimelineOrientation"],
2117
- textDecoration: ["textDecorationLine", "textDecorationStyle", "textDecorationColor"],
2118
- textEmphasis: ["textEmphasisStyle", "textEmphasisColor"],
2119
- transition: ["transitionProperty", "transitionDuration", "transitionTimingFunction", "transitionDelay"]
2120
- };
2121
-
2122
- // src/rules/prefer-atomic-properties.ts
2123
- var RULE_NAME17 = "prefer-atomic-properties";
2124
- var rule17 = createRule({
2125
- name: RULE_NAME17,
2126
- meta: {
2127
- docs: {
2128
- description: "Encourage the use of atomic properties instead of composite properties in the codebase."
2129
- },
2130
- messages: {
2131
- atomic: "Use atomic properties instead of `{{composite}}`. Prefer: \n{{atomics}}"
2132
- },
2133
- type: "suggestion",
2134
- schema: [
2135
- {
2136
- type: "object",
2137
- properties: {
2138
- whitelist: {
2139
- type: "array",
2140
- items: {
2141
- type: "string",
2142
- minLength: 0
2143
- },
2144
- uniqueItems: true
2145
- }
2146
- },
2147
- additionalProperties: false
2148
- }
2149
- ]
2150
- },
2151
- defaultOptions: [
2152
- {
2153
- whitelist: []
2154
- }
2155
- ],
2156
- create(context) {
2157
- const whitelist = context.options[0]?.whitelist ?? [];
2158
- const longhandCache = /* @__PURE__ */ new Map();
2159
- const getLonghand = (name2) => {
2160
- if (longhandCache.has(name2)) {
2161
- return longhandCache.get(name2);
2162
- }
2163
- const longhand = resolveLonghand(name2, context) ?? name2;
2164
- longhandCache.set(name2, longhand);
2165
- return longhand;
2166
- };
2167
- const compositePropertyCache = /* @__PURE__ */ new Map();
2168
- const resolveCompositeProperty = (name2) => {
2169
- if (compositePropertyCache.has(name2)) {
2170
- return compositePropertyCache.get(name2);
2171
- }
2172
- if (Object.hasOwn(compositeProperties, name2)) {
2173
- compositePropertyCache.set(name2, name2);
2174
- return name2;
2175
- }
2176
- const longhand = getLonghand(name2);
2177
- if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand)) {
2178
- compositePropertyCache.set(name2, longhand);
2179
- return longhand;
2180
- }
2181
- compositePropertyCache.set(name2, void 0);
2182
- return void 0;
2183
- };
2184
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
2185
- const isCachedPandaProp = (node) => {
2186
- if (pandaPropCache.has(node)) {
2187
- return pandaPropCache.get(node);
2188
- }
2189
- const result = isPandaProp(node, context);
2190
- pandaPropCache.set(node, result);
2191
- return !!result;
2192
- };
2193
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
2194
- const isCachedPandaAttribute = (node) => {
2195
- if (pandaAttributeCache.has(node)) {
2196
- return pandaAttributeCache.get(node);
2197
- }
2198
- const result = isPandaAttribute(node, context);
2199
- pandaAttributeCache.set(node, result);
2200
- return !!result;
2201
- };
2202
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
2203
- const isCachedRecipeVariant = (node) => {
2204
- if (recipeVariantCache.has(node)) {
2205
- return recipeVariantCache.get(node);
2206
- }
2207
- const result = isRecipeVariant(node, context);
2208
- recipeVariantCache.set(node, result);
2209
- return !!result;
2210
- };
2211
- const sendReport = (node, composite) => {
2212
- if (whitelist.includes(node.name)) return;
2213
- const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(",\n");
2214
- context.report({
2215
- node,
2216
- messageId: "atomic",
2217
- data: {
2218
- composite: node.name,
2219
- atomics
2220
- }
2221
- });
2222
- };
2223
- return {
2224
- JSXAttribute(node) {
2225
- if (!isJSXIdentifier(node.name)) return;
2226
- if (!isCachedPandaProp(node)) return;
2227
- const composite = resolveCompositeProperty(node.name.name);
2228
- if (!composite) return;
2229
- sendReport(node.name, composite);
2230
- },
2231
- Property(node) {
2232
- if (!isIdentifier(node.key)) return;
2233
- if (!isCachedPandaAttribute(node)) return;
2234
- if (isCachedRecipeVariant(node)) return;
2235
- const composite = resolveCompositeProperty(node.key.name);
2236
- if (!composite) return;
2237
- sendReport(node.key, composite);
2238
- }
2239
- };
2240
- }
2241
- });
2242
- var prefer_atomic_properties_default = rule17;
2243
-
2244
- // src/rules/prefer-composite-properties.ts
2245
- var RULE_NAME18 = "prefer-composite-properties";
2246
- var rule18 = createRule({
2247
- name: RULE_NAME18,
2248
- meta: {
2249
- docs: {
2250
- description: "Encourage the use of composite properties instead of atomic properties in the codebase."
2251
- },
2252
- messages: {
2253
- composite: "Use composite property instead of `{{atomic}}`. Prefer: `{{composite}}`."
2254
- },
2255
- type: "suggestion",
2256
- schema: [
2257
- {
2258
- type: "object",
2259
- properties: {
2260
- whitelist: {
2261
- type: "array",
2262
- items: {
2263
- type: "string",
2264
- minLength: 0
2265
- },
2266
- uniqueItems: true
2267
- }
2268
- },
2269
- additionalProperties: false
2270
- }
2271
- ]
2272
- },
2273
- defaultOptions: [
2274
- {
2275
- whitelist: []
2276
- }
2277
- ],
2278
- create(context) {
2279
- const whitelist = context.options[0]?.whitelist ?? [];
2280
- const longhandCache = /* @__PURE__ */ new Map();
2281
- const getLonghand = (name2) => {
2282
- if (longhandCache.has(name2)) {
2283
- return longhandCache.get(name2);
2284
- }
2285
- const longhand = resolveLonghand(name2, context) ?? name2;
2286
- longhandCache.set(name2, longhand);
2287
- return longhand;
2288
- };
2289
- const compositePropertyCache = /* @__PURE__ */ new Map();
2290
- const resolveCompositeProperty = (name2) => {
2291
- if (compositePropertyCache.has(name2)) {
2292
- return compositePropertyCache.get(name2);
2293
- }
2294
- const longhand = getLonghand(name2);
2295
- if (!isValidProperty(longhand, context)) {
2296
- compositePropertyCache.set(name2, void 0);
2297
- return void 0;
2298
- }
2299
- const composite = Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
2300
- compositePropertyCache.set(name2, composite);
2301
- return composite;
2302
- };
2303
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
2304
- const isCachedPandaProp = (node) => {
2305
- if (pandaPropCache.has(node)) {
2306
- return pandaPropCache.get(node);
2307
- }
2308
- const result = isPandaProp(node, context);
2309
- pandaPropCache.set(node, result);
2310
- return !!result;
2311
- };
2312
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
2313
- const isCachedPandaAttribute = (node) => {
2314
- if (pandaAttributeCache.has(node)) {
2315
- return pandaAttributeCache.get(node);
2316
- }
2317
- const result = isPandaAttribute(node, context);
2318
- pandaAttributeCache.set(node, result);
2319
- return !!result;
2320
- };
2321
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
2322
- const isCachedRecipeVariant = (node) => {
2323
- if (recipeVariantCache.has(node)) {
2324
- return recipeVariantCache.get(node);
2325
- }
2326
- const result = isRecipeVariant(node, context);
2327
- recipeVariantCache.set(node, result);
2328
- return !!result;
2329
- };
2330
- const sendReport = (node, composite) => {
2331
- if (whitelist.includes(node.name)) return;
2332
- context.report({
2333
- node,
2334
- messageId: "composite",
2335
- data: {
2336
- composite,
2337
- atomic: node.name
2338
- }
2339
- });
2340
- };
2341
- return {
2342
- JSXAttribute(node) {
2343
- if (!isJSXIdentifier(node.name)) return;
2344
- if (!isCachedPandaProp(node)) return;
2345
- const composite = resolveCompositeProperty(node.name.name);
2346
- if (!composite) return;
2347
- sendReport(node.name, composite);
2348
- },
2349
- Property(node) {
2350
- if (!isIdentifier(node.key)) return;
2351
- if (!isCachedPandaAttribute(node)) return;
2352
- if (isCachedRecipeVariant(node)) return;
2353
- const composite = resolveCompositeProperty(node.key.name);
2354
- if (!composite) return;
2355
- sendReport(node.key, composite);
2356
- }
2357
- };
2358
- }
2359
- });
2360
- var prefer_composite_properties_default = rule18;
2361
-
2362
- // src/rules/prefer-unified-property-style.ts
2363
- var RULE_NAME19 = "prefer-unified-property-style";
2364
- var rule19 = createRule({
2365
- name: RULE_NAME19,
2366
- meta: {
2367
- docs: {
2368
- description: "Discourage mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results."
2369
- },
2370
- messages: {
2371
- unify: "You're mixing atomic {{atomicProperties}} with composite property `{{composite}}`. Prefer atomic styling to mixing atomic and composite properties. Remove `{{composite}}` and use one or more of {{atomics}} instead."
2372
- },
2373
- type: "suggestion",
2374
- schema: []
2375
- },
2376
- defaultOptions: [],
2377
- create(context) {
2378
- const longhandCache = /* @__PURE__ */ new Map();
2379
- const getLonghand = (name2) => {
2380
- if (longhandCache.has(name2)) {
2381
- return longhandCache.get(name2);
2382
- }
2383
- const longhand = resolveLonghand(name2, context) ?? name2;
2384
- longhandCache.set(name2, longhand);
2385
- return longhand;
2386
- };
2387
- const compositePropertyCache = /* @__PURE__ */ new Map();
2388
- const resolveCompositeProperty = (name2) => {
2389
- if (compositePropertyCache.has(name2)) {
2390
- return compositePropertyCache.get(name2);
2391
- }
2392
- if (name2 in compositeProperties) {
2393
- compositePropertyCache.set(name2, name2);
2394
- return name2;
2395
- }
2396
- const longhand = getLonghand(name2);
2397
- if (isValidProperty(longhand, context) && longhand in compositeProperties) {
2398
- compositePropertyCache.set(name2, longhand);
2399
- return longhand;
2400
- }
2401
- compositePropertyCache.set(name2, void 0);
2402
- return void 0;
2403
- };
2404
- const pandaPropCache = /* @__PURE__ */ new WeakMap();
2405
- const isCachedPandaProp = (node) => {
2406
- if (pandaPropCache.has(node)) {
2407
- return pandaPropCache.get(node);
2408
- }
2409
- const result = isPandaProp(node, context);
2410
- pandaPropCache.set(node, result);
2411
- return !!result;
2412
- };
2413
- const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
2414
- const isCachedPandaAttribute = (node) => {
2415
- if (pandaAttributeCache.has(node)) {
2416
- return pandaAttributeCache.get(node);
2417
- }
2418
- const result = isPandaAttribute(node, context);
2419
- pandaAttributeCache.set(node, result);
2420
- return !!result;
2421
- };
2422
- const recipeVariantCache = /* @__PURE__ */ new WeakMap();
2423
- const isCachedRecipeVariant = (node) => {
2424
- if (recipeVariantCache.has(node)) {
2425
- return recipeVariantCache.get(node);
2426
- }
2427
- const result = isRecipeVariant(node, context);
2428
- recipeVariantCache.set(node, result);
2429
- return !!result;
2430
- };
2431
- const sendReport = (node, composite, siblings) => {
2432
- const atomicPropertiesSet = new Set(
2433
- siblings.filter((prop) => compositeProperties[composite].includes(getLonghand(prop)))
2434
- );
2435
- if (atomicPropertiesSet.size === 0) return;
2436
- const atomicProperties = Array.from(atomicPropertiesSet).map((prop) => `\`${prop}\``).join(", ");
2437
- const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(", ");
2438
- context.report({
2439
- node,
2440
- messageId: "unify",
2441
- data: {
2442
- composite,
2443
- atomicProperties,
2444
- atomics
2445
- }
2446
- });
2447
- };
2448
- return {
2449
- JSXAttribute(node) {
2450
- if (!isJSXIdentifier(node.name)) return;
2451
- if (!isCachedPandaProp(node)) return;
2452
- const composite = resolveCompositeProperty(node.name.name);
2453
- if (!composite) return;
2454
- if (!isJSXOpeningElement(node.parent)) return;
2455
- const siblings = node.parent.attributes.map((attr) => attr.name.name);
2456
- sendReport(node, composite, siblings);
2457
- },
2458
- Property(node) {
2459
- if (!isIdentifier(node.key)) return;
2460
- if (!isCachedPandaAttribute(node)) return;
2461
- if (isCachedRecipeVariant(node)) return;
2462
- const composite = resolveCompositeProperty(node.key.name);
2463
- if (!composite) return;
2464
- if (!isObjectExpression(node.parent)) return;
2465
- const siblings = node.parent.properties.filter((prop) => prop.type === "Property").map((prop) => isIdentifier(prop.key) ? prop.key.name : "");
2466
- sendReport(node.key, composite, siblings);
2467
- }
2468
- };
2469
- }
2470
- });
2471
- var prefer_unified_property_style_default = rule19;
2472
-
2473
- // src/rules/index.ts
2474
- var rules = {
2475
- [RULE_NAME]: file_not_included_default,
2476
- [RULE_NAME2]: no_config_function_in_source_default,
2477
- [RULE_NAME3]: no_debug_default,
2478
- [RULE_NAME4]: no_deprecated_tokens_default,
2479
- [RULE_NAME5]: no_dynamic_styling_default,
2480
- [RULE_NAME6]: no_escape_hatch_default,
2481
- [RULE_NAME7]: no_hardcoded_color_default,
2482
- [RULE_NAME8]: no_important_default,
2483
- [RULE_NAME10]: no_invalid_token_paths_default,
2484
- [RULE_NAME9]: no_invalid_nesting_default,
2485
- [RULE_NAME11]: no_margin_properties_default,
2486
- [RULE_NAME12]: no_physical_properties_default,
2487
- [RULE_NAME13]: no_property_renaming_default,
2488
- [RULE_NAME14]: no_unsafe_token_fn_usage_default,
2489
- [RULE_NAME15]: prefer_longhand_properties_default,
2490
- [RULE_NAME16]: prefer_shorthand_properties_default,
2491
- [RULE_NAME17]: prefer_atomic_properties_default,
2492
- [RULE_NAME18]: prefer_composite_properties_default,
2493
- [RULE_NAME19]: prefer_unified_property_style_default
2494
- };
2495
-
2496
- // src/configs/all.ts
2497
- var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME10];
2498
- var allRules = Object.fromEntries(
2499
- Object.entries(rules).map(([name2]) => {
2500
- return [`@pandacss/${name2}`, errorRules.includes(name2) ? "error" : "warn"];
2501
- })
2502
- );
2503
- var all_default = {
2504
- parser: "@typescript-eslint/parser",
2505
- parserOptions: { sourceType: "module" },
2506
- plugins: ["@pandacss"],
2507
- rules: allRules
2508
- };
2509
-
2510
- // src/configs/recommended.ts
2511
- var recommended_default = {
2512
- parser: "@typescript-eslint/parser",
2513
- parserOptions: { sourceType: "module" },
2514
- plugins: ["@pandacss"],
2515
- rules: {
2516
- "@pandacss/file-not-included": "error",
2517
- "@pandacss/no-config-function-in-source": "error",
2518
- "@pandacss/no-debug": "warn",
2519
- "@pandacss/no-dynamic-styling": "warn",
2520
- "@pandacss/no-hardcoded-color": "warn",
2521
- "@pandacss/no-invalid-nesting": "error",
2522
- "@pandacss/no-invalid-token-paths": "error",
2523
- "@pandacss/no-property-renaming": "warn",
2524
- "@pandacss/no-unsafe-token-fn-usage": "warn",
2525
- "@pandacss/no-deprecated-tokens": "warn"
2526
- }
2527
- };
98
+ var configs = { recommended };
2528
99
 
2529
100
  // src/index.ts
2530
- var plugin = {
2531
- meta: {
2532
- name,
2533
- version
2534
- },
2535
- rules,
2536
- configs: {
2537
- all: all_default,
2538
- recommended: recommended_default
2539
- }
101
+ var index_default = { meta: pluginMeta, configs };
102
+ export {
103
+ FileInspector as Inspector,
104
+ Linter,
105
+ PLUGIN_NAMESPACE,
106
+ ProjectCache,
107
+ RangeIndex,
108
+ bindRules,
109
+ byteToIndex,
110
+ collectStrings,
111
+ configs,
112
+ consistentPropertyStyleRuleName,
113
+ createConsistentPropertyStyleRule,
114
+ createExtractionDiagnosticsRule,
115
+ createFileNotIncludedRule,
116
+ createNoDebugRule,
117
+ createNoDeprecatedRule,
118
+ createNoImportantRule,
119
+ createNoInvalidNestingRule,
120
+ createNoInvalidTokenPathsRule,
121
+ createNoMarginPropertiesRule,
122
+ createNoPhysicalPropertiesRule,
123
+ createNoPrimitiveTokenRule,
124
+ createNoShorthandLonghandMixRule,
125
+ createPandaPlugin,
126
+ createPreferTextStyleRule,
127
+ createPreferTokenRule,
128
+ index_default as default,
129
+ extractionDiagnosticsRuleName,
130
+ fileNotIncludedRuleName,
131
+ getContextFilename,
132
+ getContextSource,
133
+ getSourceText,
134
+ loadPandaProject,
135
+ noDebugRuleName,
136
+ noDeprecatedRuleName,
137
+ noImportantRuleName,
138
+ noInvalidNestingRuleName,
139
+ noInvalidTokenPathsRuleName,
140
+ noMarginPropertiesRuleName,
141
+ noPhysicalPropertiesRuleName,
142
+ noPrimitiveTokenRuleName,
143
+ noShorthandLonghandMixRuleName,
144
+ pluginMeta,
145
+ preferTextStyleRuleName,
146
+ preferTokenRuleName,
147
+ projectCacheKey,
148
+ recommended,
149
+ reportDiagnostics,
150
+ reportPrimitiveTokenViolations,
151
+ reportTokenViolations,
152
+ resolvePandaSettings,
153
+ sourceCacheKey,
154
+ toEslintLoc
2540
155
  };
2541
- module.exports = plugin;