@pandacss/eslint-plugin 0.0.9 → 0.0.11
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 +149 -18
- package/dist/index.mjs +173 -21
- package/dist/utils/worker.js +5 -4
- package/dist/utils/worker.mjs +5 -4
- 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.
|
|
7960
|
+
var version = "0.0.11";
|
|
7961
7961
|
|
|
7962
7962
|
// src/configs/all.ts
|
|
7963
7963
|
init_cjs_shims();
|
|
@@ -8161,8 +8161,8 @@ var isPandaAttribute = (node, context) => {
|
|
|
8161
8161
|
var resolveLonghand = (name2, context) => {
|
|
8162
8162
|
return syncAction("resolveLongHand", getSyncOpts(context), name2);
|
|
8163
8163
|
};
|
|
8164
|
-
var
|
|
8165
|
-
return syncAction("
|
|
8164
|
+
var resolveShorthands = (name2, context) => {
|
|
8165
|
+
return syncAction("resolveShorthands", getSyncOpts(context), name2);
|
|
8166
8166
|
};
|
|
8167
8167
|
var isColorAttribute = (attr, context) => {
|
|
8168
8168
|
return syncAction("isColorAttribute", getSyncOpts(context), attr);
|
|
@@ -8390,7 +8390,7 @@ var rule4 = createRule({
|
|
|
8390
8390
|
return;
|
|
8391
8391
|
if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
|
|
8392
8392
|
return;
|
|
8393
|
-
if (isObjectExpression(node.value))
|
|
8393
|
+
if (isObjectExpression(node.value.expression))
|
|
8394
8394
|
return;
|
|
8395
8395
|
if (!isPandaProp(node, context))
|
|
8396
8396
|
return;
|
|
@@ -8755,12 +8755,12 @@ var no_property_renaming_default = rule8;
|
|
|
8755
8755
|
|
|
8756
8756
|
// src/rules/prefer-longhand-properties.ts
|
|
8757
8757
|
init_cjs_shims();
|
|
8758
|
-
var RULE_NAME9 = "
|
|
8758
|
+
var RULE_NAME9 = "prefer-longhand-properties";
|
|
8759
8759
|
var rule9 = createRule({
|
|
8760
8760
|
name: RULE_NAME9,
|
|
8761
8761
|
meta: {
|
|
8762
8762
|
docs: {
|
|
8763
|
-
description: "Discourage the use of shorthand properties and promote the preference for longhand
|
|
8763
|
+
description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
|
|
8764
8764
|
},
|
|
8765
8765
|
messages: {
|
|
8766
8766
|
longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
|
|
@@ -8819,12 +8819,81 @@ var rule9 = createRule({
|
|
|
8819
8819
|
});
|
|
8820
8820
|
var prefer_longhand_properties_default = rule9;
|
|
8821
8821
|
|
|
8822
|
-
// src/rules/
|
|
8822
|
+
// src/rules/prefer-shorthand-properties.ts
|
|
8823
8823
|
init_cjs_shims();
|
|
8824
|
-
var
|
|
8825
|
-
var RULE_NAME10 = "no-unsafe-token-fn-usage";
|
|
8824
|
+
var RULE_NAME10 = "prefer-shorthand-properties";
|
|
8826
8825
|
var rule10 = createRule({
|
|
8827
8826
|
name: RULE_NAME10,
|
|
8827
|
+
meta: {
|
|
8828
|
+
docs: {
|
|
8829
|
+
description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
|
|
8830
|
+
},
|
|
8831
|
+
messages: {
|
|
8832
|
+
shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
|
|
8833
|
+
replace: "Replace `{{longhand}}` with `{{shorthand}}`"
|
|
8834
|
+
},
|
|
8835
|
+
type: "suggestion",
|
|
8836
|
+
hasSuggestions: true,
|
|
8837
|
+
schema: []
|
|
8838
|
+
},
|
|
8839
|
+
defaultOptions: [],
|
|
8840
|
+
create(context) {
|
|
8841
|
+
const sendReport = (node, name2) => {
|
|
8842
|
+
const shorthands = resolveShorthands(name2, context);
|
|
8843
|
+
if (!shorthands)
|
|
8844
|
+
return;
|
|
8845
|
+
const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
|
|
8846
|
+
const data = {
|
|
8847
|
+
longhand: name2,
|
|
8848
|
+
shorthand
|
|
8849
|
+
};
|
|
8850
|
+
return context.report({
|
|
8851
|
+
node,
|
|
8852
|
+
messageId: "shorthand",
|
|
8853
|
+
data,
|
|
8854
|
+
suggest: [
|
|
8855
|
+
{
|
|
8856
|
+
messageId: "replace",
|
|
8857
|
+
data,
|
|
8858
|
+
fix: (fixer) => {
|
|
8859
|
+
return fixer.replaceTextRange(node.range, shorthands[0]);
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
]
|
|
8863
|
+
});
|
|
8864
|
+
};
|
|
8865
|
+
return {
|
|
8866
|
+
JSXAttribute(node) {
|
|
8867
|
+
if (!isJSXIdentifier(node.name))
|
|
8868
|
+
return;
|
|
8869
|
+
if (!isPandaProp(node, context))
|
|
8870
|
+
return;
|
|
8871
|
+
const longhand = resolveLonghand(node.name.name, context);
|
|
8872
|
+
if (longhand)
|
|
8873
|
+
return;
|
|
8874
|
+
sendReport(node.name, node.name.name);
|
|
8875
|
+
},
|
|
8876
|
+
Property(node) {
|
|
8877
|
+
if (!isIdentifier(node.key))
|
|
8878
|
+
return;
|
|
8879
|
+
if (!isPandaAttribute(node, context))
|
|
8880
|
+
return;
|
|
8881
|
+
const longhand = resolveLonghand(node.key.name, context);
|
|
8882
|
+
if (longhand)
|
|
8883
|
+
return;
|
|
8884
|
+
sendReport(node.key, node.key.name);
|
|
8885
|
+
}
|
|
8886
|
+
};
|
|
8887
|
+
}
|
|
8888
|
+
});
|
|
8889
|
+
var prefer_shorthand_properties_default = rule10;
|
|
8890
|
+
|
|
8891
|
+
// src/rules/no-unsafe-token-fn-usage.ts
|
|
8892
|
+
init_cjs_shims();
|
|
8893
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
8894
|
+
var RULE_NAME11 = "no-unsafe-token-fn-usage";
|
|
8895
|
+
var rule11 = createRule({
|
|
8896
|
+
name: RULE_NAME11,
|
|
8828
8897
|
meta: {
|
|
8829
8898
|
docs: {
|
|
8830
8899
|
description: "Prevent users from using the token function in situations where they could simply use the raw design token."
|
|
@@ -8920,7 +8989,7 @@ var rule10 = createRule({
|
|
|
8920
8989
|
};
|
|
8921
8990
|
}
|
|
8922
8991
|
});
|
|
8923
|
-
var no_unsafe_token_fn_usage_default =
|
|
8992
|
+
var no_unsafe_token_fn_usage_default = rule11;
|
|
8924
8993
|
|
|
8925
8994
|
// src/rules/prefer-atomic-properties.ts
|
|
8926
8995
|
init_cjs_shims();
|
|
@@ -9040,12 +9109,12 @@ var compositeProperties = {
|
|
|
9040
9109
|
};
|
|
9041
9110
|
|
|
9042
9111
|
// src/rules/prefer-atomic-properties.ts
|
|
9043
|
-
var
|
|
9044
|
-
var
|
|
9045
|
-
name:
|
|
9112
|
+
var RULE_NAME12 = "prefer-atomic-properties";
|
|
9113
|
+
var rule12 = createRule({
|
|
9114
|
+
name: RULE_NAME12,
|
|
9046
9115
|
meta: {
|
|
9047
9116
|
docs: {
|
|
9048
|
-
description: "Encourage the use of atomic properties instead of composite
|
|
9117
|
+
description: "Encourage the use of atomic properties instead of composite properties in the codebase."
|
|
9049
9118
|
},
|
|
9050
9119
|
messages: {
|
|
9051
9120
|
atomic: "Use atomic properties of `{{composite}}` instead. Prefer: \n{{atomics}}"
|
|
@@ -9058,7 +9127,7 @@ var rule11 = createRule({
|
|
|
9058
9127
|
const resolveCompositeProperty = (name2) => {
|
|
9059
9128
|
if (Object.hasOwn(compositeProperties, name2))
|
|
9060
9129
|
return name2;
|
|
9061
|
-
const longhand =
|
|
9130
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9062
9131
|
if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
|
|
9063
9132
|
return longhand;
|
|
9064
9133
|
};
|
|
@@ -9098,7 +9167,67 @@ var rule11 = createRule({
|
|
|
9098
9167
|
};
|
|
9099
9168
|
}
|
|
9100
9169
|
});
|
|
9101
|
-
var prefer_atomic_properties_default =
|
|
9170
|
+
var prefer_atomic_properties_default = rule12;
|
|
9171
|
+
|
|
9172
|
+
// src/rules/prefer-composite-properties.ts
|
|
9173
|
+
init_cjs_shims();
|
|
9174
|
+
var RULE_NAME13 = "prefer-composite-properties";
|
|
9175
|
+
var rule13 = createRule({
|
|
9176
|
+
name: RULE_NAME13,
|
|
9177
|
+
meta: {
|
|
9178
|
+
docs: {
|
|
9179
|
+
description: "Encourage the use of composite properties instead of atomic properties in the codebase."
|
|
9180
|
+
},
|
|
9181
|
+
messages: {
|
|
9182
|
+
composite: "Use composite property of `{{atomic}}` instead. \nPrefer: {{composite}}"
|
|
9183
|
+
},
|
|
9184
|
+
type: "suggestion",
|
|
9185
|
+
schema: []
|
|
9186
|
+
},
|
|
9187
|
+
defaultOptions: [],
|
|
9188
|
+
create(context) {
|
|
9189
|
+
const resolveCompositeProperty = (name2) => {
|
|
9190
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9191
|
+
if (!isValidProperty(longhand, context))
|
|
9192
|
+
return;
|
|
9193
|
+
return Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
|
|
9194
|
+
};
|
|
9195
|
+
const sendReport = (node, name2) => {
|
|
9196
|
+
const cmp = resolveCompositeProperty(name2);
|
|
9197
|
+
return context.report({
|
|
9198
|
+
node,
|
|
9199
|
+
messageId: "composite",
|
|
9200
|
+
data: {
|
|
9201
|
+
composite: cmp,
|
|
9202
|
+
atomic: name2
|
|
9203
|
+
}
|
|
9204
|
+
});
|
|
9205
|
+
};
|
|
9206
|
+
return {
|
|
9207
|
+
JSXAttribute(node) {
|
|
9208
|
+
if (!isJSXIdentifier(node.name))
|
|
9209
|
+
return;
|
|
9210
|
+
if (!isPandaProp(node, context))
|
|
9211
|
+
return;
|
|
9212
|
+
const atm = resolveCompositeProperty(node.name.name);
|
|
9213
|
+
if (!atm)
|
|
9214
|
+
return;
|
|
9215
|
+
sendReport(node, node.name.name);
|
|
9216
|
+
},
|
|
9217
|
+
Property(node) {
|
|
9218
|
+
if (!isIdentifier(node.key))
|
|
9219
|
+
return;
|
|
9220
|
+
if (!isPandaAttribute(node, context))
|
|
9221
|
+
return;
|
|
9222
|
+
const atm = resolveCompositeProperty(node.key.name);
|
|
9223
|
+
if (!atm)
|
|
9224
|
+
return;
|
|
9225
|
+
sendReport(node.key, node.key.name);
|
|
9226
|
+
}
|
|
9227
|
+
};
|
|
9228
|
+
}
|
|
9229
|
+
});
|
|
9230
|
+
var prefer_composite_properties_default = rule13;
|
|
9102
9231
|
|
|
9103
9232
|
// src/rules/index.ts
|
|
9104
9233
|
var rules = {
|
|
@@ -9111,8 +9240,10 @@ var rules = {
|
|
|
9111
9240
|
[RULE_NAME7]: no_invalid_token_paths_default,
|
|
9112
9241
|
[RULE_NAME8]: no_property_renaming_default,
|
|
9113
9242
|
[RULE_NAME9]: prefer_longhand_properties_default,
|
|
9114
|
-
[RULE_NAME10]:
|
|
9115
|
-
[RULE_NAME11]:
|
|
9243
|
+
[RULE_NAME10]: prefer_shorthand_properties_default,
|
|
9244
|
+
[RULE_NAME11]: no_unsafe_token_fn_usage_default,
|
|
9245
|
+
[RULE_NAME12]: prefer_atomic_properties_default,
|
|
9246
|
+
[RULE_NAME13]: prefer_composite_properties_default
|
|
9116
9247
|
};
|
|
9117
9248
|
|
|
9118
9249
|
// src/configs/all.ts
|
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.11";
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -7974,7 +7974,7 @@ var init_nodes = __esm({
|
|
|
7974
7974
|
});
|
|
7975
7975
|
|
|
7976
7976
|
// src/utils/helpers.ts
|
|
7977
|
-
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isInPandaFunction, isPandaAttribute, resolveLonghand,
|
|
7977
|
+
var import_scope_manager, getAncestor, getSyncOpts, getImportSpecifiers, _getImports, getImports, isValidStyledProp, isPandaIsh, findDeclaration, isLocalStyledFactory, isValidFile, isValidProperty, isPandaImport, isPandaProp, isInPandaFunction, isPandaAttribute, resolveLonghand, resolveShorthands, isColorAttribute, isColorToken, extractTokens, getInvalidTokens, getTokenImport;
|
|
7978
7978
|
var init_helpers = __esm({
|
|
7979
7979
|
"src/utils/helpers.ts"() {
|
|
7980
7980
|
"use strict";
|
|
@@ -8137,8 +8137,8 @@ var init_helpers = __esm({
|
|
|
8137
8137
|
resolveLonghand = (name2, context) => {
|
|
8138
8138
|
return syncAction("resolveLongHand", getSyncOpts(context), name2);
|
|
8139
8139
|
};
|
|
8140
|
-
|
|
8141
|
-
return syncAction("
|
|
8140
|
+
resolveShorthands = (name2, context) => {
|
|
8141
|
+
return syncAction("resolveShorthands", getSyncOpts(context), name2);
|
|
8142
8142
|
};
|
|
8143
8143
|
isColorAttribute = (attr, context) => {
|
|
8144
8144
|
return syncAction("isColorAttribute", getSyncOpts(context), attr);
|
|
@@ -8402,7 +8402,7 @@ var init_no_dynamic_styling = __esm({
|
|
|
8402
8402
|
return;
|
|
8403
8403
|
if (isJSXExpressionContainer(node.value) && isTemplateLiteral(node.value.expression) && node.value.expression.expressions.length === 0)
|
|
8404
8404
|
return;
|
|
8405
|
-
if (isObjectExpression(node.value))
|
|
8405
|
+
if (isObjectExpression(node.value.expression))
|
|
8406
8406
|
return;
|
|
8407
8407
|
if (!isPandaProp(node, context))
|
|
8408
8408
|
return;
|
|
@@ -8812,12 +8812,12 @@ var init_prefer_longhand_properties = __esm({
|
|
|
8812
8812
|
init_helpers();
|
|
8813
8813
|
init_utils();
|
|
8814
8814
|
init_nodes();
|
|
8815
|
-
RULE_NAME9 = "
|
|
8815
|
+
RULE_NAME9 = "prefer-longhand-properties";
|
|
8816
8816
|
rule9 = createRule({
|
|
8817
8817
|
name: RULE_NAME9,
|
|
8818
8818
|
meta: {
|
|
8819
8819
|
docs: {
|
|
8820
|
-
description: "Discourage the use of shorthand properties and promote the preference for longhand
|
|
8820
|
+
description: "Discourage the use of shorthand properties and promote the preference for longhand properties in the codebase."
|
|
8821
8821
|
},
|
|
8822
8822
|
messages: {
|
|
8823
8823
|
longhand: "Use longhand property of `{{shorthand}}` instead. Prefer `{{longhand}}`",
|
|
@@ -8878,9 +8878,87 @@ var init_prefer_longhand_properties = __esm({
|
|
|
8878
8878
|
}
|
|
8879
8879
|
});
|
|
8880
8880
|
|
|
8881
|
+
// src/rules/prefer-shorthand-properties.ts
|
|
8882
|
+
var RULE_NAME10, rule10, prefer_shorthand_properties_default;
|
|
8883
|
+
var init_prefer_shorthand_properties = __esm({
|
|
8884
|
+
"src/rules/prefer-shorthand-properties.ts"() {
|
|
8885
|
+
"use strict";
|
|
8886
|
+
init_esm_shims();
|
|
8887
|
+
init_helpers();
|
|
8888
|
+
init_utils();
|
|
8889
|
+
init_nodes();
|
|
8890
|
+
RULE_NAME10 = "prefer-shorthand-properties";
|
|
8891
|
+
rule10 = createRule({
|
|
8892
|
+
name: RULE_NAME10,
|
|
8893
|
+
meta: {
|
|
8894
|
+
docs: {
|
|
8895
|
+
description: "Discourage the use of longhand properties and promote the preference for shorthand properties in the codebase."
|
|
8896
|
+
},
|
|
8897
|
+
messages: {
|
|
8898
|
+
shorthand: "Use shorthand property of `{{longhand}}` instead. Prefer {{shorthand}}",
|
|
8899
|
+
replace: "Replace `{{longhand}}` with `{{shorthand}}`"
|
|
8900
|
+
},
|
|
8901
|
+
type: "suggestion",
|
|
8902
|
+
hasSuggestions: true,
|
|
8903
|
+
schema: []
|
|
8904
|
+
},
|
|
8905
|
+
defaultOptions: [],
|
|
8906
|
+
create(context) {
|
|
8907
|
+
const sendReport = (node, name2) => {
|
|
8908
|
+
const shorthands = resolveShorthands(name2, context);
|
|
8909
|
+
if (!shorthands)
|
|
8910
|
+
return;
|
|
8911
|
+
const shorthand = shorthands.map((s) => "`" + s + "`")?.join(", ");
|
|
8912
|
+
const data = {
|
|
8913
|
+
longhand: name2,
|
|
8914
|
+
shorthand
|
|
8915
|
+
};
|
|
8916
|
+
return context.report({
|
|
8917
|
+
node,
|
|
8918
|
+
messageId: "shorthand",
|
|
8919
|
+
data,
|
|
8920
|
+
suggest: [
|
|
8921
|
+
{
|
|
8922
|
+
messageId: "replace",
|
|
8923
|
+
data,
|
|
8924
|
+
fix: (fixer) => {
|
|
8925
|
+
return fixer.replaceTextRange(node.range, shorthands[0]);
|
|
8926
|
+
}
|
|
8927
|
+
}
|
|
8928
|
+
]
|
|
8929
|
+
});
|
|
8930
|
+
};
|
|
8931
|
+
return {
|
|
8932
|
+
JSXAttribute(node) {
|
|
8933
|
+
if (!isJSXIdentifier(node.name))
|
|
8934
|
+
return;
|
|
8935
|
+
if (!isPandaProp(node, context))
|
|
8936
|
+
return;
|
|
8937
|
+
const longhand = resolveLonghand(node.name.name, context);
|
|
8938
|
+
if (longhand)
|
|
8939
|
+
return;
|
|
8940
|
+
sendReport(node.name, node.name.name);
|
|
8941
|
+
},
|
|
8942
|
+
Property(node) {
|
|
8943
|
+
if (!isIdentifier(node.key))
|
|
8944
|
+
return;
|
|
8945
|
+
if (!isPandaAttribute(node, context))
|
|
8946
|
+
return;
|
|
8947
|
+
const longhand = resolveLonghand(node.key.name, context);
|
|
8948
|
+
if (longhand)
|
|
8949
|
+
return;
|
|
8950
|
+
sendReport(node.key, node.key.name);
|
|
8951
|
+
}
|
|
8952
|
+
};
|
|
8953
|
+
}
|
|
8954
|
+
});
|
|
8955
|
+
prefer_shorthand_properties_default = rule10;
|
|
8956
|
+
}
|
|
8957
|
+
});
|
|
8958
|
+
|
|
8881
8959
|
// src/rules/no-unsafe-token-fn-usage.ts
|
|
8882
8960
|
import "@typescript-eslint/utils";
|
|
8883
|
-
var
|
|
8961
|
+
var RULE_NAME11, rule11, no_unsafe_token_fn_usage_default;
|
|
8884
8962
|
var init_no_unsafe_token_fn_usage = __esm({
|
|
8885
8963
|
"src/rules/no-unsafe-token-fn-usage.ts"() {
|
|
8886
8964
|
"use strict";
|
|
@@ -8888,9 +8966,9 @@ var init_no_unsafe_token_fn_usage = __esm({
|
|
|
8888
8966
|
init_helpers();
|
|
8889
8967
|
init_utils();
|
|
8890
8968
|
init_nodes();
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
name:
|
|
8969
|
+
RULE_NAME11 = "no-unsafe-token-fn-usage";
|
|
8970
|
+
rule11 = createRule({
|
|
8971
|
+
name: RULE_NAME11,
|
|
8894
8972
|
meta: {
|
|
8895
8973
|
docs: {
|
|
8896
8974
|
description: "Prevent users from using the token function in situations where they could simply use the raw design token."
|
|
@@ -8986,7 +9064,7 @@ var init_no_unsafe_token_fn_usage = __esm({
|
|
|
8986
9064
|
};
|
|
8987
9065
|
}
|
|
8988
9066
|
});
|
|
8989
|
-
no_unsafe_token_fn_usage_default =
|
|
9067
|
+
no_unsafe_token_fn_usage_default = rule11;
|
|
8990
9068
|
}
|
|
8991
9069
|
});
|
|
8992
9070
|
|
|
@@ -9111,7 +9189,7 @@ var init_composite_properties = __esm({
|
|
|
9111
9189
|
});
|
|
9112
9190
|
|
|
9113
9191
|
// src/rules/prefer-atomic-properties.ts
|
|
9114
|
-
var
|
|
9192
|
+
var RULE_NAME12, rule12, prefer_atomic_properties_default;
|
|
9115
9193
|
var init_prefer_atomic_properties = __esm({
|
|
9116
9194
|
"src/rules/prefer-atomic-properties.ts"() {
|
|
9117
9195
|
"use strict";
|
|
@@ -9120,12 +9198,12 @@ var init_prefer_atomic_properties = __esm({
|
|
|
9120
9198
|
init_utils();
|
|
9121
9199
|
init_composite_properties();
|
|
9122
9200
|
init_nodes();
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
name:
|
|
9201
|
+
RULE_NAME12 = "prefer-atomic-properties";
|
|
9202
|
+
rule12 = createRule({
|
|
9203
|
+
name: RULE_NAME12,
|
|
9126
9204
|
meta: {
|
|
9127
9205
|
docs: {
|
|
9128
|
-
description: "Encourage the use of atomic properties instead of composite
|
|
9206
|
+
description: "Encourage the use of atomic properties instead of composite properties in the codebase."
|
|
9129
9207
|
},
|
|
9130
9208
|
messages: {
|
|
9131
9209
|
atomic: "Use atomic properties of `{{composite}}` instead. Prefer: \n{{atomics}}"
|
|
@@ -9138,7 +9216,7 @@ var init_prefer_atomic_properties = __esm({
|
|
|
9138
9216
|
const resolveCompositeProperty = (name2) => {
|
|
9139
9217
|
if (Object.hasOwn(compositeProperties, name2))
|
|
9140
9218
|
return name2;
|
|
9141
|
-
const longhand =
|
|
9219
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9142
9220
|
if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand))
|
|
9143
9221
|
return longhand;
|
|
9144
9222
|
};
|
|
@@ -9178,7 +9256,77 @@ var init_prefer_atomic_properties = __esm({
|
|
|
9178
9256
|
};
|
|
9179
9257
|
}
|
|
9180
9258
|
});
|
|
9181
|
-
prefer_atomic_properties_default =
|
|
9259
|
+
prefer_atomic_properties_default = rule12;
|
|
9260
|
+
}
|
|
9261
|
+
});
|
|
9262
|
+
|
|
9263
|
+
// src/rules/prefer-composite-properties.ts
|
|
9264
|
+
var RULE_NAME13, rule13, prefer_composite_properties_default;
|
|
9265
|
+
var init_prefer_composite_properties = __esm({
|
|
9266
|
+
"src/rules/prefer-composite-properties.ts"() {
|
|
9267
|
+
"use strict";
|
|
9268
|
+
init_esm_shims();
|
|
9269
|
+
init_helpers();
|
|
9270
|
+
init_utils();
|
|
9271
|
+
init_composite_properties();
|
|
9272
|
+
init_nodes();
|
|
9273
|
+
RULE_NAME13 = "prefer-composite-properties";
|
|
9274
|
+
rule13 = createRule({
|
|
9275
|
+
name: RULE_NAME13,
|
|
9276
|
+
meta: {
|
|
9277
|
+
docs: {
|
|
9278
|
+
description: "Encourage the use of composite properties instead of atomic properties in the codebase."
|
|
9279
|
+
},
|
|
9280
|
+
messages: {
|
|
9281
|
+
composite: "Use composite property of `{{atomic}}` instead. \nPrefer: {{composite}}"
|
|
9282
|
+
},
|
|
9283
|
+
type: "suggestion",
|
|
9284
|
+
schema: []
|
|
9285
|
+
},
|
|
9286
|
+
defaultOptions: [],
|
|
9287
|
+
create(context) {
|
|
9288
|
+
const resolveCompositeProperty = (name2) => {
|
|
9289
|
+
const longhand = resolveLonghand(name2, context) ?? name2;
|
|
9290
|
+
if (!isValidProperty(longhand, context))
|
|
9291
|
+
return;
|
|
9292
|
+
return Object.keys(compositeProperties).find((cpd) => compositeProperties[cpd].includes(longhand));
|
|
9293
|
+
};
|
|
9294
|
+
const sendReport = (node, name2) => {
|
|
9295
|
+
const cmp = resolveCompositeProperty(name2);
|
|
9296
|
+
return context.report({
|
|
9297
|
+
node,
|
|
9298
|
+
messageId: "composite",
|
|
9299
|
+
data: {
|
|
9300
|
+
composite: cmp,
|
|
9301
|
+
atomic: name2
|
|
9302
|
+
}
|
|
9303
|
+
});
|
|
9304
|
+
};
|
|
9305
|
+
return {
|
|
9306
|
+
JSXAttribute(node) {
|
|
9307
|
+
if (!isJSXIdentifier(node.name))
|
|
9308
|
+
return;
|
|
9309
|
+
if (!isPandaProp(node, context))
|
|
9310
|
+
return;
|
|
9311
|
+
const atm = resolveCompositeProperty(node.name.name);
|
|
9312
|
+
if (!atm)
|
|
9313
|
+
return;
|
|
9314
|
+
sendReport(node, node.name.name);
|
|
9315
|
+
},
|
|
9316
|
+
Property(node) {
|
|
9317
|
+
if (!isIdentifier(node.key))
|
|
9318
|
+
return;
|
|
9319
|
+
if (!isPandaAttribute(node, context))
|
|
9320
|
+
return;
|
|
9321
|
+
const atm = resolveCompositeProperty(node.key.name);
|
|
9322
|
+
if (!atm)
|
|
9323
|
+
return;
|
|
9324
|
+
sendReport(node.key, node.key.name);
|
|
9325
|
+
}
|
|
9326
|
+
};
|
|
9327
|
+
}
|
|
9328
|
+
});
|
|
9329
|
+
prefer_composite_properties_default = rule13;
|
|
9182
9330
|
}
|
|
9183
9331
|
});
|
|
9184
9332
|
|
|
@@ -9197,8 +9345,10 @@ var init_rules = __esm({
|
|
|
9197
9345
|
init_no_invalid_token_paths();
|
|
9198
9346
|
init_no_property_renaming();
|
|
9199
9347
|
init_prefer_longhand_properties();
|
|
9348
|
+
init_prefer_shorthand_properties();
|
|
9200
9349
|
init_no_unsafe_token_fn_usage();
|
|
9201
9350
|
init_prefer_atomic_properties();
|
|
9351
|
+
init_prefer_composite_properties();
|
|
9202
9352
|
rules = {
|
|
9203
9353
|
[RULE_NAME]: file_not_included_default,
|
|
9204
9354
|
[RULE_NAME2]: no_config_function_in_source_default,
|
|
@@ -9209,8 +9359,10 @@ var init_rules = __esm({
|
|
|
9209
9359
|
[RULE_NAME7]: no_invalid_token_paths_default,
|
|
9210
9360
|
[RULE_NAME8]: no_property_renaming_default,
|
|
9211
9361
|
[RULE_NAME9]: prefer_longhand_properties_default,
|
|
9212
|
-
[RULE_NAME10]:
|
|
9213
|
-
[RULE_NAME11]:
|
|
9362
|
+
[RULE_NAME10]: prefer_shorthand_properties_default,
|
|
9363
|
+
[RULE_NAME11]: no_unsafe_token_fn_usage_default,
|
|
9364
|
+
[RULE_NAME12]: prefer_atomic_properties_default,
|
|
9365
|
+
[RULE_NAME13]: prefer_composite_properties_default
|
|
9214
9366
|
};
|
|
9215
9367
|
}
|
|
9216
9368
|
});
|
package/dist/utils/worker.js
CHANGED
|
@@ -3548,8 +3548,9 @@ async function isConfigFile(fileName) {
|
|
|
3548
3548
|
async function isValidFile(ctx, fileName) {
|
|
3549
3549
|
return ctx.getFiles().includes(fileName);
|
|
3550
3550
|
}
|
|
3551
|
-
async function
|
|
3552
|
-
|
|
3551
|
+
async function resolveShorthands(ctx, name) {
|
|
3552
|
+
console.log("name", name, ctx.utility.getPropShorthandsMap().get(name));
|
|
3553
|
+
return ctx.utility.getPropShorthandsMap().get(name);
|
|
3553
3554
|
}
|
|
3554
3555
|
async function resolveLongHand(ctx, name) {
|
|
3555
3556
|
const reverseShorthandsMap = /* @__PURE__ */ new Map();
|
|
@@ -3593,8 +3594,8 @@ async function runAsync(action, opts, ...args) {
|
|
|
3593
3594
|
return isValidProperty(ctx, ...args);
|
|
3594
3595
|
case "resolveLongHand":
|
|
3595
3596
|
return resolveLongHand(ctx, ...args);
|
|
3596
|
-
case "
|
|
3597
|
-
return
|
|
3597
|
+
case "resolveShorthands":
|
|
3598
|
+
return resolveShorthands(ctx, ...args);
|
|
3598
3599
|
case "isConfigFile":
|
|
3599
3600
|
return isConfigFile(opts.currentFile);
|
|
3600
3601
|
case "isValidFile":
|
package/dist/utils/worker.mjs
CHANGED
|
@@ -3532,8 +3532,9 @@ async function isConfigFile(fileName) {
|
|
|
3532
3532
|
async function isValidFile(ctx, fileName) {
|
|
3533
3533
|
return ctx.getFiles().includes(fileName);
|
|
3534
3534
|
}
|
|
3535
|
-
async function
|
|
3536
|
-
|
|
3535
|
+
async function resolveShorthands(ctx, name) {
|
|
3536
|
+
console.log("name", name, ctx.utility.getPropShorthandsMap().get(name));
|
|
3537
|
+
return ctx.utility.getPropShorthandsMap().get(name);
|
|
3537
3538
|
}
|
|
3538
3539
|
async function resolveLongHand(ctx, name) {
|
|
3539
3540
|
const reverseShorthandsMap = /* @__PURE__ */ new Map();
|
|
@@ -3577,8 +3578,8 @@ async function runAsync(action, opts, ...args) {
|
|
|
3577
3578
|
return isValidProperty(ctx, ...args);
|
|
3578
3579
|
case "resolveLongHand":
|
|
3579
3580
|
return resolveLongHand(ctx, ...args);
|
|
3580
|
-
case "
|
|
3581
|
-
return
|
|
3581
|
+
case "resolveShorthands":
|
|
3582
|
+
return resolveShorthands(ctx, ...args);
|
|
3582
3583
|
case "isConfigFile":
|
|
3583
3584
|
return isConfigFile(opts.currentFile);
|
|
3584
3585
|
case "isValidFile":
|