@bamboocss/eslint-plugin 1.12.2 → 1.12.3

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