Skip to content

Commit 682e31f

Browse files
authored
Merge pull request #915 from amvanbaren/optional-chain-expression
Use optional chain expression
2 parents c1f744e + c82f8cd commit 682e31f

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

cli/src/get.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function printMetadata(registry: Registry, extension: Extension, output?:
7474
}
7575
let filePath: string | undefined;
7676
const stats = await optionalStat(output);
77-
if (stats && stats.isDirectory() || !stats && output.endsWith(path.sep)) {
77+
if (stats?.isDirectory() || !stats && output.endsWith(path.sep)) {
7878
const fileName = `${extension.namespace}.${extension.name}-${extension.version}.json`;
7979
filePath = path.resolve(process.cwd(), output, fileName);
8080
} else {
@@ -94,7 +94,7 @@ async function download(registry: Registry, extension: Extension, output?: strin
9494
let filePath: string | undefined;
9595
if (output) {
9696
const stats = await optionalStat(output);
97-
if (stats && stats.isDirectory() || !stats && output.endsWith(path.sep)) {
97+
if (stats?.isDirectory() || !stats && output.endsWith(path.sep)) {
9898
filePath = path.resolve(process.cwd(), output, fileName);
9999
} else {
100100
filePath = path.resolve(process.cwd(), output);

cli/src/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function doPublish(options: InternalPublishOptions = {}): Promise<void> {
3535
}
3636

3737
// if the packagePath is a link to a vsix, don't need to package it
38-
if (options.packagePath && options.packagePath.endsWith('.vsix')) {
38+
if (options.packagePath?.endsWith('.vsix')) {
3939
options.extensionFile = options.packagePath;
4040
delete options.packagePath;
4141
delete options.target;

cli/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Registry {
2828
readonly password?: string;
2929

3030
constructor(options: RegistryOptions = {}) {
31-
if (options.registryUrl && options.registryUrl.endsWith('/'))
31+
if (options.registryUrl?.endsWith('/'))
3232
this.url = options.registryUrl.substring(0, options.registryUrl.length - 1);
3333
else if (options.registryUrl)
3434
this.url = options.registryUrl;

webui/src/components/sidepanel/navigation-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const NavigationItem: FunctionComponent<PropsWithChildren<NavigationProps
2121
if (props.children) {
2222
setOpen(!open);
2323
} else if (props.route) {
24-
props.onOpenRoute && props.onOpenRoute(props.route);
24+
props.onOpenRoute?.call(props.route);
2525
navigate(props.route);
2626
}
2727
};

webui/src/pages/admin-dashboard/publisher-admin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const PublisherAdmin: FunctionComponent = props => {
4949
}
5050
setLoading(false);
5151
} catch (err) {
52-
if (err && err.status && err.status === 404) {
52+
if (err?.status === 404) {
5353
setNotFound(publisherName);
5454
setPublisher(undefined);
5555
} else {

webui/src/pages/admin-dashboard/publisher-revoke-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const PublisherRevokeDialog: FunctionComponent<PublisherRevokeDialogProps
3232
}, []);
3333

3434
if (props.publisherInfo.user.publisherAgreement
35-
&& !(user && user.additionalLogins && user.additionalLogins.find(login => login.provider === 'eclipse'))) {
35+
&& !(user?.additionalLogins?.find(login => login.provider === 'eclipse'))) {
3636
// If a publisher agreement is required, the admin must be logged in with Eclipse to revoke it
3737
return <Link href={createAbsoluteURL([service.serverUrl, 'oauth2', 'authorization', 'eclipse'])}>
3838
<Button variant='contained' color='secondary'>

webui/src/pages/user/user-namespace-extension-list-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const UserNamespaceExtensionListItem: FunctionComponent<UserNamespaceExte
6363
}}>
6464
<Box
6565
component='img'
66-
src={icon || (pageSettings && pageSettings.urls.extensionDefaultIcon) || ''}
66+
src={icon || (pageSettings?.urls.extensionDefaultIcon) || ''}
6767
alt={extension.displayName || extension.name}
6868
sx={{
6969
flex: '0 0 15%',

webui/src/pages/user/user-publisher-agreement.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const UserPublisherAgreement: FunctionComponent<UserPublisherAgreementPro
5757
};
5858

5959
const openPublisherAgreement = () => {
60-
if (!pageSettings || !pageSettings.urls.publisherAgreement) {
60+
if (!pageSettings.urls.publisherAgreement) {
6161
handleError({ error: 'Publisher agreement text is not available.' });
6262
} else {
6363
setDialogOpen(true);
@@ -99,31 +99,31 @@ export const UserPublisherAgreement: FunctionComponent<UserPublisherAgreementPro
9999
}
100100
</Typography>
101101
:
102-
!user.additionalLogins || !user.additionalLogins.find(login => login.provider === 'eclipse') ?
102+
user.additionalLogins?.find(login => login.provider === 'eclipse') ?
103103
<>
104104
<Typography variant='body1'>
105105
You need to sign the Eclipse Foundation Open VSX Publisher Agreement before you can publish
106-
any extension to this registry. To start the signing process, please log in with
107-
an Eclipse Foundation account.
106+
any extension to this registry.
108107
</Typography>
109108
<Box mt={2} display='flex' justifyContent='flex-end'>
110-
<Link href={createAbsoluteURL([service.serverUrl, 'oauth2', 'authorization', 'eclipse'])}>
111-
<Button variant='outlined' color='secondary'>
112-
Log in with Eclipse
113-
</Button>
114-
</Link>
109+
<Button onClick={openPublisherAgreement} variant='outlined' color='secondary'>
110+
Show Publisher Agreement
111+
</Button>
115112
</Box>
116113
</>
117114
:
118115
<>
119116
<Typography variant='body1'>
120117
You need to sign the Eclipse Foundation Open VSX Publisher Agreement before you can publish
121-
any extension to this registry.
118+
any extension to this registry. To start the signing process, please log in with
119+
an Eclipse Foundation account.
122120
</Typography>
123121
<Box mt={2} display='flex' justifyContent='flex-end'>
124-
<Button onClick={openPublisherAgreement} variant='outlined' color='secondary'>
125-
Show Publisher Agreement
126-
</Button>
122+
<Link href={createAbsoluteURL([service.serverUrl, 'oauth2', 'authorization', 'eclipse'])}>
123+
<Button variant='outlined' color='secondary'>
124+
Log in with Eclipse
125+
</Button>
126+
</Link>
127127
</Box>
128128
</>}
129129
</Paper>

0 commit comments

Comments
 (0)