widefleet-linux-x64-gnu 0.0.0-stage → 0.3.1

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.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -2
  3. package/esbuild +0 -0
  4. package/licenses/esbuild.txt +21 -0
  5. package/package.json +34 -4
  6. package/release.json +5 -0
  7. package/starter/.gitattributes +2 -0
  8. package/starter/.gitignore +19 -0
  9. package/starter/.oxfmtrc.json +33 -0
  10. package/starter/.oxlintrc.json +69 -0
  11. package/starter/AGENTS.md +31 -0
  12. package/starter/LICENSE +21 -0
  13. package/starter/README.md +143 -0
  14. package/starter/package.json +41 -0
  15. package/starter/pnpm-lock.yaml +2374 -0
  16. package/starter/pnpm-workspace.yaml +5 -0
  17. package/starter/src/app.d.ts +15 -0
  18. package/starter/src/app.html +11 -0
  19. package/starter/src/hooks.client.ts +11 -0
  20. package/starter/src/hooks.server.ts +50 -0
  21. package/starter/src/lib/capture-error.ts +48 -0
  22. package/starter/src/lib/errors.ts +42 -0
  23. package/starter/src/lib/server/browser-errors.ts +88 -0
  24. package/starter/src/lib/server/capture-error.ts +24 -0
  25. package/starter/src/lib/server/data.ts +48 -0
  26. package/starter/src/lib/server/identity.ts +30 -0
  27. package/starter/src/routes/+page.server.ts +72 -0
  28. package/starter/src/routes/+page.svelte +45 -0
  29. package/starter/src/routes/photos/[id]/+server.ts +21 -0
  30. package/starter/tools/oxlint/anti-slop/LICENSE +21 -0
  31. package/starter/tools/oxlint/anti-slop/UPSTREAM.md +7 -0
  32. package/starter/tools/oxlint/anti-slop/effect/index.ts +21 -0
  33. package/starter/tools/oxlint/anti-slop/effect/rules/no-manual-effect-error-tag.ts +52 -0
  34. package/starter/tools/oxlint/anti-slop/effect/rules/no-manual-tag-comparison.ts +45 -0
  35. package/starter/tools/oxlint/anti-slop/effect/rules/no-manual-tagged-construction.ts +37 -0
  36. package/starter/tools/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts +52 -0
  37. package/starter/tools/oxlint/anti-slop/effect/rules/prefer-effect-match.ts +54 -0
  38. package/starter/tools/oxlint/anti-slop/effect/shared/tagged-values.ts +97 -0
  39. package/starter/tools/oxlint/anti-slop/index.ts +47 -0
  40. package/starter/tools/oxlint/anti-slop/rules/no-array-filter-map.ts +28 -0
  41. package/starter/tools/oxlint/anti-slop/rules/no-chained-type-assertions.ts +77 -0
  42. package/starter/tools/oxlint/anti-slop/rules/no-conditional-empty-object-spread.ts +49 -0
  43. package/starter/tools/oxlint/anti-slop/rules/no-known-value-widening.ts +415 -0
  44. package/starter/tools/oxlint/anti-slop/rules/no-module-mocking.ts +80 -0
  45. package/starter/tools/oxlint/anti-slop/rules/no-object-parameters.ts +83 -0
  46. package/starter/tools/oxlint/anti-slop/rules/no-reduce-accumulator-copy.ts +109 -0
  47. package/starter/tools/oxlint/anti-slop/rules/no-reflect-apply.ts +28 -0
  48. package/starter/tools/oxlint/anti-slop/rules/no-reflect-get.ts +28 -0
  49. package/starter/tools/oxlint/anti-slop/rules/no-runtime-typeof.ts +77 -0
  50. package/starter/tools/oxlint/anti-slop/rules/no-shape-in-symbol-names.ts +46 -0
  51. package/starter/tools/oxlint/anti-slop/rules/no-unknown-parameters.ts +69 -0
  52. package/starter/tools/oxlint/anti-slop/rules/no-unknown-returns.ts +82 -0
  53. package/starter/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts +54 -0
  54. package/starter/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts +154 -0
  55. package/starter/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts +366 -0
  56. package/starter/tools/oxlint/anti-slop/rules/require-readable-spacing.ts +47 -0
  57. package/starter/tools/oxlint/anti-slop/rules/require-safety-comment-for-type-assertion.ts +131 -0
  58. package/starter/tools/oxlint/anti-slop/shared/array-method.ts +94 -0
  59. package/starter/tools/oxlint/anti-slop/shared/dictionary-types.ts +515 -0
  60. package/starter/tools/oxlint/anti-slop/shared/function-parameters.ts +49 -0
  61. package/starter/tools/oxlint/anti-slop/shared/lexical-type-parameters.ts +61 -0
  62. package/starter/tools/oxlint/anti-slop/shared/reflect-method.ts +24 -0
  63. package/starter/tools/oxlint/anti-slop/shared/scope.ts +15 -0
  64. package/starter/tools/oxlint/anti-slop/shared/type-alias-resolution.ts +250 -0
  65. package/starter/tools/oxlint/anti-slop/vendor/eslint-stylistic/LICENSE +22 -0
  66. package/starter/tools/oxlint/anti-slop/vendor/eslint-stylistic/UPSTREAM.md +28 -0
  67. package/starter/tools/oxlint/anti-slop/vendor/eslint-stylistic/padding-line-ast.ts +51 -0
  68. package/starter/tools/oxlint/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.ts +906 -0
  69. package/starter/tools/oxlint/anti-slop/vendor/eslint-stylistic/padding-line-options.d.ts +87 -0
  70. package/starter/tools/prepare.ts +5 -0
  71. package/starter/tools/types.ts +25 -0
  72. package/starter/tsconfig.json +17 -0
  73. package/starter/vite.config.ts +8 -0
  74. package/starter/wrangler.jsonc +17 -0
  75. package/widefleet +4 -0
