Skip to content
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

Drop unused code #5067

Merged
merged 7 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion src/analysis/analysisVisitors/renderersAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { PipelineFlavor } from "@/pageEditor/pageEditorTypes";

export const MULTIPLE_RENDERERS_ERROR_MESSAGE =
"A panel can only have one renderer. There are one or more other renderers configured for this extension.";
export const RENDERER_MUST_BE_LAST_BLOCK_ERROR_MESSAGE =
const RENDERER_MUST_BE_LAST_BLOCK_ERROR_MESSAGE =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This export could be useful!"

If/when it is, re-exporting it takes seconds

"A renderer must be the last brick.";

class RenderersAnalysis extends AnalysisVisitorWithResolvedBlocks {
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/analysisVisitors/varAnalysis/varMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type ExistenceNode = {
* @param selfExistence Existence of the current node
* @param allowAnyChild Whether the current node allows any child (i.e. doesn't have a strict schema)
*/
export function createNode(
function createNode(
selfExistence: VarExistence,
allowAnyChild = false
): ExistenceNode {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/RequireAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type RequireAuthProps = {
/**
* Hook to determine authentication status. Authentication can be via native PixieBrix token, or partner Bearer JWT.
*/
export const useRequiredAuth = () => {
const useRequiredAuth = () => {
const dispatch = useDispatch();
const hasCachedLoggedIn = useSelector(selectIsLoggedIn);
const { hasToken, tokenLoading, tokenError } = useLinkState();
Expand Down
2 changes: 1 addition & 1 deletion src/auth/authUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { type Me } from "@/types/contract";
import { type UserDataUpdate, type AuthState } from "@/auth/authTypes";
import { type UUID } from "@/core";

export function selectOrganizations(
function selectOrganizations(
organizationMemberships: Me["organization_memberships"]
): AuthState["organizations"] {
if (organizationMemberships == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/useRequiredPartnerAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const PARTNER_MAP = new Map<string, Set<RegistryId>>([
],
]);

export type RequiredPartnerState = {
type RequiredPartnerState = {
/**
* True if the user's is a partner account.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/background/contextMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const MENU_PREFIX = "pixiebrix-";
// >= 1 seconds because it also waits for the content script to be ready
const CONTEXT_SCRIPT_INSTALL_MS = 5000;

export type SelectionMenuOptions = {
type SelectionMenuOptions = {
extensionId: UUID;
title: string;
contexts: Menus.ContextType[];
Expand Down
4 changes: 2 additions & 2 deletions src/background/dataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import { type ManualStorageKey, readStorage, setStorage } from "@/chrome";
import { type JsonObject } from "type-fest";

export const LOCAL_DATA_STORE = "LOCAL_DATA_STORE" as ManualStorageKey;
export const KEY_PREFIX = "@@";
const LOCAL_DATA_STORE = "LOCAL_DATA_STORE" as ManualStorageKey;
const KEY_PREFIX = "@@";

export async function getRecord(primaryKey: string): Promise<unknown> {
const data = await readStorage<Record<string, unknown>>(LOCAL_DATA_STORE, {});
Expand Down
4 changes: 2 additions & 2 deletions src/background/externalProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ import {

type ChromeMessageSender = chrome.runtime.MessageSender;

export const MESSAGE_PREFIX = "@@pixiebrix/background/";
const MESSAGE_PREFIX = "@@pixiebrix/background/";

const handlers = new Map<string, HandlerEntry>();

/**
* Return true if a message sender is either the extension itself, or an externally connectable page
* https://developer.chrome.com/extensions/security#sanitize
*/
export function allowBackgroundSender(
function allowBackgroundSender(
sender: ChromeMessageSender | Runtime.MessageSender
): boolean {
if (sender == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/background/partnerIntegrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import axios from "axios";
/**
* A principal on a remote service, e.g., an Automation Anywhere Control Room.
*/
export type PartnerPrincipal = {
type PartnerPrincipal = {
/**
* The hostname of the remote service, e.g., the Automation Anywhere Control Room.
*/
Expand Down
4 changes: 1 addition & 3 deletions src/background/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ async function proxyRequest<T>(

const UNAUTHORIZED_STATUS_CODES = new Set([401, 403]);

export function isAuthenticationError(
error: Pick<AxiosError, "response">
): boolean {
function isAuthenticationError(error: Pick<AxiosError, "response">): boolean {
// Response should be an object, but be defensive
if (error.response == null || !isObject(error.response)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/PipelineExpressionVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import PipelineVisitor, {
} from "./PipelineVisitor";
import { type DocumentElement } from "@/components/documentBuilder/documentBuilderTypes";

export type VisitDocumentElementArgs = {
type VisitDocumentElementArgs = {
position: BlockPosition;
blockConfig: BlockConfig;
element: DocumentElement;
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/PipelineVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type VisitPipelineExtra = {
*/
pipelinePropName?: string | undefined;
};
export type VisitRootPipelineExtra = {
type VisitRootPipelineExtra = {
extensionPointType: ExtensionPointType;
};

Expand Down
2 changes: 1 addition & 1 deletion src/blocks/effects/highlightText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const highlightId = validateRegistryId("@pixiebrix/html/highlight-text");
/**
* Recursively wrap text in an element and its children.
*/
export function wrapText({
function wrapText({
nodes,
pattern,
color,
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/effects/replaceText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function getTextNodes(roots: Node[]): Text[] {
/**
* Recursively replace text in an element and its children, without modifying the structure of the document.
*/
export function replaceText({
function replaceText({
nodes,
pattern,
replacement,
Expand Down
11 changes: 0 additions & 11 deletions src/blocks/readers/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ export function registerFactory(readerType: string, read: Read): void {
_readerFactories.set(readerType, read);
}

export function makeRead(
config: ReaderTypeConfig
): (root: ReaderRoot) => Promise<ReaderOutput> {
const doRead = _readerFactories.get(config.type);
if (!doRead) {
throw new Error(`Reader type ${config.type} not implemented`);
}

return async (root: ReaderRoot) => doRead(config, root);
}

export function readerFactory(component: unknown): IReader {
validateReaderDefinition(component);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type FrameworkOption = {
detected?: FrameworkMeta;
};

export const readerOptions: FrameworkOption[] = [
const readerOptions: FrameworkOption[] = [
{ value: "react", label: "React" },
{
// XXX: check if this needs to be vue or vuejs
Expand Down
6 changes: 2 additions & 4 deletions src/blocks/transformers/component/TableReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import {
import { findSingleElement } from "@/utils/requireSingleElement";
import { lowerCase } from "lodash";

export const TABLE_READER_ID = validateRegistryId("@pixiebrix/table-reader");
export const TABLE_READER_ALL_ID = validateRegistryId(
"@pixiebrix/table-reader-all"
);
const TABLE_READER_ID = validateRegistryId("@pixiebrix/table-reader");
const TABLE_READER_ALL_ID = validateRegistryId("@pixiebrix/table-reader-all");

export class TableReader extends Transformer {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { type UnknownObject } from "@/types";
* @see https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API
* @since 1.4.10
*/
export type URLPattern = string | URLPatternInit;
type URLPattern = string | URLPatternInit;

/**
* An availability rule. For a rule to match, there must be match from each of the provided entries.
Expand Down
2 changes: 2 additions & 0 deletions src/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type ReduxStorageKey = string & {
_reduxStorageKeyBrand: never;
};

// Used only in the app
export function setChromeExtensionId(extensionId = ""): void {
forbidContext("extension");

Expand All @@ -52,6 +53,7 @@ export function setChromeExtensionId(extensionId = ""): void {
}
}

// Used only in the app
export function getChromeExtensionId(): string {
forbidContext("extension");

Expand Down
5 changes: 1 addition & 4 deletions src/components/BrickIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ import { type MarketplaceListing } from "@/types/contract";
import getType from "@/runtime/getType";
import { type BlockType } from "@/runtime/runtimeTypes";

export function getDefaultBrickIcon(
brick: IBrick,
blockType: BlockType
): IconProp {
function getDefaultBrickIcon(brick: IBrick, blockType: BlockType): IconProp {
if ("schema" in brick) {
return faCloud;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const initialModalState: ModalContextProps = {
},
};

export const ModalContext = createContext<ModalContextProps>(initialModalState);
const ModalContext = createContext<ModalContextProps>(initialModalState);

const ConfirmationModal: React.FunctionComponent<
ModalProps & {
Expand Down
59 changes: 0 additions & 59 deletions src/components/ServiceSelector.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/addBlockModal/BlockGridItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Alert from "@/components/Alert";

export const BLOCK_ITEM_FIXED_HEIGHT_PX = 89;

export type BlockItemProps = {
type BlockItemProps = {
block: BlockResult;
onSelect: () => void;
onShowDetail: () => void;
Expand Down
61 changes: 0 additions & 61 deletions src/components/addBlockModal/QuickAdd.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/documentBuilder/documentBuilderTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type DocumentElement<
children?: DocumentElement[];
};

export type ListDocumentConfig = {
type ListDocumentConfig = {
array: Expression;
elementKey?: string;
element: DeferExpression<DocumentElement>;
Expand All @@ -69,7 +69,7 @@ export type PipelineDocumentConfig = {
label: string;
pipeline: PipelineExpression;
};
export type PipelineDocumentElement = DocumentElement<
type PipelineDocumentElement = DocumentElement<
"pipeline",
PipelineDocumentConfig
>;
Expand Down
Loading