@pandacss/eslint-plugin 0.0.0-dev-20240208175853 → 0.0.0-dev-20240209200922
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 +315 -142
- package/dist/index.mjs +349 -155
- 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.0.0-dev-
|
|
7960
|
+
var version = "0.0.0-dev-20240209200922";
|
|
7961
7961
|
|
|
7962
7962
|
// src/configs/all.ts
|
|
7963
7963
|
init_cjs_shims();
|
|
@@ -8004,6 +8004,7 @@ var isJSXIdentifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_
|
|
|
8004
8004
|
var isCallExpression = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.CallExpression);
|
|
8005
8005
|
var isImportDeclaration = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ImportDeclaration);
|
|
8006
8006
|
var isImportSpecifier = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.ImportSpecifier);
|
|
8007
|
+
var isProperty = (0, import_ast_utils.isNodeOfType)(import_utils2.AST_NODE_TYPES.Property);
|
|
8007
8008
|
|
|
8008
8009
|
// src/utils/helpers.ts
|
|
8009
8010
|
var getAncestor = (ofType, for_) => {
|
|
@@ -8580,13 +8581,109 @@ var rule6 = createRule({
|
|
|
8580
8581
|
});
|
|
8581
8582
|
var no_hardcoded_color_default = rule6;
|
|
8582
8583
|
|
|
8583
|
-
// src/rules/no-
|
|
8584
|
+
// src/rules/no-important.ts
|
|
8584
8585
|
init_cjs_shims();
|
|
8585
|
-
var
|
|
8586
|
-
var
|
|
8587
|
-
var RULE_NAME7 = "no-
|
|
8586
|
+
var exclamationRegex = /\s*!$/;
|
|
8587
|
+
var importantRegex = /\s*!important\s*$/;
|
|
8588
|
+
var RULE_NAME7 = "no-important";
|
|
8588
8589
|
var rule7 = createRule({
|
|
8589
8590
|
name: RULE_NAME7,
|
|
8591
|
+
meta: {
|
|
8592
|
+
docs: {
|
|
8593
|
+
description: "Disallow usage of important keyword. Prioroitize specificity for a maintainable and predictable styling structure."
|
|
8594
|
+
},
|
|
8595
|
+
messages: {
|
|
8596
|
+
important: "Avoid using the !important keyword. Refactor your code to prioritize specificity for predictable styling.",
|
|
8597
|
+
remove: "Remove the `{{keyword}}` keyword."
|
|
8598
|
+
},
|
|
8599
|
+
type: "suggestion",
|
|
8600
|
+
hasSuggestions: true,
|
|
8601
|
+
schema: []
|
|
8602
|
+
},
|
|
8603
|
+
defaultOptions: [],
|
|
8604
|
+
create(context) {
|
|
8605
|
+
const removeQuotes = ([start, end]) => [start + 1, end - 1];
|
|
8606
|
+
const hasImportantKeyword = (value) => {
|
|
8607
|
+
if (!value)
|
|
8608
|
+
return false;
|
|
8609
|
+
return exclamationRegex.test(value) || importantRegex.test(value);
|
|
8610
|
+
};
|
|
8611
|
+
const removeImportantKeyword = (input) => {
|
|
8612
|
+
if (exclamationRegex.test(input)) {
|
|
8613
|
+
return { fixed: input.replace(exclamationRegex, ""), keyword: "!" };
|
|
8614
|
+
} else if (importantRegex.test(input)) {
|
|
8615
|
+
return { fixed: input.replace(importantRegex, ""), keyword: "!important" };
|
|
8616
|
+
} else {
|
|
8617
|
+
return { fixed: input, keyword: null };
|
|
8618
|
+
}
|
|
8619
|
+
};
|
|
8620
|
+
const handleLiteral = (node) => {
|
|
8621
|
+
if (!isLiteral(node))
|
|
8622
|
+
return;
|
|
8623
|
+
if (!hasImportantKeyword(node.value?.toString()))
|
|
8624
|
+
return;
|
|
8625
|
+
sendReport(node);
|
|
8626
|
+
};
|
|
8627
|
+
const handleTemplateLiteral = (node) => {
|
|
8628
|
+
if (!isTemplateLiteral(node))
|
|
8629
|
+
return;
|
|
8630
|
+
if (node.expressions.length > 0)
|
|
8631
|
+
return;
|
|
8632
|
+
if (!hasImportantKeyword(node.quasis[0].value.raw))
|
|
8633
|
+
return;
|
|
8634
|
+
sendReport(node.quasis[0], node.quasis[0].value.raw);
|
|
8635
|
+
};
|
|
8636
|
+
const sendReport = (node, _value) => {
|
|
8637
|
+
const value = _value ?? node.value?.toString();
|
|
8638
|
+
const { keyword, fixed } = removeImportantKeyword(value);
|
|
8639
|
+
return context.report({
|
|
8640
|
+
node,
|
|
8641
|
+
messageId: "important",
|
|
8642
|
+
suggest: [
|
|
8643
|
+
{
|
|
8644
|
+
messageId: "remove",
|
|
8645
|
+
data: { keyword },
|
|
8646
|
+
fix: (fixer) => {
|
|
8647
|
+
return fixer.replaceTextRange(removeQuotes(node.range), fixed);
|
|
8648
|
+
}
|
|
8649
|
+
}
|
|
8650
|
+
]
|
|
8651
|
+
});
|
|
8652
|
+
};
|
|
8653
|
+
return {
|
|
8654
|
+
JSXAttribute(node) {
|
|
8655
|
+
if (!node.value)
|
|
8656
|
+
return;
|
|
8657
|
+
if (!isPandaProp(node, context))
|
|
8658
|
+
return;
|
|
8659
|
+
handleLiteral(node.value);
|
|
8660
|
+
if (!isJSXExpressionContainer(node.value))
|
|
8661
|
+
return;
|
|
8662
|
+
handleLiteral(node.value.expression);
|
|
8663
|
+
handleTemplateLiteral(node.value.expression);
|
|
8664
|
+
},
|
|
8665
|
+
Property(node) {
|
|
8666
|
+
if (!isIdentifier(node.key))
|
|
8667
|
+
return;
|
|
8668
|
+
if (!isLiteral(node.value) && !isTemplateLiteral(node.value))
|
|
8669
|
+
return;
|
|
8670
|
+
if (!isPandaAttribute(node, context))
|
|
8671
|
+
return;
|
|
8672
|
+
handleLiteral(node.value);
|
|
8673
|
+
handleTemplateLiteral(node.value);
|
|
8674
|
+
}
|
|
8675
|
+
};
|
|
8676
|
+
}
|
|
8677
|
+
});
|
|
8678
|
+
var no_important_default = rule7;
|
|
8679
|
+
|
|
8680
|
+
// src/rules/no-invalid-token-paths.ts
|
|
8681
|
+
init_cjs_shims();
|
|
8682
|
+
var import_utils11 = require("@typescript-eslint/utils");
|
|
8683
|
+
var import_ast_utils2 = require("@typescript-eslint/utils/ast-utils");
|
|
8684
|
+
var RULE_NAME8 = "no-invalid-token-paths";
|
|
8685
|
+
var rule8 = createRule({
|
|
8686
|
+
name: RULE_NAME8,
|
|
8590
8687
|
meta: {
|
|
8591
8688
|
docs: {
|
|
8592
8689
|
description: "Disallow the use of invalid token paths within token function syntax."
|
|
@@ -8639,7 +8736,7 @@ var rule7 = createRule({
|
|
|
8639
8736
|
Property(node) {
|
|
8640
8737
|
if (!isIdentifier(node.key))
|
|
8641
8738
|
return;
|
|
8642
|
-
if (!(0, import_ast_utils2.isNodeOfTypes)([
|
|
8739
|
+
if (!(0, import_ast_utils2.isNodeOfTypes)([import_utils11.AST_NODE_TYPES.Literal, import_utils11.AST_NODE_TYPES.TemplateLiteral])(node.value))
|
|
8643
8740
|
return;
|
|
8644
8741
|
if (!isPandaAttribute(node, context))
|
|
8645
8742
|
return;
|
|
@@ -8686,13 +8783,13 @@ var rule7 = createRule({
|
|
|
8686
8783
|
};
|
|
8687
8784
|
}
|
|
8688
8785
|
});
|
|
8689
|
-
var no_invalid_token_paths_default =
|
|
8786
|
+
var no_invalid_token_paths_default = rule8;
|
|
8690
8787
|
|
|
8691
8788
|
// src/rules/no-property-renaming.ts
|
|
8692
8789
|
init_cjs_shims();
|
|
8693
|
-
var
|
|
8694
|
-
var
|
|
8695
|
-
name:
|
|
8790
|
+
var RULE_NAME9 = "no-property-renaming";
|
|
8791
|
+
var rule9 = createRule({
|
|
8792
|
+
name: RULE_NAME9,
|
|
8696
8793
|
meta: {
|
|
8697
8794
|
docs: {
|
|
8698
8795
|
description: "Ensure user does not rename a property for a pattern or style prop. \nIt doesn't get tracked."
|
|
@@ -8751,20 +8848,21 @@ var rule8 = createRule({
|
|
|
8751
8848
|
};
|
|
8752
8849
|
}
|
|
8753
8850
|
});
|
|
8754
|
-
var no_property_renaming_default =
|
|
8851
|
+
var no_property_renaming_default = rule9;
|
|
8755
8852
|
|
|
8756
|
-
// src/rules/
|
|
8853
|
+
// src/rules/no-unsafe-token-fn-usage.ts
|
|
8757
8854
|
init_cjs_shims();
|
|
8758
|
-
var
|
|
8759
|
-
var
|
|
8760
|
-
|
|
8855
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
8856
|
+
var RULE_NAME10 = "no-unsafe-token-fn-usage";
|
|
8857
|
+
var rule10 = createRule({
|
|
8858
|
+
name: RULE_NAME10,
|
|
8761
8859
|
meta: {
|
|
8762
8860
|
docs: {
|
|
8763
|
-
description: "
|
|
8861
|
+
description: "Prevent users from using the token function in situations where they could simply use the raw design token."
|
|
8764
8862
|
},
|
|
8765
8863
|
messages: {
|
|
8766
|
-
|
|
8767
|
-
replace: "Replace
|
|
8864
|
+
noUnsafeTokenFnUsage: "Unneccessary token function usage. Prefer design token",
|
|
8865
|
+
replace: "Replace token function with `{{safe}}`"
|
|
8768
8866
|
},
|
|
8769
8867
|
type: "suggestion",
|
|
8770
8868
|
hasSuggestions: true,
|
|
@@ -8772,22 +8870,57 @@ var rule9 = createRule({
|
|
|
8772
8870
|
},
|
|
8773
8871
|
defaultOptions: [],
|
|
8774
8872
|
create(context) {
|
|
8775
|
-
const
|
|
8776
|
-
const
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8873
|
+
const isUnsafeCallExpression = (node) => {
|
|
8874
|
+
const tkImport = getTokenImport(context);
|
|
8875
|
+
return isIdentifier(node.callee) && node.callee.name === tkImport?.alias;
|
|
8876
|
+
};
|
|
8877
|
+
const tokenWrap = (value) => value ? `token(${value})` : "";
|
|
8878
|
+
const handleRuntimeFm = (node) => {
|
|
8879
|
+
if (!isCallExpression(node))
|
|
8880
|
+
return;
|
|
8881
|
+
if (!isUnsafeCallExpression(node))
|
|
8882
|
+
return;
|
|
8883
|
+
const value = node.arguments[0];
|
|
8884
|
+
if (isLiteral(value)) {
|
|
8885
|
+
sendReport(node, tokenWrap(value.value?.toString()));
|
|
8886
|
+
}
|
|
8887
|
+
if (isTemplateLiteral(value)) {
|
|
8888
|
+
sendReport(node, tokenWrap(value.quasis[0].value.raw));
|
|
8889
|
+
}
|
|
8890
|
+
};
|
|
8891
|
+
const isCompositeValue = (input) => {
|
|
8892
|
+
if (!input)
|
|
8893
|
+
return;
|
|
8894
|
+
const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
|
|
8895
|
+
return !tokenRegex.test(input);
|
|
8896
|
+
};
|
|
8897
|
+
const handleLiteral = (node) => {
|
|
8898
|
+
if (!isLiteral(node))
|
|
8899
|
+
return;
|
|
8900
|
+
if (isCompositeValue(node.value?.toString()))
|
|
8901
|
+
return;
|
|
8902
|
+
sendReport(node);
|
|
8903
|
+
};
|
|
8904
|
+
const handleTemplateLiteral = (node) => {
|
|
8905
|
+
if (!isTemplateLiteral(node))
|
|
8906
|
+
return;
|
|
8907
|
+
if (node.expressions.length > 0)
|
|
8908
|
+
return;
|
|
8909
|
+
sendReport(node, node.quasis[0].value.raw);
|
|
8910
|
+
};
|
|
8911
|
+
const sendReport = (node, _value) => {
|
|
8912
|
+
const value = _value ?? node.value?.toString();
|
|
8913
|
+
const tkImports = extractTokens(value);
|
|
8914
|
+
const token = tkImports[0].replace(/^[^.]*\./, "");
|
|
8781
8915
|
return context.report({
|
|
8782
8916
|
node,
|
|
8783
|
-
messageId: "
|
|
8784
|
-
data,
|
|
8917
|
+
messageId: "noUnsafeTokenFnUsage",
|
|
8785
8918
|
suggest: [
|
|
8786
8919
|
{
|
|
8787
8920
|
messageId: "replace",
|
|
8788
|
-
data,
|
|
8921
|
+
data: { safe: token },
|
|
8789
8922
|
fix: (fixer) => {
|
|
8790
|
-
return fixer.replaceTextRange(node.range,
|
|
8923
|
+
return fixer.replaceTextRange(node.range, `'${token}'`);
|
|
8791
8924
|
}
|
|
8792
8925
|
}
|
|
8793
8926
|
]
|
|
@@ -8795,42 +8928,43 @@ var rule9 = createRule({
|
|
|
8795
8928
|
};
|
|
8796
8929
|
return {
|
|
8797
8930
|
JSXAttribute(node) {
|
|
8798
|
-
if (!
|
|
8931
|
+
if (!node.value)
|
|
8799
8932
|
return;
|
|
8800
8933
|
if (!isPandaProp(node, context))
|
|
8801
8934
|
return;
|
|
8802
|
-
|
|
8803
|
-
if (!
|
|
8935
|
+
handleLiteral(node.value);
|
|
8936
|
+
if (!isJSXExpressionContainer(node.value))
|
|
8804
8937
|
return;
|
|
8805
|
-
|
|
8938
|
+
handleLiteral(node.value.expression);
|
|
8939
|
+
handleTemplateLiteral(node.value.expression);
|
|
8940
|
+
handleRuntimeFm(node.value.expression);
|
|
8806
8941
|
},
|
|
8807
8942
|
Property(node) {
|
|
8808
|
-
if (!
|
|
8943
|
+
if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value))
|
|
8809
8944
|
return;
|
|
8810
8945
|
if (!isPandaAttribute(node, context))
|
|
8811
8946
|
return;
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
sendReport(node.key, node.key.name);
|
|
8947
|
+
handleRuntimeFm(node.value);
|
|
8948
|
+
handleLiteral(node.value);
|
|
8949
|
+
handleTemplateLiteral(node.value);
|
|
8816
8950
|
}
|
|
8817
8951
|
};
|
|
8818
8952
|
}
|
|
8819
8953
|
});
|
|
8820
|
-
var
|
|
8954
|
+
var no_unsafe_token_fn_usage_default = rule10;
|
|
8821
8955
|
|
|
8822
|
-
// src/rules/prefer-
|
|
8956
|
+
// src/rules/prefer-longhand-properties.ts
|
|
8823
8957
|
init_cjs_shims();
|
|
8824
|
-
var
|
|
8825
|
-
var
|
|
8826
|
-
name:
|
|
8958
|
+
var RULE_NAME11 = "prefer-longhand-properties";
|
|
8959
|
+
var rule11 = createRule({
|
|
8960
|
+
name: RULE_NAME11,
|
|
8827
8961
|
meta: {
|
|
8828
8962
|
docs: {
|
|
8829
|
-
description: "Discourage the use of
|
|
8963
|
+
description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
|
|
8830
8964
|
},
|
|
8831
8965
|
messages: {
|
|
8832
|
-
|
|
8833
|
-
replace: "Replace `{{
|
|
8966
|
+
longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
|
|
8967
|
+
replace: "Replace `{{shorthand}}` with `{{longhand}}`"
|
|
8834
8968
|
},
|
|
8835
8969
|
type: "suggestion",
|
|
8836
8970
|
hasSuggestions: true,
|
|
@@ -8839,24 +8973,21 @@ var rule10 = createRule({
|
|
|
8839
8973
|
defaultOptions: [],
|
|
8840
8974
|
create(context) {
|
|
8841
8975
|
const sendReport = (node, name2) => {
|
|
8842
|
-
const
|
|
8843
|
-
if (!shorthands)
|
|
8844
|
-
return;
|
|
8845
|
-
const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
|
|
8976
|
+
const longhand = resolveLonghand(name2, context);
|
|
8846
8977
|
const data = {
|
|
8847
|
-
|
|
8848
|
-
|
|
8978
|
+
shorthand: name2,
|
|
8979
|
+
longhand
|
|
8849
8980
|
};
|
|
8850
8981
|
return context.report({
|
|
8851
8982
|
node,
|
|
8852
|
-
messageId: "
|
|
8983
|
+
messageId: "longhand",
|
|
8853
8984
|
data,
|
|
8854
8985
|
suggest: [
|
|
8855
8986
|
{
|
|
8856
8987
|
messageId: "replace",
|
|
8857
8988
|
data,
|
|
8858
8989
|
fix: (fixer) => {
|
|
8859
|
-
return fixer.replaceTextRange(node.range,
|
|
8990
|
+
return fixer.replaceTextRange(node.range, longhand);
|
|
8860
8991
|
}
|
|
8861
8992
|
}
|
|
8862
8993
|
]
|
|
@@ -8869,7 +9000,7 @@ var rule10 = createRule({
|
|
|
8869
9000
|
if (!isPandaProp(node, context))
|
|
8870
9001
|
return;
|
|
8871
9002
|
const longhand = resolveLonghand(node.name.name, context);
|
|
8872
|
-
if (longhand)
|
|
9003
|
+
if (!longhand)
|
|
8873
9004
|
return;
|
|
8874
9005
|
sendReport(node.name, node.name.name);
|
|
8875
9006
|
},
|
|
@@ -8879,28 +9010,27 @@ var rule10 = createRule({
|
|
|
8879
9010
|
if (!isPandaAttribute(node, context))
|
|
8880
9011
|
return;
|
|
8881
9012
|
const longhand = resolveLonghand(node.key.name, context);
|
|
8882
|
-
if (longhand)
|
|
9013
|
+
if (!longhand)
|
|
8883
9014
|
return;
|
|
8884
9015
|
sendReport(node.key, node.key.name);
|
|
8885
9016
|
}
|
|
8886
9017
|
};
|
|
8887
9018
|
}
|
|
8888
9019
|
});
|
|
8889
|
-
var
|
|
9020
|
+
var prefer_longhand_properties_default = rule11;
|
|
8890
9021
|
|
|
8891
|
-
// src/rules/
|
|
9022
|
+
// src/rules/prefer-shorthand-properties.ts
|
|
8892
9023
|
init_cjs_shims();
|
|
8893
|
-
var
|
|
8894
|
-
var
|
|
8895
|
-
|
|
8896
|
-
name: RULE_NAME11,
|
|
9024
|
+
var RULE_NAME12 = "prefer-shorthand-properties";
|
|
9025
|
+
var rule12 = createRule({
|
|
9026
|
+
name: RULE_NAME12,
|
|
8897
9027
|
meta: {
|
|
8898
9028
|
docs: {
|
|
8899
|
-
description: "
|
|
9029
|
+
description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
|
|
8900
9030
|
},
|
|
8901
9031
|
messages: {
|
|
8902
|
-
|
|
8903
|
-
replace: "Replace
|
|
9032
|
+
shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
|
|
9033
|
+
replace: "Replace `{{longhand}}` with `{{shorthand}}`"
|
|
8904
9034
|
},
|
|
8905
9035
|
type: "suggestion",
|
|
8906
9036
|
hasSuggestions: true,
|
|
@@ -8908,57 +9038,25 @@ var rule11 = createRule({
|
|
|
8908
9038
|
},
|
|
8909
9039
|
defaultOptions: [],
|
|
8910
9040
|
create(context) {
|
|
8911
|
-
const
|
|
8912
|
-
const
|
|
8913
|
-
|
|
8914
|
-
};
|
|
8915
|
-
const tokenWrap = (value) => value ? `token(${value})` : "";
|
|
8916
|
-
const handleRuntimeFm = (node) => {
|
|
8917
|
-
if (!isCallExpression(node))
|
|
8918
|
-
return;
|
|
8919
|
-
if (!isUnsafeCallExpression(node))
|
|
8920
|
-
return;
|
|
8921
|
-
const value = node.arguments[0];
|
|
8922
|
-
if (isLiteral(value)) {
|
|
8923
|
-
sendReport(node, tokenWrap(value.value?.toString()));
|
|
8924
|
-
}
|
|
8925
|
-
if (isTemplateLiteral(value)) {
|
|
8926
|
-
sendReport(node, tokenWrap(value.quasis[0].value.raw));
|
|
8927
|
-
}
|
|
8928
|
-
};
|
|
8929
|
-
const isCompositeValue = (input) => {
|
|
8930
|
-
if (!input)
|
|
8931
|
-
return;
|
|
8932
|
-
const tokenRegex = /^(?:token\([^)]*\)|\{[^}]*\})$/;
|
|
8933
|
-
return !tokenRegex.test(input);
|
|
8934
|
-
};
|
|
8935
|
-
const handleLiteral = (node) => {
|
|
8936
|
-
if (!isLiteral(node))
|
|
8937
|
-
return;
|
|
8938
|
-
if (isCompositeValue(node.value?.toString()))
|
|
8939
|
-
return;
|
|
8940
|
-
sendReport(node);
|
|
8941
|
-
};
|
|
8942
|
-
const handleTemplateLiteral = (node) => {
|
|
8943
|
-
if (!isTemplateLiteral(node))
|
|
8944
|
-
return;
|
|
8945
|
-
if (node.expressions.length > 0)
|
|
9041
|
+
const sendReport = (node, name2) => {
|
|
9042
|
+
const shorthands = resolveShorthands(name2, context);
|
|
9043
|
+
if (!shorthands)
|
|
8946
9044
|
return;
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
const token = tkImports[0].replace(/^[^.]*\./, "");
|
|
9045
|
+
const shorthand = shorthands.map((s) => `\`${s}\``)?.join(", ");
|
|
9046
|
+
const data = {
|
|
9047
|
+
longhand: name2,
|
|
9048
|
+
shorthand
|
|
9049
|
+
};
|
|
8953
9050
|
return context.report({
|
|
8954
9051
|
node,
|
|
8955
|
-
messageId: "
|
|
9052
|
+
messageId: "shorthand",
|
|
9053
|
+
data,
|
|
8956
9054
|
suggest: [
|
|
8957
9055
|
{
|
|
8958
9056
|
messageId: "replace",
|
|
8959
|
-
data
|
|
9057
|
+
data,
|
|
8960
9058
|
fix: (fixer) => {
|
|
8961
|
-
return fixer.replaceTextRange(node.range,
|
|
9059
|
+
return fixer.replaceTextRange(node.range, shorthands[0]);
|
|
8962
9060
|
}
|
|
8963
9061
|
}
|
|
8964
9062
|
]
|
|
@@ -8966,30 +9064,29 @@ var rule11 = createRule({
|
|
|
8966
9064
|
};
|
|
8967
9065
|
return {
|
|
8968
9066
|
JSXAttribute(node) {
|
|
8969
|
-
if (!node.
|
|
9067
|
+
if (!isJSXIdentifier(node.name))
|
|
8970
9068
|
return;
|
|
8971
9069
|
if (!isPandaProp(node, context))
|
|
8972
9070
|
return;
|
|
8973
|
-
|
|
8974
|
-
if (
|
|
9071
|
+
const longhand = resolveLonghand(node.name.name, context);
|
|
9072
|
+
if (longhand)
|
|
8975
9073
|
return;
|
|
8976
|
-
|
|
8977
|
-
handleTemplateLiteral(node.value.expression);
|
|
8978
|
-
handleRuntimeFm(node.value.expression);
|
|
9074
|
+
sendReport(node.name, node.name.name);
|
|
8979
9075
|
},
|
|
8980
9076
|
Property(node) {
|
|
8981
|
-
if (!
|
|
9077
|
+
if (!isIdentifier(node.key))
|
|
8982
9078
|
return;
|
|
8983
9079
|
if (!isPandaAttribute(node, context))
|
|
8984
9080
|
return;
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
9081
|
+
const longhand = resolveLonghand(node.key.name, context);
|
|
9082
|
+
if (longhand)
|
|
9083
|
+
return;
|
|
9084
|
+
sendReport(node.key, node.key.name);
|
|
8988
9085
|
}
|
|
8989
9086
|
};
|
|
8990
9087
|
}
|
|
8991
9088
|
});
|
|
8992
|
-
var
|
|
9089
|
+
var prefer_shorthand_properties_default = rule12;
|
|
8993
9090
|
|
|
8994
9091
|
// src/rules/prefer-atomic-properties.ts
|
|
8995
9092
|
init_cjs_shims();
|
|
@@ -9109,9 +9206,9 @@ var compositeProperties = {
|
|
|
9109
9206
|
};
|
|
9110
9207
|
|
|
9111
9208
|
// src/rules/prefer-atomic-properties.ts
|
|
9112
|
-
var
|
|
9113
|
-
var
|
|
9114
|
-
name:
|
|
9209
|
+
var RULE_NAME13 = "prefer-atomic-properties";
|
|
9210
|
+
var rule13 = createRule({
|
|
9211
|
+
name: RULE_NAME13,
|
|
9115
9212
|
meta: {
|
|
9116
9213
|
docs: {
|
|
9117
9214
|
description: "Encourage the use of atomic properties instead of composite properties in the codebase."
|
|
@@ -9132,8 +9229,8 @@ var rule12 = createRule({
|
|
|
9132
9229
|
return longhand;
|
|
9133
9230
|
};
|
|
9134
9231
|
const sendReport = (node, name2) => {
|
|
9135
|
-
const
|
|
9136
|
-
const atomics = compositeProperties[
|
|
9232
|
+
const cmp = resolveCompositeProperty(name2);
|
|
9233
|
+
const atomics = compositeProperties[cmp].map((name3) => `\`${name3}\``).join(",\n");
|
|
9137
9234
|
return context.report({
|
|
9138
9235
|
node,
|
|
9139
9236
|
messageId: "atomic",
|
|
@@ -9149,8 +9246,8 @@ var rule12 = createRule({
|
|
|
9149
9246
|
return;
|
|
9150
9247
|
if (!isPandaProp(node, context))
|
|
9151
9248
|
return;
|
|
9152
|
-
const
|
|
9153
|
-
if (!
|
|
9249
|
+
const cmp = resolveCompositeProperty(node.name.name);
|
|
9250
|
+
if (!cmp)
|
|
9154
9251
|
return;
|
|
9155
9252
|
sendReport(node, node.name.name);
|
|
9156
9253
|
},
|
|
@@ -9159,21 +9256,21 @@ var rule12 = createRule({
|
|
|
9159
9256
|
return;
|
|
9160
9257
|
if (!isPandaAttribute(node, context))
|
|
9161
9258
|
return;
|
|
9162
|
-
const
|
|
9163
|
-
if (!
|
|
9259
|
+
const cmp = resolveCompositeProperty(node.key.name);
|
|
9260
|
+
if (!cmp)
|
|
9164
9261
|
return;
|
|
9165
9262
|
sendReport(node.key, node.key.name);
|
|
9166
9263
|
}
|
|
9167
9264
|
};
|
|
9168
9265
|
}
|
|
9169
9266
|
});
|
|
9170
|
-
var prefer_atomic_properties_default =
|
|
9267
|
+
var prefer_atomic_properties_default = rule13;
|
|
9171
9268
|
|
|
9172
9269
|
// src/rules/prefer-composite-properties.ts
|
|
9173
9270
|
init_cjs_shims();
|
|
9174
|
-
var
|
|
9175
|
-
var
|
|
9176
|
-
name:
|
|
9271
|
+
var RULE_NAME14 = "prefer-composite-properties";
|
|
9272
|
+
var rule14 = createRule({
|
|
9273
|
+
name: RULE_NAME14,
|
|
9177
9274
|
meta: {
|
|
9178
9275
|
docs: {
|
|
9179
9276
|
description: "Encourage the use of composite properties instead of atomic properties in the codebase."
|
|
@@ -9227,7 +9324,80 @@ var rule13 = createRule({
|
|
|
9227
9324
|
};
|
|
9228
9325
|
}
|
|
9229
9326
|
});
|
|
9230
|
-
var prefer_composite_properties_default =
|
|
9327
|
+
var prefer_composite_properties_default = rule14;
|
|
9328
|
+
|
|
9329
|
+
// src/rules/prefer-unified-property-style.ts
|
|
9330
|
+
init_cjs_shims();
|
|
9331
|
+
var RULE_NAME15 = "prefer-unified-property-style";
|
|
9332
|
+
var rule15 = createRule({
|
|
9333
|
+
name: RULE_NAME15,
|
|
9334
|
+
meta: {
|
|
9335
|
+
docs: {
|
|
9336
|
+
description: "Discourage against mixing atomic and composite forms of the same property in a style declaration. Atomic styles give more consistent results"
|
|
9337
|
+
},
|
|
9338
|
+
messages: {
|
|
9339
|
+
unify: "You're mixing atomic {{atomicProperties}} with composite property {{composite}}. \nPrefer atomic styling to mixing atomic and composite properties. \nRemove `{{composite}}` and use one or more of {{atomics}} instead"
|
|
9340
|
+
},
|
|
9341
|
+
type: "suggestion",
|
|
9342
|
+
schema: []
|
|
9343
|
+
},
|
|
9344
|
+
defaultOptions: [],
|
|
9345
|
+
create(context) {
|
|
9346
|
+
const getLonghand = (name2) => resolveLonghand(name2, context) ?? name2;
|
|
9347
|
+
const resolveCompositeProperty = (name2) => {
|
|
9348
|
+
if (Object.hasOwn(compositeProperties, name2))
|
|
9349
|
+
return name2;
|
|
9350
|
+
const longhand = getLonghand(name2);
|
|
9351
|
+
if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
|
|
9352
|
+
return longhand;
|
|
9353
|
+
};
|
|
9354
|
+
const sendReport = (node, cmp, siblings) => {
|
|
9355
|
+
const _atomicProperties = siblings.filter((prop) => compositeProperties[cmp].includes(getLonghand(prop))).map((prop) => `\`${prop}\``);
|
|
9356
|
+
if (!_atomicProperties.length)
|
|
9357
|
+
return;
|
|
9358
|
+
const atomicProperties = _atomicProperties.join(", ") + (_atomicProperties.length === 1 ? " style" : " styles");
|
|
9359
|
+
const atomics = compositeProperties[cmp].map((name2) => `\`${name2}\``).join(", ");
|
|
9360
|
+
context.report({
|
|
9361
|
+
node,
|
|
9362
|
+
messageId: "unify",
|
|
9363
|
+
data: {
|
|
9364
|
+
composite: cmp,
|
|
9365
|
+
atomicProperties,
|
|
9366
|
+
atomics
|
|
9367
|
+
}
|
|
9368
|
+
});
|
|
9369
|
+
};
|
|
9370
|
+
return {
|
|
9371
|
+
JSXAttribute(node) {
|
|
9372
|
+
if (!isJSXIdentifier(node.name))
|
|
9373
|
+
return;
|
|
9374
|
+
if (!isPandaProp(node, context))
|
|
9375
|
+
return;
|
|
9376
|
+
const cmp = resolveCompositeProperty(node.name.name);
|
|
9377
|
+
if (!cmp)
|
|
9378
|
+
return;
|
|
9379
|
+
if (!isJSXOpeningElement(node.parent))
|
|
9380
|
+
return;
|
|
9381
|
+
const siblings = node.parent.attributes.map((attr) => attr.name.name);
|
|
9382
|
+
sendReport(node, cmp, siblings);
|
|
9383
|
+
},
|
|
9384
|
+
Property(node) {
|
|
9385
|
+
if (!isIdentifier(node.key))
|
|
9386
|
+
return;
|
|
9387
|
+
if (!isPandaAttribute(node, context))
|
|
9388
|
+
return;
|
|
9389
|
+
const cmp = resolveCompositeProperty(node.key.name);
|
|
9390
|
+
if (!cmp)
|
|
9391
|
+
return;
|
|
9392
|
+
if (!isObjectExpression(node.parent))
|
|
9393
|
+
return;
|
|
9394
|
+
const siblings = node.parent.properties.map((prop) => isIdentifier(prop.key) && prop.key.name);
|
|
9395
|
+
sendReport(node.key, cmp, siblings);
|
|
9396
|
+
}
|
|
9397
|
+
};
|
|
9398
|
+
}
|
|
9399
|
+
});
|
|
9400
|
+
var prefer_unified_property_style_default = rule15;
|
|
9231
9401
|
|
|
9232
9402
|
// src/rules/index.ts
|
|
9233
9403
|
var rules = {
|
|
@@ -9237,17 +9407,19 @@ var rules = {
|
|
|
9237
9407
|
[RULE_NAME4]: no_dynamic_styling_default,
|
|
9238
9408
|
[RULE_NAME5]: no_escape_hatch_default,
|
|
9239
9409
|
[RULE_NAME6]: no_hardcoded_color_default,
|
|
9240
|
-
[RULE_NAME7]:
|
|
9241
|
-
[RULE_NAME8]:
|
|
9242
|
-
[RULE_NAME9]:
|
|
9243
|
-
[RULE_NAME10]:
|
|
9244
|
-
[RULE_NAME11]:
|
|
9245
|
-
[RULE_NAME12]:
|
|
9246
|
-
[RULE_NAME13]:
|
|
9410
|
+
[RULE_NAME7]: no_important_default,
|
|
9411
|
+
[RULE_NAME8]: no_invalid_token_paths_default,
|
|
9412
|
+
[RULE_NAME9]: no_property_renaming_default,
|
|
9413
|
+
[RULE_NAME10]: no_unsafe_token_fn_usage_default,
|
|
9414
|
+
[RULE_NAME11]: prefer_longhand_properties_default,
|
|
9415
|
+
[RULE_NAME12]: prefer_shorthand_properties_default,
|
|
9416
|
+
[RULE_NAME13]: prefer_atomic_properties_default,
|
|
9417
|
+
[RULE_NAME14]: prefer_composite_properties_default,
|
|
9418
|
+
[RULE_NAME15]: prefer_unified_property_style_default
|
|
9247
9419
|
};
|
|
9248
9420
|
|
|
9249
9421
|
// src/configs/all.ts
|
|
9250
|
-
var errorRules = [RULE_NAME, RULE_NAME2,
|
|
9422
|
+
var errorRules = [RULE_NAME, RULE_NAME2, RULE_NAME8];
|
|
9251
9423
|
var allRules = Object.fromEntries(
|
|
9252
9424
|
Object.entries(rules).map(([name2]) => {
|
|
9253
9425
|
return [`@pandacss/${name2}`, errorRules.includes(name2) ? "error" : "warn"];
|
|
@@ -9271,8 +9443,9 @@ var recommended_default = {
|
|
|
9271
9443
|
"@pandacss/no-config-function-in-source": "error",
|
|
9272
9444
|
"@pandacss/no-debug": "warn",
|
|
9273
9445
|
"@pandacss/no-dynamic-styling": "warn",
|
|
9446
|
+
"@pandacss/no-invalid-token-paths": "error",
|
|
9274
9447
|
"@pandacss/no-property-renaming": "warn",
|
|
9275
|
-
"@pandacss/
|
|
9448
|
+
"@pandacss/prefer-unified-property-style": "warn"
|
|
9276
9449
|
}
|
|
9277
9450
|
};
|
|
9278
9451
|
|