Skip to content

chore(hub-common): enforce tslint #1835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pull-request-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- name: Install Dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Build
run: npm run build

Expand Down
10 changes: 2 additions & 8 deletions packages/common/e2e/tslint.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{
"extends": [
"tslint:recommended",
"tslint-config-standard",
"tslint-config-prettier"
"../../../tslint.json"
],
"rules": {
"no-console": false,
"strict-type-predicates": false,
"ordered-imports": ["any"],
"only-arrow-functions": [false],
"object-literal-sort-keys": false,
"interface-name": [true, "always-prefix"]
"no-unused-variable": false
}
}
4 changes: 2 additions & 2 deletions packages/common/src/ArcGISContextManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IArcGISContext } from "./types/IArcGISContext";

import { getHubApiFromPortalUrl } from "./urls/getHubApiFromPortalUrl";
import { getPortalBaseFromOrgUrl } from "./urls/getPortalBaseFromOrgUrl";
import { Level, Logger } from "./utils/logger";
import { Logger } from "./utils/logger";
import { HubServiceStatus } from "./core";
import { cloneObject, maybeAdd } from "./util";
import { base64ToUnicode, unicodeToBase64 } from "./utils/encoding";
Expand All @@ -18,7 +18,7 @@ import { failSafe } from "./utils/fail-safe";
import { updateUserHubSettings } from "./utils/hubUserAppResources";
import { IUserHubSettings } from "./utils/IUserHubSettings";
import { fetchAndMigrateUserHubSettings } from "./utils/internal/fetchAndMigrateUserHubSettings";
import { getProp, getWithDefault, setProp } from "./objects";
import { getProp, getWithDefault } from "./objects";
import { fetchOrgLimits, IOrgLimit, OrgLimitType } from "./org/fetchOrgLimits";
import type { IArcGISContextManagerOptions } from "./types/IArcGISContextManagerOptions";
import type { IUserResourceConfig } from "./types/IUserResourceConfig";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGroup, getItemGroups } from "@esri/arcgis-rest-portal";
import { getItemGroups } from "@esri/arcgis-rest-portal";
import { HubEntity, HubEntityType } from "../../core/types";
import { getTypesFromEntityType } from "../../core/getTypesFromEntityType";
import { getProp } from "../../objects/get-prop";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types";
import { IUiSchema } from "../../core/schemas/types";
import { IArcGISContext } from "../../types";
import { IHubChannel } from "../../core/types";
import { buildUiSchema as buildUiSchemaCreate } from "./ChannelUiSchemaCreate";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HubEntityType } from "../../core/types";
import {
COLLABORATION_TYPES,
CollaborationType,
IEntityPermissionPolicy,
} from "../../permissions/types/IEntityPermissionPolicy";
import {
Expand All @@ -17,26 +16,6 @@ export interface IHubRoleConfigValue {
roles: Record<string, { value: string; id?: string }>;
}

const COLLABORATION_TYPE_TO_ENTITY_TYPE_MAP: Partial<
Record<CollaborationType, HubEntityType>
> = {
[COLLABORATION_TYPES.user]: "user",
[COLLABORATION_TYPES.group]: "group",
[COLLABORATION_TYPES.groupAdmin]: "group",
[COLLABORATION_TYPES.org]: "organization",
[COLLABORATION_TYPES.orgAdmin]: "organization",
};

const COLLABORATION_TYPE_TO_ROLE_MAP: Partial<
Record<CollaborationType, string>
> = {
[COLLABORATION_TYPES.user]: "user",
[COLLABORATION_TYPES.group]: "member",
[COLLABORATION_TYPES.groupAdmin]: "admin",
[COLLABORATION_TYPES.org]: "member",
[COLLABORATION_TYPES.orgAdmin]: "admin",
};

/**
* @private
* Transforms an array of IEntityPermissionPolicy (Hub entity) objects to an array of IHubRoleConfigValue (entity editor) objects
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
import { HubEntityType } from "../../core/types/HubEntityType";
import {
COLLABORATION_TYPES,
CollaborationType,
IEntityPermissionPolicy,
} from "../../permissions/types";
import {
CHANNEL_PERMISSIONS,
ChannelNonePermission,
} from "./ChannelBusinessRules";
import { ChannelNonePermission } from "./ChannelBusinessRules";
import { IHubRoleConfigValue } from "./transformEntityPermissionPoliciesToFormValues";

const ENTITY_TYPE_TO_COLLABORATION_TYPE_MAP: Partial<
Record<HubEntityType, { [key: string]: CollaborationType }>
> = {
user: {
user: COLLABORATION_TYPES.user,
},
organization: {
admin: COLLABORATION_TYPES.orgAdmin,
member: COLLABORATION_TYPES.org,
},
group: {
admin: COLLABORATION_TYPES.groupAdmin,
member: COLLABORATION_TYPES.group,
},
};

/**
* @private
* Transforms an array of IHubRoleConfigValue objects into an array of IEntityPermissionPolicy objects
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const site: string[] = ["Hub Site Application", "Site Application"];
*/
export const getCollection = (type?: string) => {
if (!type) {
return;
return undefined;
}
const lowerCaseType = type.toLocaleLowerCase();
return Object.keys(collections).find((key) => {
Expand All @@ -264,7 +264,7 @@ export const getCollection = (type?: string) => {
*/
export const getCollectionTypes = (collection?: string) => {
if (!collection) {
return;
return undefined;
}
const lowerCaseCollection = collection.toLocaleLowerCase();
return collections[lowerCaseCollection];
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/content/_internal/computeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
IServiceExtendedProps,
} from "../../core/types/IHubEditableContent";
import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl";
import { isDiscussable } from "../../discussions";
import {
hasServiceCapability,
ServiceCapabilities,
Expand Down
11 changes: 5 additions & 6 deletions packages/common/src/core/catalogContains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { isCuid } from "../utils/is-cuid";
import { isGuid } from "../utils/is-guid";
import type { IArcGISContext } from "../types/IArcGISContext";
import { hubSearch } from "../search/hubSearch";
import { getWithDefault } from "../objects/get-with-default";

/**
* Given an identifier and a catalog, check if the catalog contains the identifier.
Expand Down Expand Up @@ -116,11 +115,11 @@ export async function catalogContains(
isContained = queryResponse.results.reduce(
(slugKeywordPresent, entry) => {
// try .keywords, then rawResult.typeKeywords, else empty array
const kwds = getWithDefault(
entry,
"typeKeywords",
getWithDefault(entry, "rawResult.typeKeywords", [])
);
// const kwds = getWithDefault(
// entry,
// "typeKeywords",
// getWithDefault(entry, "rawResult.typeKeywords", [])
// );
// if (kwds.includes(pred.typekeywords)) {
// slugKeywordPresent = true;
// }
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/core/deepCatalogContains.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { IArcGISContext } from "../types/IArcGISContext";
import { getProp } from "../objects/get-prop";
import { getEntityTypeFromType } from "../search/_internal/getEntityTypeFromType";
import { IHubCatalog } from "../search/types/IHubCatalog";
import { IContainsResponse, IDeepCatalogInfo } from "../search/types/types";
import { deepContains, pathToCatalogInfo } from "./_internal/deepContains";
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/core/fetchHubEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { fetchHubGroup } from "../groups/HubGroups";
import { fetchInitiativeTemplate } from "../initiative-templates/fetch";
import { fetchSurvey } from "../surveys/fetch";
import { fetchEvent } from "../events/fetch";
import { convertUserToHubUser, fetchHubUser } from "../users";
import { fetchHubUser } from "../users";
import { fetchOrganization } from "../org/fetch";
import { fetchHubChannel } from "../channels/fetch";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { IArcGISContext } from "../../../../types/IArcGISContext";
import { getWellKnownCatalog } from "../../../../search/wellKnownCatalog";
import {
IUiSchema,
UiSchemaMessageTypes,
UiSchemaRuleEffects,
} from "../../types";
import { IUiSchema, UiSchemaRuleEffects } from "../../types";
import { IEventGalleryCardEditorOptions } from "../EditorOptions";
import { fetchCategoriesUiSchemaElement } from "../fetchCategoriesUiSchemaElement";
import { getTagItems } from "../getTagItems";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export async function getCardEditorSchemas(
let uiSchema;
let schemaPromise;
let uiSchemaPromise;
// defaults is used below... but maybe in a closure?
// tslint:disable-next-line:no-unused-variable
let defaults;

switch (cardType) {
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/core/schemas/internal/getTagItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ISearchOptions, searchItems } from "@esri/arcgis-rest-portal";

import { IHubRequestOptions } from "../../../hub-types";
import { IUiSchemaComboboxItem } from "../types";
import { EntityEditorOptions } from "./EditorOptions";
/**
* Fetch the entity's org tags (limited to the top 200),
* merge with any configured on the entity itself, and convert
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/core/schemas/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { JSONSchema } from "json-schema-typed";
import Ajv from "ajv";

import { ProjectEditorTypes } from "../../projects/_internal/ProjectSchema";
import { InitiativeEditorTypes } from "../../initiatives/_internal/InitiativeSchema";
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/discussions/_internal/computeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { IModel } from "../../hub-types";

import { IHubDiscussion } from "../../core";

import { isDiscussable } from "../utils";
import { computeItemProps } from "../../core/_internal/computeItemProps";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ function validateOptions(options: IFetchDownloadFileOptions) {
* @returns a download api url that can be polled
*/
function getDownloadApiRequestUrl(options: IFetchDownloadFileOptions) {
const { entity, format, context, layers, geometry, where, updateCache } =
options;
const { entity, format, context, layers, geometry, where } = options;

const searchParams = new URLSearchParams({
redirect: "false", // Needed to get the download URL instead of the file itself
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IHubEditableContent } from "../../../core/types/IHubEditableContent";
import { IDynamicDownloadFormat, ServiceDownloadFormat } from "../../types";
import { IDynamicDownloadFormat } from "../../types";
import { CreateReplicaFormat, CREATE_REPLICA_FORMATS } from "../_types";

/**
Expand Down
6 changes: 1 addition & 5 deletions packages/common/src/downloads/_internal/getDownloadFlow.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
DownloadFlowType,
IHubEditableContent,
IServiceExtendedProps,
} from "../../core";
import { DownloadFlowType, IHubEditableContent } from "../../core";
import { getProp } from "../../objects/get-prop";
import { canUseCreateReplica } from "../canUseCreateReplica";
import { canUseHubDownloadSystem } from "../canUseHubDownloadSystem";
Expand Down
5 changes: 1 addition & 4 deletions packages/common/src/downloads/getHubDownloadApiFormats.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { getCreateReplicaFormats } from "./_internal/format-fetchers/getCreateReplicaFormats";
import { getPagingJobFormats } from "./_internal/format-fetchers/getPagingJobFormats";
import { IDynamicDownloadFormat } from "./types";
import {
IHubEditableContent,
IServiceExtendedProps,
} from "../core/types/IHubEditableContent";
import { IHubEditableContent } from "../core/types/IHubEditableContent";
import { canUseCreateReplica } from "./canUseCreateReplica";
import { canUseHubDownloadSystem } from "./canUseHubDownloadSystem";
import { getFgdbJobFormats } from "./_internal/format-fetchers/getFgdbJobFormats";
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/events/_internal/EventUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { HubEventAttendanceType, HubEventCapacityType } from "../types";
import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent";
import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";
import { getWellKnownCatalog } from "../../search/wellKnownCatalog";
import { buildReferencedContentSchema } from "./buildReferencedContentSchema";
import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement";
import { getEntityThumbnailUrl } from "../../core/getEntityThumbnailUrl";
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/events/_internal/PropertyMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
mapEntityToStore,
mapStoreToEntity,
} from "../../core/_internal/PropertyMapper";
import { HubActionLink } from "../../core/types/ActionLinks";
import { IHubEvent } from "../../core/types/IHubEvent";
import { SettableAccessLevel } from "../../core/types/types";
import { cloneObject } from "../../util";
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/groups/HubGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
createGroup,
updateGroup,
protectGroup,
unprotectGroup,
} from "@esri/arcgis-rest-portal";
import { IRequestOptions } from "@esri/arcgis-rest-request";
import { IHubGroup } from "../core/types/IHubGroup";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export const buildDefaults = async (
options: EntityEditorOptions,
context: IArcGISContext
): Promise<IConfigurationValues> => {
const { name } = options;
return {
...getWellKnownGroup("hubFollowersGroup", context),
};
Expand Down
2 changes: 0 additions & 2 deletions packages/common/src/groups/_internal/GroupUiSchemaSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IUiSchema, UiSchemaRuleEffects } from "../../core";
import type { IArcGISContext } from "../../types/IArcGISContext";
import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions";
import { IHubGroup } from "../../core";

/**
* @private
Expand All @@ -14,7 +13,6 @@ export const buildUiSchema = async (
options: EntityEditorOptions,
context: IArcGISContext
): Promise<IUiSchema> => {
const entity = options as IHubGroup;
return {
type: "Layout",
elements: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { UserSession } from "@esri/arcgis-rest-auth";
import { IRequestOptions } from "@esri/arcgis-rest-request";
import { IHubInitiativeTemplate } from "../../core";
import { isDiscussable } from "../../discussions";
import { processEntityFeatures } from "../../permissions/_internal/processEntityFeatures";
import { getItemThumbnailUrl } from "../../resources";
import { IModel } from "../../hub-types";
Expand Down
12 changes: 2 additions & 10 deletions packages/common/src/initiative-templates/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@ import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
// Note - we separate these imports so we can cleanly spy on things in tests
import { createModel, getModel, updateModel } from "../models";
import { constructSlug } from "../items/slugs";
import {
IPortal,
IUserItemOptions,
removeItem,
} from "@esri/arcgis-rest-portal";
import { IUserItemOptions, removeItem } from "@esri/arcgis-rest-portal";
import { PropertyMapper } from "../core/_internal/PropertyMapper";
import {
IHubInitiativeTemplate,
IHubInitiativeTemplateEditor,
} from "../core/types/IHubInitiativeTemplate";
import { IHubInitiativeTemplate } from "../core/types/IHubInitiativeTemplate";
import {
DEFAULT_INITIATIVE_TEMPLATE,
DEFAULT_INITIATIVE_TEMPLATE_MODEL,
Expand All @@ -24,7 +17,6 @@ import { setDiscussableKeyword } from "../discussions";
import { IModel } from "../hub-types";
import { ensureUniqueEntitySlug } from "../items/_internal/ensureUniqueEntitySlug";
import { IHubItemEntity } from "../core";
import { editorToEntity } from "../core/schemas/internal/metrics/editorToEntity";

/**
* @private
Expand Down
11 changes: 2 additions & 9 deletions packages/common/src/initiative-templates/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@ import { IRequestOptions } from "@esri/arcgis-rest-request";
import { getItem, IItem } from "@esri/arcgis-rest-portal";

import { getFamily } from "../content/get-family";
import {
deriveLocationFromItem,
getHubRelativeUrl,
} from "../content/_internal/internalContentUtils";
import { deriveLocationFromItem } from "../content/_internal/internalContentUtils";
import { IHubInitiativeTemplate } from "../core/types";
import { PropertyMapper } from "../core/_internal/PropertyMapper";
import { getItemBySlug } from "../items/slugs";

import { fetchModelFromItem } from "../models";
import { IHubSearchResult } from "../search";
import { IHubRequestOptions, IModel } from "../hub-types";
import { isGuid, mapBy } from "../utils";
import { isGuid } from "../utils";
import { computeProps } from "./_internal/computeProps";
import { getPropertyMap } from "./_internal/getPropertyMap";
import { getItemThumbnailUrl } from "../resources/get-item-thumbnail-url";
import { getItemHomeUrl } from "../urls/get-item-home-url";
import { getItemIdentifier } from "../items";
import { getRelativeWorkspaceUrl } from "../core/getRelativeWorkspaceUrl";
import { computeLinks } from "./_internal/computeLinks";

export async function fetchInitiativeTemplate(
Expand Down
2 changes: 0 additions & 2 deletions packages/common/src/initiatives/HubInitiative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ import {
} from "../core";
import { IEditorConfig } from "../core/schemas/types";
import { enrichEntity } from "../core/enrichEntity";
import { IGroup } from "@esri/arcgis-rest-types";
import { getProp, getWithDefault } from "../objects";
import { upsertResource } from "../resources/upsertResource";
import { doesResourceExist } from "../resources/doesResourceExist";
import { removeResource } from "../resources/removeResource";
import { metricToEditor } from "../metrics/metricToEditor";
import { getGroup } from "@esri/arcgis-rest-portal";
import { MembershipAccess } from "../core/types";
import { convertGroupToHubGroup } from "../groups/_internal/convertGroupToHubGroup";
import { getEditorSlug } from "../core/_internal/getEditorSlug";

Expand Down
Loading