Skip to content

Commit fe1d5f6

Browse files
authored
chore: enable additional correctness lint rules (#4672)
## Summary Enable additional lint rules that catch unsafe optional-chain assertions, inherited-property iteration, anonymous symbols, and unsafe external links. The existing violations now use explicit values and own-property checks, so the rules can prevent those patterns from returning.
1 parent cffaa05 commit fe1d5f6

12 files changed

Lines changed: 26 additions & 31 deletions

File tree

.oxlintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
],
3535
"no-empty-pattern": "off",
3636
"no-control-regex": "off",
37-
"typescript/no-non-null-asserted-optional-chain": "off",
37+
"typescript/no-non-null-asserted-optional-chain": "error",
3838
"no-unused-expressions": [
3939
"error",
4040
{
@@ -47,6 +47,9 @@
4747
"import/namespace": "off",
4848
"react-hooks/exhaustive-deps": "off",
4949
"react-hooks/rules-of-hooks": "off",
50+
"guard-for-in": "error",
51+
"symbol-description": "error",
52+
"react/jsx-no-target-blank": "error",
5053
"trigger/no-thrown-unawaited-redirect": "error",
5154
"trigger-prisma/no-unbounded-list-filter": "error",
5255
"trigger-prisma/no-unbounded-list-filter-in-args-helper": "error"

apps/webapp/app/components/primitives/Callout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export function Callout({
9292
<a
9393
href={to}
9494
target="_blank"
95+
rel="noreferrer"
9596
className={cn(
9697
`flex w-full items-start justify-between gap-2.5 rounded-md border py-2 pl-2 pr-3 shadow-md backdrop-blur-xs`,
9798
variantDefinition.className,

apps/webapp/app/services/metadata/updateMetadata.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ export class UpdateMetadataService {
589589
await this._runStore.updateMetadata(
590590
runId,
591591
{
592-
metadata: metadataPacket?.data!,
592+
metadata: metadataPacket.data!,
593593
metadataType: metadataPacket?.dataType,
594594
metadataVersion: {
595595
increment: 1,

apps/webapp/app/services/routeBuilders/permissions.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function checkPermissions<K extends string>(
2929
): Record<K, boolean> {
3030
const result = {} as Record<K, boolean>;
3131
for (const key in checks) {
32+
if (!Object.hasOwn(checks, key)) continue;
3233
const check = checks[key];
3334
result[key] =
3435
"requireSuper" in check ? ability.canSuper() : ability.can(check.action, check.resource);

apps/webapp/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function installPrimarySignalHandlers() {
3737

3838
const forward = (signal: NodeJS.Signals) => {
3939
for (const id in cluster.workers) {
40+
if (!Object.hasOwn(cluster.workers, id)) continue;
4041
const w = cluster.workers[id];
4142
if (w?.process?.pid) {
4243
try {

packages/core/src/v3/apiClient/core.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,9 @@ async function waitForRetry(
605605
// https://stackoverflow.com/a/34491287
606606
export function isEmptyObj(obj: object | null | undefined): boolean {
607607
if (!obj) return true;
608-
for (const _k in obj) return false;
608+
for (const key in obj) {
609+
if (Object.hasOwn(obj, key)) return false;
610+
}
609611
return true;
610612
}
611613

packages/core/src/v3/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,7 @@ export function createTaskMetadataFailedErrorStack(
11721172
const groupedIssues = groupTaskMetadataIssuesByTask(data.tasks, data.zodIssues);
11731173

11741174
for (const key in groupedIssues) {
1175+
if (!Object.hasOwn(groupedIssues, key)) continue;
11751176
const taskWithIssues = groupedIssues[key];
11761177

11771178
if (!taskWithIssues) {

packages/core/src/v3/locals/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocalsKey, LocalsManager } from "./types.js";
33
export class NoopLocalsManager implements LocalsManager {
44
createLocal<T>(id: string): LocalsKey<T> {
55
return {
6-
__type: Symbol(),
6+
__type: Symbol(id),
77
id,
88
};
99
}

packages/core/src/v3/serverOnly/httpServer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ export class HttpServer {
346346

347347
private findRoute(url: string): string | null {
348348
for (const route in this.routes) {
349+
if (!Object.hasOwn(this.routes, route)) continue;
349350
const routeParts = route.split("/");
350351
const urlWithoutQueryParams = url.split("?")[0];
351352

packages/core/src/v3/utils/flattenAttributes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ export function unflattenAttributes(
346346
const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
347347
const arrayResult = Array(maxIndex + 1);
348348
for (const key in result) {
349+
if (!Object.hasOwn(result, key)) continue;
349350
arrayResult[parseInt(key)] = result[key];
350351
}
351352
return arrayResult as any;

0 commit comments

Comments
 (0)