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