@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.cjs +79 -94
- package/dist/index.d.cts +40 -0
- package/dist/index.d.mts +41 -0
- package/dist/index.mjs +2130 -2316
- package/dist/utils/worker.cjs +155 -6
- package/dist/utils/worker.d.cts +53 -0
- package/dist/utils/worker.d.mts +54 -0
- package/dist/utils/worker.mjs +135 -4
- package/package.json +16 -16
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/utils--KVHU2cv.mjs +0 -164
- package/dist/utils--KVHU2cv.mjs.map +0 -1
- package/dist/utils-BbqZf2ZV.cjs +0 -217
- package/dist/utils-BbqZf2ZV.cjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,297 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (!
|
|
361
|
-
if (!
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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:
|
|
412
|
+
node: property.key,
|
|
459
413
|
suggest: [{
|
|
460
|
-
fix: (fixer) => fixer.removeRange([
|
|
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
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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
|
-
|
|
477
|
-
|
|
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
|
-
|
|
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
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
-
|
|
543
|
-
|
|
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
|
-
|
|
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
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
if (
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
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
|
-
|
|
626
|
-
|
|
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
|
-
|
|
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
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
if (
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
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
|
-
|
|
701
|
-
|
|
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
|
-
|
|
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
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
if (
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
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
|
-
|
|
788
|
-
|
|
789
|
-
|
|
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
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
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
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
const
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
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
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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
|
-
|
|
858
|
-
|
|
859
|
-
|
|
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
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
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
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
if (
|
|
896
|
-
|
|
897
|
-
|
|
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
|
-
|
|
927
|
-
|
|
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
|
-
|
|
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
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
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
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
if (!
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
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
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
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
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
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
|
-
|
|
1038
|
+
longhandCache.set(name, longhand);
|
|
1244
1039
|
return longhand;
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
if (
|
|
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
|
-
|
|
1058
|
+
bambooPropertyCache.set(node, result);
|
|
1256
1059
|
return Boolean(result);
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
|
|
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
|
-
|
|
1072
|
+
recipeVariantCache.set(node, result);
|
|
1262
1073
|
return Boolean(result);
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
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:
|
|
1204
|
+
physical: node.name
|
|
1276
1205
|
},
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
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
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
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
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
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
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
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
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
const
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
messageId: "
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
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
|
-
|
|
1559
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
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
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
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
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
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
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
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
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
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
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
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
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
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
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
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
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
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
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
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
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
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
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
};
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
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
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
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
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
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
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
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
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
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
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
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
|
|
2456
|
-
|
|
2457
|
-
export { };
|
|
2458
|
-
//# sourceMappingURL=index.mjs.map
|
|
2272
|
+
export { plugin as default };
|