@pandacss/eslint-plugin 0.1.15 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-65XWD4AU.mjs → chunk-YLUMOAQM.mjs} +2 -2
- package/dist/index.js +953 -443
- package/dist/index.mjs +953 -444
- package/dist/utils/worker.js +5 -8
- package/dist/utils/worker.mjs +6 -9
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
__esm,
|
|
4
4
|
__toESM,
|
|
5
5
|
init_esm_shims
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YLUMOAQM.mjs";
|
|
7
7
|
|
|
8
8
|
// package.json
|
|
9
9
|
var name, version;
|
|
10
10
|
var init_package = __esm({
|
|
11
11
|
"package.json"() {
|
|
12
12
|
name = "@pandacss/eslint-plugin";
|
|
13
|
-
version = "0.1
|
|
13
|
+
version = "0.2.1";
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -34,7 +34,8 @@ var init_utils = __esm({
|
|
|
34
34
|
try {
|
|
35
35
|
return _syncAction(...args);
|
|
36
36
|
} catch (error) {
|
|
37
|
-
|
|
37
|
+
console.error("syncAction error:", error);
|
|
38
|
+
return void 0;
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
}
|
|
@@ -8008,7 +8009,7 @@ function isRecipeVariant(node, context) {
|
|
|
8008
8009
|
if (length < requiredLength + extraLength)
|
|
8009
8010
|
return true;
|
|
8010
8011
|
}
|
|
8011
|
-
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, hasPkgImport, isPandaConfigFunction, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isStyledProperty, isInPandaFunction, isInJSXProp, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport, getTaggedTemplateCaller;
|
|
8012
|
+
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, hasPkgImport, isPandaConfigFunction, _getImports, importsCache, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isStyledProperty, isInPandaFunction, isInJSXProp, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, invalidTokensCache, extractTokens, getInvalidTokens, getTokenImport, getTaggedTemplateCaller;
|
|
8012
8013
|
var init_helpers = __esm({
|
|
8013
8014
|
"src/utils/helpers.ts"() {
|
|
8014
8015
|
"use strict";
|
|
@@ -8064,13 +8065,17 @@ var init_helpers = __esm({
|
|
|
8064
8065
|
}));
|
|
8065
8066
|
return imports;
|
|
8066
8067
|
};
|
|
8068
|
+
importsCache = /* @__PURE__ */ new WeakMap();
|
|
8067
8069
|
getImports = (context) => {
|
|
8070
|
+
if (importsCache.has(context)) {
|
|
8071
|
+
return importsCache.get(context);
|
|
8072
|
+
}
|
|
8068
8073
|
const imports = _getImports(context);
|
|
8069
|
-
|
|
8074
|
+
const filteredImports = imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8075
|
+
importsCache.set(context, filteredImports);
|
|
8076
|
+
return filteredImports;
|
|
8070
8077
|
};
|
|
8071
8078
|
isValidStyledProp = (node, context) => {
|
|
8072
|
-
if (typeof node === "string")
|
|
8073
|
-
return;
|
|
8074
8079
|
return isJSXIdentifier(node) && isValidProperty(node.name, context);
|
|
8075
8080
|
};
|
|
8076
8081
|
isPandaIsh = (name2, context) => {
|
|
@@ -8081,14 +8086,20 @@ var init_helpers = __esm({
|
|
|
8081
8086
|
};
|
|
8082
8087
|
findDeclaration = (name2, context) => {
|
|
8083
8088
|
try {
|
|
8084
|
-
const
|
|
8089
|
+
const src = context.sourceCode;
|
|
8090
|
+
if (!src) {
|
|
8091
|
+
console.warn("\u26A0\uFE0F ESLint's sourceCode is not available. Ensure that the rule is invoked with valid code.");
|
|
8092
|
+
return void 0;
|
|
8093
|
+
}
|
|
8094
|
+
const scope = (0, import_scope_manager.analyze)(src.ast, {
|
|
8085
8095
|
sourceType: "module"
|
|
8086
8096
|
});
|
|
8087
8097
|
const decl = scope.variables.find((v) => v.name === name2)?.defs.find((d) => isIdentifier(d.name) && d.name.name === name2)?.node;
|
|
8088
8098
|
if (isVariableDeclarator(decl))
|
|
8089
8099
|
return decl;
|
|
8090
8100
|
} catch (error) {
|
|
8091
|
-
|
|
8101
|
+
console.error("Error in findDeclaration:", error);
|
|
8102
|
+
return void 0;
|
|
8092
8103
|
}
|
|
8093
8104
|
};
|
|
8094
8105
|
isLocalStyledFactory = (node, context) => {
|
|
@@ -8164,6 +8175,8 @@ var init_helpers = __esm({
|
|
|
8164
8175
|
return;
|
|
8165
8176
|
if (!isPandaProp(jsxAttrAncestor, context))
|
|
8166
8177
|
return;
|
|
8178
|
+
if (typeof jsxAttrAncestor.name === "string")
|
|
8179
|
+
return;
|
|
8167
8180
|
if (!isValidStyledProp(jsxAttrAncestor.name, context))
|
|
8168
8181
|
return;
|
|
8169
8182
|
return true;
|
|
@@ -8192,6 +8205,7 @@ var init_helpers = __esm({
|
|
|
8192
8205
|
return;
|
|
8193
8206
|
return syncAction("isColorToken", getSyncOpts(context), value);
|
|
8194
8207
|
};
|
|
8208
|
+
invalidTokensCache = /* @__PURE__ */ new Map();
|
|
8195
8209
|
extractTokens = (value) => {
|
|
8196
8210
|
const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{}]+)\}/g;
|
|
8197
8211
|
const matches = [];
|
|
@@ -8209,10 +8223,15 @@ var init_helpers = __esm({
|
|
|
8209
8223
|
return matches.filter(Boolean);
|
|
8210
8224
|
};
|
|
8211
8225
|
getInvalidTokens = (value, context) => {
|
|
8226
|
+
if (invalidTokensCache.has(value)) {
|
|
8227
|
+
return invalidTokensCache.get(value);
|
|
8228
|
+
}
|
|
8212
8229
|
const tokens = extractTokens(value);
|
|
8213
8230
|
if (!tokens.length)
|
|
8214
8231
|
return [];
|
|
8215
|
-
|
|
8232
|
+
const invalidTokens = syncAction("filterInvalidTokens", getSyncOpts(context), tokens);
|
|
8233
|
+
invalidTokensCache.set(value, invalidTokens);
|
|
8234
|
+
return invalidTokens;
|
|
8216
8235
|
};
|
|
8217
8236
|
getTokenImport = (context) => {
|
|
8218
8237
|
const imports = _getImports(context);
|
|
@@ -8237,6 +8256,7 @@ var init_helpers = __esm({
|
|
|
8237
8256
|
});
|
|
8238
8257
|
|
|
8239
8258
|
// src/rules/file-not-included.ts
|
|
8259
|
+
import "@typescript-eslint/utils";
|
|
8240
8260
|
var RULE_NAME, rule, file_not_included_default;
|
|
8241
8261
|
var init_file_not_included = __esm({
|
|
8242
8262
|
"src/rules/file-not-included.ts"() {
|
|
@@ -8249,26 +8269,32 @@ var init_file_not_included = __esm({
|
|
|
8249
8269
|
name: RULE_NAME,
|
|
8250
8270
|
meta: {
|
|
8251
8271
|
docs: {
|
|
8252
|
-
description: "Disallow the use of
|
|
8272
|
+
description: "Disallow the use of Panda CSS in files that are not included in the specified Panda CSS `include` config."
|
|
8253
8273
|
},
|
|
8254
8274
|
messages: {
|
|
8255
|
-
include: "The use of Panda CSS is not allowed in this file. Please
|
|
8275
|
+
include: "The use of Panda CSS is not allowed in this file. Please ensure the file is included in the Panda CSS `include` configuration."
|
|
8256
8276
|
},
|
|
8257
|
-
type: "
|
|
8277
|
+
type: "problem",
|
|
8258
8278
|
schema: []
|
|
8259
8279
|
},
|
|
8260
8280
|
defaultOptions: [],
|
|
8261
8281
|
create(context) {
|
|
8282
|
+
const isFileIncluded = isValidFile(context);
|
|
8283
|
+
if (isFileIncluded) {
|
|
8284
|
+
return {};
|
|
8285
|
+
}
|
|
8286
|
+
let hasReported = false;
|
|
8262
8287
|
return {
|
|
8263
8288
|
ImportDeclaration(node) {
|
|
8264
|
-
if (
|
|
8289
|
+
if (hasReported)
|
|
8265
8290
|
return;
|
|
8266
|
-
if (
|
|
8291
|
+
if (!isPandaImport(node, context))
|
|
8267
8292
|
return;
|
|
8268
8293
|
context.report({
|
|
8269
8294
|
node,
|
|
8270
8295
|
messageId: "include"
|
|
8271
8296
|
});
|
|
8297
|
+
hasReported = true;
|
|
8272
8298
|
}
|
|
8273
8299
|
};
|
|
8274
8300
|
}
|
|
@@ -8278,7 +8304,8 @@ var init_file_not_included = __esm({
|
|
|
8278
8304
|
});
|
|
8279
8305
|
|
|
8280
8306
|
// src/rules/no-config-function-in-source.ts
|
|
8281
|
-
|
|
8307
|
+
import "@typescript-eslint/utils";
|
|
8308
|
+
var RULE_NAME2, CONFIG_FUNCTIONS, rule2, no_config_function_in_source_default;
|
|
8282
8309
|
var init_no_config_function_in_source = __esm({
|
|
8283
8310
|
"src/rules/no-config-function-in-source.ts"() {
|
|
8284
8311
|
"use strict";
|
|
@@ -8287,55 +8314,80 @@ var init_no_config_function_in_source = __esm({
|
|
|
8287
8314
|
init_utils();
|
|
8288
8315
|
init_helpers();
|
|
8289
8316
|
RULE_NAME2 = "no-config-function-in-source";
|
|
8317
|
+
CONFIG_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
8318
|
+
"defineConfig",
|
|
8319
|
+
"defineRecipe",
|
|
8320
|
+
"defineSlotRecipe",
|
|
8321
|
+
"defineParts",
|
|
8322
|
+
"definePattern",
|
|
8323
|
+
"definePreset",
|
|
8324
|
+
"defineKeyframes",
|
|
8325
|
+
"defineGlobalStyles",
|
|
8326
|
+
"defineUtility",
|
|
8327
|
+
"defineTextStyles",
|
|
8328
|
+
"defineLayerStyles",
|
|
8329
|
+
"defineStyles",
|
|
8330
|
+
"defineTokens",
|
|
8331
|
+
"defineSemanticTokens"
|
|
8332
|
+
]);
|
|
8290
8333
|
rule2 = createRule({
|
|
8291
8334
|
name: RULE_NAME2,
|
|
8292
8335
|
meta: {
|
|
8293
8336
|
docs: {
|
|
8294
|
-
description: "Prohibit the use of config functions outside the Panda config."
|
|
8337
|
+
description: "Prohibit the use of config functions outside the Panda config file."
|
|
8295
8338
|
},
|
|
8296
8339
|
messages: {
|
|
8297
|
-
configFunction: "Unnecessary`{{name}}` call.
|
|
8340
|
+
configFunction: "Unnecessary `{{name}}` call. Config functions should only be used in the Panda config file.",
|
|
8298
8341
|
delete: "Delete `{{name}}` call."
|
|
8299
8342
|
},
|
|
8300
|
-
type: "
|
|
8343
|
+
type: "problem",
|
|
8301
8344
|
hasSuggestions: true,
|
|
8302
8345
|
schema: []
|
|
8303
8346
|
},
|
|
8304
8347
|
defaultOptions: [],
|
|
8305
8348
|
create(context) {
|
|
8306
|
-
if (!hasPkgImport(context))
|
|
8349
|
+
if (!hasPkgImport(context)) {
|
|
8350
|
+
return {};
|
|
8351
|
+
}
|
|
8352
|
+
const isPandaFile = isValidFile(context);
|
|
8353
|
+
if (!isPandaFile) {
|
|
8307
8354
|
return {};
|
|
8355
|
+
}
|
|
8308
8356
|
return {
|
|
8309
8357
|
CallExpression(node) {
|
|
8310
|
-
if (!isValidFile(context))
|
|
8311
|
-
return;
|
|
8312
8358
|
if (!isIdentifier(node.callee))
|
|
8313
8359
|
return;
|
|
8314
|
-
|
|
8360
|
+
const functionName = node.callee.name;
|
|
8361
|
+
if (!CONFIG_FUNCTIONS.has(functionName))
|
|
8315
8362
|
return;
|
|
8316
|
-
if (!isPandaConfigFunction(context,
|
|
8363
|
+
if (!isPandaConfigFunction(context, functionName))
|
|
8317
8364
|
return;
|
|
8318
8365
|
context.report({
|
|
8319
8366
|
node,
|
|
8320
8367
|
messageId: "configFunction",
|
|
8321
8368
|
data: {
|
|
8322
|
-
name:
|
|
8369
|
+
name: functionName
|
|
8323
8370
|
},
|
|
8324
8371
|
suggest: [
|
|
8325
8372
|
{
|
|
8326
8373
|
messageId: "delete",
|
|
8327
8374
|
data: {
|
|
8328
|
-
name:
|
|
8375
|
+
name: functionName
|
|
8329
8376
|
},
|
|
8330
8377
|
fix(fixer) {
|
|
8331
8378
|
const declaration = getAncestor(isVariableDeclaration, node);
|
|
8332
|
-
const
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
fixer.remove(declaration
|
|
8337
|
-
|
|
8338
|
-
|
|
8379
|
+
const importSpecifiers = getImportSpecifiers(context);
|
|
8380
|
+
const importSpec = importSpecifiers.find((s) => s.specifier.local.name === functionName);
|
|
8381
|
+
const fixes = [];
|
|
8382
|
+
if (declaration) {
|
|
8383
|
+
fixes.push(fixer.remove(declaration));
|
|
8384
|
+
} else {
|
|
8385
|
+
fixes.push(fixer.remove(node));
|
|
8386
|
+
}
|
|
8387
|
+
if (importSpec?.specifier) {
|
|
8388
|
+
fixes.push(fixer.remove(importSpec.specifier));
|
|
8389
|
+
}
|
|
8390
|
+
return fixes;
|
|
8339
8391
|
}
|
|
8340
8392
|
}
|
|
8341
8393
|
]
|
|
@@ -8345,32 +8397,16 @@ var init_no_config_function_in_source = __esm({
|
|
|
8345
8397
|
}
|
|
8346
8398
|
});
|
|
8347
8399
|
no_config_function_in_source_default = rule2;
|
|
8348
|
-
CONFIG_FUNCTIONS = [
|
|
8349
|
-
"defineConfig",
|
|
8350
|
-
"defineRecipe",
|
|
8351
|
-
"defineSlotRecipe",
|
|
8352
|
-
"defineParts",
|
|
8353
|
-
"definePattern",
|
|
8354
|
-
"definePreset",
|
|
8355
|
-
"defineKeyframes",
|
|
8356
|
-
"defineGlobalStyles",
|
|
8357
|
-
"defineUtility",
|
|
8358
|
-
"defineTextStyles",
|
|
8359
|
-
"defineLayerStyles",
|
|
8360
|
-
"defineStyles",
|
|
8361
|
-
"defineTokens",
|
|
8362
|
-
"defineSemanticTokens"
|
|
8363
|
-
];
|
|
8364
8400
|
}
|
|
8365
8401
|
});
|
|
8366
8402
|
|
|
8367
8403
|
// src/rules/no-debug.ts
|
|
8404
|
+
import "@typescript-eslint/utils";
|
|
8368
8405
|
var RULE_NAME3, rule3, no_debug_default;
|
|
8369
8406
|
var init_no_debug = __esm({
|
|
8370
8407
|
"src/rules/no-debug.ts"() {
|
|
8371
8408
|
"use strict";
|
|
8372
8409
|
init_esm_shims();
|
|
8373
|
-
init_nodes();
|
|
8374
8410
|
init_utils();
|
|
8375
8411
|
init_helpers();
|
|
8376
8412
|
RULE_NAME3 = "no-debug";
|
|
@@ -8385,16 +8421,14 @@ var init_no_debug = __esm({
|
|
|
8385
8421
|
prop: "Remove the debug prop.",
|
|
8386
8422
|
property: "Remove the debug property."
|
|
8387
8423
|
},
|
|
8388
|
-
type: "
|
|
8424
|
+
type: "problem",
|
|
8389
8425
|
hasSuggestions: true,
|
|
8390
8426
|
schema: []
|
|
8391
8427
|
},
|
|
8392
8428
|
defaultOptions: [],
|
|
8393
8429
|
create(context) {
|
|
8394
8430
|
return {
|
|
8395
|
-
JSXAttribute(node) {
|
|
8396
|
-
if (!isJSXIdentifier(node.name) || node.name.name !== "debug")
|
|
8397
|
-
return;
|
|
8431
|
+
'JSXAttribute[name.name="debug"]'(node) {
|
|
8398
8432
|
if (!isPandaProp(node, context))
|
|
8399
8433
|
return;
|
|
8400
8434
|
context.report({
|
|
@@ -8408,9 +8442,7 @@ var init_no_debug = __esm({
|
|
|
8408
8442
|
]
|
|
8409
8443
|
});
|
|
8410
8444
|
},
|
|
8411
|
-
Property(node) {
|
|
8412
|
-
if (!isIdentifier(node.key) || node.key.name !== "debug")
|
|
8413
|
-
return;
|
|
8445
|
+
'Property[key.name="debug"]'(node) {
|
|
8414
8446
|
if (!isPandaAttribute(node, context))
|
|
8415
8447
|
return;
|
|
8416
8448
|
if (isRecipeVariant(node, context))
|
|
@@ -8434,20 +8466,7 @@ var init_no_debug = __esm({
|
|
|
8434
8466
|
});
|
|
8435
8467
|
|
|
8436
8468
|
// src/rules/no-dynamic-styling.ts
|
|
8437
|
-
|
|
8438
|
-
array.elements.forEach((node) => {
|
|
8439
|
-
if (!node)
|
|
8440
|
-
return;
|
|
8441
|
-
if (isLiteral(node))
|
|
8442
|
-
return;
|
|
8443
|
-
if (isTemplateLiteral(node) && node.expressions.length === 0)
|
|
8444
|
-
return;
|
|
8445
|
-
context.report({
|
|
8446
|
-
node,
|
|
8447
|
-
messageId: "dynamic"
|
|
8448
|
-
});
|
|
8449
|
-
});
|
|
8450
|
-
}
|
|
8469
|
+
import "@typescript-eslint/utils";
|
|
8451
8470
|
var RULE_NAME4, rule4, no_dynamic_styling_default;
|
|
8452
8471
|
var init_no_dynamic_styling = __esm({
|
|
8453
8472
|
"src/rules/no-dynamic-styling.ts"() {
|
|
@@ -8461,42 +8480,66 @@ var init_no_dynamic_styling = __esm({
|
|
|
8461
8480
|
name: RULE_NAME4,
|
|
8462
8481
|
meta: {
|
|
8463
8482
|
docs: {
|
|
8464
|
-
description: "Ensure
|
|
8483
|
+
description: "Ensure users don't use dynamic styling. Prefer static styles, leverage CSS variables, or recipes for known dynamic styles."
|
|
8465
8484
|
},
|
|
8466
8485
|
messages: {
|
|
8467
|
-
dynamic: "Remove dynamic value. Prefer static styles",
|
|
8468
|
-
dynamicProperty: "Remove dynamic property. Prefer static style property",
|
|
8469
|
-
dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition"
|
|
8486
|
+
dynamic: "Remove dynamic value. Prefer static styles.",
|
|
8487
|
+
dynamicProperty: "Remove dynamic property. Prefer static style property.",
|
|
8488
|
+
dynamicRecipeVariant: "Remove dynamic variant. Prefer static variant definition."
|
|
8470
8489
|
},
|
|
8471
|
-
type: "
|
|
8490
|
+
type: "problem",
|
|
8472
8491
|
schema: []
|
|
8473
8492
|
},
|
|
8474
8493
|
defaultOptions: [],
|
|
8475
8494
|
create(context) {
|
|
8495
|
+
function isStaticValue(node) {
|
|
8496
|
+
if (!node)
|
|
8497
|
+
return false;
|
|
8498
|
+
if (isLiteral(node))
|
|
8499
|
+
return true;
|
|
8500
|
+
if (isTemplateLiteral(node) && node.expressions.length === 0)
|
|
8501
|
+
return true;
|
|
8502
|
+
if (isObjectExpression(node))
|
|
8503
|
+
return true;
|
|
8504
|
+
return false;
|
|
8505
|
+
}
|
|
8506
|
+
function checkArrayElements(array) {
|
|
8507
|
+
array.elements.forEach((element) => {
|
|
8508
|
+
if (!element)
|
|
8509
|
+
return;
|
|
8510
|
+
if (isStaticValue(element))
|
|
8511
|
+
return;
|
|
8512
|
+
context.report({
|
|
8513
|
+
node: element,
|
|
8514
|
+
messageId: "dynamic"
|
|
8515
|
+
});
|
|
8516
|
+
});
|
|
8517
|
+
}
|
|
8476
8518
|
return {
|
|
8519
|
+
// JSX Attributes
|
|
8477
8520
|
JSXAttribute(node) {
|
|
8478
8521
|
if (!node.value)
|
|
8479
8522
|
return;
|
|
8480
8523
|
if (isLiteral(node.value))
|
|
8481
8524
|
return;
|
|
8482
|
-
if (isJSXExpressionContainer(node.value) && isLiteral(node.value.expression))
|
|
8483
|
-
return;
|
|
8484
|
-
if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
|
|
8485
|
-
return;
|
|
8486
|
-
if (isObjectExpression(node.value.expression))
|
|
8487
|
-
return;
|
|
8488
8525
|
if (!isPandaProp(node, context))
|
|
8489
8526
|
return;
|
|
8490
|
-
if (
|
|
8491
|
-
|
|
8527
|
+
if (isJSXExpressionContainer(node.value)) {
|
|
8528
|
+
const expr = node.value.expression;
|
|
8529
|
+
if (isStaticValue(expr))
|
|
8530
|
+
return;
|
|
8531
|
+
if (isArrayExpression(expr)) {
|
|
8532
|
+
checkArrayElements(expr);
|
|
8533
|
+
return;
|
|
8534
|
+
}
|
|
8492
8535
|
}
|
|
8493
8536
|
context.report({
|
|
8494
8537
|
node: node.value,
|
|
8495
8538
|
messageId: "dynamic"
|
|
8496
8539
|
});
|
|
8497
8540
|
},
|
|
8498
|
-
// Dynamic properties
|
|
8499
|
-
"Property[computed=true]"(node) {
|
|
8541
|
+
// Dynamic properties with computed keys
|
|
8542
|
+
"Property[computed=true]": (node) => {
|
|
8500
8543
|
if (!isInPandaFunction(node, context))
|
|
8501
8544
|
return;
|
|
8502
8545
|
context.report({
|
|
@@ -8504,19 +8547,19 @@ var init_no_dynamic_styling = __esm({
|
|
|
8504
8547
|
messageId: isRecipeVariant(node, context) ? "dynamicRecipeVariant" : "dynamicProperty"
|
|
8505
8548
|
});
|
|
8506
8549
|
},
|
|
8550
|
+
// Object Properties
|
|
8507
8551
|
Property(node) {
|
|
8508
8552
|
if (!isIdentifier(node.key))
|
|
8509
8553
|
return;
|
|
8510
|
-
if (
|
|
8511
|
-
return;
|
|
8512
|
-
if (isTemplateLiteral(node.value) && node.value.expressions.length === 0)
|
|
8554
|
+
if (!isPandaAttribute(node, context))
|
|
8513
8555
|
return;
|
|
8514
|
-
if (
|
|
8556
|
+
if (isRecipeVariant(node, context))
|
|
8515
8557
|
return;
|
|
8516
|
-
if (
|
|
8558
|
+
if (isStaticValue(node.value))
|
|
8517
8559
|
return;
|
|
8518
8560
|
if (isArrayExpression(node.value)) {
|
|
8519
|
-
|
|
8561
|
+
checkArrayElements(node.value);
|
|
8562
|
+
return;
|
|
8520
8563
|
}
|
|
8521
8564
|
context.report({
|
|
8522
8565
|
node: node.value,
|
|
@@ -8532,6 +8575,7 @@ var init_no_dynamic_styling = __esm({
|
|
|
8532
8575
|
|
|
8533
8576
|
// src/rules/no-escape-hatch.ts
|
|
8534
8577
|
import { getArbitraryValue } from "@pandacss/shared";
|
|
8578
|
+
import "@typescript-eslint/utils";
|
|
8535
8579
|
var RULE_NAME5, rule5, no_escape_hatch_default;
|
|
8536
8580
|
var init_no_escape_hatch = __esm({
|
|
8537
8581
|
"src/rules/no-escape-hatch.ts"() {
|
|
@@ -8548,47 +8592,37 @@ var init_no_escape_hatch = __esm({
|
|
|
8548
8592
|
description: "Prohibit the use of escape hatch syntax in the code."
|
|
8549
8593
|
},
|
|
8550
8594
|
messages: {
|
|
8551
|
-
escapeHatch: "Avoid using the escape hatch [value] for undefined tokens.
|
|
8595
|
+
escapeHatch: "Avoid using the escape hatch [value] for undefined tokens. Define a corresponding token in your design system for better consistency and maintainability.",
|
|
8552
8596
|
remove: "Remove the square brackets (`[]`)."
|
|
8553
8597
|
},
|
|
8554
|
-
type: "
|
|
8598
|
+
type: "problem",
|
|
8555
8599
|
hasSuggestions: true,
|
|
8556
8600
|
schema: []
|
|
8557
8601
|
},
|
|
8558
8602
|
defaultOptions: [],
|
|
8559
8603
|
create(context) {
|
|
8560
|
-
const
|
|
8604
|
+
const removeBrackets = (range) => {
|
|
8605
|
+
const [start, end] = range;
|
|
8606
|
+
return [start + 1, end - 1];
|
|
8607
|
+
};
|
|
8561
8608
|
const hasEscapeHatch = (value) => {
|
|
8562
8609
|
if (!value)
|
|
8563
8610
|
return false;
|
|
8611
|
+
if (!value.includes("["))
|
|
8612
|
+
return false;
|
|
8564
8613
|
return getArbitraryValue(value) !== value.trim();
|
|
8565
8614
|
};
|
|
8566
|
-
const
|
|
8567
|
-
if (!
|
|
8568
|
-
return;
|
|
8569
|
-
if (!hasEscapeHatch(node.value?.toString()))
|
|
8570
|
-
return;
|
|
8571
|
-
sendReport(node);
|
|
8572
|
-
};
|
|
8573
|
-
const handleTemplateLiteral = (node) => {
|
|
8574
|
-
if (!isTemplateLiteral(node))
|
|
8615
|
+
const handleNodeValue = (node, value) => {
|
|
8616
|
+
if (!hasEscapeHatch(value))
|
|
8575
8617
|
return;
|
|
8576
|
-
|
|
8577
|
-
return;
|
|
8578
|
-
if (!hasEscapeHatch(node.quasis[0].value.raw))
|
|
8579
|
-
return;
|
|
8580
|
-
sendReport(node.quasis[0], node.quasis[0].value.raw);
|
|
8581
|
-
};
|
|
8582
|
-
const sendReport = (node, _value) => {
|
|
8583
|
-
const value = _value ?? node.value?.toString();
|
|
8584
|
-
return context.report({
|
|
8618
|
+
context.report({
|
|
8585
8619
|
node,
|
|
8586
8620
|
messageId: "escapeHatch",
|
|
8587
8621
|
suggest: [
|
|
8588
8622
|
{
|
|
8589
8623
|
messageId: "remove",
|
|
8590
8624
|
fix: (fixer) => {
|
|
8591
|
-
return fixer.replaceTextRange(
|
|
8625
|
+
return fixer.replaceTextRange(removeBrackets(node.range), getArbitraryValue(value));
|
|
8592
8626
|
}
|
|
8593
8627
|
}
|
|
8594
8628
|
]
|
|
@@ -8600,23 +8634,36 @@ var init_no_escape_hatch = __esm({
|
|
|
8600
8634
|
return;
|
|
8601
8635
|
if (!isPandaProp(node, context))
|
|
8602
8636
|
return;
|
|
8603
|
-
|
|
8604
|
-
if (
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8637
|
+
const { value } = node;
|
|
8638
|
+
if (isLiteral(value)) {
|
|
8639
|
+
const val = value.value?.toString() ?? "";
|
|
8640
|
+
handleNodeValue(value, val);
|
|
8641
|
+
} else if (isJSXExpressionContainer(value)) {
|
|
8642
|
+
const expr = value.expression;
|
|
8643
|
+
if (isLiteral(expr)) {
|
|
8644
|
+
const val = expr.value?.toString() ?? "";
|
|
8645
|
+
handleNodeValue(expr, val);
|
|
8646
|
+
} else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
|
|
8647
|
+
const val = expr.quasis[0].value.raw;
|
|
8648
|
+
handleNodeValue(expr.quasis[0], val);
|
|
8649
|
+
}
|
|
8650
|
+
}
|
|
8608
8651
|
},
|
|
8609
8652
|
Property(node) {
|
|
8610
8653
|
if (!isIdentifier(node.key))
|
|
8611
8654
|
return;
|
|
8612
|
-
if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
|
|
8613
|
-
return;
|
|
8614
8655
|
if (!isPandaAttribute(node, context))
|
|
8615
8656
|
return;
|
|
8616
8657
|
if (isRecipeVariant(node, context))
|
|
8617
8658
|
return;
|
|
8618
|
-
|
|
8619
|
-
|
|
8659
|
+
const value = node.value;
|
|
8660
|
+
if (isLiteral(value)) {
|
|
8661
|
+
const val = value.value?.toString() ?? "";
|
|
8662
|
+
handleNodeValue(value, val);
|
|
8663
|
+
} else if (isTemplateLiteral(value) && value.expressions.length === 0) {
|
|
8664
|
+
const val = value.quasis[0].value.raw;
|
|
8665
|
+
handleNodeValue(value.quasis[0], val);
|
|
8666
|
+
}
|
|
8620
8667
|
}
|
|
8621
8668
|
};
|
|
8622
8669
|
}
|
|
@@ -8626,6 +8673,7 @@ var init_no_escape_hatch = __esm({
|
|
|
8626
8673
|
});
|
|
8627
8674
|
|
|
8628
8675
|
// src/rules/no-hardcoded-color.ts
|
|
8676
|
+
import "@typescript-eslint/utils";
|
|
8629
8677
|
var RULE_NAME6, rule6, no_hardcoded_color_default;
|
|
8630
8678
|
var init_no_hardcoded_color = __esm({
|
|
8631
8679
|
"src/rules/no-hardcoded-color.ts"() {
|
|
@@ -8644,7 +8692,7 @@ var init_no_hardcoded_color = __esm({
|
|
|
8644
8692
|
messages: {
|
|
8645
8693
|
invalidColor: "`{{color}}` is not a valid color token."
|
|
8646
8694
|
},
|
|
8647
|
-
type: "
|
|
8695
|
+
type: "problem",
|
|
8648
8696
|
schema: [
|
|
8649
8697
|
{
|
|
8650
8698
|
type: "object",
|
|
@@ -8652,7 +8700,8 @@ var init_no_hardcoded_color = __esm({
|
|
|
8652
8700
|
noOpacity: {
|
|
8653
8701
|
type: "boolean"
|
|
8654
8702
|
}
|
|
8655
|
-
}
|
|
8703
|
+
},
|
|
8704
|
+
additionalProperties: false
|
|
8656
8705
|
}
|
|
8657
8706
|
]
|
|
8658
8707
|
},
|
|
@@ -8663,19 +8712,55 @@ var init_no_hardcoded_color = __esm({
|
|
|
8663
8712
|
],
|
|
8664
8713
|
create(context) {
|
|
8665
8714
|
const noOpacity = context.options[0]?.noOpacity;
|
|
8666
|
-
const
|
|
8715
|
+
const colorTokenCache = /* @__PURE__ */ new Map();
|
|
8716
|
+
const colorAttributeCache = /* @__PURE__ */ new Map();
|
|
8717
|
+
const isColorToken2 = (token) => {
|
|
8718
|
+
if (colorTokenCache.has(token)) {
|
|
8719
|
+
return colorTokenCache.get(token);
|
|
8720
|
+
}
|
|
8721
|
+
const result = isColorToken(token, context);
|
|
8722
|
+
colorTokenCache.set(token, result);
|
|
8723
|
+
return !!result;
|
|
8724
|
+
};
|
|
8725
|
+
const isColorAttribute2 = (attribute) => {
|
|
8726
|
+
if (colorAttributeCache.has(attribute)) {
|
|
8727
|
+
return colorAttributeCache.get(attribute);
|
|
8728
|
+
}
|
|
8729
|
+
const result = isColorAttribute(attribute, context);
|
|
8730
|
+
colorAttributeCache.set(attribute, result);
|
|
8731
|
+
return result;
|
|
8732
|
+
};
|
|
8733
|
+
const isTokenFunctionUsed = (value) => {
|
|
8667
8734
|
if (!value)
|
|
8668
8735
|
return false;
|
|
8669
8736
|
const tokens = extractTokens(value);
|
|
8670
8737
|
return tokens.length > 0;
|
|
8671
8738
|
};
|
|
8672
|
-
const
|
|
8739
|
+
const isValidColorToken = (value) => {
|
|
8673
8740
|
if (!value)
|
|
8674
8741
|
return false;
|
|
8675
|
-
const
|
|
8676
|
-
const
|
|
8677
|
-
const isValidToken =
|
|
8678
|
-
return noOpacity ? isValidToken && !
|
|
8742
|
+
const [colorToken, opacity] = value.split("/");
|
|
8743
|
+
const hasOpacity = opacity !== void 0 && opacity.length > 0;
|
|
8744
|
+
const isValidToken = isColorToken2(colorToken);
|
|
8745
|
+
return noOpacity ? isValidToken && !hasOpacity : isValidToken;
|
|
8746
|
+
};
|
|
8747
|
+
const reportInvalidColor = (node, color) => {
|
|
8748
|
+
context.report({
|
|
8749
|
+
node,
|
|
8750
|
+
messageId: "invalidColor",
|
|
8751
|
+
data: {
|
|
8752
|
+
color
|
|
8753
|
+
}
|
|
8754
|
+
});
|
|
8755
|
+
};
|
|
8756
|
+
const checkColorValue = (node, value, attributeName) => {
|
|
8757
|
+
if (!isColorAttribute2(attributeName))
|
|
8758
|
+
return;
|
|
8759
|
+
if (isTokenFunctionUsed(value))
|
|
8760
|
+
return;
|
|
8761
|
+
if (isValidColorToken(value))
|
|
8762
|
+
return;
|
|
8763
|
+
reportInvalidColor(node, value);
|
|
8679
8764
|
};
|
|
8680
8765
|
return {
|
|
8681
8766
|
JSXAttribute(node) {
|
|
@@ -8683,49 +8768,38 @@ var init_no_hardcoded_color = __esm({
|
|
|
8683
8768
|
return;
|
|
8684
8769
|
if (!isPandaProp(node, context) || !node.value)
|
|
8685
8770
|
return;
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
messageId: "invalidColor",
|
|
8701
|
-
data: {
|
|
8702
|
-
color: node.value.expression.value?.toString()
|
|
8703
|
-
}
|
|
8704
|
-
});
|
|
8771
|
+
const attributeName = node.name.name;
|
|
8772
|
+
const valueNode = node.value;
|
|
8773
|
+
if (isLiteral(valueNode)) {
|
|
8774
|
+
const value = valueNode.value?.toString() || "";
|
|
8775
|
+
checkColorValue(valueNode, value, attributeName);
|
|
8776
|
+
} else if (isJSXExpressionContainer(valueNode)) {
|
|
8777
|
+
const expression = valueNode.expression;
|
|
8778
|
+
if (isLiteral(expression)) {
|
|
8779
|
+
const value = expression.value?.toString() || "";
|
|
8780
|
+
checkColorValue(expression, value, attributeName);
|
|
8781
|
+
} else if (isTemplateLiteral(expression) && expression.expressions.length === 0) {
|
|
8782
|
+
const value = expression.quasis[0].value.raw;
|
|
8783
|
+
checkColorValue(expression.quasis[0], value, attributeName);
|
|
8784
|
+
}
|
|
8705
8785
|
}
|
|
8706
8786
|
},
|
|
8707
8787
|
Property(node) {
|
|
8708
8788
|
if (!isIdentifier(node.key))
|
|
8709
8789
|
return;
|
|
8710
|
-
if (!isLiteral(node.value))
|
|
8711
|
-
return;
|
|
8712
8790
|
if (!isPandaAttribute(node, context))
|
|
8713
8791
|
return;
|
|
8714
8792
|
if (isRecipeVariant(node, context))
|
|
8715
8793
|
return;
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
if (
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
data: {
|
|
8726
|
-
color: node.value.value?.toString()
|
|
8727
|
-
}
|
|
8728
|
-
});
|
|
8794
|
+
const attributeName = node.key.name;
|
|
8795
|
+
const valueNode = node.value;
|
|
8796
|
+
if (isLiteral(valueNode)) {
|
|
8797
|
+
const value = valueNode.value?.toString() || "";
|
|
8798
|
+
checkColorValue(valueNode, value, attributeName);
|
|
8799
|
+
} else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
|
|
8800
|
+
const value = valueNode.quasis[0].value.raw;
|
|
8801
|
+
checkColorValue(valueNode.quasis[0], value, attributeName);
|
|
8802
|
+
}
|
|
8729
8803
|
}
|
|
8730
8804
|
};
|
|
8731
8805
|
}
|
|
@@ -8736,6 +8810,7 @@ var init_no_hardcoded_color = __esm({
|
|
|
8736
8810
|
|
|
8737
8811
|
// src/rules/no-important.ts
|
|
8738
8812
|
import { getArbitraryValue as getArbitraryValue2 } from "@pandacss/shared";
|
|
8813
|
+
import "@typescript-eslint/utils";
|
|
8739
8814
|
var exclamationRegex, importantRegex, RULE_NAME7, rule7, no_important_default;
|
|
8740
8815
|
var init_no_important = __esm({
|
|
8741
8816
|
"src/rules/no-important.ts"() {
|
|
@@ -8751,56 +8826,72 @@ var init_no_important = __esm({
|
|
|
8751
8826
|
name: RULE_NAME7,
|
|
8752
8827
|
meta: {
|
|
8753
8828
|
docs: {
|
|
8754
|
-
description: "Disallow usage of important keyword.
|
|
8829
|
+
description: "Disallow usage of !important keyword. Prioritize specificity for a maintainable and predictable styling structure."
|
|
8755
8830
|
},
|
|
8756
8831
|
messages: {
|
|
8757
|
-
important: "Avoid using the
|
|
8832
|
+
important: "Avoid using the {{keyword}} keyword. Refactor your code to prioritize specificity for predictable styling.",
|
|
8758
8833
|
remove: "Remove the `{{keyword}}` keyword."
|
|
8759
8834
|
},
|
|
8760
|
-
type: "
|
|
8835
|
+
type: "problem",
|
|
8761
8836
|
hasSuggestions: true,
|
|
8762
8837
|
schema: []
|
|
8763
8838
|
},
|
|
8764
8839
|
defaultOptions: [],
|
|
8765
8840
|
create(context) {
|
|
8766
|
-
const removeQuotes = (
|
|
8767
|
-
|
|
8768
|
-
|
|
8841
|
+
const removeQuotes = (range) => {
|
|
8842
|
+
const [start, end] = range;
|
|
8843
|
+
return [start + 1, end - 1];
|
|
8844
|
+
};
|
|
8845
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
8846
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
8847
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
8848
|
+
const isCachedPandaProp = (node) => {
|
|
8849
|
+
if (pandaPropCache.has(node)) {
|
|
8850
|
+
return pandaPropCache.get(node);
|
|
8851
|
+
}
|
|
8852
|
+
const result = isPandaProp(node, context);
|
|
8853
|
+
pandaPropCache.set(node, result);
|
|
8854
|
+
return !!result;
|
|
8855
|
+
};
|
|
8856
|
+
const isCachedPandaAttribute = (node) => {
|
|
8857
|
+
if (pandaAttributeCache.has(node)) {
|
|
8858
|
+
return pandaAttributeCache.get(node);
|
|
8859
|
+
}
|
|
8860
|
+
const result = isPandaAttribute(node, context);
|
|
8861
|
+
pandaAttributeCache.set(node, result);
|
|
8862
|
+
return !!result;
|
|
8863
|
+
};
|
|
8864
|
+
const isCachedRecipeVariant = (node) => {
|
|
8865
|
+
if (recipeVariantCache.has(node)) {
|
|
8866
|
+
return recipeVariantCache.get(node);
|
|
8867
|
+
}
|
|
8868
|
+
const result = isRecipeVariant(node, context);
|
|
8869
|
+
recipeVariantCache.set(node, result);
|
|
8870
|
+
return !!result;
|
|
8871
|
+
};
|
|
8872
|
+
const hasImportantKeyword = (value) => {
|
|
8873
|
+
if (!value)
|
|
8769
8874
|
return false;
|
|
8770
|
-
const
|
|
8771
|
-
return exclamationRegex.test(
|
|
8875
|
+
const arbitraryValue = getArbitraryValue2(value);
|
|
8876
|
+
return exclamationRegex.test(arbitraryValue) || importantRegex.test(arbitraryValue);
|
|
8772
8877
|
};
|
|
8773
8878
|
const removeImportantKeyword = (input) => {
|
|
8774
|
-
if (
|
|
8775
|
-
return { fixed: input.replace(
|
|
8776
|
-
} else if (
|
|
8777
|
-
return { fixed: input.replace(
|
|
8879
|
+
if (importantRegex.test(input)) {
|
|
8880
|
+
return { fixed: input.replace(importantRegex, "").trimEnd(), keyword: "!important" };
|
|
8881
|
+
} else if (exclamationRegex.test(input)) {
|
|
8882
|
+
return { fixed: input.replace(exclamationRegex, "").trimEnd(), keyword: "!" };
|
|
8778
8883
|
} else {
|
|
8779
8884
|
return { fixed: input, keyword: null };
|
|
8780
8885
|
}
|
|
8781
8886
|
};
|
|
8782
|
-
const
|
|
8783
|
-
if (!
|
|
8887
|
+
const handleNodeValue = (node, value) => {
|
|
8888
|
+
if (!hasImportantKeyword(value))
|
|
8784
8889
|
return;
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
sendReport(node);
|
|
8788
|
-
};
|
|
8789
|
-
const handleTemplateLiteral = (node) => {
|
|
8790
|
-
if (!isTemplateLiteral(node))
|
|
8791
|
-
return;
|
|
8792
|
-
if (node.expressions.length > 0)
|
|
8793
|
-
return;
|
|
8794
|
-
if (!hasImportantKeyword(node.quasis[0].value.raw))
|
|
8795
|
-
return;
|
|
8796
|
-
sendReport(node.quasis[0], node.quasis[0].value.raw);
|
|
8797
|
-
};
|
|
8798
|
-
const sendReport = (node, _value) => {
|
|
8799
|
-
const value = _value ?? node.value?.toString();
|
|
8800
|
-
const { keyword, fixed } = removeImportantKeyword(value);
|
|
8801
|
-
return context.report({
|
|
8890
|
+
const { fixed, keyword } = removeImportantKeyword(value);
|
|
8891
|
+
context.report({
|
|
8802
8892
|
node,
|
|
8803
8893
|
messageId: "important",
|
|
8894
|
+
data: { keyword },
|
|
8804
8895
|
suggest: [
|
|
8805
8896
|
{
|
|
8806
8897
|
messageId: "remove",
|
|
@@ -8813,28 +8904,43 @@ var init_no_important = __esm({
|
|
|
8813
8904
|
});
|
|
8814
8905
|
};
|
|
8815
8906
|
return {
|
|
8907
|
+
// JSX Attributes
|
|
8816
8908
|
JSXAttribute(node) {
|
|
8817
8909
|
if (!node.value)
|
|
8818
8910
|
return;
|
|
8819
|
-
if (!
|
|
8820
|
-
return;
|
|
8821
|
-
handleLiteral(node.value);
|
|
8822
|
-
if (!isJSXExpressionContainer(node.value))
|
|
8911
|
+
if (!isCachedPandaProp(node))
|
|
8823
8912
|
return;
|
|
8824
|
-
|
|
8825
|
-
|
|
8913
|
+
const valueNode = node.value;
|
|
8914
|
+
if (isLiteral(valueNode)) {
|
|
8915
|
+
const val = valueNode.value?.toString() ?? "";
|
|
8916
|
+
handleNodeValue(valueNode, val);
|
|
8917
|
+
} else if (isJSXExpressionContainer(valueNode)) {
|
|
8918
|
+
const expr = valueNode.expression;
|
|
8919
|
+
if (isLiteral(expr)) {
|
|
8920
|
+
const val = expr.value?.toString() ?? "";
|
|
8921
|
+
handleNodeValue(expr, val);
|
|
8922
|
+
} else if (isTemplateLiteral(expr) && expr.expressions.length === 0) {
|
|
8923
|
+
const val = expr.quasis[0].value.raw;
|
|
8924
|
+
handleNodeValue(expr.quasis[0], val);
|
|
8925
|
+
}
|
|
8926
|
+
}
|
|
8826
8927
|
},
|
|
8928
|
+
// Object Properties
|
|
8827
8929
|
Property(node) {
|
|
8828
8930
|
if (!isIdentifier(node.key))
|
|
8829
8931
|
return;
|
|
8830
|
-
if (!
|
|
8932
|
+
if (!isCachedPandaAttribute(node))
|
|
8831
8933
|
return;
|
|
8832
|
-
if (
|
|
8833
|
-
return;
|
|
8834
|
-
if (isRecipeVariant(node, context))
|
|
8934
|
+
if (isCachedRecipeVariant(node))
|
|
8835
8935
|
return;
|
|
8836
|
-
|
|
8837
|
-
|
|
8936
|
+
const valueNode = node.value;
|
|
8937
|
+
if (isLiteral(valueNode)) {
|
|
8938
|
+
const val = valueNode.value?.toString() ?? "";
|
|
8939
|
+
handleNodeValue(valueNode, val);
|
|
8940
|
+
} else if (isTemplateLiteral(valueNode) && valueNode.expressions.length === 0) {
|
|
8941
|
+
const val = valueNode.quasis[0].value.raw;
|
|
8942
|
+
handleNodeValue(valueNode.quasis[0], val);
|
|
8943
|
+
}
|
|
8838
8944
|
}
|
|
8839
8945
|
};
|
|
8840
8946
|
}
|
|
@@ -8844,6 +8950,7 @@ var init_no_important = __esm({
|
|
|
8844
8950
|
});
|
|
8845
8951
|
|
|
8846
8952
|
// src/rules/no-invalid-nesting.ts
|
|
8953
|
+
import "@typescript-eslint/utils";
|
|
8847
8954
|
var RULE_NAME8, rule8, no_invalid_nesting_default;
|
|
8848
8955
|
var init_no_invalid_nesting = __esm({
|
|
8849
8956
|
"src/rules/no-invalid-nesting.ts"() {
|
|
@@ -8857,35 +8964,78 @@ var init_no_invalid_nesting = __esm({
|
|
|
8857
8964
|
name: RULE_NAME8,
|
|
8858
8965
|
meta: {
|
|
8859
8966
|
docs: {
|
|
8860
|
-
description: "Warn against invalid nesting.
|
|
8967
|
+
description: "Warn against invalid nesting. Nested styles must contain the `&` character."
|
|
8861
8968
|
},
|
|
8862
8969
|
messages: {
|
|
8863
8970
|
nesting: "Invalid style nesting. Nested styles must contain the `&` character."
|
|
8864
8971
|
},
|
|
8865
|
-
type: "
|
|
8972
|
+
type: "problem",
|
|
8866
8973
|
schema: []
|
|
8867
8974
|
},
|
|
8868
8975
|
defaultOptions: [],
|
|
8869
8976
|
create(context) {
|
|
8977
|
+
const pandaFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
8978
|
+
const jsxPropCache = /* @__PURE__ */ new WeakMap();
|
|
8979
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
8980
|
+
const styledPropertyCache = /* @__PURE__ */ new WeakMap();
|
|
8981
|
+
const isCachedInPandaFunction = (node) => {
|
|
8982
|
+
if (pandaFunctionCache.has(node)) {
|
|
8983
|
+
return pandaFunctionCache.get(node);
|
|
8984
|
+
}
|
|
8985
|
+
const result = !!isInPandaFunction(node, context);
|
|
8986
|
+
pandaFunctionCache.set(node, result);
|
|
8987
|
+
return !!result;
|
|
8988
|
+
};
|
|
8989
|
+
const isCachedInJSXProp = (node) => {
|
|
8990
|
+
if (jsxPropCache.has(node)) {
|
|
8991
|
+
return jsxPropCache.get(node);
|
|
8992
|
+
}
|
|
8993
|
+
const result = isInJSXProp(node, context);
|
|
8994
|
+
jsxPropCache.set(node, result);
|
|
8995
|
+
return !!result;
|
|
8996
|
+
};
|
|
8997
|
+
const isCachedRecipeVariant = (node) => {
|
|
8998
|
+
if (recipeVariantCache.has(node)) {
|
|
8999
|
+
return recipeVariantCache.get(node);
|
|
9000
|
+
}
|
|
9001
|
+
const result = isRecipeVariant(node, context);
|
|
9002
|
+
recipeVariantCache.set(node, result);
|
|
9003
|
+
return !!result;
|
|
9004
|
+
};
|
|
9005
|
+
const isCachedStyledProperty = (node) => {
|
|
9006
|
+
if (styledPropertyCache.has(node)) {
|
|
9007
|
+
return styledPropertyCache.get(node);
|
|
9008
|
+
}
|
|
9009
|
+
const result = isStyledProperty(node, context);
|
|
9010
|
+
styledPropertyCache.set(node, result);
|
|
9011
|
+
return !!result;
|
|
9012
|
+
};
|
|
9013
|
+
const isInvalidNestingSelector = (node) => {
|
|
9014
|
+
if (isLiteral(node) && typeof node.value === "string") {
|
|
9015
|
+
return !node.value.includes("&");
|
|
9016
|
+
} else if (isTemplateLiteral(node) && node.expressions.length === 0) {
|
|
9017
|
+
return !node.quasis[0].value.raw.includes("&");
|
|
9018
|
+
}
|
|
9019
|
+
return false;
|
|
9020
|
+
};
|
|
8870
9021
|
return {
|
|
8871
|
-
Property
|
|
8872
|
-
|
|
9022
|
+
// Use AST selector to target Property nodes with non-Identifier keys whose value is an ObjectExpression
|
|
9023
|
+
'Property[key.type!=/Identifier/][value.type="ObjectExpression"]'(node) {
|
|
9024
|
+
const inPandaFunction = isCachedInPandaFunction(node);
|
|
9025
|
+
const inJSXProp = isCachedInJSXProp(node);
|
|
9026
|
+
if (!inPandaFunction && !inJSXProp)
|
|
8873
9027
|
return;
|
|
8874
|
-
|
|
8875
|
-
if (!caller && !isInJSXProp(node, context))
|
|
9028
|
+
if (isCachedRecipeVariant(node))
|
|
8876
9029
|
return;
|
|
8877
|
-
if (
|
|
9030
|
+
if (isCachedStyledProperty(node))
|
|
8878
9031
|
return;
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
node: node.key,
|
|
8887
|
-
messageId: "nesting"
|
|
8888
|
-
});
|
|
9032
|
+
const keyNode = node.key;
|
|
9033
|
+
if (isInvalidNestingSelector(keyNode)) {
|
|
9034
|
+
context.report({
|
|
9035
|
+
node: keyNode,
|
|
9036
|
+
messageId: "nesting"
|
|
9037
|
+
});
|
|
9038
|
+
}
|
|
8889
9039
|
}
|
|
8890
9040
|
};
|
|
8891
9041
|
}
|
|
@@ -8915,87 +9065,89 @@ var init_no_invalid_token_paths = __esm({
|
|
|
8915
9065
|
messages: {
|
|
8916
9066
|
noInvalidTokenPaths: "`{{token}}` is an invalid token path."
|
|
8917
9067
|
},
|
|
8918
|
-
type: "
|
|
9068
|
+
type: "problem",
|
|
8919
9069
|
schema: []
|
|
8920
9070
|
},
|
|
8921
9071
|
defaultOptions: [],
|
|
8922
9072
|
create(context) {
|
|
8923
|
-
const
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
sendReport(node);
|
|
8927
|
-
};
|
|
8928
|
-
const handleTemplateLiteral = (node) => {
|
|
8929
|
-
if (!isTemplateLiteral(node))
|
|
9073
|
+
const invalidTokensCache2 = /* @__PURE__ */ new Map();
|
|
9074
|
+
const sendReport = (node, value) => {
|
|
9075
|
+
if (!value)
|
|
8930
9076
|
return;
|
|
8931
|
-
|
|
9077
|
+
let tokens = invalidTokensCache2.get(value);
|
|
9078
|
+
if (!tokens) {
|
|
9079
|
+
tokens = getInvalidTokens(value, context);
|
|
9080
|
+
invalidTokensCache2.set(value, tokens);
|
|
9081
|
+
}
|
|
9082
|
+
if (tokens.length === 0)
|
|
8932
9083
|
return;
|
|
8933
|
-
|
|
9084
|
+
tokens.forEach((token) => {
|
|
9085
|
+
context.report({
|
|
9086
|
+
node,
|
|
9087
|
+
messageId: "noInvalidTokenPaths",
|
|
9088
|
+
data: { token }
|
|
9089
|
+
});
|
|
9090
|
+
});
|
|
8934
9091
|
};
|
|
8935
|
-
const
|
|
8936
|
-
|
|
8937
|
-
const tokens = getInvalidTokens(value, context);
|
|
8938
|
-
if (!tokens)
|
|
9092
|
+
const handleLiteralOrTemplate = (node) => {
|
|
9093
|
+
if (!node)
|
|
8939
9094
|
return;
|
|
8940
|
-
if (
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
});
|
|
8947
|
-
});
|
|
9095
|
+
if (isLiteral(node)) {
|
|
9096
|
+
const value = node.value?.toString();
|
|
9097
|
+
sendReport(node, value);
|
|
9098
|
+
} else if (isTemplateLiteral(node) && node.expressions.length === 0) {
|
|
9099
|
+
const value = node.quasis[0].value.raw;
|
|
9100
|
+
sendReport(node.quasis[0], value);
|
|
8948
9101
|
}
|
|
8949
9102
|
};
|
|
8950
9103
|
return {
|
|
8951
9104
|
JSXAttribute(node) {
|
|
8952
|
-
if (!node.value)
|
|
8953
|
-
return;
|
|
8954
|
-
if (!isPandaProp(node, context))
|
|
8955
|
-
return;
|
|
8956
|
-
handleLiteral(node.value);
|
|
8957
|
-
if (!isJSXExpressionContainer(node.value))
|
|
9105
|
+
if (!node.value || !isPandaProp(node, context))
|
|
8958
9106
|
return;
|
|
8959
|
-
|
|
8960
|
-
|
|
9107
|
+
if (isLiteral(node.value)) {
|
|
9108
|
+
handleLiteralOrTemplate(node.value);
|
|
9109
|
+
} else if (isJSXExpressionContainer(node.value)) {
|
|
9110
|
+
handleLiteralOrTemplate(node.value.expression);
|
|
9111
|
+
}
|
|
8961
9112
|
},
|
|
8962
9113
|
Property(node) {
|
|
8963
|
-
if (!isIdentifier(node.key))
|
|
8964
|
-
return;
|
|
8965
|
-
if (!isNodeOfTypes([AST_NODE_TYPES2.Literal, AST_NODE_TYPES2.TemplateLiteral])(node.value))
|
|
8966
|
-
return;
|
|
8967
|
-
if (!isPandaAttribute(node, context))
|
|
8968
|
-
return;
|
|
8969
|
-
if (isRecipeVariant(node, context))
|
|
9114
|
+
if (!isIdentifier(node.key) || !isNodeOfTypes([AST_NODE_TYPES2.Literal, AST_NODE_TYPES2.TemplateLiteral])(node.value) || !isPandaAttribute(node, context) || isRecipeVariant(node, context)) {
|
|
8970
9115
|
return;
|
|
8971
|
-
|
|
8972
|
-
|
|
9116
|
+
}
|
|
9117
|
+
handleLiteralOrTemplate(node.value);
|
|
8973
9118
|
},
|
|
8974
9119
|
TaggedTemplateExpression(node) {
|
|
8975
9120
|
const caller = getTaggedTemplateCaller(node);
|
|
8976
|
-
if (!caller)
|
|
8977
|
-
return;
|
|
8978
|
-
if (!isPandaIsh(caller, context))
|
|
8979
|
-
return;
|
|
8980
|
-
const quasis = node.quasi.quasis[0];
|
|
8981
|
-
const styles = quasis.value.raw;
|
|
8982
|
-
const tokens = getInvalidTokens(styles, context);
|
|
8983
|
-
if (!tokens)
|
|
9121
|
+
if (!caller || !isPandaIsh(caller, context))
|
|
8984
9122
|
return;
|
|
8985
|
-
|
|
8986
|
-
|
|
9123
|
+
const quasis = node.quasi.quasis;
|
|
9124
|
+
quasis.forEach((quasi) => {
|
|
9125
|
+
const styles = quasi.value.raw;
|
|
9126
|
+
if (!styles)
|
|
8987
9127
|
return;
|
|
8988
|
-
let
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
context.report({
|
|
8993
|
-
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
|
|
8994
|
-
messageId: "noInvalidTokenPaths",
|
|
8995
|
-
data: { token }
|
|
8996
|
-
});
|
|
8997
|
-
index = styles.indexOf(token, index + 1);
|
|
9128
|
+
let tokens = invalidTokensCache2.get(styles);
|
|
9129
|
+
if (!tokens) {
|
|
9130
|
+
tokens = getInvalidTokens(styles, context);
|
|
9131
|
+
invalidTokensCache2.set(styles, tokens);
|
|
8998
9132
|
}
|
|
9133
|
+
if (tokens.length === 0)
|
|
9134
|
+
return;
|
|
9135
|
+
tokens.forEach((token) => {
|
|
9136
|
+
let index = styles.indexOf(token);
|
|
9137
|
+
while (index !== -1) {
|
|
9138
|
+
const start = quasi.range[0] + index + 1;
|
|
9139
|
+
const end = start + token.length;
|
|
9140
|
+
context.report({
|
|
9141
|
+
loc: {
|
|
9142
|
+
start: context.sourceCode.getLocFromIndex(start),
|
|
9143
|
+
end: context.sourceCode.getLocFromIndex(end)
|
|
9144
|
+
},
|
|
9145
|
+
messageId: "noInvalidTokenPaths",
|
|
9146
|
+
data: { token }
|
|
9147
|
+
});
|
|
9148
|
+
index = styles.indexOf(token, index + token.length);
|
|
9149
|
+
}
|
|
9150
|
+
});
|
|
8999
9151
|
});
|
|
9000
9152
|
}
|
|
9001
9153
|
};
|
|
@@ -9029,29 +9181,69 @@ var init_no_margin_properties = __esm({
|
|
|
9029
9181
|
},
|
|
9030
9182
|
defaultOptions: [],
|
|
9031
9183
|
create(context) {
|
|
9032
|
-
const
|
|
9184
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9185
|
+
const getLonghand = (name2) => {
|
|
9186
|
+
if (longhandCache.has(name2)) {
|
|
9187
|
+
return longhandCache.get(name2);
|
|
9188
|
+
}
|
|
9189
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9190
|
+
longhandCache.set(name2, longhand);
|
|
9191
|
+
return longhand;
|
|
9192
|
+
};
|
|
9193
|
+
const marginRegex = /margin/i;
|
|
9194
|
+
const isMarginProperty = (name2) => {
|
|
9195
|
+
const longhand = getLonghand(name2).toLowerCase();
|
|
9196
|
+
return marginRegex.test(longhand);
|
|
9197
|
+
};
|
|
9033
9198
|
const sendReport = (node) => {
|
|
9034
|
-
if (!
|
|
9199
|
+
if (!isMarginProperty(node.name))
|
|
9035
9200
|
return;
|
|
9036
|
-
|
|
9201
|
+
context.report({
|
|
9037
9202
|
node,
|
|
9038
9203
|
messageId: "noMargin"
|
|
9039
9204
|
});
|
|
9040
9205
|
};
|
|
9206
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9207
|
+
const isCachedPandaProp = (node) => {
|
|
9208
|
+
if (pandaPropCache.has(node)) {
|
|
9209
|
+
return pandaPropCache.get(node);
|
|
9210
|
+
}
|
|
9211
|
+
const result = isPandaProp(node, context);
|
|
9212
|
+
pandaPropCache.set(node, result);
|
|
9213
|
+
return !!result;
|
|
9214
|
+
};
|
|
9215
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9216
|
+
const isCachedPandaAttribute = (node) => {
|
|
9217
|
+
if (pandaAttributeCache.has(node)) {
|
|
9218
|
+
return pandaAttributeCache.get(node);
|
|
9219
|
+
}
|
|
9220
|
+
const result = isPandaAttribute(node, context);
|
|
9221
|
+
pandaAttributeCache.set(node, result);
|
|
9222
|
+
return !!result;
|
|
9223
|
+
};
|
|
9224
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9225
|
+
const isCachedRecipeVariant = (node) => {
|
|
9226
|
+
if (recipeVariantCache.has(node)) {
|
|
9227
|
+
return recipeVariantCache.get(node);
|
|
9228
|
+
}
|
|
9229
|
+
const result = isRecipeVariant(node, context);
|
|
9230
|
+
recipeVariantCache.set(node, result);
|
|
9231
|
+
return !!result;
|
|
9232
|
+
};
|
|
9041
9233
|
return {
|
|
9042
9234
|
JSXAttribute(node) {
|
|
9043
9235
|
if (!isJSXIdentifier(node.name))
|
|
9044
9236
|
return;
|
|
9045
|
-
if (!
|
|
9237
|
+
if (!isCachedPandaProp(node))
|
|
9046
9238
|
return;
|
|
9047
9239
|
sendReport(node.name);
|
|
9048
9240
|
},
|
|
9049
9241
|
Property(node) {
|
|
9050
9242
|
if (!isIdentifier(node.key))
|
|
9051
9243
|
return;
|
|
9052
|
-
if (!
|
|
9244
|
+
if (!isCachedPandaAttribute(node))
|
|
9053
9245
|
return;
|
|
9054
|
-
if (
|
|
9246
|
+
if (isCachedRecipeVariant(node))
|
|
9055
9247
|
return;
|
|
9056
9248
|
sendReport(node.key);
|
|
9057
9249
|
}
|
|
@@ -9120,11 +9312,11 @@ var init_no_physical_properties = __esm({
|
|
|
9120
9312
|
name: RULE_NAME11,
|
|
9121
9313
|
meta: {
|
|
9122
9314
|
docs: {
|
|
9123
|
-
description: "Encourage the use of
|
|
9315
|
+
description: "Encourage the use of logical properties over physical properties to foster a responsive and adaptable user interface."
|
|
9124
9316
|
},
|
|
9125
9317
|
messages: {
|
|
9126
|
-
physical: "Use logical property of {{physical}}
|
|
9127
|
-
replace: "Replace `{{physical}}` with `{{logical}}
|
|
9318
|
+
physical: "Use logical property instead of {{physical}}. Prefer `{{logical}}`.",
|
|
9319
|
+
replace: "Replace `{{physical}}` with `{{logical}}`."
|
|
9128
9320
|
},
|
|
9129
9321
|
type: "suggestion",
|
|
9130
9322
|
hasSuggestions: true,
|
|
@@ -9132,17 +9324,53 @@ var init_no_physical_properties = __esm({
|
|
|
9132
9324
|
},
|
|
9133
9325
|
defaultOptions: [],
|
|
9134
9326
|
create(context) {
|
|
9135
|
-
const
|
|
9327
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9328
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9329
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9330
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9331
|
+
const getLonghand = (name2) => {
|
|
9332
|
+
if (longhandCache.has(name2)) {
|
|
9333
|
+
return longhandCache.get(name2);
|
|
9334
|
+
}
|
|
9335
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9336
|
+
longhandCache.set(name2, longhand);
|
|
9337
|
+
return longhand;
|
|
9338
|
+
};
|
|
9339
|
+
const isCachedPandaProp = (node) => {
|
|
9340
|
+
if (pandaPropCache.has(node)) {
|
|
9341
|
+
return pandaPropCache.get(node);
|
|
9342
|
+
}
|
|
9343
|
+
const result = isPandaProp(node, context);
|
|
9344
|
+
pandaPropCache.set(node, result);
|
|
9345
|
+
return !!result;
|
|
9346
|
+
};
|
|
9347
|
+
const isCachedPandaAttribute = (node) => {
|
|
9348
|
+
if (pandaAttributeCache.has(node)) {
|
|
9349
|
+
return pandaAttributeCache.get(node);
|
|
9350
|
+
}
|
|
9351
|
+
const result = isPandaAttribute(node, context);
|
|
9352
|
+
pandaAttributeCache.set(node, result);
|
|
9353
|
+
return !!result;
|
|
9354
|
+
};
|
|
9355
|
+
const isCachedRecipeVariant = (node) => {
|
|
9356
|
+
if (recipeVariantCache.has(node)) {
|
|
9357
|
+
return recipeVariantCache.get(node);
|
|
9358
|
+
}
|
|
9359
|
+
const result = isRecipeVariant(node, context);
|
|
9360
|
+
recipeVariantCache.set(node, result);
|
|
9361
|
+
return !!result;
|
|
9362
|
+
};
|
|
9136
9363
|
const sendReport = (node) => {
|
|
9137
|
-
|
|
9364
|
+
const longhandName = getLonghand(node.name);
|
|
9365
|
+
if (!(longhandName in physicalProperties))
|
|
9138
9366
|
return;
|
|
9139
|
-
const logical = physicalProperties[
|
|
9140
|
-
const
|
|
9141
|
-
|
|
9367
|
+
const logical = physicalProperties[longhandName];
|
|
9368
|
+
const physicalName = `\`${node.name}\`${longhandName !== node.name ? ` (resolved to \`${longhandName}\`)` : ""}`;
|
|
9369
|
+
context.report({
|
|
9142
9370
|
node,
|
|
9143
9371
|
messageId: "physical",
|
|
9144
9372
|
data: {
|
|
9145
|
-
physical:
|
|
9373
|
+
physical: physicalName,
|
|
9146
9374
|
logical
|
|
9147
9375
|
},
|
|
9148
9376
|
suggest: [
|
|
@@ -9153,7 +9381,7 @@ var init_no_physical_properties = __esm({
|
|
|
9153
9381
|
logical
|
|
9154
9382
|
},
|
|
9155
9383
|
fix: (fixer) => {
|
|
9156
|
-
return fixer.
|
|
9384
|
+
return fixer.replaceText(node, logical);
|
|
9157
9385
|
}
|
|
9158
9386
|
}
|
|
9159
9387
|
]
|
|
@@ -9163,16 +9391,16 @@ var init_no_physical_properties = __esm({
|
|
|
9163
9391
|
JSXAttribute(node) {
|
|
9164
9392
|
if (!isJSXIdentifier(node.name))
|
|
9165
9393
|
return;
|
|
9166
|
-
if (!
|
|
9394
|
+
if (!isCachedPandaProp(node))
|
|
9167
9395
|
return;
|
|
9168
9396
|
sendReport(node.name);
|
|
9169
9397
|
},
|
|
9170
9398
|
Property(node) {
|
|
9171
9399
|
if (!isIdentifier(node.key))
|
|
9172
9400
|
return;
|
|
9173
|
-
if (!
|
|
9401
|
+
if (!isCachedPandaAttribute(node))
|
|
9174
9402
|
return;
|
|
9175
|
-
if (
|
|
9403
|
+
if (isCachedRecipeVariant(node))
|
|
9176
9404
|
return;
|
|
9177
9405
|
sendReport(node.key);
|
|
9178
9406
|
}
|
|
@@ -9197,19 +9425,46 @@ var init_no_property_renaming = __esm({
|
|
|
9197
9425
|
name: RULE_NAME12,
|
|
9198
9426
|
meta: {
|
|
9199
9427
|
docs: {
|
|
9200
|
-
description: "Ensure
|
|
9428
|
+
description: "Ensure that properties for patterns or style props are not renamed, as it prevents proper tracking."
|
|
9201
9429
|
},
|
|
9202
9430
|
messages: {
|
|
9203
|
-
noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute.
|
|
9431
|
+
noRenaming: "Incoming `{{prop}}` prop is different from the expected `{{expected}}` attribute. Panda will not track this prop."
|
|
9204
9432
|
},
|
|
9205
|
-
type: "
|
|
9433
|
+
type: "problem",
|
|
9206
9434
|
schema: []
|
|
9207
9435
|
},
|
|
9208
9436
|
defaultOptions: [],
|
|
9209
9437
|
create(context) {
|
|
9438
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9439
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9440
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9441
|
+
const isCachedPandaProp = (node) => {
|
|
9442
|
+
if (pandaPropCache.has(node)) {
|
|
9443
|
+
return pandaPropCache.get(node);
|
|
9444
|
+
}
|
|
9445
|
+
const result = isPandaProp(node, context);
|
|
9446
|
+
pandaPropCache.set(node, result);
|
|
9447
|
+
return !!result;
|
|
9448
|
+
};
|
|
9449
|
+
const isCachedPandaAttribute = (node) => {
|
|
9450
|
+
if (pandaAttributeCache.has(node)) {
|
|
9451
|
+
return pandaAttributeCache.get(node);
|
|
9452
|
+
}
|
|
9453
|
+
const result = isPandaAttribute(node, context);
|
|
9454
|
+
pandaAttributeCache.set(node, result);
|
|
9455
|
+
return !!result;
|
|
9456
|
+
};
|
|
9457
|
+
const isCachedRecipeVariant = (node) => {
|
|
9458
|
+
if (recipeVariantCache.has(node)) {
|
|
9459
|
+
return recipeVariantCache.get(node);
|
|
9460
|
+
}
|
|
9461
|
+
const result = isRecipeVariant(node, context);
|
|
9462
|
+
recipeVariantCache.set(node, result);
|
|
9463
|
+
return !!result;
|
|
9464
|
+
};
|
|
9210
9465
|
const sendReport = (node, expected, prop) => {
|
|
9211
|
-
|
|
9212
|
-
node
|
|
9466
|
+
context.report({
|
|
9467
|
+
node,
|
|
9213
9468
|
messageId: "noRenaming",
|
|
9214
9469
|
data: {
|
|
9215
9470
|
expected,
|
|
@@ -9219,10 +9474,9 @@ var init_no_property_renaming = __esm({
|
|
|
9219
9474
|
};
|
|
9220
9475
|
const handleReport = (node, value, attr) => {
|
|
9221
9476
|
if (isIdentifier(value) && attr !== value.name) {
|
|
9222
|
-
|
|
9223
|
-
}
|
|
9224
|
-
|
|
9225
|
-
return sendReport(node, attr, value.property.name);
|
|
9477
|
+
sendReport(node, attr, value.name);
|
|
9478
|
+
} else if (isMemberExpression(value) && isIdentifier(value.property) && attr !== value.property.name) {
|
|
9479
|
+
sendReport(node, attr, value.property.name);
|
|
9226
9480
|
}
|
|
9227
9481
|
};
|
|
9228
9482
|
return {
|
|
@@ -9231,24 +9485,24 @@ var init_no_property_renaming = __esm({
|
|
|
9231
9485
|
return;
|
|
9232
9486
|
if (!isJSXExpressionContainer(node.value))
|
|
9233
9487
|
return;
|
|
9234
|
-
if (!
|
|
9488
|
+
if (!isCachedPandaProp(node))
|
|
9235
9489
|
return;
|
|
9236
9490
|
const attr = node.name.name.toString();
|
|
9237
9491
|
const expression = node.value.expression;
|
|
9238
|
-
handleReport(node, expression, attr);
|
|
9492
|
+
handleReport(node.value, expression, attr);
|
|
9239
9493
|
},
|
|
9240
9494
|
Property(node) {
|
|
9241
9495
|
if (!isIdentifier(node.key))
|
|
9242
9496
|
return;
|
|
9243
9497
|
if (!isIdentifier(node.value) && !isMemberExpression(node.value))
|
|
9244
9498
|
return;
|
|
9245
|
-
if (!
|
|
9499
|
+
if (!isCachedPandaAttribute(node))
|
|
9246
9500
|
return;
|
|
9247
|
-
if (
|
|
9501
|
+
if (isCachedRecipeVariant(node))
|
|
9248
9502
|
return;
|
|
9249
|
-
const attr = node.key.name
|
|
9503
|
+
const attr = node.key.name;
|
|
9250
9504
|
const value = node.value;
|
|
9251
|
-
handleReport(node, value, attr);
|
|
9505
|
+
handleReport(node.value, value, attr);
|
|
9252
9506
|
}
|
|
9253
9507
|
};
|
|
9254
9508
|
}
|
|
@@ -9276,8 +9530,8 @@ var init_no_unsafe_token_fn_usage = __esm({
|
|
|
9276
9530
|
description: "Prevent users from using the token function in situations where they could simply use the raw design token."
|
|
9277
9531
|
},
|
|
9278
9532
|
messages: {
|
|
9279
|
-
noUnsafeTokenFnUsage: "
|
|
9280
|
-
replace: "Replace token function with `{{safe}}
|
|
9533
|
+
noUnsafeTokenFnUsage: "Unnecessary token function usage. Prefer design token.",
|
|
9534
|
+
replace: "Replace token function with `{{safe}}`."
|
|
9281
9535
|
},
|
|
9282
9536
|
type: "suggestion",
|
|
9283
9537
|
hasSuggestions: true,
|
|
@@ -9285,11 +9539,42 @@ var init_no_unsafe_token_fn_usage = __esm({
|
|
|
9285
9539
|
},
|
|
9286
9540
|
defaultOptions: [],
|
|
9287
9541
|
create(context) {
|
|
9542
|
+
let tokenImportCache;
|
|
9543
|
+
const getCachedTokenImport = () => {
|
|
9544
|
+
if (tokenImportCache !== void 0) {
|
|
9545
|
+
return tokenImportCache;
|
|
9546
|
+
}
|
|
9547
|
+
tokenImportCache = getTokenImport(context);
|
|
9548
|
+
return tokenImportCache;
|
|
9549
|
+
};
|
|
9288
9550
|
const isUnsafeCallExpression = (node) => {
|
|
9289
|
-
const tkImport =
|
|
9551
|
+
const tkImport = getCachedTokenImport();
|
|
9290
9552
|
return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
|
|
9291
9553
|
};
|
|
9292
9554
|
const tokenWrap = (value) => value ? `token(${value})` : "";
|
|
9555
|
+
const isCompositeValue = (input) => {
|
|
9556
|
+
if (!input)
|
|
9557
|
+
return false;
|
|
9558
|
+
const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
|
|
9559
|
+
return !tokenRegex.test(input);
|
|
9560
|
+
};
|
|
9561
|
+
const sendReport = (node, value) => {
|
|
9562
|
+
const tkImports = extractTokens(value);
|
|
9563
|
+
if (!tkImports.length)
|
|
9564
|
+
return;
|
|
9565
|
+
const token = tkImports[0].replace(/^[^.]*\./, "");
|
|
9566
|
+
context.report({
|
|
9567
|
+
node,
|
|
9568
|
+
messageId: "noUnsafeTokenFnUsage",
|
|
9569
|
+
suggest: [
|
|
9570
|
+
{
|
|
9571
|
+
messageId: "replace",
|
|
9572
|
+
data: { safe: token },
|
|
9573
|
+
fix: (fixer) => fixer.replaceText(node, `'${token}'`)
|
|
9574
|
+
}
|
|
9575
|
+
]
|
|
9576
|
+
});
|
|
9577
|
+
};
|
|
9293
9578
|
const handleRuntimeFm = (node) => {
|
|
9294
9579
|
if (!isCallExpression(node))
|
|
9295
9580
|
return;
|
|
@@ -9297,17 +9582,12 @@ var init_no_unsafe_token_fn_usage = __esm({
|
|
|
9297
9582
|
return;
|
|
9298
9583
|
const value = node.arguments[0];
|
|
9299
9584
|
if (isLiteral(value)) {
|
|
9300
|
-
|
|
9585
|
+
const val = getArbitraryValue3(value.value?.toString() ?? "");
|
|
9586
|
+
sendReport(node, tokenWrap(val));
|
|
9587
|
+
} else if (isTemplateLiteral(value) && value.expressions.length === 0) {
|
|
9588
|
+
const val = getArbitraryValue3(value.quasis[0].value.raw);
|
|
9589
|
+
sendReport(node, tokenWrap(val));
|
|
9301
9590
|
}
|
|
9302
|
-
if (isTemplateLiteral(value)) {
|
|
9303
|
-
sendReport(node, tokenWrap(getArbitraryValue3(value.quasis[0].value.raw)));
|
|
9304
|
-
}
|
|
9305
|
-
};
|
|
9306
|
-
const isCompositeValue = (input) => {
|
|
9307
|
-
if (!input)
|
|
9308
|
-
return;
|
|
9309
|
-
const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
|
|
9310
|
-
return !tokenRegex.test(input);
|
|
9311
9591
|
};
|
|
9312
9592
|
const handleLiteral = (node) => {
|
|
9313
9593
|
if (!isLiteral(node))
|
|
@@ -9318,54 +9598,63 @@ var init_no_unsafe_token_fn_usage = __esm({
|
|
|
9318
9598
|
sendReport(node, value);
|
|
9319
9599
|
};
|
|
9320
9600
|
const handleTemplateLiteral = (node) => {
|
|
9321
|
-
if (!isTemplateLiteral(node))
|
|
9601
|
+
if (!isTemplateLiteral(node) || node.expressions.length > 0)
|
|
9322
9602
|
return;
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
sendReport(node, getArbitraryValue3(node.quasis[0].value.raw));
|
|
9603
|
+
const value = getArbitraryValue3(node.quasis[0].value.raw);
|
|
9604
|
+
sendReport(node, value);
|
|
9326
9605
|
};
|
|
9327
|
-
const
|
|
9328
|
-
|
|
9329
|
-
if (
|
|
9330
|
-
return;
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9606
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9607
|
+
const isCachedPandaProp = (node) => {
|
|
9608
|
+
if (pandaPropCache.has(node)) {
|
|
9609
|
+
return pandaPropCache.get(node);
|
|
9610
|
+
}
|
|
9611
|
+
const result = isPandaProp(node, context);
|
|
9612
|
+
pandaPropCache.set(node, result);
|
|
9613
|
+
return !!result;
|
|
9614
|
+
};
|
|
9615
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9616
|
+
const isCachedPandaAttribute = (node) => {
|
|
9617
|
+
if (pandaAttributeCache.has(node)) {
|
|
9618
|
+
return pandaAttributeCache.get(node);
|
|
9619
|
+
}
|
|
9620
|
+
const result = isPandaAttribute(node, context);
|
|
9621
|
+
pandaAttributeCache.set(node, result);
|
|
9622
|
+
return !!result;
|
|
9623
|
+
};
|
|
9624
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9625
|
+
const isCachedRecipeVariant = (node) => {
|
|
9626
|
+
if (recipeVariantCache.has(node)) {
|
|
9627
|
+
return recipeVariantCache.get(node);
|
|
9628
|
+
}
|
|
9629
|
+
const result = isRecipeVariant(node, context);
|
|
9630
|
+
recipeVariantCache.set(node, result);
|
|
9631
|
+
return !!result;
|
|
9345
9632
|
};
|
|
9346
9633
|
return {
|
|
9347
9634
|
JSXAttribute(node) {
|
|
9348
9635
|
if (!node.value)
|
|
9349
9636
|
return;
|
|
9350
|
-
if (!
|
|
9637
|
+
if (!isCachedPandaProp(node))
|
|
9351
9638
|
return;
|
|
9352
9639
|
handleLiteral(node.value);
|
|
9353
|
-
if (
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9640
|
+
if (isJSXExpressionContainer(node.value)) {
|
|
9641
|
+
const expression = node.value.expression;
|
|
9642
|
+
handleLiteral(expression);
|
|
9643
|
+
handleTemplateLiteral(expression);
|
|
9644
|
+
handleRuntimeFm(expression);
|
|
9645
|
+
}
|
|
9358
9646
|
},
|
|
9359
9647
|
Property(node) {
|
|
9360
|
-
if (!
|
|
9648
|
+
if (!isCachedPandaAttribute(node))
|
|
9361
9649
|
return;
|
|
9362
|
-
if (
|
|
9650
|
+
if (isCachedRecipeVariant(node))
|
|
9363
9651
|
return;
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9652
|
+
const valueNode = node.value;
|
|
9653
|
+
if (isCallExpression(valueNode) || isLiteral(valueNode) || isTemplateLiteral(valueNode)) {
|
|
9654
|
+
handleRuntimeFm(valueNode);
|
|
9655
|
+
handleLiteral(valueNode);
|
|
9656
|
+
handleTemplateLiteral(valueNode);
|
|
9657
|
+
}
|
|
9369
9658
|
}
|
|
9370
9659
|
};
|
|
9371
9660
|
}
|
|
@@ -9391,8 +9680,8 @@ var init_prefer_longhand_properties = __esm({
|
|
|
9391
9680
|
description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
|
|
9392
9681
|
},
|
|
9393
9682
|
messages: {
|
|
9394
|
-
longhand: "Use longhand property of `{{shorthand}}
|
|
9395
|
-
replace: "Replace `{{shorthand}}` with `{{longhand}}
|
|
9683
|
+
longhand: "Use longhand property instead of `{{shorthand}}`. Prefer `{{longhand}}`.",
|
|
9684
|
+
replace: "Replace `{{shorthand}}` with `{{longhand}}`."
|
|
9396
9685
|
},
|
|
9397
9686
|
type: "suggestion",
|
|
9398
9687
|
hasSuggestions: true,
|
|
@@ -9400,15 +9689,51 @@ var init_prefer_longhand_properties = __esm({
|
|
|
9400
9689
|
},
|
|
9401
9690
|
defaultOptions: [],
|
|
9402
9691
|
create(context) {
|
|
9692
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9693
|
+
const getLonghand = (name2) => {
|
|
9694
|
+
if (longhandCache.has(name2)) {
|
|
9695
|
+
return longhandCache.get(name2);
|
|
9696
|
+
}
|
|
9697
|
+
const longhand = resolveLonghand(name2, context);
|
|
9698
|
+
longhandCache.set(name2, longhand);
|
|
9699
|
+
return longhand;
|
|
9700
|
+
};
|
|
9701
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9702
|
+
const isCachedPandaProp = (node) => {
|
|
9703
|
+
if (pandaPropCache.has(node)) {
|
|
9704
|
+
return pandaPropCache.get(node);
|
|
9705
|
+
}
|
|
9706
|
+
const result = isPandaProp(node, context);
|
|
9707
|
+
pandaPropCache.set(node, result);
|
|
9708
|
+
return !!result;
|
|
9709
|
+
};
|
|
9710
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9711
|
+
const isCachedPandaAttribute = (node) => {
|
|
9712
|
+
if (pandaAttributeCache.has(node)) {
|
|
9713
|
+
return pandaAttributeCache.get(node);
|
|
9714
|
+
}
|
|
9715
|
+
const result = isPandaAttribute(node, context);
|
|
9716
|
+
pandaAttributeCache.set(node, result);
|
|
9717
|
+
return !!result;
|
|
9718
|
+
};
|
|
9719
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9720
|
+
const isCachedRecipeVariant = (node) => {
|
|
9721
|
+
if (recipeVariantCache.has(node)) {
|
|
9722
|
+
return recipeVariantCache.get(node);
|
|
9723
|
+
}
|
|
9724
|
+
const result = isRecipeVariant(node, context);
|
|
9725
|
+
recipeVariantCache.set(node, result);
|
|
9726
|
+
return !!result;
|
|
9727
|
+
};
|
|
9403
9728
|
const sendReport = (node) => {
|
|
9404
|
-
const longhand =
|
|
9405
|
-
if (!longhand)
|
|
9729
|
+
const longhand = getLonghand(node.name);
|
|
9730
|
+
if (!longhand || longhand === node.name)
|
|
9406
9731
|
return;
|
|
9407
9732
|
const data = {
|
|
9408
9733
|
shorthand: node.name,
|
|
9409
9734
|
longhand
|
|
9410
9735
|
};
|
|
9411
|
-
|
|
9736
|
+
context.report({
|
|
9412
9737
|
node,
|
|
9413
9738
|
messageId: "longhand",
|
|
9414
9739
|
data,
|
|
@@ -9416,9 +9741,7 @@ var init_prefer_longhand_properties = __esm({
|
|
|
9416
9741
|
{
|
|
9417
9742
|
messageId: "replace",
|
|
9418
9743
|
data,
|
|
9419
|
-
fix: (fixer) =>
|
|
9420
|
-
return fixer.replaceTextRange(node.range, longhand);
|
|
9421
|
-
}
|
|
9744
|
+
fix: (fixer) => fixer.replaceText(node, longhand)
|
|
9422
9745
|
}
|
|
9423
9746
|
]
|
|
9424
9747
|
});
|
|
@@ -9427,16 +9750,16 @@ var init_prefer_longhand_properties = __esm({
|
|
|
9427
9750
|
JSXAttribute(node) {
|
|
9428
9751
|
if (!isJSXIdentifier(node.name))
|
|
9429
9752
|
return;
|
|
9430
|
-
if (!
|
|
9753
|
+
if (!isCachedPandaProp(node))
|
|
9431
9754
|
return;
|
|
9432
9755
|
sendReport(node.name);
|
|
9433
9756
|
},
|
|
9434
9757
|
Property(node) {
|
|
9435
9758
|
if (!isIdentifier(node.key))
|
|
9436
9759
|
return;
|
|
9437
|
-
if (!
|
|
9760
|
+
if (!isCachedPandaAttribute(node))
|
|
9438
9761
|
return;
|
|
9439
|
-
if (
|
|
9762
|
+
if (isCachedRecipeVariant(node))
|
|
9440
9763
|
return;
|
|
9441
9764
|
sendReport(node.key);
|
|
9442
9765
|
}
|
|
@@ -9464,8 +9787,8 @@ var init_prefer_shorthand_properties = __esm({
|
|
|
9464
9787
|
description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
|
|
9465
9788
|
},
|
|
9466
9789
|
messages: {
|
|
9467
|
-
shorthand: "Use shorthand property of `{{longhand}}
|
|
9468
|
-
replace: "Replace `{{longhand}}` with `{{shorthand}}
|
|
9790
|
+
shorthand: "Use shorthand property instead of `{{longhand}}`. Prefer `{{shorthand}}`.",
|
|
9791
|
+
replace: "Replace `{{longhand}}` with `{{shorthand}}`."
|
|
9469
9792
|
},
|
|
9470
9793
|
type: "suggestion",
|
|
9471
9794
|
hasSuggestions: true,
|
|
@@ -9473,19 +9796,64 @@ var init_prefer_shorthand_properties = __esm({
|
|
|
9473
9796
|
},
|
|
9474
9797
|
defaultOptions: [],
|
|
9475
9798
|
create(context) {
|
|
9799
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
9800
|
+
const getLonghand = (name2) => {
|
|
9801
|
+
if (longhandCache.has(name2)) {
|
|
9802
|
+
return longhandCache.get(name2);
|
|
9803
|
+
}
|
|
9804
|
+
const longhand = resolveLonghand(name2, context);
|
|
9805
|
+
longhandCache.set(name2, longhand);
|
|
9806
|
+
return longhand;
|
|
9807
|
+
};
|
|
9808
|
+
const shorthandsCache = /* @__PURE__ */ new Map();
|
|
9809
|
+
const getShorthands = (name2) => {
|
|
9810
|
+
if (shorthandsCache.has(name2)) {
|
|
9811
|
+
return shorthandsCache.get(name2);
|
|
9812
|
+
}
|
|
9813
|
+
const shorthands = resolveShorthands(name2, context);
|
|
9814
|
+
shorthandsCache.set(name2, shorthands);
|
|
9815
|
+
return shorthands;
|
|
9816
|
+
};
|
|
9817
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
9818
|
+
const isCachedPandaProp = (node) => {
|
|
9819
|
+
if (pandaPropCache.has(node)) {
|
|
9820
|
+
return pandaPropCache.get(node);
|
|
9821
|
+
}
|
|
9822
|
+
const result = isPandaProp(node, context);
|
|
9823
|
+
pandaPropCache.set(node, result);
|
|
9824
|
+
return !!result;
|
|
9825
|
+
};
|
|
9826
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
9827
|
+
const isCachedPandaAttribute = (node) => {
|
|
9828
|
+
if (pandaAttributeCache.has(node)) {
|
|
9829
|
+
return pandaAttributeCache.get(node);
|
|
9830
|
+
}
|
|
9831
|
+
const result = isPandaAttribute(node, context);
|
|
9832
|
+
pandaAttributeCache.set(node, result);
|
|
9833
|
+
return !!result;
|
|
9834
|
+
};
|
|
9835
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
9836
|
+
const isCachedRecipeVariant = (node) => {
|
|
9837
|
+
if (recipeVariantCache.has(node)) {
|
|
9838
|
+
return recipeVariantCache.get(node);
|
|
9839
|
+
}
|
|
9840
|
+
const result = isRecipeVariant(node, context);
|
|
9841
|
+
recipeVariantCache.set(node, result);
|
|
9842
|
+
return !!result;
|
|
9843
|
+
};
|
|
9476
9844
|
const sendReport = (node) => {
|
|
9477
|
-
const longhand =
|
|
9845
|
+
const longhand = getLonghand(node.name);
|
|
9478
9846
|
if (longhand)
|
|
9479
9847
|
return;
|
|
9480
|
-
const shorthands =
|
|
9481
|
-
if (!shorthands)
|
|
9848
|
+
const shorthands = getShorthands(node.name);
|
|
9849
|
+
if (!shorthands || shorthands.length === 0)
|
|
9482
9850
|
return;
|
|
9483
|
-
const
|
|
9851
|
+
const shorthandList = shorthands.map((s) => `\`${s}\``).join(", ");
|
|
9484
9852
|
const data = {
|
|
9485
9853
|
longhand: node.name,
|
|
9486
|
-
shorthand
|
|
9854
|
+
shorthand: shorthandList
|
|
9487
9855
|
};
|
|
9488
|
-
|
|
9856
|
+
context.report({
|
|
9489
9857
|
node,
|
|
9490
9858
|
messageId: "shorthand",
|
|
9491
9859
|
data,
|
|
@@ -9493,9 +9861,7 @@ var init_prefer_shorthand_properties = __esm({
|
|
|
9493
9861
|
{
|
|
9494
9862
|
messageId: "replace",
|
|
9495
9863
|
data,
|
|
9496
|
-
fix: (fixer) =>
|
|
9497
|
-
return fixer.replaceTextRange(node.range, shorthands[0]);
|
|
9498
|
-
}
|
|
9864
|
+
fix: (fixer) => fixer.replaceText(node, shorthands[0])
|
|
9499
9865
|
}
|
|
9500
9866
|
]
|
|
9501
9867
|
});
|
|
@@ -9504,16 +9870,16 @@ var init_prefer_shorthand_properties = __esm({
|
|
|
9504
9870
|
JSXAttribute(node) {
|
|
9505
9871
|
if (!isJSXIdentifier(node.name))
|
|
9506
9872
|
return;
|
|
9507
|
-
if (!
|
|
9873
|
+
if (!isCachedPandaProp(node))
|
|
9508
9874
|
return;
|
|
9509
9875
|
sendReport(node.name);
|
|
9510
9876
|
},
|
|
9511
9877
|
Property(node) {
|
|
9512
9878
|
if (!isIdentifier(node.key))
|
|
9513
9879
|
return;
|
|
9514
|
-
if (!
|
|
9880
|
+
if (!isCachedPandaAttribute(node))
|
|
9515
9881
|
return;
|
|
9516
|
-
if (
|
|
9882
|
+
if (isCachedRecipeVariant(node))
|
|
9517
9883
|
return;
|
|
9518
9884
|
sendReport(node.key);
|
|
9519
9885
|
}
|
|
@@ -9650,8 +10016,8 @@ var init_prefer_atomic_properties = __esm({
|
|
|
9650
10016
|
"src/rules/prefer-atomic-properties.ts"() {
|
|
9651
10017
|
"use strict";
|
|
9652
10018
|
init_esm_shims();
|
|
9653
|
-
init_helpers();
|
|
9654
10019
|
init_utils();
|
|
10020
|
+
init_helpers();
|
|
9655
10021
|
init_composite_properties();
|
|
9656
10022
|
init_nodes();
|
|
9657
10023
|
RULE_NAME16 = "prefer-atomic-properties";
|
|
@@ -9662,26 +10028,69 @@ var init_prefer_atomic_properties = __esm({
|
|
|
9662
10028
|
description: "Encourage the use of atomic properties instead of composite properties in the codebase."
|
|
9663
10029
|
},
|
|
9664
10030
|
messages: {
|
|
9665
|
-
atomic: "Use atomic properties of `{{composite}}
|
|
10031
|
+
atomic: "Use atomic properties instead of `{{composite}}`. Prefer: \n{{atomics}}"
|
|
9666
10032
|
},
|
|
9667
10033
|
type: "suggestion",
|
|
9668
10034
|
schema: []
|
|
9669
10035
|
},
|
|
9670
10036
|
defaultOptions: [],
|
|
9671
10037
|
create(context) {
|
|
10038
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
10039
|
+
const getLonghand = (name2) => {
|
|
10040
|
+
if (longhandCache.has(name2)) {
|
|
10041
|
+
return longhandCache.get(name2);
|
|
10042
|
+
}
|
|
10043
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
10044
|
+
longhandCache.set(name2, longhand);
|
|
10045
|
+
return longhand;
|
|
10046
|
+
};
|
|
10047
|
+
const compositePropertyCache = /* @__PURE__ */ new Map();
|
|
9672
10048
|
const resolveCompositeProperty = (name2) => {
|
|
9673
|
-
if (
|
|
10049
|
+
if (compositePropertyCache.has(name2)) {
|
|
10050
|
+
return compositePropertyCache.get(name2);
|
|
10051
|
+
}
|
|
10052
|
+
if (Object.hasOwn(compositeProperties, name2)) {
|
|
10053
|
+
compositePropertyCache.set(name2, name2);
|
|
9674
10054
|
return name2;
|
|
9675
|
-
|
|
9676
|
-
|
|
10055
|
+
}
|
|
10056
|
+
const longhand = getLonghand(name2);
|
|
10057
|
+
if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand)) {
|
|
10058
|
+
compositePropertyCache.set(name2, longhand);
|
|
9677
10059
|
return longhand;
|
|
10060
|
+
}
|
|
10061
|
+
compositePropertyCache.set(name2, void 0);
|
|
10062
|
+
return void 0;
|
|
9678
10063
|
};
|
|
9679
|
-
const
|
|
9680
|
-
|
|
9681
|
-
if (
|
|
9682
|
-
return;
|
|
9683
|
-
|
|
9684
|
-
|
|
10064
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
10065
|
+
const isCachedPandaProp = (node) => {
|
|
10066
|
+
if (pandaPropCache.has(node)) {
|
|
10067
|
+
return pandaPropCache.get(node);
|
|
10068
|
+
}
|
|
10069
|
+
const result = isPandaProp(node, context);
|
|
10070
|
+
pandaPropCache.set(node, result);
|
|
10071
|
+
return !!result;
|
|
10072
|
+
};
|
|
10073
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
10074
|
+
const isCachedPandaAttribute = (node) => {
|
|
10075
|
+
if (pandaAttributeCache.has(node)) {
|
|
10076
|
+
return pandaAttributeCache.get(node);
|
|
10077
|
+
}
|
|
10078
|
+
const result = isPandaAttribute(node, context);
|
|
10079
|
+
pandaAttributeCache.set(node, result);
|
|
10080
|
+
return !!result;
|
|
10081
|
+
};
|
|
10082
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
10083
|
+
const isCachedRecipeVariant = (node) => {
|
|
10084
|
+
if (recipeVariantCache.has(node)) {
|
|
10085
|
+
return recipeVariantCache.get(node);
|
|
10086
|
+
}
|
|
10087
|
+
const result = isRecipeVariant(node, context);
|
|
10088
|
+
recipeVariantCache.set(node, result);
|
|
10089
|
+
return !!result;
|
|
10090
|
+
};
|
|
10091
|
+
const sendReport = (node, composite) => {
|
|
10092
|
+
const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(",\n");
|
|
10093
|
+
context.report({
|
|
9685
10094
|
node,
|
|
9686
10095
|
messageId: "atomic",
|
|
9687
10096
|
data: {
|
|
@@ -9694,18 +10103,24 @@ var init_prefer_atomic_properties = __esm({
|
|
|
9694
10103
|
JSXAttribute(node) {
|
|
9695
10104
|
if (!isJSXIdentifier(node.name))
|
|
9696
10105
|
return;
|
|
9697
|
-
if (!
|
|
10106
|
+
if (!isCachedPandaProp(node))
|
|
9698
10107
|
return;
|
|
9699
|
-
|
|
10108
|
+
const composite = resolveCompositeProperty(node.name.name);
|
|
10109
|
+
if (!composite)
|
|
10110
|
+
return;
|
|
10111
|
+
sendReport(node.name, composite);
|
|
9700
10112
|
},
|
|
9701
10113
|
Property(node) {
|
|
9702
10114
|
if (!isIdentifier(node.key))
|
|
9703
10115
|
return;
|
|
9704
|
-
if (!
|
|
10116
|
+
if (!isCachedPandaAttribute(node))
|
|
9705
10117
|
return;
|
|
9706
|
-
if (
|
|
10118
|
+
if (isCachedRecipeVariant(node))
|
|
9707
10119
|
return;
|
|
9708
|
-
|
|
10120
|
+
const composite = resolveCompositeProperty(node.key.name);
|
|
10121
|
+
if (!composite)
|
|
10122
|
+
return;
|
|
10123
|
+
sendReport(node.key, composite);
|
|
9709
10124
|
}
|
|
9710
10125
|
};
|
|
9711
10126
|
}
|
|
@@ -9732,28 +10147,69 @@ var init_prefer_composite_properties = __esm({
|
|
|
9732
10147
|
description: "Encourage the use of composite properties instead of atomic properties in the codebase."
|
|
9733
10148
|
},
|
|
9734
10149
|
messages: {
|
|
9735
|
-
composite: "Use composite property of `{{atomic}}
|
|
10150
|
+
composite: "Use composite property instead of `{{atomic}}`. Prefer: `{{composite}}`."
|
|
9736
10151
|
},
|
|
9737
10152
|
type: "suggestion",
|
|
9738
10153
|
schema: []
|
|
9739
10154
|
},
|
|
9740
10155
|
defaultOptions: [],
|
|
9741
10156
|
create(context) {
|
|
9742
|
-
const
|
|
10157
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
10158
|
+
const getLonghand = (name2) => {
|
|
10159
|
+
if (longhandCache.has(name2)) {
|
|
10160
|
+
return longhandCache.get(name2);
|
|
10161
|
+
}
|
|
9743
10162
|
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
return Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
|
|
10163
|
+
longhandCache.set(name2, longhand);
|
|
10164
|
+
return longhand;
|
|
9747
10165
|
};
|
|
9748
|
-
const
|
|
9749
|
-
|
|
9750
|
-
if (
|
|
9751
|
-
return;
|
|
9752
|
-
|
|
10166
|
+
const compositePropertyCache = /* @__PURE__ */ new Map();
|
|
10167
|
+
const resolveCompositeProperty = (name2) => {
|
|
10168
|
+
if (compositePropertyCache.has(name2)) {
|
|
10169
|
+
return compositePropertyCache.get(name2);
|
|
10170
|
+
}
|
|
10171
|
+
const longhand = getLonghand(name2);
|
|
10172
|
+
if (!isValidProperty(longhand, context)) {
|
|
10173
|
+
compositePropertyCache.set(name2, void 0);
|
|
10174
|
+
return void 0;
|
|
10175
|
+
}
|
|
10176
|
+
const composite = Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
|
|
10177
|
+
compositePropertyCache.set(name2, composite);
|
|
10178
|
+
return composite;
|
|
10179
|
+
};
|
|
10180
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
10181
|
+
const isCachedPandaProp = (node) => {
|
|
10182
|
+
if (pandaPropCache.has(node)) {
|
|
10183
|
+
return pandaPropCache.get(node);
|
|
10184
|
+
}
|
|
10185
|
+
const result = isPandaProp(node, context);
|
|
10186
|
+
pandaPropCache.set(node, result);
|
|
10187
|
+
return !!result;
|
|
10188
|
+
};
|
|
10189
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
10190
|
+
const isCachedPandaAttribute = (node) => {
|
|
10191
|
+
if (pandaAttributeCache.has(node)) {
|
|
10192
|
+
return pandaAttributeCache.get(node);
|
|
10193
|
+
}
|
|
10194
|
+
const result = isPandaAttribute(node, context);
|
|
10195
|
+
pandaAttributeCache.set(node, result);
|
|
10196
|
+
return !!result;
|
|
10197
|
+
};
|
|
10198
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
10199
|
+
const isCachedRecipeVariant = (node) => {
|
|
10200
|
+
if (recipeVariantCache.has(node)) {
|
|
10201
|
+
return recipeVariantCache.get(node);
|
|
10202
|
+
}
|
|
10203
|
+
const result = isRecipeVariant(node, context);
|
|
10204
|
+
recipeVariantCache.set(node, result);
|
|
10205
|
+
return !!result;
|
|
10206
|
+
};
|
|
10207
|
+
const sendReport = (node, composite) => {
|
|
10208
|
+
context.report({
|
|
9753
10209
|
node,
|
|
9754
10210
|
messageId: "composite",
|
|
9755
10211
|
data: {
|
|
9756
|
-
composite
|
|
10212
|
+
composite,
|
|
9757
10213
|
atomic: node.name
|
|
9758
10214
|
}
|
|
9759
10215
|
});
|
|
@@ -9762,18 +10218,24 @@ var init_prefer_composite_properties = __esm({
|
|
|
9762
10218
|
JSXAttribute(node) {
|
|
9763
10219
|
if (!isJSXIdentifier(node.name))
|
|
9764
10220
|
return;
|
|
9765
|
-
if (!
|
|
10221
|
+
if (!isCachedPandaProp(node))
|
|
9766
10222
|
return;
|
|
9767
|
-
|
|
10223
|
+
const composite = resolveCompositeProperty(node.name.name);
|
|
10224
|
+
if (!composite)
|
|
10225
|
+
return;
|
|
10226
|
+
sendReport(node.name, composite);
|
|
9768
10227
|
},
|
|
9769
10228
|
Property(node) {
|
|
9770
10229
|
if (!isIdentifier(node.key))
|
|
9771
10230
|
return;
|
|
9772
|
-
if (!
|
|
10231
|
+
if (!isCachedPandaAttribute(node))
|
|
9773
10232
|
return;
|
|
9774
|
-
if (
|
|
10233
|
+
if (isCachedRecipeVariant(node))
|
|
9775
10234
|
return;
|
|
9776
|
-
|
|
10235
|
+
const composite = resolveCompositeProperty(node.key.name);
|
|
10236
|
+
if (!composite)
|
|
10237
|
+
return;
|
|
10238
|
+
sendReport(node.key, composite);
|
|
9777
10239
|
}
|
|
9778
10240
|
};
|
|
9779
10241
|
}
|
|
@@ -9797,35 +10259,82 @@ var init_prefer_unified_property_style = __esm({
|
|
|
9797
10259
|
name: RULE_NAME18,
|
|
9798
10260
|
meta: {
|
|
9799
10261
|
docs: {
|
|
9800
|
-
description: "Discourage
|
|
10262
|
+
description: "Discourage mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results."
|
|
9801
10263
|
},
|
|
9802
10264
|
messages: {
|
|
9803
|
-
unify: "You're mixing atomic {{atomicProperties}} with composite property {{composite}}
|
|
10265
|
+
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."
|
|
9804
10266
|
},
|
|
9805
10267
|
type: "suggestion",
|
|
9806
10268
|
schema: []
|
|
9807
10269
|
},
|
|
9808
10270
|
defaultOptions: [],
|
|
9809
10271
|
create(context) {
|
|
9810
|
-
const
|
|
10272
|
+
const longhandCache = /* @__PURE__ */ new Map();
|
|
10273
|
+
const getLonghand = (name2) => {
|
|
10274
|
+
if (longhandCache.has(name2)) {
|
|
10275
|
+
return longhandCache.get(name2);
|
|
10276
|
+
}
|
|
10277
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
10278
|
+
longhandCache.set(name2, longhand);
|
|
10279
|
+
return longhand;
|
|
10280
|
+
};
|
|
10281
|
+
const compositePropertyCache = /* @__PURE__ */ new Map();
|
|
9811
10282
|
const resolveCompositeProperty = (name2) => {
|
|
9812
|
-
if (name2
|
|
10283
|
+
if (compositePropertyCache.has(name2)) {
|
|
10284
|
+
return compositePropertyCache.get(name2);
|
|
10285
|
+
}
|
|
10286
|
+
if (name2 in compositeProperties) {
|
|
10287
|
+
compositePropertyCache.set(name2, name2);
|
|
9813
10288
|
return name2;
|
|
10289
|
+
}
|
|
9814
10290
|
const longhand = getLonghand(name2);
|
|
9815
|
-
if (isValidProperty(longhand, context) && longhand in compositeProperties)
|
|
10291
|
+
if (isValidProperty(longhand, context) && longhand in compositeProperties) {
|
|
10292
|
+
compositePropertyCache.set(name2, longhand);
|
|
9816
10293
|
return longhand;
|
|
10294
|
+
}
|
|
10295
|
+
compositePropertyCache.set(name2, void 0);
|
|
10296
|
+
return void 0;
|
|
9817
10297
|
};
|
|
9818
|
-
const
|
|
9819
|
-
|
|
9820
|
-
if (
|
|
10298
|
+
const pandaPropCache = /* @__PURE__ */ new WeakMap();
|
|
10299
|
+
const isCachedPandaProp = (node) => {
|
|
10300
|
+
if (pandaPropCache.has(node)) {
|
|
10301
|
+
return pandaPropCache.get(node);
|
|
10302
|
+
}
|
|
10303
|
+
const result = isPandaProp(node, context);
|
|
10304
|
+
pandaPropCache.set(node, result);
|
|
10305
|
+
return !!result;
|
|
10306
|
+
};
|
|
10307
|
+
const pandaAttributeCache = /* @__PURE__ */ new WeakMap();
|
|
10308
|
+
const isCachedPandaAttribute = (node) => {
|
|
10309
|
+
if (pandaAttributeCache.has(node)) {
|
|
10310
|
+
return pandaAttributeCache.get(node);
|
|
10311
|
+
}
|
|
10312
|
+
const result = isPandaAttribute(node, context);
|
|
10313
|
+
pandaAttributeCache.set(node, result);
|
|
10314
|
+
return !!result;
|
|
10315
|
+
};
|
|
10316
|
+
const recipeVariantCache = /* @__PURE__ */ new WeakMap();
|
|
10317
|
+
const isCachedRecipeVariant = (node) => {
|
|
10318
|
+
if (recipeVariantCache.has(node)) {
|
|
10319
|
+
return recipeVariantCache.get(node);
|
|
10320
|
+
}
|
|
10321
|
+
const result = isRecipeVariant(node, context);
|
|
10322
|
+
recipeVariantCache.set(node, result);
|
|
10323
|
+
return !!result;
|
|
10324
|
+
};
|
|
10325
|
+
const sendReport = (node, composite, siblings) => {
|
|
10326
|
+
const atomicPropertiesSet = new Set(
|
|
10327
|
+
siblings.filter((prop) => compositeProperties[composite].includes(getLonghand(prop)))
|
|
10328
|
+
);
|
|
10329
|
+
if (atomicPropertiesSet.size === 0)
|
|
9821
10330
|
return;
|
|
9822
|
-
const atomicProperties =
|
|
9823
|
-
const atomics = compositeProperties[
|
|
10331
|
+
const atomicProperties = Array.from(atomicPropertiesSet).map((prop) => `\`${prop}\``).join(", ");
|
|
10332
|
+
const atomics = compositeProperties[composite].map((name2) => `\`${name2}\``).join(", ");
|
|
9824
10333
|
context.report({
|
|
9825
10334
|
node,
|
|
9826
10335
|
messageId: "unify",
|
|
9827
10336
|
data: {
|
|
9828
|
-
composite
|
|
10337
|
+
composite,
|
|
9829
10338
|
atomicProperties,
|
|
9830
10339
|
atomics
|
|
9831
10340
|
}
|
|
@@ -9835,30 +10344,30 @@ var init_prefer_unified_property_style = __esm({
|
|
|
9835
10344
|
JSXAttribute(node) {
|
|
9836
10345
|
if (!isJSXIdentifier(node.name))
|
|
9837
10346
|
return;
|
|
9838
|
-
if (!
|
|
10347
|
+
if (!isCachedPandaProp(node))
|
|
9839
10348
|
return;
|
|
9840
|
-
const
|
|
9841
|
-
if (!
|
|
10349
|
+
const composite = resolveCompositeProperty(node.name.name);
|
|
10350
|
+
if (!composite)
|
|
9842
10351
|
return;
|
|
9843
10352
|
if (!isJSXOpeningElement(node.parent))
|
|
9844
10353
|
return;
|
|
9845
10354
|
const siblings = node.parent.attributes.map((attr) => attr.name.name);
|
|
9846
|
-
sendReport(node,
|
|
10355
|
+
sendReport(node, composite, siblings);
|
|
9847
10356
|
},
|
|
9848
10357
|
Property(node) {
|
|
9849
10358
|
if (!isIdentifier(node.key))
|
|
9850
10359
|
return;
|
|
9851
|
-
if (!
|
|
10360
|
+
if (!isCachedPandaAttribute(node))
|
|
9852
10361
|
return;
|
|
9853
|
-
if (
|
|
10362
|
+
if (isCachedRecipeVariant(node))
|
|
9854
10363
|
return;
|
|
9855
|
-
const
|
|
9856
|
-
if (!
|
|
10364
|
+
const composite = resolveCompositeProperty(node.key.name);
|
|
10365
|
+
if (!composite)
|
|
9857
10366
|
return;
|
|
9858
10367
|
if (!isObjectExpression(node.parent))
|
|
9859
10368
|
return;
|
|
9860
|
-
const siblings = node.parent.properties.map((prop) => isIdentifier(prop.key)
|
|
9861
|
-
sendReport(node.key,
|
|
10369
|
+
const siblings = node.parent.properties.filter((prop) => prop.type === "Property").map((prop) => isIdentifier(prop.key) ? prop.key.name : "");
|
|
10370
|
+
sendReport(node.key, composite, siblings);
|
|
9862
10371
|
}
|
|
9863
10372
|
};
|
|
9864
10373
|
}
|