@pandacss/eslint-plugin 0.1.4 → 0.1.6
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 +52 -38
- package/dist/index.mjs +53 -39
- package/dist/utils/worker.js +2218 -1858
- package/dist/utils/worker.mjs +2218 -1858
- 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.1.
|
|
7960
|
+
var version = "0.1.6";
|
|
7961
7961
|
|
|
7962
7962
|
// src/configs/all.ts
|
|
7963
7963
|
init_cjs_shims();
|
|
@@ -8024,7 +8024,7 @@ var getSyncOpts = (context) => {
|
|
|
8024
8024
|
};
|
|
8025
8025
|
var getImportSpecifiers = (context) => {
|
|
8026
8026
|
const specifiers = [];
|
|
8027
|
-
context.sourceCode
|
|
8027
|
+
context.sourceCode?.ast.body.forEach((node) => {
|
|
8028
8028
|
if (!isImportDeclaration(node))
|
|
8029
8029
|
return;
|
|
8030
8030
|
const mod = node.source.value;
|
|
@@ -8057,7 +8057,11 @@ var _getImports = (context) => {
|
|
|
8057
8057
|
};
|
|
8058
8058
|
var getImports = (context) => {
|
|
8059
8059
|
const imports = _getImports(context);
|
|
8060
|
-
|
|
8060
|
+
try {
|
|
8061
|
+
return imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8062
|
+
} catch (error) {
|
|
8063
|
+
return [];
|
|
8064
|
+
}
|
|
8061
8065
|
};
|
|
8062
8066
|
var isValidStyledProp = (node, context) => {
|
|
8063
8067
|
if (typeof node === "string")
|
|
@@ -8116,7 +8120,7 @@ var isPandaProp = (node, context) => {
|
|
|
8116
8120
|
return;
|
|
8117
8121
|
return true;
|
|
8118
8122
|
};
|
|
8119
|
-
var
|
|
8123
|
+
var isStyledNode = (node, context, calleeName) => {
|
|
8120
8124
|
if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key))
|
|
8121
8125
|
return;
|
|
8122
8126
|
if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName))
|
|
@@ -8127,6 +8131,13 @@ var isStyledProperty = (node, context, calleeName) => {
|
|
|
8127
8131
|
return;
|
|
8128
8132
|
return true;
|
|
8129
8133
|
};
|
|
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
|
+
};
|
|
8130
8141
|
var isInPandaFunction = (node, context) => {
|
|
8131
8142
|
const callAncestor = getAncestor(isCallExpression, node);
|
|
8132
8143
|
if (!callAncestor)
|
|
@@ -8205,6 +8216,21 @@ var getTokenImport = (context) => {
|
|
|
8205
8216
|
const imports = _getImports(context);
|
|
8206
8217
|
return imports.find((imp) => imp.name === "token");
|
|
8207
8218
|
};
|
|
8219
|
+
var getTaggedTemplateCaller = (node) => {
|
|
8220
|
+
if (isIdentifier(node.tag)) {
|
|
8221
|
+
return node.tag.name;
|
|
8222
|
+
}
|
|
8223
|
+
if (isMemberExpression(node.tag)) {
|
|
8224
|
+
if (!isIdentifier(node.tag.object))
|
|
8225
|
+
return;
|
|
8226
|
+
return node.tag.object.name;
|
|
8227
|
+
}
|
|
8228
|
+
if (isCallExpression(node.tag)) {
|
|
8229
|
+
if (!isIdentifier(node.tag.callee))
|
|
8230
|
+
return;
|
|
8231
|
+
return node.tag.callee.name;
|
|
8232
|
+
}
|
|
8233
|
+
};
|
|
8208
8234
|
|
|
8209
8235
|
// src/rules/file-not-included.ts
|
|
8210
8236
|
var RULE_NAME = "file-not-included";
|
|
@@ -8817,41 +8843,29 @@ var rule9 = createRule({
|
|
|
8817
8843
|
handleTemplateLiteral(node.value);
|
|
8818
8844
|
},
|
|
8819
8845
|
TaggedTemplateExpression(node) {
|
|
8820
|
-
const
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
while (index !== -1) {
|
|
8831
|
-
const start = quasis.range[0] + 1 + index;
|
|
8832
|
-
const end = start + token.length;
|
|
8833
|
-
context.report({
|
|
8834
|
-
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
|
|
8835
|
-
messageId: "noInvalidTokenPaths",
|
|
8836
|
-
data: { token }
|
|
8837
|
-
});
|
|
8838
|
-
index = styles.indexOf(token, index + 1);
|
|
8839
|
-
}
|
|
8840
|
-
});
|
|
8841
|
-
};
|
|
8842
|
-
if (isIdentifier(node.tag)) {
|
|
8843
|
-
handleExpression(node.tag.name);
|
|
8844
|
-
}
|
|
8845
|
-
if (isMemberExpression(node.tag)) {
|
|
8846
|
-
if (!isIdentifier(node.tag.object))
|
|
8847
|
-
return;
|
|
8848
|
-
handleExpression(node.tag.object.name);
|
|
8849
|
-
}
|
|
8850
|
-
if (isCallExpression(node.tag)) {
|
|
8851
|
-
if (!isIdentifier(node.tag.callee))
|
|
8846
|
+
const caller = getTaggedTemplateCaller(node);
|
|
8847
|
+
if (!caller)
|
|
8848
|
+
return;
|
|
8849
|
+
if (!isPandaIsh(caller, context))
|
|
8850
|
+
return;
|
|
8851
|
+
const quasis = node.quasi.quasis[0];
|
|
8852
|
+
const styles = quasis.value.raw;
|
|
8853
|
+
const tokens = getInvalidTokens(styles, context);
|
|
8854
|
+
tokens.forEach((token, i, arr) => {
|
|
8855
|
+
if (arr.indexOf(token) < i)
|
|
8852
8856
|
return;
|
|
8853
|
-
|
|
8854
|
-
|
|
8857
|
+
let index = styles.indexOf(token);
|
|
8858
|
+
while (index !== -1) {
|
|
8859
|
+
const start = quasis.range[0] + 1 + index;
|
|
8860
|
+
const end = start + token.length;
|
|
8861
|
+
context.report({
|
|
8862
|
+
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
|
|
8863
|
+
messageId: "noInvalidTokenPaths",
|
|
8864
|
+
data: { token }
|
|
8865
|
+
});
|
|
8866
|
+
index = styles.indexOf(token, index + 1);
|
|
8867
|
+
}
|
|
8868
|
+
});
|
|
8855
8869
|
}
|
|
8856
8870
|
};
|
|
8857
8871
|
}
|
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.6";
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -7975,7 +7975,7 @@ var init_nodes = __esm({
|
|
|
7975
7975
|
});
|
|
7976
7976
|
|
|
7977
7977
|
// src/utils/helpers.ts
|
|
7978
|
-
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;
|
|
7978
|
+
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, hasPkgImport, isPandaConfigFunction, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isStyledNode, isStyledProperty, isInPandaFunction, isInJSXProp, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport, getTaggedTemplateCaller;
|
|
7979
7979
|
var init_helpers = __esm({
|
|
7980
7980
|
"src/utils/helpers.ts"() {
|
|
7981
7981
|
"use strict";
|
|
@@ -8000,7 +8000,7 @@ var init_helpers = __esm({
|
|
|
8000
8000
|
};
|
|
8001
8001
|
getImportSpecifiers = (context) => {
|
|
8002
8002
|
const specifiers = [];
|
|
8003
|
-
context.sourceCode
|
|
8003
|
+
context.sourceCode?.ast.body.forEach((node) => {
|
|
8004
8004
|
if (!isImportDeclaration(node))
|
|
8005
8005
|
return;
|
|
8006
8006
|
const mod = node.source.value;
|
|
@@ -8033,7 +8033,11 @@ var init_helpers = __esm({
|
|
|
8033
8033
|
};
|
|
8034
8034
|
getImports = (context) => {
|
|
8035
8035
|
const imports = _getImports(context);
|
|
8036
|
-
|
|
8036
|
+
try {
|
|
8037
|
+
return imports.filter((imp) => syncAction("matchImports", getSyncOpts(context), imp));
|
|
8038
|
+
} catch (error) {
|
|
8039
|
+
return [];
|
|
8040
|
+
}
|
|
8037
8041
|
};
|
|
8038
8042
|
isValidStyledProp = (node, context) => {
|
|
8039
8043
|
if (typeof node === "string")
|
|
@@ -8092,7 +8096,7 @@ var init_helpers = __esm({
|
|
|
8092
8096
|
return;
|
|
8093
8097
|
return true;
|
|
8094
8098
|
};
|
|
8095
|
-
|
|
8099
|
+
isStyledNode = (node, context, calleeName) => {
|
|
8096
8100
|
if (!isIdentifier(node.key) && !isLiteral(node.key) && !isTemplateLiteral(node.key))
|
|
8097
8101
|
return;
|
|
8098
8102
|
if (isIdentifier(node.key) && !isValidProperty(node.key.name, context, calleeName))
|
|
@@ -8103,6 +8107,13 @@ var init_helpers = __esm({
|
|
|
8103
8107
|
return;
|
|
8104
8108
|
return true;
|
|
8105
8109
|
};
|
|
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
|
+
};
|
|
8106
8117
|
isInPandaFunction = (node, context) => {
|
|
8107
8118
|
const callAncestor = getAncestor(isCallExpression, node);
|
|
8108
8119
|
if (!callAncestor)
|
|
@@ -8181,6 +8192,21 @@ var init_helpers = __esm({
|
|
|
8181
8192
|
const imports = _getImports(context);
|
|
8182
8193
|
return imports.find((imp) => imp.name === "token");
|
|
8183
8194
|
};
|
|
8195
|
+
getTaggedTemplateCaller = (node) => {
|
|
8196
|
+
if (isIdentifier(node.tag)) {
|
|
8197
|
+
return node.tag.name;
|
|
8198
|
+
}
|
|
8199
|
+
if (isMemberExpression(node.tag)) {
|
|
8200
|
+
if (!isIdentifier(node.tag.object))
|
|
8201
|
+
return;
|
|
8202
|
+
return node.tag.object.name;
|
|
8203
|
+
}
|
|
8204
|
+
if (isCallExpression(node.tag)) {
|
|
8205
|
+
if (!isIdentifier(node.tag.callee))
|
|
8206
|
+
return;
|
|
8207
|
+
return node.tag.callee.name;
|
|
8208
|
+
}
|
|
8209
|
+
};
|
|
8184
8210
|
}
|
|
8185
8211
|
});
|
|
8186
8212
|
|
|
@@ -8874,41 +8900,29 @@ var init_no_invalid_token_paths = __esm({
|
|
|
8874
8900
|
handleTemplateLiteral(node.value);
|
|
8875
8901
|
},
|
|
8876
8902
|
TaggedTemplateExpression(node) {
|
|
8877
|
-
const
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
while (index !== -1) {
|
|
8888
|
-
const start = quasis.range[0] + 1 + index;
|
|
8889
|
-
const end = start + token.length;
|
|
8890
|
-
context.report({
|
|
8891
|
-
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
|
|
8892
|
-
messageId: "noInvalidTokenPaths",
|
|
8893
|
-
data: { token }
|
|
8894
|
-
});
|
|
8895
|
-
index = styles.indexOf(token, index + 1);
|
|
8896
|
-
}
|
|
8897
|
-
});
|
|
8898
|
-
};
|
|
8899
|
-
if (isIdentifier(node.tag)) {
|
|
8900
|
-
handleExpression(node.tag.name);
|
|
8901
|
-
}
|
|
8902
|
-
if (isMemberExpression(node.tag)) {
|
|
8903
|
-
if (!isIdentifier(node.tag.object))
|
|
8904
|
-
return;
|
|
8905
|
-
handleExpression(node.tag.object.name);
|
|
8906
|
-
}
|
|
8907
|
-
if (isCallExpression(node.tag)) {
|
|
8908
|
-
if (!isIdentifier(node.tag.callee))
|
|
8903
|
+
const caller = getTaggedTemplateCaller(node);
|
|
8904
|
+
if (!caller)
|
|
8905
|
+
return;
|
|
8906
|
+
if (!isPandaIsh(caller, context))
|
|
8907
|
+
return;
|
|
8908
|
+
const quasis = node.quasi.quasis[0];
|
|
8909
|
+
const styles = quasis.value.raw;
|
|
8910
|
+
const tokens = getInvalidTokens(styles, context);
|
|
8911
|
+
tokens.forEach((token, i, arr) => {
|
|
8912
|
+
if (arr.indexOf(token) < i)
|
|
8909
8913
|
return;
|
|
8910
|
-
|
|
8911
|
-
|
|
8914
|
+
let index = styles.indexOf(token);
|
|
8915
|
+
while (index !== -1) {
|
|
8916
|
+
const start = quasis.range[0] + 1 + index;
|
|
8917
|
+
const end = start + token.length;
|
|
8918
|
+
context.report({
|
|
8919
|
+
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
|
|
8920
|
+
messageId: "noInvalidTokenPaths",
|
|
8921
|
+
data: { token }
|
|
8922
|
+
});
|
|
8923
|
+
index = styles.indexOf(token, index + 1);
|
|
8924
|
+
}
|
|
8925
|
+
});
|
|
8912
8926
|
}
|
|
8913
8927
|
};
|
|
8914
8928
|
}
|