@pandacss/eslint-plugin 0.1.6 → 0.1.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 +51 -24
- package/dist/index.mjs +53 -26
- package/dist/utils/worker.js +0 -23
- package/dist/utils/worker.mjs +1 -24
- package/package.json +1 -1
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.1.
|
|
7960
|
+
var version = "0.1.8";
|
|
7961
7961
|
|
|
7962
7962
|
// src/configs/all.ts
|
|
7963
7963
|
init_cjs_shims();
|
|
@@ -7979,7 +7979,14 @@ var createRule = import_utils.ESLintUtils.RuleCreator(
|
|
|
7979
7979
|
);
|
|
7980
7980
|
var isBase = process.env.NODE_ENV !== "test" || importMetaUrl.endsWith("dist/index.js");
|
|
7981
7981
|
var distDir = (0, import_node_url.fileURLToPath)(new URL(isBase ? "./" : "../../dist", importMetaUrl));
|
|
7982
|
-
var
|
|
7982
|
+
var _syncAction = (0, import_synckit.createSyncFn)((0, import_node_path.join)(distDir, "utils/worker.mjs"));
|
|
7983
|
+
var syncAction = (...args) => {
|
|
7984
|
+
try {
|
|
7985
|
+
return _syncAction(...args);
|
|
7986
|
+
} catch (error) {
|
|
7987
|
+
return;
|
|
7988
|
+
}
|
|
7989
|
+
};
|
|
7983
7990
|
|
|
7984
7991
|
// src/utils/helpers.ts
|
|
7985
7992
|
init_cjs_shims();
|
|
@@ -8057,11 +8064,7 @@ var _getImports = (context) => {
|
|
|
8057
8064
|
};
|
|
8058
8065
|
var getImports = (context) => {
|
|
8059
8066
|
const imports = _getImports(context);
|
|
8060
|
-
|
|
8061
|
-
return imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8062
|
-
} catch (error) {
|
|
8063
|
-
return [];
|
|
8064
|
-
}
|
|
8067
|
+
return imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8065
8068
|
};
|
|
8066
8069
|
var isValidStyledProp = (node, context) => {
|
|
8067
8070
|
if (typeof node === "string")
|
|
@@ -8120,7 +8123,7 @@ var isPandaProp = (node, context) => {
|
|
|
8120
8123
|
return;
|
|
8121
8124
|
return true;
|
|
8122
8125
|
};
|
|
8123
|
-
var
|
|
8126
|
+
var isStyledProperty = (node, context, calleeName) => {
|
|
8124
8127
|
if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key))
|
|
8125
8128
|
return;
|
|
8126
8129
|
if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName))
|
|
@@ -8131,13 +8134,6 @@ var isStyledNode = (node, context, calleeName) => {
|
|
|
8131
8134
|
return;
|
|
8132
8135
|
return true;
|
|
8133
8136
|
};
|
|
8134
|
-
var isStyledProperty = (node, context, calleeName) => {
|
|
8135
|
-
const ancestor = node.parent.parent;
|
|
8136
|
-
const isValidFuncAncestor = isCallExpression(ancestor) && isIdentifier(ancestor.callee) && isPandaIsh(ancestor.callee.name, context);
|
|
8137
|
-
if (isValidFuncAncestor)
|
|
8138
|
-
return isStyledNode(node, context, calleeName);
|
|
8139
|
-
return isStyledNode(ancestor, context, calleeName) && isStyledNode(node, context, calleeName);
|
|
8140
|
-
};
|
|
8141
8137
|
var isInPandaFunction = (node, context) => {
|
|
8142
8138
|
const callAncestor = getAncestor(isCallExpression, node);
|
|
8143
8139
|
if (!callAncestor)
|
|
@@ -8758,23 +8754,50 @@ var rule8 = createRule({
|
|
|
8758
8754
|
Property(node) {
|
|
8759
8755
|
if (!isObjectExpression(node.value) || isIdentifier(node.key))
|
|
8760
8756
|
return;
|
|
8761
|
-
|
|
8757
|
+
const caller = isInPandaFunction(node, context);
|
|
8758
|
+
if (!caller && !isInJSXProp(node, context))
|
|
8762
8759
|
return;
|
|
8763
8760
|
if (isStyledProperty(node, context))
|
|
8764
8761
|
return;
|
|
8765
|
-
const
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
}
|
|
8762
|
+
const invalidNesting = isInvalidNesting(node, context, caller);
|
|
8763
|
+
if (!invalidNesting)
|
|
8764
|
+
return;
|
|
8765
|
+
context.report({
|
|
8766
|
+
node: node.key,
|
|
8767
|
+
messageId: "nesting"
|
|
8768
|
+
});
|
|
8773
8769
|
}
|
|
8774
8770
|
};
|
|
8775
8771
|
}
|
|
8776
8772
|
});
|
|
8777
8773
|
var no_invalid_nesting_default = rule8;
|
|
8774
|
+
function isInvalidNesting(node, context, caller) {
|
|
8775
|
+
const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
|
|
8776
|
+
if (!recipe)
|
|
8777
|
+
return checkNode(node);
|
|
8778
|
+
let currentNode = node;
|
|
8779
|
+
let length = 0;
|
|
8780
|
+
let styleObjectParent = null;
|
|
8781
|
+
while (currentNode) {
|
|
8782
|
+
if (currentNode.key && ["base", "variants"].includes(currentNode.key.name)) {
|
|
8783
|
+
styleObjectParent = currentNode.key.name;
|
|
8784
|
+
}
|
|
8785
|
+
currentNode = currentNode.parent;
|
|
8786
|
+
if (!styleObjectParent)
|
|
8787
|
+
length++;
|
|
8788
|
+
}
|
|
8789
|
+
const requiredLength = caller === "cva" ? 2 : 4;
|
|
8790
|
+
const extraLength = styleObjectParent === "base" ? 0 : 4;
|
|
8791
|
+
if (length >= requiredLength + extraLength) {
|
|
8792
|
+
return checkNode(node);
|
|
8793
|
+
}
|
|
8794
|
+
return false;
|
|
8795
|
+
}
|
|
8796
|
+
function checkNode(node) {
|
|
8797
|
+
const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
|
|
8798
|
+
const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
|
|
8799
|
+
return invalidLiteral || invalidTemplateLiteral;
|
|
8800
|
+
}
|
|
8778
8801
|
|
|
8779
8802
|
// src/rules/no-invalid-token-paths.ts
|
|
8780
8803
|
init_cjs_shims();
|
|
@@ -8810,6 +8833,8 @@ var rule9 = createRule({
|
|
|
8810
8833
|
const sendReport = (node, _value) => {
|
|
8811
8834
|
const value = _value ?? node.value?.toString();
|
|
8812
8835
|
const tokens = getInvalidTokens(value, context);
|
|
8836
|
+
if (!tokens)
|
|
8837
|
+
return;
|
|
8813
8838
|
if (tokens.length > 0) {
|
|
8814
8839
|
tokens.forEach((token) => {
|
|
8815
8840
|
context.report({
|
|
@@ -8851,6 +8876,8 @@ var rule9 = createRule({
|
|
|
8851
8876
|
const quasis = node.quasi.quasis[0];
|
|
8852
8877
|
const styles = quasis.value.raw;
|
|
8853
8878
|
const tokens = getInvalidTokens(styles, context);
|
|
8879
|
+
if (!tokens)
|
|
8880
|
+
return;
|
|
8854
8881
|
tokens.forEach((token, i, arr) => {
|
|
8855
8882
|
if (arr.indexOf(token) < i)
|
|
8856
8883
|
return;
|
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.1.
|
|
13
|
+
version = "0.1.8";
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ import { ESLintUtils } from "@typescript-eslint/utils";
|
|
|
19
19
|
import { createSyncFn } from "synckit";
|
|
20
20
|
import { join } from "node:path";
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
|
-
var createRule, isBase, distDir, syncAction;
|
|
22
|
+
var createRule, isBase, distDir, _syncAction, syncAction;
|
|
23
23
|
var init_utils = __esm({
|
|
24
24
|
"src/utils/index.ts"() {
|
|
25
25
|
"use strict";
|
|
@@ -29,7 +29,14 @@ var init_utils = __esm({
|
|
|
29
29
|
);
|
|
30
30
|
isBase = process.env.NODE_ENV !== "test" || import.meta.url.endsWith("dist/index.js");
|
|
31
31
|
distDir = fileURLToPath(new URL(isBase ? "./" : "../../dist", import.meta.url));
|
|
32
|
-
|
|
32
|
+
_syncAction = createSyncFn(join(distDir, "utils/worker.mjs"));
|
|
33
|
+
syncAction = (...args) => {
|
|
34
|
+
try {
|
|
35
|
+
return _syncAction(...args);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
33
40
|
}
|
|
34
41
|
});
|
|
35
42
|
|
|
@@ -7975,7 +7982,7 @@ var init_nodes = __esm({
|
|
|
7975
7982
|
});
|
|
7976
7983
|
|
|
7977
7984
|
// src/utils/helpers.ts
|
|
7978
|
-
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, hasPkgImport, isPandaConfigFunction, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp,
|
|
7985
|
+
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;
|
|
7979
7986
|
var init_helpers = __esm({
|
|
7980
7987
|
"src/utils/helpers.ts"() {
|
|
7981
7988
|
"use strict";
|
|
@@ -8033,11 +8040,7 @@ var init_helpers = __esm({
|
|
|
8033
8040
|
};
|
|
8034
8041
|
getImports = (context) => {
|
|
8035
8042
|
const imports = _getImports(context);
|
|
8036
|
-
|
|
8037
|
-
return imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8038
|
-
} catch (error) {
|
|
8039
|
-
return [];
|
|
8040
|
-
}
|
|
8043
|
+
return imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8041
8044
|
};
|
|
8042
8045
|
isValidStyledProp = (node, context) => {
|
|
8043
8046
|
if (typeof node === "string")
|
|
@@ -8096,7 +8099,7 @@ var init_helpers = __esm({
|
|
|
8096
8099
|
return;
|
|
8097
8100
|
return true;
|
|
8098
8101
|
};
|
|
8099
|
-
|
|
8102
|
+
isStyledProperty = (node, context, calleeName) => {
|
|
8100
8103
|
if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key))
|
|
8101
8104
|
return;
|
|
8102
8105
|
if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName))
|
|
@@ -8107,13 +8110,6 @@ var init_helpers = __esm({
|
|
|
8107
8110
|
return;
|
|
8108
8111
|
return true;
|
|
8109
8112
|
};
|
|
8110
|
-
isStyledProperty = (node, context, calleeName) => {
|
|
8111
|
-
const ancestor = node.parent.parent;
|
|
8112
|
-
const isValidFuncAncestor = isCallExpression(ancestor) && isIdentifier(ancestor.callee) && isPandaIsh(ancestor.callee.name, context);
|
|
8113
|
-
if (isValidFuncAncestor)
|
|
8114
|
-
return isStyledNode(node, context, calleeName);
|
|
8115
|
-
return isStyledNode(ancestor, context, calleeName) && isStyledNode(node, context, calleeName);
|
|
8116
|
-
};
|
|
8117
8113
|
isInPandaFunction = (node, context) => {
|
|
8118
8114
|
const callAncestor = getAncestor(isCallExpression, node);
|
|
8119
8115
|
if (!callAncestor)
|
|
@@ -8779,6 +8775,33 @@ var init_no_important = __esm({
|
|
|
8779
8775
|
});
|
|
8780
8776
|
|
|
8781
8777
|
// src/rules/no-invalid-nesting.ts
|
|
8778
|
+
function isInvalidNesting(node, context, caller) {
|
|
8779
|
+
const recipe = getImports(context).find((imp) => ["cva", "sva"].includes(imp.name) && imp.alias === caller);
|
|
8780
|
+
if (!recipe)
|
|
8781
|
+
return checkNode(node);
|
|
8782
|
+
let currentNode = node;
|
|
8783
|
+
let length = 0;
|
|
8784
|
+
let styleObjectParent = null;
|
|
8785
|
+
while (currentNode) {
|
|
8786
|
+
if (currentNode.key && ["base", "variants"].includes(currentNode.key.name)) {
|
|
8787
|
+
styleObjectParent = currentNode.key.name;
|
|
8788
|
+
}
|
|
8789
|
+
currentNode = currentNode.parent;
|
|
8790
|
+
if (!styleObjectParent)
|
|
8791
|
+
length++;
|
|
8792
|
+
}
|
|
8793
|
+
const requiredLength = caller === "cva" ? 2 : 4;
|
|
8794
|
+
const extraLength = styleObjectParent === "base" ? 0 : 4;
|
|
8795
|
+
if (length >= requiredLength + extraLength) {
|
|
8796
|
+
return checkNode(node);
|
|
8797
|
+
}
|
|
8798
|
+
return false;
|
|
8799
|
+
}
|
|
8800
|
+
function checkNode(node) {
|
|
8801
|
+
const invalidLiteral = isLiteral(node.key) && typeof node.key.value === "string" && !node.key.value.includes("&");
|
|
8802
|
+
const invalidTemplateLiteral = isTemplateLiteral(node.key) && !node.key.quasis[0].value.raw.includes("&");
|
|
8803
|
+
return invalidLiteral || invalidTemplateLiteral;
|
|
8804
|
+
}
|
|
8782
8805
|
var RULE_NAME8, rule8, no_invalid_nesting_default;
|
|
8783
8806
|
var init_no_invalid_nesting = __esm({
|
|
8784
8807
|
"src/rules/no-invalid-nesting.ts"() {
|
|
@@ -8806,18 +8829,18 @@ var init_no_invalid_nesting = __esm({
|
|
|
8806
8829
|
Property(node) {
|
|
8807
8830
|
if (!isObjectExpression(node.value) || isIdentifier(node.key))
|
|
8808
8831
|
return;
|
|
8809
|
-
|
|
8832
|
+
const caller = isInPandaFunction(node, context);
|
|
8833
|
+
if (!caller && !isInJSXProp(node, context))
|
|
8810
8834
|
return;
|
|
8811
8835
|
if (isStyledProperty(node, context))
|
|
8812
8836
|
return;
|
|
8813
|
-
const
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
}
|
|
8837
|
+
const invalidNesting = isInvalidNesting(node, context, caller);
|
|
8838
|
+
if (!invalidNesting)
|
|
8839
|
+
return;
|
|
8840
|
+
context.report({
|
|
8841
|
+
node: node.key,
|
|
8842
|
+
messageId: "nesting"
|
|
8843
|
+
});
|
|
8821
8844
|
}
|
|
8822
8845
|
};
|
|
8823
8846
|
}
|
|
@@ -8867,6 +8890,8 @@ var init_no_invalid_token_paths = __esm({
|
|
|
8867
8890
|
const sendReport = (node, _value) => {
|
|
8868
8891
|
const value = _value ?? node.value?.toString();
|
|
8869
8892
|
const tokens = getInvalidTokens(value, context);
|
|
8893
|
+
if (!tokens)
|
|
8894
|
+
return;
|
|
8870
8895
|
if (tokens.length > 0) {
|
|
8871
8896
|
tokens.forEach((token) => {
|
|
8872
8897
|
context.report({
|
|
@@ -8908,6 +8933,8 @@ var init_no_invalid_token_paths = __esm({
|
|
|
8908
8933
|
const quasis = node.quasi.quasis[0];
|
|
8909
8934
|
const styles = quasis.value.raw;
|
|
8910
8935
|
const tokens = getInvalidTokens(styles, context);
|
|
8936
|
+
if (!tokens)
|
|
8937
|
+
return;
|
|
8911
8938
|
tokens.forEach((token, i, arr) => {
|
|
8912
8939
|
if (arr.indexOf(token) < i)
|
|
8913
8940
|
return;
|
package/dist/utils/worker.js
CHANGED
|
@@ -3869,27 +3869,6 @@ async function getContext(opts) {
|
|
|
3869
3869
|
return await promise;
|
|
3870
3870
|
}
|
|
3871
3871
|
}
|
|
3872
|
-
async function getExtendWarnings() {
|
|
3873
|
-
if (!configPath)
|
|
3874
|
-
return [];
|
|
3875
|
-
const cwd = import_path.default.dirname(configPath);
|
|
3876
|
-
const { config: config2 } = await (0, import_config3.bundleConfig)({ cwd, file: configPath });
|
|
3877
|
-
if (!config2.presets || config2.presets.length === 0)
|
|
3878
|
-
return [];
|
|
3879
|
-
if (config2.eject)
|
|
3880
|
-
return [];
|
|
3881
|
-
const warnings = /* @__PURE__ */ new Set();
|
|
3882
|
-
if (config2.theme && !config2.theme.extend) {
|
|
3883
|
-
warnings.add("theme");
|
|
3884
|
-
}
|
|
3885
|
-
if (config2.conditions && !config2.conditions.extend) {
|
|
3886
|
-
warnings.add("conditions");
|
|
3887
|
-
}
|
|
3888
|
-
if (config2.patterns && !config2.patterns.extend) {
|
|
3889
|
-
warnings.add("patterns");
|
|
3890
|
-
}
|
|
3891
|
-
return Array.from(warnings);
|
|
3892
|
-
}
|
|
3893
3872
|
async function filterInvalidTokens(ctx, paths) {
|
|
3894
3873
|
return paths.filter((path2) => !ctx.utility.tokens.view.get(path2));
|
|
3895
3874
|
}
|
|
@@ -3970,8 +3949,6 @@ async function runAsync(action, opts, ...args) {
|
|
|
3970
3949
|
return isColorToken(ctx, ...args);
|
|
3971
3950
|
case "filterInvalidTokens":
|
|
3972
3951
|
return filterInvalidTokens(ctx, ...args);
|
|
3973
|
-
case "getExtendWarnings":
|
|
3974
|
-
return getExtendWarnings();
|
|
3975
3952
|
}
|
|
3976
3953
|
}
|
|
3977
3954
|
function run(action, opts, ...args) {
|
package/dist/utils/worker.mjs
CHANGED
|
@@ -3830,7 +3830,7 @@ init_esm_shims();
|
|
|
3830
3830
|
|
|
3831
3831
|
// src/utils/worker.ts
|
|
3832
3832
|
import { resolveTsPathPattern } from "@pandacss/config/ts-path";
|
|
3833
|
-
import { findConfig
|
|
3833
|
+
import { findConfig } from "@pandacss/config";
|
|
3834
3834
|
import path from "path";
|
|
3835
3835
|
var promise;
|
|
3836
3836
|
var configPath;
|
|
@@ -3853,27 +3853,6 @@ async function getContext(opts) {
|
|
|
3853
3853
|
return await promise;
|
|
3854
3854
|
}
|
|
3855
3855
|
}
|
|
3856
|
-
async function getExtendWarnings() {
|
|
3857
|
-
if (!configPath)
|
|
3858
|
-
return [];
|
|
3859
|
-
const cwd = path.dirname(configPath);
|
|
3860
|
-
const { config: config2 } = await bundleConfig({ cwd, file: configPath });
|
|
3861
|
-
if (!config2.presets || config2.presets.length === 0)
|
|
3862
|
-
return [];
|
|
3863
|
-
if (config2.eject)
|
|
3864
|
-
return [];
|
|
3865
|
-
const warnings = /* @__PURE__ */ new Set();
|
|
3866
|
-
if (config2.theme && !config2.theme.extend) {
|
|
3867
|
-
warnings.add("theme");
|
|
3868
|
-
}
|
|
3869
|
-
if (config2.conditions && !config2.conditions.extend) {
|
|
3870
|
-
warnings.add("conditions");
|
|
3871
|
-
}
|
|
3872
|
-
if (config2.patterns && !config2.patterns.extend) {
|
|
3873
|
-
warnings.add("patterns");
|
|
3874
|
-
}
|
|
3875
|
-
return Array.from(warnings);
|
|
3876
|
-
}
|
|
3877
3856
|
async function filterInvalidTokens(ctx, paths) {
|
|
3878
3857
|
return paths.filter((path2) => !ctx.utility.tokens.view.get(path2));
|
|
3879
3858
|
}
|
|
@@ -3954,8 +3933,6 @@ async function runAsync(action, opts, ...args) {
|
|
|
3954
3933
|
return isColorToken(ctx, ...args);
|
|
3955
3934
|
case "filterInvalidTokens":
|
|
3956
3935
|
return filterInvalidTokens(ctx, ...args);
|
|
3957
|
-
case "getExtendWarnings":
|
|
3958
|
-
return getExtendWarnings();
|
|
3959
3936
|
}
|
|
3960
3937
|
}
|
|
3961
3938
|
function run(action, opts, ...args) {
|