@foldkit/oxlint-plugin 0.7.0-canary.9869cf777983 → 0.7.0-canary.c49937d15e79
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/all.json +2 -0
- package/dist/index.js +77 -2
- package/package.json +1 -1
- package/recommended.json +2 -0
package/all.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"foldkit/no-disabling-dev-guardrails": "error",
|
|
20
20
|
"foldkit/no-duplicate-onmount-per-element": "error",
|
|
21
21
|
"foldkit/no-empty-children-array": "error",
|
|
22
|
+
"foldkit/no-empty-commands-array": "error",
|
|
22
23
|
"foldkit/no-empty-object-tagged-call": "error",
|
|
23
24
|
"foldkit/no-hand-rolled-command-struct": "error",
|
|
24
25
|
"foldkit/no-hardcoded-route-strings": "error",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"foldkit/no-disabling-dev-guardrails": "off",
|
|
73
74
|
"foldkit/no-duplicate-onmount-per-element": "off",
|
|
74
75
|
"foldkit/no-empty-children-array": "off",
|
|
76
|
+
"foldkit/no-empty-commands-array": "off",
|
|
75
77
|
"foldkit/no-empty-object-tagged-call": "off",
|
|
76
78
|
"foldkit/no-hand-rolled-command-struct": "off",
|
|
77
79
|
"foldkit/no-hardcoded-route-strings": "off",
|
package/dist/index.js
CHANGED
|
@@ -11687,6 +11687,80 @@ var noEmptyChildrenArray = Rule_exports.define({
|
|
|
11687
11687
|
}
|
|
11688
11688
|
});
|
|
11689
11689
|
|
|
11690
|
+
// src/rules/no-empty-commands-array.ts
|
|
11691
|
+
var COMMANDS_PROPERTY = "commands";
|
|
11692
|
+
var isObjectProperty = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Property";
|
|
11693
|
+
var staticPropertyName2 = (property) => {
|
|
11694
|
+
if (!property.computed && isIdentifier(property.key)) {
|
|
11695
|
+
return Option_exports.some(property.key.name);
|
|
11696
|
+
}
|
|
11697
|
+
return staticStringValue(property.key);
|
|
11698
|
+
};
|
|
11699
|
+
var isEmptyCommandsProperty = (property) => Option_exports.contains(staticPropertyName2(property), COMMANDS_PROPERTY) && isArrayExpression(property.value) && Array_exports.isReadonlyArrayEmpty(property.value.elements);
|
|
11700
|
+
var removalRange = (object, property, index) => {
|
|
11701
|
+
const maybePrevious = Array_exports.get(object.properties, index - 1);
|
|
11702
|
+
if (Option_exports.isSome(maybePrevious)) {
|
|
11703
|
+
return [maybePrevious.value.end, property.end];
|
|
11704
|
+
}
|
|
11705
|
+
const maybeNext = Array_exports.get(object.properties, index + 1);
|
|
11706
|
+
if (Option_exports.isSome(maybeNext)) {
|
|
11707
|
+
return [property.start, maybeNext.value.start];
|
|
11708
|
+
}
|
|
11709
|
+
return property.range;
|
|
11710
|
+
};
|
|
11711
|
+
var emptyCommandsMessage = "Return { model } instead of the literal { model, commands: [] }. Return a computed Commands collection directly, even when it may be empty.";
|
|
11712
|
+
var noEmptyCommandsArray = Rule_exports.define({
|
|
11713
|
+
name: "no-empty-commands-array",
|
|
11714
|
+
meta: Rule_exports.meta({
|
|
11715
|
+
type: "suggestion",
|
|
11716
|
+
description: "Omit a literal empty commands property from an update result.",
|
|
11717
|
+
fixable: "code"
|
|
11718
|
+
}),
|
|
11719
|
+
create: function* () {
|
|
11720
|
+
const ctx = yield* RuleContext;
|
|
11721
|
+
return {
|
|
11722
|
+
ObjectExpression: (node) => {
|
|
11723
|
+
if (!isObjectExpression(node)) {
|
|
11724
|
+
return Effect_exports.void;
|
|
11725
|
+
}
|
|
11726
|
+
const hasSpread = Array_exports.some(
|
|
11727
|
+
node.properties,
|
|
11728
|
+
(property) => property.type === "SpreadElement"
|
|
11729
|
+
);
|
|
11730
|
+
const commandProperties = Array_exports.filter(
|
|
11731
|
+
node.properties,
|
|
11732
|
+
(property) => isObjectProperty(property) && Option_exports.contains(staticPropertyName2(property), COMMANDS_PROPERTY)
|
|
11733
|
+
);
|
|
11734
|
+
const hasComments = Array_exports.isReadonlyArrayNonEmpty(
|
|
11735
|
+
ctx.sourceCode.getCommentsInside(node)
|
|
11736
|
+
);
|
|
11737
|
+
return Effect_exports.forEach(
|
|
11738
|
+
node.properties.entries(),
|
|
11739
|
+
([index, property]) => {
|
|
11740
|
+
if (!isObjectProperty(property) || !isEmptyCommandsProperty(property)) {
|
|
11741
|
+
return Effect_exports.void;
|
|
11742
|
+
}
|
|
11743
|
+
const diagnostic = Diagnostic_exports.make({
|
|
11744
|
+
node: property,
|
|
11745
|
+
message: emptyCommandsMessage
|
|
11746
|
+
});
|
|
11747
|
+
if (hasSpread || hasComments || Array_exports.isReadonlyArrayNonEmpty(Array_exports.drop(commandProperties, 1))) {
|
|
11748
|
+
return ctx.report(diagnostic);
|
|
11749
|
+
}
|
|
11750
|
+
return ctx.report(
|
|
11751
|
+
Diagnostic_exports.withFix(
|
|
11752
|
+
diagnostic,
|
|
11753
|
+
(fixer) => fixer.removeRange(removalRange(node, property, index))
|
|
11754
|
+
)
|
|
11755
|
+
);
|
|
11756
|
+
},
|
|
11757
|
+
{ discard: true }
|
|
11758
|
+
);
|
|
11759
|
+
}
|
|
11760
|
+
};
|
|
11761
|
+
}
|
|
11762
|
+
});
|
|
11763
|
+
|
|
11690
11764
|
// src/rules/no-empty-object-tagged-call.ts
|
|
11691
11765
|
var constructorName = (callee) => {
|
|
11692
11766
|
if (isIdentifier(callee) && /^[A-Z][A-Za-z0-9]*$/.test(callee.name)) {
|
|
@@ -11944,7 +12018,7 @@ var staticMemberName = (node) => {
|
|
|
11944
12018
|
}
|
|
11945
12019
|
return void 0;
|
|
11946
12020
|
};
|
|
11947
|
-
var
|
|
12021
|
+
var staticPropertyName3 = (property) => {
|
|
11948
12022
|
if (property.key.type === "Identifier") {
|
|
11949
12023
|
return property.key.name;
|
|
11950
12024
|
}
|
|
@@ -12022,7 +12096,7 @@ var noNonportableServerGlobals = Rule_exports.define({
|
|
|
12022
12096
|
if (property.type !== "Property") {
|
|
12023
12097
|
return [];
|
|
12024
12098
|
}
|
|
12025
|
-
const name =
|
|
12099
|
+
const name = staticPropertyName3(property);
|
|
12026
12100
|
return name !== void 0 && restrictedGlobalNames.has(name) ? [{ name, property }] : [];
|
|
12027
12101
|
});
|
|
12028
12102
|
return isUnshadowedGlobalReference(references, source) ? Effect_exports.forEach(
|
|
@@ -12762,6 +12836,7 @@ var basePlugin = Plugin_exports.define({
|
|
|
12762
12836
|
"no-disabling-dev-guardrails": noDisablingDevGuardrails,
|
|
12763
12837
|
"no-duplicate-onmount-per-element": noDuplicateOnmountPerElement,
|
|
12764
12838
|
"no-empty-children-array": noEmptyChildrenArray,
|
|
12839
|
+
"no-empty-commands-array": noEmptyCommandsArray,
|
|
12765
12840
|
"no-empty-object-tagged-call": noEmptyObjectTaggedCall,
|
|
12766
12841
|
"no-hand-rolled-command-struct": noHandRolledCommandStruct,
|
|
12767
12842
|
"no-hardcoded-route-strings": noHardcodedRouteStrings,
|
package/package.json
CHANGED
package/recommended.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"foldkit/no-disabling-dev-guardrails": "error",
|
|
20
20
|
"foldkit/no-duplicate-onmount-per-element": "error",
|
|
21
21
|
"foldkit/no-empty-children-array": "error",
|
|
22
|
+
"foldkit/no-empty-commands-array": "error",
|
|
22
23
|
"foldkit/no-empty-object-tagged-call": "error",
|
|
23
24
|
"foldkit/no-hand-rolled-command-struct": "error",
|
|
24
25
|
"foldkit/no-hardcoded-route-strings": "error",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"foldkit/no-disabling-dev-guardrails": "off",
|
|
73
74
|
"foldkit/no-duplicate-onmount-per-element": "off",
|
|
74
75
|
"foldkit/no-empty-children-array": "off",
|
|
76
|
+
"foldkit/no-empty-commands-array": "off",
|
|
75
77
|
"foldkit/no-empty-object-tagged-call": "off",
|
|
76
78
|
"foldkit/no-hand-rolled-command-struct": "off",
|
|
77
79
|
"foldkit/no-hardcoded-route-strings": "off",
|