@@ -0,0 +1,37 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+
3
+ import {
4
+ isMatchPatternObject,
5
+ isStringLiteral,
6
+ propertyName,
7
+ } from "../shared/tagged-values.ts";
8
+
9
+ export const noManualTaggedConstructionRule = defineRule({
10
+ meta: {
11
+ type: "problem",
12
+ docs: {
13
+ description:
14
+ "Construct tagged values with their existing Effect constructor instead of writing `_tag` manually.",
15
+ },
16
+ messages: {
17
+ manualConstruction:
18
+ "Use the existing Schema tagged `.make`, tagged class/error constructor, or Data.taggedEnum variant constructor instead of writing a literal `_tag` object.",
19
+ },
20
+ },
21
+ createOnce(context) {
22
+ return {
23
+ ObjectExpression(node) {
24
+ if (isMatchPatternObject(node)) return;
25
+ const tag = node.properties.find(
26
+ (property) =>
27
+ property.type === "Property" &&
28
+ propertyName(property) === "_tag" &&
29
+ isStringLiteral(property.value),
30
+ );
31
+ if (tag !== undefined) {
32
+ context.report({ node: tag, messageId: "manualConstruction" });
33
+ }
34
+ },
35
+ };
36
+ },
37
+ });
@@ -0,0 +1,52 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+
3
+ import type { ESTree } from "@oxlint/plugins";
4
+
5
+ const SERVICE_CONSTRUCTOR_NAME = /^make[A-Z]/u;
6
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
7
+
8
+ function isProjectLocalImport(source: string): boolean {
9
+ return source.startsWith("./") || source.startsWith("../");
10
+ }
11
+
12
+ function getImportedName(specifier: ESTree.ImportSpecifier): string {
13
+ if (specifier.imported.type === "Identifier") return specifier.imported.name;
14
+ return specifier.imported.value;
15
+ }
16
+
17
+ /** Keep dependency-bearing Effect service constructors local to their owning capability modules. */
18
+ export const noServiceConstructorImportsRule = defineRule({
19
+ meta: {
20
+ type: "problem",
21
+ docs: {
22
+ description:
23
+ "Disallow project-local make<CapabilityName> imports outside test and spec files.",
24
+ },
25
+ messages: {
26
+ serviceConstructorImport:
27
+ 'Do not import Effect service constructor "{{name}}" into runtime code. Import the owning Layer, yield the contextual service, and allow its requirements to propagate to the composition root.',
28
+ },
29
+ },
30
+ create(context) {
31
+ const isTestFile = TEST_FILE.test(context.filename.replaceAll("\\", "/"));
32
+
33
+ return {
34
+ ImportDeclaration(node) {
35
+ if (isTestFile || !isProjectLocalImport(node.source.value)) return;
36
+
37
+ for (const specifier of node.specifiers) {
38
+ if (specifier.type !== "ImportSpecifier") continue;
39
+
40
+ const importedName = getImportedName(specifier);
41
+ if (!SERVICE_CONSTRUCTOR_NAME.test(importedName)) continue;
42
+
43
+ context.report({
44
+ node: specifier,
45
+ messageId: "serviceConstructorImport",
46
+ data: { name: importedName },
47
+ });
48
+ }
49
+ },
50
+ };
51
+ },
52
+ });
@@ -0,0 +1,54 @@
1
+ import { defineRule, type ESTree } from "@oxlint/plugins";
2
+
3
+ const equalityOperators = new Set(["==", "===", "!=", "!=="]);
4
+
5
+ export const preferEffectMatchRule = defineRule({
6
+ meta: {
7
+ type: "problem",
8
+ docs: {
9
+ description:
10
+ "Use Match from Effect for chained literal ternaries over the same value.",
11
+ },
12
+ messages: {
13
+ preferMatch:
14
+ "Use Match from Effect instead of a chained literal ternary.",
15
+ },
16
+ },
17
+ createOnce(context) {
18
+ const isLiteral = (node: ESTree.Node): boolean =>
19
+ node.type === "Literal" ||
20
+ (node.type === "TemplateLiteral" && node.expressions.length === 0);
21
+
22
+ const comparedValue = (node: ESTree.Expression): string | undefined => {
23
+ if (
24
+ node.type !== "BinaryExpression" ||
25
+ !equalityOperators.has(node.operator)
26
+ ) {
27
+ return undefined;
28
+ }
29
+ if (isLiteral(node.left)) return context.sourceCode.getText(node.right);
30
+ if (isLiteral(node.right)) return context.sourceCode.getText(node.left);
31
+ return undefined;
32
+ };
33
+
34
+ return {
35
+ ConditionalExpression(node) {
36
+ if (node.parent?.type === "ConditionalExpression") return;
37
+ const value = comparedValue(node.test);
38
+ if (value === undefined) return;
39
+
40
+ let alternate = node.alternate;
41
+ let literalChecks = 1;
42
+ while (alternate.type === "ConditionalExpression") {
43
+ if (comparedValue(alternate.test) !== value) return;
44
+ literalChecks += 1;
45
+ alternate = alternate.alternate;
46
+ }
47
+
48
+ if (literalChecks > 1) {
49
+ context.report({ node, messageId: "preferMatch" });
50
+ }
51
+ },
52
+ };
53
+ },
54
+ });
@@ -0,0 +1,97 @@
1
+ import type { ESTree } from "@oxlint/plugins";
2
+
3
+ const equalityOperators = new Set(["==", "===", "!=", "!=="]);
4
+ const broadEffectCatchMethods = new Set(["catch", "catchAll", "catchIf"]);
5
+
6
+ export const isStringLiteral = (
7
+ node: ESTree.Node | null | undefined,
8
+ ): node is ESTree.StringLiteral =>
9
+ node?.type === "Literal" && typeof node.value === "string";
10
+
11
+ export const isTagMember = (
12
+ node: ESTree.Node | null | undefined,
13
+ ): node is ESTree.MemberExpression =>
14
+ node?.type === "MemberExpression" &&
15
+ ((!node.computed &&
16
+ node.property.type === "Identifier" &&
17
+ node.property.name === "_tag") ||
18
+ (node.computed &&
19
+ isStringLiteral(node.property) &&
20
+ node.property.value === "_tag"));
21
+
22
+ export const tagMemberFromComparison = (
23
+ node: ESTree.BinaryExpression,
24
+ ): ESTree.MemberExpression | undefined => {
25
+ if (!equalityOperators.has(node.operator)) return undefined;
26
+ if (isTagMember(node.left) && isStringLiteral(node.right)) return node.left;
27
+ if (isTagMember(node.right) && isStringLiteral(node.left)) return node.right;
28
+ return undefined;
29
+ };
30
+
31
+ const isBroadEffectCatchCall = (
32
+ node: ESTree.Node | null | undefined,
33
+ ): node is ESTree.CallExpression =>
34
+ node?.type === "CallExpression" &&
35
+ node.callee.type === "MemberExpression" &&
36
+ node.callee.object.type === "Identifier" &&
37
+ node.callee.object.name === "Effect" &&
38
+ !node.callee.computed &&
39
+ node.callee.property.type === "Identifier" &&
40
+ broadEffectCatchMethods.has(node.callee.property.name);
41
+
42
+ export const isInsideBroadEffectHandler = (node: ESTree.Node): boolean => {
43
+ let current: ESTree.Node | null | undefined = node.parent;
44
+ while (current !== null && current !== undefined) {
45
+ if (
46
+ current.type === "ArrowFunctionExpression" ||
47
+ current.type === "FunctionExpression"
48
+ ) {
49
+ return (
50
+ isBroadEffectCatchCall(current.parent) &&
51
+ current.parent.arguments.includes(current)
52
+ );
53
+ }
54
+ current = current.parent;
55
+ }
56
+ return false;
57
+ };
58
+
59
+ export const isReasonTagMember = (node: ESTree.MemberExpression): boolean =>
60
+ node.object.type === "MemberExpression" &&
61
+ ((!node.object.computed &&
62
+ node.object.property.type === "Identifier" &&
63
+ node.object.property.name === "reason") ||
64
+ (node.object.computed &&
65
+ isStringLiteral(node.object.property) &&
66
+ node.object.property.value === "reason"));
67
+
68
+ export const propertyName = (
69
+ property: ESTree.ObjectProperty,
70
+ ): string | undefined => {
71
+ if (!property.computed && property.key.type === "Identifier") {
72
+ return property.key.name;
73
+ }
74
+ if (
75
+ property.key.type === "Literal" &&
76
+ typeof property.key.value === "string"
77
+ ) {
78
+ return property.key.value;
79
+ }
80
+ return undefined;
81
+ };
82
+
83
+ export const isMatchPatternObject = (node: ESTree.ObjectExpression): boolean => {
84
+ const call = node.parent;
85
+ if (call?.type !== "CallExpression" || !call.arguments.includes(node)) {
86
+ return false;
87
+ }
88
+ const callee = call.callee;
89
+ return (
90
+ callee.type === "MemberExpression" &&
91
+ callee.object.type === "Identifier" &&
92
+ callee.object.name === "Match" &&
93
+ !callee.computed &&
94
+ callee.property.type === "Identifier" &&
95
+ (callee.property.name === "when" || callee.property.name === "not")
96
+ );
97
+ };
@@ -0,0 +1,47 @@
1
+ import { eslintCompatPlugin } from "@oxlint/plugins";
2
+
3
+ import { noArrayFilterMapRule } from "./rules/no-array-filter-map.ts";
4
+ import { noReduceAccumulatorCopyRule } from "./rules/no-reduce-accumulator-copy.ts";
5
+ import { noChainedTypeAssertionsRule } from "./rules/no-chained-type-assertions.ts";
6
+ import { noConditionalEmptyObjectSpreadRule } from "./rules/no-conditional-empty-object-spread.ts";
7
+ import { noKnownValueWideningRule } from "./rules/no-known-value-widening.ts";
8
+ import { noModuleMockingRule } from "./rules/no-module-mocking.ts";
9
+ import { noObjectParametersRule } from "./rules/no-object-parameters.ts";
10
+ import { noReflectApplyRule } from "./rules/no-reflect-apply.ts";
11
+ import { noReflectGetRule } from "./rules/no-reflect-get.ts";
12
+ import { noRuntimeTypeofRule } from "./rules/no-runtime-typeof.ts";
13
+ import { noForbiddenTermInSymbolNamesRule } from "./rules/no-shape-in-symbol-names.ts";
14
+ import { noUnknownParametersRule } from "./rules/no-unknown-parameters.ts";
15
+ import { noUnknownReturnsRule } from "./rules/no-unknown-returns.ts";
16
+ import { noUnknownTypeAliasesRule } from "./rules/no-unknown-type-aliases.ts";
17
+ import { noUnsafeDictionaryTypeRule } from "./rules/no-unsafe-dictionary-type.ts";
18
+ import { noWidenThenAssertRule } from "./rules/no-widen-then-assert.ts";
19
+ import { requireReadableSpacingRule } from "./rules/require-readable-spacing.ts";
20
+ import { requireSafetyCommentForTypeAssertionRule } from "./rules/require-safety-comment-for-type-assertion.ts";
21
+
22
+ /** Generic Oxlint rules that reject low-evidence and low-signal implementation patterns. */
23
+ const antiSlopPlugin = eslintCompatPlugin({
24
+ meta: { name: "anti-slop" },
25
+ rules: {
26
+ "no-array-filter-map": noArrayFilterMapRule,
27
+ "no-reduce-accumulator-copy": noReduceAccumulatorCopyRule,
28
+ "no-chained-type-assertions": noChainedTypeAssertionsRule,
29
+ "no-conditional-empty-object-spread": noConditionalEmptyObjectSpreadRule,
30
+ "no-known-value-widening": noKnownValueWideningRule,
31
+ "no-module-mocking": noModuleMockingRule,
32
+ "no-object-parameters": noObjectParametersRule,
33
+ "no-reflect-apply": noReflectApplyRule,
34
+ "no-reflect-get": noReflectGetRule,
35
+ "no-runtime-typeof": noRuntimeTypeofRule,
36
+ "no-unsafe-dictionary-type": noUnsafeDictionaryTypeRule,
37
+ "no-shape-in-symbol-names": noForbiddenTermInSymbolNamesRule,
38
+ "no-unknown-parameters": noUnknownParametersRule,
39
+ "no-unknown-returns": noUnknownReturnsRule,
40
+ "no-unknown-type-aliases": noUnknownTypeAliasesRule,
41
+ "no-widen-then-assert": noWidenThenAssertRule,
42
+ "require-readable-spacing": requireReadableSpacingRule,
43
+ "require-safety-comment-for-type-assertion": requireSafetyCommentForTypeAssertionRule,
44
+ },
45
+ });
46
+
47
+ export default antiSlopPlugin;
@@ -0,0 +1,28 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+
3
+ import { arrayMethodTarget, isKnownArrayExpression, unwrapArrayExpression } from "../shared/array-method.ts";
4
+
5
+ /** Reject eager array filter/map pipelines; lazy iterator helpers remain allowed. */
6
+ export const noArrayFilterMapRule = defineRule({
7
+ meta: {
8
+ type: "suggestion",
9
+ docs: { description: "Disallow adjacent array filter/map passes in favor of lazy iterator helpers or a single transformation." },
10
+ messages: {
11
+ arrayFilterMap: "Avoid consecutive array `{{first}}` and `{{second}}` passes. Prefer `.values().{{first}}(...).{{second}}(...).toArray()` where iterator helpers are supported, or a single `flatMap`/mutating reducer. Preserve callback ordering, indexes, and filtering semantics.",
12
+ },
13
+ },
14
+ createOnce(context) {
15
+ return {
16
+ CallExpression(node) {
17
+ const outer = arrayMethodTarget(node.callee);
18
+ if (outer === null || (outer.name !== "map" && outer.name !== "filter")) return;
19
+ const innerCall = unwrapArrayExpression(outer.object);
20
+ if (innerCall.type !== "CallExpression") return;
21
+ const inner = arrayMethodTarget(innerCall.callee);
22
+ if (inner === null || inner.name !== (outer.name === "map" ? "filter" : "map")) return;
23
+ if (!isKnownArrayExpression(context.sourceCode, inner.object)) return;
24
+ context.report({ node, messageId: "arrayFilterMap", data: { first: inner.name, second: outer.name } });
25
+ },
26
+ };
27
+ },
28
+ });
@@ -0,0 +1,77 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import type { ESTree } from "@oxlint/plugins";
3
+
4
+ type TypeAssertionExpression = ESTree.TSAsExpression | ESTree.TSTypeAssertion;
5
+
6
+ function isTypeAssertionExpression(node: ESTree.Node): node is TypeAssertionExpression {
7
+ return node.type === "TSAsExpression" || node.type === "TSTypeAssertion";
8
+ }
9
+
10
+ function unwrapParenthesizedExpression(expression: ESTree.Expression): ESTree.Expression {
11
+ let current = expression;
12
+ while (current.type === "ParenthesizedExpression") {
13
+ current = current.expression;
14
+ }
15
+ return current;
16
+ }
17
+
18
+ function isConstAssertion(node: TypeAssertionExpression): boolean {
19
+ const { typeAnnotation } = node;
20
+ return (
21
+ typeAnnotation.type === "TSTypeReference" &&
22
+ typeAnnotation.typeName.type === "Identifier" &&
23
+ typeAnnotation.typeName.name === "const"
24
+ );
25
+ }
26
+
27
+ function isOutermostAssertionInChain(node: TypeAssertionExpression): boolean {
28
+ let current: ESTree.Expression = node;
29
+ let parent = node.parent;
30
+
31
+ while (parent.type === "ParenthesizedExpression" && parent.expression === current) {
32
+ current = parent;
33
+ parent = parent.parent;
34
+ }
35
+
36
+ return !isTypeAssertionExpression(parent) || parent.expression !== current;
37
+ }
38
+
39
+ function isForbiddenAssertionChain(node: TypeAssertionExpression): boolean {
40
+ let assertionCount = 0;
41
+ let hasNonConstAssertion = false;
42
+ let current: ESTree.Expression = node;
43
+
44
+ while (isTypeAssertionExpression(current)) {
45
+ assertionCount += 1;
46
+ hasNonConstAssertion ||= !isConstAssertion(current);
47
+ current = unwrapParenthesizedExpression(current.expression);
48
+ }
49
+
50
+ return assertionCount > 1 && hasNonConstAssertion;
51
+ }
52
+
53
+ /** Disallow nested TypeScript type assertions, while permitting chains made only of const assertions. */
54
+ export const noChainedTypeAssertionsRule = defineRule({
55
+ meta: {
56
+ type: "problem",
57
+ docs: {
58
+ description:
59
+ "Disallow chained TypeScript as and angle-bracket assertions, including parenthesized chains.",
60
+ },
61
+ messages: {
62
+ chained:
63
+ "This assertion chain discards type evidence. Keep the original precise type, or parse untrusted input at its boundary before narrowing it.",
64
+ },
65
+ },
66
+ createOnce(context) {
67
+ const checkTypeAssertion = (node: TypeAssertionExpression) => {
68
+ if (!isOutermostAssertionInChain(node) || !isForbiddenAssertionChain(node)) return;
69
+ context.report({ node, messageId: "chained" });
70
+ };
71
+
72
+ return {
73
+ TSAsExpression: checkTypeAssertion,
74
+ TSTypeAssertion: checkTypeAssertion,
75
+ };
76
+ },
77
+ });
@@ -0,0 +1,49 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import type { ESTree } from "@oxlint/plugins";
3
+
4
+ function unwrapParentheses(node: ESTree.Expression): ESTree.Expression {
5
+ let current = node;
6
+ while (current.type === "ParenthesizedExpression") {
7
+ current = current.expression;
8
+ }
9
+ return current;
10
+ }
11
+
12
+ function isEmptyObjectExpression(node: ESTree.Expression): boolean {
13
+ return node.type === "ObjectExpression" && node.properties.length === 0;
14
+ }
15
+
16
+ function isConditionalEmptyObjectSpread(node: ESTree.Expression): boolean {
17
+ const conditional = unwrapParentheses(node);
18
+ return (
19
+ conditional.type === "ConditionalExpression" &&
20
+ (isEmptyObjectExpression(conditional.consequent) ||
21
+ isEmptyObjectExpression(conditional.alternate))
22
+ );
23
+ }
24
+
25
+ /** Ban conditional empty-object spreads without changing their omission semantics. */
26
+ export const noConditionalEmptyObjectSpreadRule = defineRule({
27
+ meta: {
28
+ type: "suggestion",
29
+ docs: {
30
+ description:
31
+ "Disallow object spreads that conditionally spread an empty object to omit fields.",
32
+ },
33
+ messages: {
34
+ avoid:
35
+ "This conditional spread hides property omission behind an empty object. Build the object in separate statements and add the property only when present.",
36
+ },
37
+ },
38
+ createOnce(context) {
39
+ return {
40
+ SpreadElement(node) {
41
+ if (node.parent.type !== "ObjectExpression") return;
42
+
43
+ if (isConditionalEmptyObjectSpread(node.argument)) {
44
+ context.report({ node, messageId: "avoid" });
45
+ }
46
+ },
47
+ };
48
+ },
49
+ });