Skip to content

Commit

Permalink
chore: Fix lint @typescript-eslint/prefer-optional-chain
Browse files Browse the repository at this point in the history
  • Loading branch information
dividedmind committed Apr 21, 2024
1 parent 3967019 commit 5ea54de
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/cmds/compare-report/Preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function filterFindings(findings: FindingChange[], section: Section | Exp
return findings.filter(
(finding) =>
(!includeDomains || includeDomains.includes(finding.finding.impactDomain || 'Stability')) &&
(!excludeDomains || !excludeDomains.includes(finding.finding.impactDomain || 'Stability'))
(!excludeDomains?.includes(finding.finding.impactDomain || 'Stability'))
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/fingerprint/algorithms.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function buildTree(events) {
});

const commands = rootEvents.filter(
(e) => e.kind === 'http_server_request' || (e.labels && e.labels.includes('command'))
(e) => e.kind === 'http_server_request' || (e.labels?.includes('command'))
);
if (commands.length > 0) {
return commands;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/inspect/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const filter = (rl, context, home) => {
filter(rl, context, home);
}

if (!filterField || !filterField.filterName) {
if (!filterField?.filterName) {
return retry();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SanitizedUri {
}

function hasUrl(remote: unknown): remote is { url: string } {
return remote && remote['url'];
return remote?.['url'];
}

async function findAndSanitizeRepository(dir: string): Promise<SanitizedUri | void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/serveAndOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default async function serveAndOpen(
const pathname = requestUrl.pathname;
if (pathname === '/') {
return serveStaticFile(baseDir, file, 'text/html');
} else if (pathname && pathname.startsWith('/resource')) {
} else if (pathname?.startsWith('/resource')) {
const pathname = requestUrl.query;
if (pathname) serveStaticFile(process.cwd(), decodeURIComponent(pathname));
else send404();
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ export async function mtime(filePath: PathLike): Promise<number | undefined> {
// as temp files).

const fileStat = await statFile(filePath);
if (!fileStat || !fileStat.isFile()) {
if (!fileStat?.isFile()) {
return;
}
return fileStat.mtimeMs;
}

export async function isFile(filePath: PathLike): Promise<boolean> {
const fileStat = await statFile(filePath);
return !!(fileStat && fileStat.isFile());
return !!fileStat?.isFile();
}

/**
Expand Down Expand Up @@ -147,7 +147,7 @@ export async function processNamedFiles(
// If the directory contains the target fileName, add it to the process queue and return.
const targetFileName = join(dir, fileName);
const target = await stats(targetFileName);
if (target && target.isFile()) {
if (target?.isFile()) {
matchCount += 1;
q.push(targetFileName);
return;
Expand All @@ -162,7 +162,7 @@ export async function processNamedFiles(
}
for (const childName of children) {
const child = await stats(join(dir, childName));
if (child && child.isDirectory()) {
if (child?.isDirectory()) {
await processDir(join(dir, childName));
}
}
Expand Down Expand Up @@ -256,8 +256,8 @@ export function prefixLines(str: string, prefix: string): string {
return str.replace(/^/gm, prefix);
}

export function formatValue(value: ReturnValueObject) {
if (value === null || value === undefined || value.value === null || value.value === undefined) {
export function formatValue(value?: ReturnValueObject) {
if (value?.value === null || value?.value === undefined) {
return 'Null';
}

Expand Down

0 comments on commit 5ea54de

Please sign in to comment.