@pandacss/eslint-plugin 0.0.6 → 0.0.8
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 +40 -25
- package/dist/index.mjs +42 -27
- package/dist/utils/worker.js +44 -2
- package/dist/utils/worker.mjs +45 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -7957,7 +7957,7 @@ init_cjs_shims();
|
|
|
7957
7957
|
|
|
7958
7958
|
// package.json
|
|
7959
7959
|
var name = "@pandacss/eslint-plugin";
|
|
7960
|
-
var version = "0.0.
|
|
7960
|
+
var version = "0.0.8";
|
|
7961
7961
|
|
|
7962
7962
|
// src/configs/all.ts
|
|
7963
7963
|
init_cjs_shims();
|
|
@@ -7992,6 +7992,7 @@ var import_utils2 = require("@typescript-eslint/utils");
|
|
|
7992
7992
|
var isIdentifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Identifier);
|
|
7993
7993
|
var isLiteral = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Literal);
|
|
7994
7994
|
var isTemplateLiteral = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.TemplateLiteral);
|
|
7995
|
+
var isObjectExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ObjectExpression);
|
|
7995
7996
|
var isMemberExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.MemberExpression);
|
|
7996
7997
|
var isVariableDeclarator = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.VariableDeclarator);
|
|
7997
7998
|
var isVariableDeclaration = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.VariableDeclaration);
|
|
@@ -8099,17 +8100,14 @@ var isLocalStyledFactory = (node, context) => {
|
|
|
8099
8100
|
var isValidFile = (context) => {
|
|
8100
8101
|
return syncAction("isValidFile", getSyncOpts(context));
|
|
8101
8102
|
};
|
|
8102
|
-
var isValidProperty = (name2, context) => {
|
|
8103
|
-
return syncAction("isValidProperty", getSyncOpts(context), name2);
|
|
8103
|
+
var isValidProperty = (name2, context, calleName) => {
|
|
8104
|
+
return syncAction("isValidProperty", getSyncOpts(context), name2, calleName);
|
|
8104
8105
|
};
|
|
8105
8106
|
var isPandaImport = (node, context) => {
|
|
8106
8107
|
const imports = getImports(context);
|
|
8107
8108
|
return imports.some((imp) => imp.mod === node.source.value);
|
|
8108
8109
|
};
|
|
8109
8110
|
var isPandaProp = (node, context) => {
|
|
8110
|
-
const prop = node.name.name;
|
|
8111
|
-
if (typeof prop !== "string" || !isValidProperty(prop, context))
|
|
8112
|
-
return;
|
|
8113
8111
|
const jsxAncestor = getAncestor(isJSXOpeningElement, node);
|
|
8114
8112
|
if (!jsxAncestor)
|
|
8115
8113
|
return;
|
|
@@ -8119,33 +8117,46 @@ var isPandaProp = (node, context) => {
|
|
|
8119
8117
|
return;
|
|
8120
8118
|
if (!isPandaIsh(jsxAncestor.name.name, context) && !isLocalStyledFactory(jsxAncestor, context))
|
|
8121
8119
|
return;
|
|
8120
|
+
const prop = node.name.name;
|
|
8121
|
+
if (typeof prop !== "string" || !isValidProperty(prop, context, jsxAncestor.name.name))
|
|
8122
|
+
return;
|
|
8122
8123
|
return true;
|
|
8123
8124
|
};
|
|
8124
|
-
var
|
|
8125
|
+
var isInPandaFunction = (node, context) => {
|
|
8125
8126
|
const callAncestor = getAncestor(isCallExpression, node);
|
|
8126
|
-
if (!callAncestor)
|
|
8127
|
-
const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
|
|
8128
|
-
const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
|
|
8129
|
-
if (!jsxExprAncestor || !jsxAttrAncestor)
|
|
8130
|
-
return;
|
|
8131
|
-
if (!isPandaProp(jsxAttrAncestor, context))
|
|
8132
|
-
return;
|
|
8133
|
-
if (!isValidStyledProp(jsxAttrAncestor.name, context))
|
|
8134
|
-
return;
|
|
8135
|
-
return true;
|
|
8136
|
-
}
|
|
8137
|
-
if (!isIdentifier(node.key))
|
|
8138
|
-
return;
|
|
8139
|
-
const attr = node.key.name;
|
|
8140
|
-
if (!isValidProperty(attr, context))
|
|
8127
|
+
if (!callAncestor)
|
|
8141
8128
|
return;
|
|
8129
|
+
let calleeName;
|
|
8142
8130
|
if (isIdentifier(callAncestor.callee)) {
|
|
8143
|
-
|
|
8131
|
+
calleeName = callAncestor.callee.name;
|
|
8144
8132
|
}
|
|
8145
8133
|
if (isMemberExpression(callAncestor.callee) && isIdentifier(callAncestor.callee.object)) {
|
|
8146
|
-
|
|
8134
|
+
calleeName = callAncestor.callee.object.name;
|
|
8147
8135
|
}
|
|
8148
|
-
|
|
8136
|
+
if (!calleeName)
|
|
8137
|
+
return;
|
|
8138
|
+
if (!isPandaIsh(calleeName, context))
|
|
8139
|
+
return;
|
|
8140
|
+
if (!isIdentifier(node.key))
|
|
8141
|
+
return;
|
|
8142
|
+
const attr = node.key.name;
|
|
8143
|
+
if (!isValidProperty(attr, context, calleeName))
|
|
8144
|
+
return;
|
|
8145
|
+
return true;
|
|
8146
|
+
};
|
|
8147
|
+
var isPandaAttribute = (node, context) => {
|
|
8148
|
+
const callAncestor = getAncestor(isCallExpression, node);
|
|
8149
|
+
if (callAncestor)
|
|
8150
|
+
return isInPandaFunction(node, context);
|
|
8151
|
+
const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
|
|
8152
|
+
const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
|
|
8153
|
+
if (!jsxExprAncestor || !jsxAttrAncestor)
|
|
8154
|
+
return;
|
|
8155
|
+
if (!isPandaProp(jsxAttrAncestor, context))
|
|
8156
|
+
return;
|
|
8157
|
+
if (!isValidStyledProp(jsxAttrAncestor.name, context))
|
|
8158
|
+
return;
|
|
8159
|
+
return true;
|
|
8149
8160
|
};
|
|
8150
8161
|
var resolveLonghand = (name2, context) => {
|
|
8151
8162
|
return syncAction("resolveLongHand", getSyncOpts(context), name2);
|
|
@@ -8379,6 +8390,8 @@ var rule4 = createRule({
|
|
|
8379
8390
|
return;
|
|
8380
8391
|
if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
|
|
8381
8392
|
return;
|
|
8393
|
+
if (isObjectExpression(node.value))
|
|
8394
|
+
return;
|
|
8382
8395
|
if (!isPandaProp(node, context))
|
|
8383
8396
|
return;
|
|
8384
8397
|
context.report({
|
|
@@ -8393,6 +8406,8 @@ var rule4 = createRule({
|
|
|
8393
8406
|
return;
|
|
8394
8407
|
if (isTemplateLiteral(node.value) && node.value.expressions.length === 0)
|
|
8395
8408
|
return;
|
|
8409
|
+
if (isObjectExpression(node.value))
|
|
8410
|
+
return;
|
|
8396
8411
|
if (!isPandaAttribute(node, context))
|
|
8397
8412
|
return;
|
|
8398
8413
|
context.report({
|
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.0.
|
|
13
|
+
version = "0.0.8";
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -7950,7 +7950,7 @@ var require_dist3 = __commonJS({
|
|
|
7950
7950
|
// src/utils/nodes.ts
|
|
7951
7951
|
import { isNodeOfType } from "@typescript-eslint/utils/ast-utils";
|
|
7952
7952
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
7953
|
-
var isIdentifier, isLiteral, isTemplateLiteral, isMemberExpression, isVariableDeclarator, isVariableDeclaration, isJSXMemberExpression, isJSXOpeningElement, isJSXExpressionContainer, isJSXAttribute, isJSXIdentifier, isCallExpression, isImportDeclaration, isImportSpecifier;
|
|
7953
|
+
var isIdentifier, isLiteral, isTemplateLiteral, isObjectExpression, isMemberExpression, isVariableDeclarator, isVariableDeclaration, isJSXMemberExpression, isJSXOpeningElement, isJSXExpressionContainer, isJSXAttribute, isJSXIdentifier, isCallExpression, isImportDeclaration, isImportSpecifier;
|
|
7954
7954
|
var init_nodes = __esm({
|
|
7955
7955
|
"src/utils/nodes.ts"() {
|
|
7956
7956
|
"use strict";
|
|
@@ -7958,6 +7958,7 @@ var init_nodes = __esm({
|
|
|
7958
7958
|
isIdentifier = isNodeOfType(AST_NODE_TYPES.Identifier);
|
|
7959
7959
|
isLiteral = isNodeOfType(AST_NODE_TYPES.Literal);
|
|
7960
7960
|
isTemplateLiteral = isNodeOfType(AST_NODE_TYPES.TemplateLiteral);
|
|
7961
|
+
isObjectExpression = isNodeOfType(AST_NODE_TYPES.ObjectExpression);
|
|
7961
7962
|
isMemberExpression = isNodeOfType(AST_NODE_TYPES.MemberExpression);
|
|
7962
7963
|
isVariableDeclarator = isNodeOfType(AST_NODE_TYPES.VariableDeclarator);
|
|
7963
7964
|
isVariableDeclaration = isNodeOfType(AST_NODE_TYPES.VariableDeclaration);
|
|
@@ -7973,7 +7974,7 @@ var init_nodes = __esm({
|
|
|
7973
7974
|
});
|
|
7974
7975
|
|
|
7975
7976
|
// src/utils/helpers.ts
|
|
7976
|
-
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isPandaAttribute, resolveLonghand, resolveShorthand, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
|
|
7977
|
+
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isInPandaFunction, isPandaAttribute, resolveLonghand, resolveShorthand, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
|
|
7977
7978
|
var init_helpers = __esm({
|
|
7978
7979
|
"src/utils/helpers.ts"() {
|
|
7979
7980
|
"use strict";
|
|
@@ -8075,17 +8076,14 @@ var init_helpers = __esm({
|
|
|
8075
8076
|
isValidFile = (context) => {
|
|
8076
8077
|
return syncAction("isValidFile", getSyncOpts(context));
|
|
8077
8078
|
};
|
|
8078
|
-
isValidProperty = (name2, context) => {
|
|
8079
|
-
return syncAction("isValidProperty", getSyncOpts(context), name2);
|
|
8079
|
+
isValidProperty = (name2, context, calleName) => {
|
|
8080
|
+
return syncAction("isValidProperty", getSyncOpts(context), name2, calleName);
|
|
8080
8081
|
};
|
|
8081
8082
|
isPandaImport = (node, context) => {
|
|
8082
8083
|
const imports = getImports(context);
|
|
8083
8084
|
return imports.some((imp) => imp.mod === node.source.value);
|
|
8084
8085
|
};
|
|
8085
8086
|
isPandaProp = (node, context) => {
|
|
8086
|
-
const prop = node.name.name;
|
|
8087
|
-
if (typeof prop !== "string" || !isValidProperty(prop, context))
|
|
8088
|
-
return;
|
|
8089
8087
|
const jsxAncestor = getAncestor(isJSXOpeningElement, node);
|
|
8090
8088
|
if (!jsxAncestor)
|
|
8091
8089
|
return;
|
|
@@ -8095,33 +8093,46 @@ var init_helpers = __esm({
|
|
|
8095
8093
|
return;
|
|
8096
8094
|
if (!isPandaIsh(jsxAncestor.name.name, context) && !isLocalStyledFactory(jsxAncestor, context))
|
|
8097
8095
|
return;
|
|
8096
|
+
const prop = node.name.name;
|
|
8097
|
+
if (typeof prop !== "string" || !isValidProperty(prop, context, jsxAncestor.name.name))
|
|
8098
|
+
return;
|
|
8098
8099
|
return true;
|
|
8099
8100
|
};
|
|
8100
|
-
|
|
8101
|
+
isInPandaFunction = (node, context) => {
|
|
8101
8102
|
const callAncestor = getAncestor(isCallExpression, node);
|
|
8102
|
-
if (!callAncestor)
|
|
8103
|
-
const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
|
|
8104
|
-
const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
|
|
8105
|
-
if (!jsxExprAncestor || !jsxAttrAncestor)
|
|
8106
|
-
return;
|
|
8107
|
-
if (!isPandaProp(jsxAttrAncestor, context))
|
|
8108
|
-
return;
|
|
8109
|
-
if (!isValidStyledProp(jsxAttrAncestor.name, context))
|
|
8110
|
-
return;
|
|
8111
|
-
return true;
|
|
8112
|
-
}
|
|
8113
|
-
if (!isIdentifier(node.key))
|
|
8114
|
-
return;
|
|
8115
|
-
const attr = node.key.name;
|
|
8116
|
-
if (!isValidProperty(attr, context))
|
|
8103
|
+
if (!callAncestor)
|
|
8117
8104
|
return;
|
|
8105
|
+
let calleeName;
|
|
8118
8106
|
if (isIdentifier(callAncestor.callee)) {
|
|
8119
|
-
|
|
8107
|
+
calleeName = callAncestor.callee.name;
|
|
8120
8108
|
}
|
|
8121
8109
|
if (isMemberExpression(callAncestor.callee) && isIdentifier(callAncestor.callee.object)) {
|
|
8122
|
-
|
|
8110
|
+
calleeName = callAncestor.callee.object.name;
|
|
8123
8111
|
}
|
|
8124
|
-
|
|
8112
|
+
if (!calleeName)
|
|
8113
|
+
return;
|
|
8114
|
+
if (!isPandaIsh(calleeName, context))
|
|
8115
|
+
return;
|
|
8116
|
+
if (!isIdentifier(node.key))
|
|
8117
|
+
return;
|
|
8118
|
+
const attr = node.key.name;
|
|
8119
|
+
if (!isValidProperty(attr, context, calleeName))
|
|
8120
|
+
return;
|
|
8121
|
+
return true;
|
|
8122
|
+
};
|
|
8123
|
+
isPandaAttribute = (node, context) => {
|
|
8124
|
+
const callAncestor = getAncestor(isCallExpression, node);
|
|
8125
|
+
if (callAncestor)
|
|
8126
|
+
return isInPandaFunction(node, context);
|
|
8127
|
+
const jsxExprAncestor = getAncestor(isJSXExpressionContainer, node);
|
|
8128
|
+
const jsxAttrAncestor = getAncestor(isJSXAttribute, node);
|
|
8129
|
+
if (!jsxExprAncestor || !jsxAttrAncestor)
|
|
8130
|
+
return;
|
|
8131
|
+
if (!isPandaProp(jsxAttrAncestor, context))
|
|
8132
|
+
return;
|
|
8133
|
+
if (!isValidStyledProp(jsxAttrAncestor.name, context))
|
|
8134
|
+
return;
|
|
8135
|
+
return true;
|
|
8125
8136
|
};
|
|
8126
8137
|
resolveLonghand = (name2, context) => {
|
|
8127
8138
|
return syncAction("resolveLongHand", getSyncOpts(context), name2);
|
|
@@ -8391,6 +8402,8 @@ var init_no_dynamic_styling = __esm({
|
|
|
8391
8402
|
return;
|
|
8392
8403
|
if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
|
|
8393
8404
|
return;
|
|
8405
|
+
if (isObjectExpression(node.value))
|
|
8406
|
+
return;
|
|
8394
8407
|
if (!isPandaProp(node, context))
|
|
8395
8408
|
return;
|
|
8396
8409
|
context.report({
|
|
@@ -8405,6 +8418,8 @@ var init_no_dynamic_styling = __esm({
|
|
|
8405
8418
|
return;
|
|
8406
8419
|
if (isTemplateLiteral(node.value) && node.value.expressions.length === 0)
|
|
8407
8420
|
return;
|
|
8421
|
+
if (isObjectExpression(node.value))
|
|
8422
|
+
return;
|
|
8408
8423
|
if (!isPandaAttribute(node, context))
|
|
8409
8424
|
return;
|
|
8410
8425
|
context.report({
|
package/dist/utils/worker.js
CHANGED
|
@@ -3390,6 +3390,7 @@ var createContext = (userConfig) => {
|
|
|
3390
3390
|
var import_ts_path = require("@pandacss/config/ts-path");
|
|
3391
3391
|
var import_config3 = require("@pandacss/config");
|
|
3392
3392
|
var import_path = __toESM(require("path"));
|
|
3393
|
+
var import_fs = __toESM(require("fs"));
|
|
3393
3394
|
var promise;
|
|
3394
3395
|
var configPath;
|
|
3395
3396
|
async function _getContext(configPath2) {
|
|
@@ -3401,6 +3402,7 @@ async function _getContext(configPath2) {
|
|
|
3401
3402
|
}
|
|
3402
3403
|
async function getContext(opts) {
|
|
3403
3404
|
if (process.env.NODE_ENV === "test") {
|
|
3405
|
+
configPath = opts.configPath;
|
|
3404
3406
|
const ctx = createContext({ importMap: "./panda" });
|
|
3405
3407
|
ctx.getFiles = () => ["App.tsx"];
|
|
3406
3408
|
return ctx;
|
|
@@ -3410,6 +3412,27 @@ async function getContext(opts) {
|
|
|
3410
3412
|
return await promise;
|
|
3411
3413
|
}
|
|
3412
3414
|
}
|
|
3415
|
+
async function getExtendWarnings() {
|
|
3416
|
+
if (!configPath)
|
|
3417
|
+
return [];
|
|
3418
|
+
const cwd = import_path.default.dirname(configPath);
|
|
3419
|
+
const { config: config2 } = await (0, import_config3.bundleConfig)({ cwd, file: configPath });
|
|
3420
|
+
if (!config2.presets || config2.presets.length === 0)
|
|
3421
|
+
return [];
|
|
3422
|
+
if (config2.eject)
|
|
3423
|
+
return [];
|
|
3424
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
3425
|
+
if (config2.theme && !config2.theme.extend) {
|
|
3426
|
+
warnings.add("theme");
|
|
3427
|
+
}
|
|
3428
|
+
if (config2.conditions && !config2.conditions.extend) {
|
|
3429
|
+
warnings.add("conditions");
|
|
3430
|
+
}
|
|
3431
|
+
if (config2.patterns && !config2.patterns.extend) {
|
|
3432
|
+
warnings.add("patterns");
|
|
3433
|
+
}
|
|
3434
|
+
return Array.from(warnings);
|
|
3435
|
+
}
|
|
3413
3436
|
async function filterInvalidTokenz(ctx, paths) {
|
|
3414
3437
|
return paths.filter((path2) => !ctx.utility.tokens.get(path2));
|
|
3415
3438
|
}
|
|
@@ -3422,6 +3445,14 @@ async function isColorAttribute(ctx, _attr) {
|
|
|
3422
3445
|
const attrConfig = ctx.utility.config[attr];
|
|
3423
3446
|
return attrConfig?.values === "colors";
|
|
3424
3447
|
}
|
|
3448
|
+
var arePathsEqual = (path1, path2) => {
|
|
3449
|
+
const stats1 = import_fs.default.statSync(path1);
|
|
3450
|
+
const stats2 = import_fs.default.statSync(path2);
|
|
3451
|
+
return stats1.dev === stats2.dev && stats1.ino === stats2.ino;
|
|
3452
|
+
};
|
|
3453
|
+
async function isConfigFile(fileName) {
|
|
3454
|
+
return arePathsEqual(configPath, fileName);
|
|
3455
|
+
}
|
|
3425
3456
|
async function isValidFile(ctx, fileName) {
|
|
3426
3457
|
return ctx.getFiles().includes(fileName);
|
|
3427
3458
|
}
|
|
@@ -3437,8 +3468,15 @@ async function resolveLongHand(ctx, name) {
|
|
|
3437
3468
|
}
|
|
3438
3469
|
return reverseShorthandsMap.get(name);
|
|
3439
3470
|
}
|
|
3440
|
-
async function isValidProperty(ctx, name) {
|
|
3441
|
-
|
|
3471
|
+
async function isValidProperty(ctx, name, patternName) {
|
|
3472
|
+
if (ctx.isValidProperty(name))
|
|
3473
|
+
return true;
|
|
3474
|
+
if (!patternName)
|
|
3475
|
+
return;
|
|
3476
|
+
const pattern = ctx.patterns.details.find((p) => p.baseName === patternName || p.jsx.includes(patternName))?.config.properties;
|
|
3477
|
+
if (!pattern)
|
|
3478
|
+
return;
|
|
3479
|
+
return Object.keys(pattern).includes(name);
|
|
3442
3480
|
}
|
|
3443
3481
|
async function matchFile(ctx, name, imports) {
|
|
3444
3482
|
const file = ctx.imports.file(imports);
|
|
@@ -3465,6 +3503,8 @@ async function runAsync(action, opts, ...args) {
|
|
|
3465
3503
|
return resolveLongHand(ctx, ...args);
|
|
3466
3504
|
case "resolveShorthand":
|
|
3467
3505
|
return resolveShorthand(ctx, ...args);
|
|
3506
|
+
case "isConfigFile":
|
|
3507
|
+
return isConfigFile(opts.currentFile);
|
|
3468
3508
|
case "isValidFile":
|
|
3469
3509
|
return isValidFile(ctx, opts.currentFile);
|
|
3470
3510
|
case "isColorAttribute":
|
|
@@ -3473,6 +3513,8 @@ async function runAsync(action, opts, ...args) {
|
|
|
3473
3513
|
return isColorToken(ctx, ...args);
|
|
3474
3514
|
case "filterInvalidTokenz":
|
|
3475
3515
|
return filterInvalidTokenz(ctx, ...args);
|
|
3516
|
+
case "getExtendWarnings":
|
|
3517
|
+
return getExtendWarnings();
|
|
3476
3518
|
}
|
|
3477
3519
|
}
|
|
3478
3520
|
function run(action, opts, ...args) {
|
package/dist/utils/worker.mjs
CHANGED
|
@@ -3372,8 +3372,9 @@ init_esm_shims();
|
|
|
3372
3372
|
|
|
3373
3373
|
// src/utils/worker.ts
|
|
3374
3374
|
import { resolveTsPathPattern } from "@pandacss/config/ts-path";
|
|
3375
|
-
import { findConfig } from "@pandacss/config";
|
|
3375
|
+
import { findConfig, bundleConfig } from "@pandacss/config";
|
|
3376
3376
|
import path from "path";
|
|
3377
|
+
import fs from "fs";
|
|
3377
3378
|
var promise;
|
|
3378
3379
|
var configPath;
|
|
3379
3380
|
async function _getContext(configPath2) {
|
|
@@ -3385,6 +3386,7 @@ async function _getContext(configPath2) {
|
|
|
3385
3386
|
}
|
|
3386
3387
|
async function getContext(opts) {
|
|
3387
3388
|
if (process.env.NODE_ENV === "test") {
|
|
3389
|
+
configPath = opts.configPath;
|
|
3388
3390
|
const ctx = createContext({ importMap: "./panda" });
|
|
3389
3391
|
ctx.getFiles = () => ["App.tsx"];
|
|
3390
3392
|
return ctx;
|
|
@@ -3394,6 +3396,27 @@ async function getContext(opts) {
|
|
|
3394
3396
|
return await promise;
|
|
3395
3397
|
}
|
|
3396
3398
|
}
|
|
3399
|
+
async function getExtendWarnings() {
|
|
3400
|
+
if (!configPath)
|
|
3401
|
+
return [];
|
|
3402
|
+
const cwd = path.dirname(configPath);
|
|
3403
|
+
const { config: config2 } = await bundleConfig({ cwd, file: configPath });
|
|
3404
|
+
if (!config2.presets || config2.presets.length === 0)
|
|
3405
|
+
return [];
|
|
3406
|
+
if (config2.eject)
|
|
3407
|
+
return [];
|
|
3408
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
3409
|
+
if (config2.theme && !config2.theme.extend) {
|
|
3410
|
+
warnings.add("theme");
|
|
3411
|
+
}
|
|
3412
|
+
if (config2.conditions && !config2.conditions.extend) {
|
|
3413
|
+
warnings.add("conditions");
|
|
3414
|
+
}
|
|
3415
|
+
if (config2.patterns && !config2.patterns.extend) {
|
|
3416
|
+
warnings.add("patterns");
|
|
3417
|
+
}
|
|
3418
|
+
return Array.from(warnings);
|
|
3419
|
+
}
|
|
3397
3420
|
async function filterInvalidTokenz(ctx, paths) {
|
|
3398
3421
|
return paths.filter((path2) => !ctx.utility.tokens.get(path2));
|
|
3399
3422
|
}
|
|
@@ -3406,6 +3429,14 @@ async function isColorAttribute(ctx, _attr) {
|
|
|
3406
3429
|
const attrConfig = ctx.utility.config[attr];
|
|
3407
3430
|
return attrConfig?.values === "colors";
|
|
3408
3431
|
}
|
|
3432
|
+
var arePathsEqual = (path1, path2) => {
|
|
3433
|
+
const stats1 = fs.statSync(path1);
|
|
3434
|
+
const stats2 = fs.statSync(path2);
|
|
3435
|
+
return stats1.dev === stats2.dev && stats1.ino === stats2.ino;
|
|
3436
|
+
};
|
|
3437
|
+
async function isConfigFile(fileName) {
|
|
3438
|
+
return arePathsEqual(configPath, fileName);
|
|
3439
|
+
}
|
|
3409
3440
|
async function isValidFile(ctx, fileName) {
|
|
3410
3441
|
return ctx.getFiles().includes(fileName);
|
|
3411
3442
|
}
|
|
@@ -3421,8 +3452,15 @@ async function resolveLongHand(ctx, name) {
|
|
|
3421
3452
|
}
|
|
3422
3453
|
return reverseShorthandsMap.get(name);
|
|
3423
3454
|
}
|
|
3424
|
-
async function isValidProperty(ctx, name) {
|
|
3425
|
-
|
|
3455
|
+
async function isValidProperty(ctx, name, patternName) {
|
|
3456
|
+
if (ctx.isValidProperty(name))
|
|
3457
|
+
return true;
|
|
3458
|
+
if (!patternName)
|
|
3459
|
+
return;
|
|
3460
|
+
const pattern = ctx.patterns.details.find((p) => p.baseName === patternName || p.jsx.includes(patternName))?.config.properties;
|
|
3461
|
+
if (!pattern)
|
|
3462
|
+
return;
|
|
3463
|
+
return Object.keys(pattern).includes(name);
|
|
3426
3464
|
}
|
|
3427
3465
|
async function matchFile(ctx, name, imports) {
|
|
3428
3466
|
const file = ctx.imports.file(imports);
|
|
@@ -3449,6 +3487,8 @@ async function runAsync(action, opts, ...args) {
|
|
|
3449
3487
|
return resolveLongHand(ctx, ...args);
|
|
3450
3488
|
case "resolveShorthand":
|
|
3451
3489
|
return resolveShorthand(ctx, ...args);
|
|
3490
|
+
case "isConfigFile":
|
|
3491
|
+
return isConfigFile(opts.currentFile);
|
|
3452
3492
|
case "isValidFile":
|
|
3453
3493
|
return isValidFile(ctx, opts.currentFile);
|
|
3454
3494
|
case "isColorAttribute":
|
|
@@ -3457,6 +3497,8 @@ async function runAsync(action, opts, ...args) {
|
|
|
3457
3497
|
return isColorToken(ctx, ...args);
|
|
3458
3498
|
case "filterInvalidTokenz":
|
|
3459
3499
|
return filterInvalidTokenz(ctx, ...args);
|
|
3500
|
+
case "getExtendWarnings":
|
|
3501
|
+
return getExtendWarnings();
|
|
3460
3502
|
}
|
|
3461
3503
|
}
|
|
3462
3504
|
function run(action, opts, ...args) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/eslint-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Eslint plugin for Panda CSS",
|
|
5
5
|
"author": "Abraham Aremu <anubra266@gmail.com>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@pandacss/config": "^0.
|
|
30
|
-
"@pandacss/generator": "^0.
|
|
31
|
-
"@pandacss/node": "^0.
|
|
32
|
-
"@pandacss/shared": "^0.
|
|
29
|
+
"@pandacss/config": "^0.29.1",
|
|
30
|
+
"@pandacss/generator": "^0.29.1",
|
|
31
|
+
"@pandacss/node": "^0.29.1",
|
|
32
|
+
"@pandacss/shared": "^0.29.1",
|
|
33
33
|
"@typescript-eslint/utils": "^6.19.1",
|
|
34
34
|
"hookable": "^5.5.3",
|
|
35
35
|
"synckit": "^0.9.0"
|