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

tidy warnings #7566

Merged
merged 1 commit into from
Jun 20, 2024
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
2 changes: 2 additions & 0 deletions packages/insomnia/src/common/markdown-to-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ marked.setOptions({
breaks: false,
pedantic: false,
smartypants: false,
headerIds: false,
mangle: false,
});

export const markdownToHTML = (input: string) => dompurify.sanitize(marked.parse(input));
8 changes: 4 additions & 4 deletions packages/insomnia/src/main.development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const _launchApp = async () => {
} else {
// Called when second instance launched with args (Windows/Linux)
app.on('second-instance', (_1, args) => {
console.log('Second instance listener received:', args.join('||'));
console.log('[main] Second instance listener received:', args.join('||'));
window = windowUtils.createWindowsAndReturnMain();
if (window) {
if (window.isMinimized()) {
Expand Down Expand Up @@ -229,16 +229,16 @@ async function _createModelInstances() {
const scratchpadProject = await models.project.getById(models.project.SCRATCHPAD_PROJECT_ID);
const scratchPad = await models.workspace.getById(models.workspace.SCRATCHPAD_WORKSPACE_ID);
if (!scratchpadProject) {
console.log('Initializing Scratch Pad Project');
console.log('[main] Initializing Scratch Pad Project');
await models.project.create({ _id: models.project.SCRATCHPAD_PROJECT_ID, name: getProductName(), remoteId: null, parentId: models.organization.SCRATCHPAD_ORGANIZATION_ID });
}

if (!scratchPad) {
console.log('Initializing Scratch Pad');
console.log('[main] Initializing Scratch Pad');
await models.workspace.create({ _id: models.workspace.SCRATCHPAD_WORKSPACE_ID, name: 'Scratch Pad', parentId: models.project.SCRATCHPAD_PROJECT_ID, scope: 'collection' });
}
} catch (err) {
console.warn('Failed to create default project. It probably already exists', err);
console.warn('[main] Failed to create default project. It probably already exists', err);
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/insomnia/src/main/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function backup() {
// skip if backup already exists at version path
const backupFiles = await readdir(versionPath);
if (backupFiles.length) {
console.log('Backup found at:', versionPath);
console.log('[main] Backup found at:', versionPath);
return;
}
const files = await readdir(dataPath);
Expand All @@ -46,9 +46,9 @@ export async function backup() {
await copyFile(path.join(dataPath, file), path.join(versionPath, file));
}
});
console.log('Exported backup to:', versionPath);
console.log('[main] Exported backup to:', versionPath);
} catch (err) {
console.log('Error exporting backup:', err);
console.log('[main] Error exporting backup:', err);
}
}

Expand All @@ -58,17 +58,17 @@ export async function restoreBackup(version: string) {
const versionPath = path.join(dataPath, 'backups', version);
const files = await readdir(versionPath);
if (!files.length) {
console.log('No backup found at:', versionPath);
console.log('[main] No backup found at:', versionPath);
return;
}
files.forEach(async (file: string) => {
if (file.endsWith('.db')) {
await copyFile(path.join(versionPath, file), path.join(dataPath, file));
}
});
console.log('Restored backup from:', versionPath);
console.log('[main] Restored backup from:', versionPath);
} catch (err) {
console.log('Error restoring backup:', err);
console.log('[main] Error restoring backup:', err);
}
electron.app.relaunch();
electron.app.exit();
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/main/network/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ const sendPayload = async (ws: WebSocket, options: { payload: string; requestId:
if (error) {
console.error(error);
} else {
console.log('Message sent');
console.log('[main] Message sent');
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/main/squirrel-startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function checkIfRestartNeeded() {
}

const cmd = process.argv[1];
console.log('processing squirrel command `%s`', cmd);
console.log('[main] processing squirrel command `%s`', cmd);
const target = path.basename(process.execPath);

switch (cmd) {
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/plugins/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function getThemeBlockCSS(block?: ThemeBlock) {
addVar(variable, rgb.string());
addVar(`${variable}-rgb`, rgb.array().join(', '));
} catch (err) {
console.log('Failed to parse theme color', value);
console.log('[theme] Failed to parse theme color', value);
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const main: Window['main'] = {
invariant(port, 'hiddenWindowPort is undefined');

port.onmessage = event => {
console.log('received result:', event.data);
console.log('[preload] received result:', event.data);
if (event.data.error) {
reject(new Error(event.data.error));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/sync/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class Store {
// Without the `await` here, the catch won't get called
value = await this._deserialize(ext, rawValue);
} catch (err) {
console.log('Failed to deserialize', rawValue.toString('base64'));
console.log('[sync] Failed to deserialize', rawValue.toString('base64'));
throw new Error(`Failed to deserialize key=${key} err=${err}`);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/insomnia/src/templating/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ export function render(
const renderMode = config.renderMode || RENDER_ALL;
return new Promise<string | null>(async (resolve, reject) => {
// NOTE: this is added as a breadcrumb because renderString sometimes hangs
const id = setTimeout(() => console.log('Warning: nunjucks failed to respond within 5 seconds'), 5000);
const id = setTimeout(() => console.log('[templating] Warning: nunjucks failed to respond within 5 seconds'), 5000);
const nj = await getNunjucks(renderMode, config.ignoreUndefinedEnvVariable);
nj?.renderString(text, templatingContext, (err: Error | null, result: any) => {
clearTimeout(id);
if (err) {
console.log('Error rendering template', err);
console.warn('[templating] Error rendering template', err);
const sanitizedMsg = err.message
.replace(/\(unknown path\)\s/, '')
.replace(/\[Line \d+, Column \d*]/, '')
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/auth-session-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function submitAuthCode(code: string) {
export function getLoginUrl() {
const publicKey = window.localStorage.getItem('insomnia.publicKey');
if (!publicKey) {
console.log('No public key found');
console.log('[auth] No public key found');
return '';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
tryToSetOption('lint', newValue);
}
} catch (err) {
console.log('Failed to set CodeMirror option', err.message);
console.log('[codemirror] Failed to set CodeMirror option', err.message);
}
onChange(doc.getValue() || '');
setOriginalCode(doc.getValue() || '');
Expand All @@ -516,7 +516,7 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
try {
codeMirror.current?.setOption(key, value);
} catch (err) {
console.log('Failed to set CodeMirror option', err.message, { key, value });
console.log('[codemirror] Failed to set CodeMirror option', err.message, { key, value });
}
};
useEffect(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/insomnia/src/ui/components/editable-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const EditableInput = ({
e.stopPropagation();
e.preventDefault();
if (clickTimeout !== null) {
console.log('click: timeout exists');
clearTimeout(clickTimeout);
}
// If timeout passes fire the single click
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export const KeyValueEditor: FC<Props> = ({
}

return (
<GridListItem className="flex outline-none bg-[--color-bg] flex-shrink-0 h-[--line-height-sm] items-center gap-2 px-2 data-[dragging]:opacity-50">
<GridListItem textValue={pair.name + '-' + pair.value} className="flex outline-none bg-[--color-bg] flex-shrink-0 h-[--line-height-sm] items-center gap-2 px-2 data-[dragging]:opacity-50">
<Button slot="drag" className="cursor-grab invisible p-2 w-5 flex focus-visible:bg-[--hl-sm] justify-center items-center flex-shrink-0">
<Icon icon="grip-vertical" className='w-2 text-[--hl]' />
</Button>
Expand Down Expand Up @@ -444,7 +444,7 @@ export const KeyValueEditor: FC<Props> = ({
}

return (
<GridListItem id={pair.id} className={`grid relative outline-none bg-[--color-bg] flex-shrink-0 h-[--line-height-sm] gap-2 px-2 data-[dragging]:opacity-50 ${showDescription ? '[grid-template-columns:max-content_1fr_1fr_1fr_max-content]' : '[grid-template-columns:max-content_1fr_1fr_max-content]'}`}>
<GridListItem id={pair.id} textValue={pair.name + '-' + pair.value} className={`grid relative outline-none bg-[--color-bg] flex-shrink-0 h-[--line-height-sm] gap-2 px-2 data-[dragging]:opacity-50 ${showDescription ? '[grid-template-columns:max-content_1fr_1fr_1fr_max-content]' : '[grid-template-columns:max-content_1fr_1fr_max-content]'}`}>
<Button slot="drag" className="cursor-grab p-2 w-5 flex focus-visible:bg-[--hl-sm] justify-center items-center flex-shrink-0">
<Icon icon="grip-vertical" className='w-2 text-[--hl]' />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const HistoryViewWrapperComponentFactory = ({ mockServer, mockRoute }: { mockSer
setLogs(res);
return;
}
console.log('Error: fetching logs from remote', { mockbinUrl, res });
console.log('[mock] Error: fetching logs from remote', { mockbinUrl, res });
} catch (e) {
// network erros will be managed by the upsert trigger, so we can ignore them here
console.log({ mockbinUrl, e });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const PasteCurlModal = ({ onHide, onImport, defaultValue }: ModalProps &
setReq(importedRequest);

} catch (error) {
console.log('error', error);
console.log('[importer] error', error);
setIsValid(false);
setReq({});
} finally {
Expand Down Expand Up @@ -59,7 +59,7 @@ export const PasteCurlModal = ({ onHide, onImport, defaultValue }: ModalProps &
setReq(importedRequest);

} catch (error) {
console.log('error', error);
console.log('[importer] error', error);
setIsValid(false);
setReq({});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const InsomniaEventStreamProvider: FC<PropsWithChildren> = ({ children })
setPresence(rows);
}
} catch (e) {
console.log('Error parsing response', e);
console.log('[sse] Error parsing response', e);
}
}
}
Expand Down Expand Up @@ -164,14 +164,14 @@ export const InsomniaEventStreamProvider: FC<PropsWithChildren> = ({ children })
});
}
} catch (e) {
console.log('Error parsing response from SSE', e);
console.log('[sse] Error parsing response from SSE', e);
}
});
return () => {
source.close();
};
} catch (e) {
console.log('ERROR', e);
console.log('[sse] ERROR', e);
return;
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/insomnia/src/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ try {
window.localStorage.setItem('hasUserLoggedInBefore', skipOnboarding.toString());
}
} catch (e) {
console.log('Failed to parse session data', e);
console.log('[onboarding] Failed to parse session data', e);
}

async function getInitialEntry() {
Expand Down Expand Up @@ -112,7 +112,7 @@ async function renderApp() {
session.encPrivateKey
);
} catch (e) {
console.log('Failed to parse session data', e);
console.log('[init] Failed to parse session data', e);
}
}

Expand Down Expand Up @@ -1140,7 +1140,6 @@ async function renderApp() {
if (bothHaveValueButNotEqual) {
// transforms /organization/:org_* to /organization/:org_id
const routeWithoutUUID = nextRoute.replace(/_[a-f0-9]{32}/g, '_id');
// console.log('Tracking page view', { name: routeWithoutUUID });
window.main.trackPageView({ name: routeWithoutUUID });
}

Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/routes/mock-route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const MockRouteRoute = () => {
if (typeof res === 'string') {
return '';
}
console.log('Error: invalid response from remote', { res, mockbinUrl });
console.log('[mock] Error: invalid response from remote', { res, mockbinUrl });
return 'Unexpected response, see console for details';
} catch (e) {
console.log(e);
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/routes/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async function syncOrganization(sessionId: string, accountId: string) {
localStorage.setItem(`${accountId}:user`, JSON.stringify(user));
localStorage.setItem(`${accountId}:currentPlan`, JSON.stringify(currentPlan));
} catch (error) {
console.log('Failed to load Organizations', error);
console.log('[organization] Failed to load Organizations', error);
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/insomnia/src/ui/routes/project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ interface TeamProject {

async function getAllTeamProjects(organizationId: string) {
const { id: sessionId } = await userSession.getOrCreate();
console.log('Fetching projects for team', organizationId);
if (!sessionId) {
return [];
}

console.log('[project] Fetching', organizationId);
const response = await insomniaFetch<{
data: {
id: string;
Expand Down Expand Up @@ -245,7 +245,7 @@ export const indexLoader: LoaderFunction = async ({ params }) => {
});
}
} catch (err) {
console.log('Could not fetch remote projects.');
console.log('[project] Could not fetch remote projects.');
}

// Check if the last visited project exists and redirect to it
Expand All @@ -262,7 +262,7 @@ export const indexLoader: LoaderFunction = async ({ params }) => {
const existingProject = await models.project.getById(match.params.projectId);

if (existingProject) {
console.log('Redirecting to last visited project', existingProject._id);
console.log('[project] Redirecting to last visited project', existingProject._id);
return redirect(`/organization/${match?.params.organizationId}/project/${existingProject._id}`);
}
}
Expand Down Expand Up @@ -534,7 +534,7 @@ const getLearningFeature = async (fallbackLearningFeature: LearningFeature) => {
});
window.localStorage.setItem('learning-feature-last-fetch', Date.now().toString());
} catch (err) {
console.log('Could not fetch learning feature data.');
console.log('[project] Could not fetch learning feature data.');
}
}
return learningFeature;
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/routes/request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export const sendAction: ActionFunction = async ({ request, params }) => {
return writeToDownloadPath(filePath, responsePatch, requestMeta, requestData.settings.maxHistoryResponses);
}
} catch (e) {
console.log('Failed to send request', e);
console.log('[request] Failed to send request', e);
window.main.completeExecutionStep({ requestId });
const url = new URL(request.url);
url.searchParams.set('error', e);
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/routes/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Root = () => {
try {
parsedUrl = new URL(url);
} catch (err) {
console.log('Invalid args, expected insomnia://x/y/z', url);
console.log('[deep-link] Invalid args, expected insomnia://x/y/z', url);
return;
}
let urlWithoutParams = url.substring(0, url.indexOf('?')) || url;
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/worker/spectral-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SpectralRunner {
return;
}
if (diagnostics) {
console.log('Received diagnostics for old task, ignoring');
console.log('[spectral] Received diagnostics for old task, ignoring');
} else {
console.error('Error while running diagnostics:', e.data);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/worker/spectral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const loadRuleset = async (rulesetPath: string) => {
cachedRuleset.path = rulesetPath;
cachedRuleset.ruleset = ruleset;
} catch (err) {
console.log('Error while parsing ruleset:', err);
console.log('[spectral] Error while parsing ruleset:', err);
}
}

Expand Down
Loading