Skip to content

Commit 0f725cf

Browse files
authored
chore: enable lint cleanup rules (#4673)
## Summary Enable small cleanup rules for redundant boolean expressions, object ownership checks, assignments, and object construction. The existing call sites now use the simpler equivalent forms, keeping future code consistent without changing behavior. Base: [#4672](#4672)
1 parent fe1d5f6 commit 0f725cf

17 files changed

Lines changed: 42 additions & 34 deletions

File tree

.oxlintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
"react-hooks/rules-of-hooks": "off",
5050
"guard-for-in": "error",
5151
"symbol-description": "error",
52+
"no-unneeded-ternary": "error",
53+
"prefer-object-has-own": "error",
54+
"no-redeclare": "error",
55+
"no-multi-assign": "error",
56+
"prefer-object-spread": "error",
5257
"react/jsx-no-target-blank": "error",
5358
"trigger/no-thrown-unawaited-redirect": "error",
5459
"trigger-prisma/no-unbounded-list-filter": "error",
@@ -75,6 +80,12 @@
7580
"trigger-prisma/no-unbounded-list-filter": "off",
7681
"trigger-prisma/no-unbounded-list-filter-in-args-helper": "off"
7782
}
83+
},
84+
{
85+
"files": ["internal-packages/tsql/**"],
86+
"rules": {
87+
"prefer-object-has-own": "off"
88+
}
7889
}
7990
]
8091
}

apps/webapp/app/components/billing/UsageBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ type LegendProps = {
106106

107107
function Legend({ text, value, position, percentage, tooltipContent }: LegendProps) {
108108
const flipLegendPositionValue = 80;
109-
const flipLegendPosition = percentage > flipLegendPositionValue ? true : false;
109+
const flipLegendPosition = percentage > flipLegendPositionValue;
110110
return (
111111
<div
112112
className={cn(

apps/webapp/app/components/primitives/TreeView/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function applyVisibility<TData>(tree: FlatTree<TData>, state: NodesState)
7878
const parent = node.parentId
7979
? acc[node.parentId]
8080
: { selected: defaultSelected, expanded: defaultExpanded, visible: true };
81-
const visible = parent.expanded && parent.visible === true ? true : false;
81+
const visible = parent.expanded && parent.visible === true;
8282
acc[node.id] = { ...nodeState, visible };
8383

8484
return acc;

apps/webapp/app/hooks/useThemeColor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { useEffect, useState } from "react";
77
*/
88
function toRgb(color: string): string {
99
const canvas = document.createElement("canvas");
10-
canvas.width = canvas.height = 1;
10+
canvas.width = 1;
11+
canvas.height = 1;
1112
const ctx = canvas.getContext("2d");
1213
if (!ctx) return color;
1314
ctx.fillStyle = color;

apps/webapp/app/presenters/v3/ApiErrorListPresenter.server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ export const ApiErrorListSearchParams = z.object({
4848
const statuses = value.split(",");
4949
// hasOwnProperty, not `in`: `in` walks the prototype chain, so
5050
// `filter[status]=toString` would pass and map to a function.
51-
const invalid = statuses.filter(
52-
(status) => !Object.prototype.hasOwnProperty.call(API_STATUS_TO_DB, status)
53-
);
51+
const invalid = statuses.filter((status) => !Object.hasOwn(API_STATUS_TO_DB, status));
5452

5553
if (invalid.length > 0) {
5654
ctx.addIssue({

apps/webapp/app/presenters/v3/ApiWebhookDeliveryPresenter.server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ export const ApiWebhookDeliveryListSearchParams = z.object({
5555
.transform((value, ctx) => {
5656
if (!value) return undefined;
5757
const statuses = value.split(",");
58-
const invalid = statuses.filter(
59-
(s) => !Object.prototype.hasOwnProperty.call(API_STATUS_TO_DB, s)
60-
);
58+
const invalid = statuses.filter((s) => !Object.hasOwn(API_STATUS_TO_DB, s));
6159
if (invalid.length > 0) {
6260
ctx.addIssue({
6361
code: z.ZodIssueCode.custom,

apps/webapp/app/v3/eventRepository/common.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export function removePrivateProperties(
172172

173173
export function isEmptyObject(obj: object) {
174174
for (var prop in obj) {
175-
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
175+
if (Object.hasOwn(obj, prop)) {
176176
return false;
177177
}
178178
}

apps/webapp/app/v3/eventRepository/eventRepository.server.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,13 +1692,11 @@ function parseStyleField(style: Prisma.JsonValue): TaskEventStyle {
16921692
}
16931693

16941694
if (typeof unsafe === "object") {
1695-
return Object.assign(
1696-
{
1697-
icon: undefined,
1698-
variant: undefined,
1699-
},
1700-
unsafe
1701-
) as TaskEventStyle;
1695+
return {
1696+
icon: undefined,
1697+
variant: undefined,
1698+
...unsafe,
1699+
} as TaskEventStyle;
17021700
}
17031701

17041702
return {};

apps/webapp/app/v3/eventRepository/traceExport.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const FORMATS: Record<TraceExportFormatName, TraceExportFormat> = {
199199

200200
/** Resolve a `?format=` value to a format, defaulting to `log`. */
201201
export function getTraceExportFormat(name: string | null | undefined): TraceExportFormat {
202-
if (name && Object.prototype.hasOwnProperty.call(FORMATS, name)) {
202+
if (name && Object.hasOwn(FORMATS, name)) {
203203
return FORMATS[name as TraceExportFormatName];
204204
}
205205
return logFormat;

apps/webapp/app/v3/services/alerts/createAlertChannel.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class CreateAlertChannelService extends BaseService {
104104
properties: await this.#createProperties(options.channel),
105105
enabled: true,
106106
deduplicationKey: options.deduplicationKey,
107-
userProvidedDeduplicationKey: options.deduplicationKey ? true : false,
107+
userProvidedDeduplicationKey: Boolean(options.deduplicationKey),
108108
environmentTypes,
109109
},
110110
});

0 commit comments

Comments
 (0)