Skip to content

Commit

Permalink
feat: add autoformatting/linting recommendations to vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Jan 7, 2025
1 parent cfa96da commit 9504c16
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .vscode.recommended/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
14 changes: 14 additions & 0 deletions .vscode.recommended/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"eslint.options": {
"extensions": [".js", ".ts"]
},
"eslint.run": "onSave",
"eslint.validate": ["javascript", "typescript"],
"files.insertFinalNewline": true,
"html.validate.scripts": false,
"html.validate.styles": false,
"javascript.validate.enable": false
}
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ again.
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.
information on using pull requests.

## Setup: VSCode

Copy the `.vscode.recommended` folder into `.vscode` and edit the contents to your liking.

Make sure to go to the `Extensions` tab and install the recommended extensions!
43 changes: 33 additions & 10 deletions client/src/www/shared/error_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,36 @@ import {Integration as SentryIntegration} from '@sentry/types';
export type Tags = {[id: string]: string | boolean | number};

export interface OutlineErrorReporter {
report(userFeedback: string, feedbackCategory: string, userEmail?: string, tags?: Tags): Promise<void>;
report(
userFeedback: string,
feedbackCategory: string,
userEmail?: string,
tags?: Tags
): Promise<void>;
}

export class SentryErrorReporter implements OutlineErrorReporter {
constructor(appVersion: string, dsn: string, private tags: Tags) {
constructor(
appVersion: string,
dsn: string,
private tags: Tags
) {
if (dsn) {
Sentry.init({dsn, release: appVersion, integrations: getSentryBrowserIntegrations});
Sentry.init({
dsn,
release: appVersion,
integrations: getSentryBrowserIntegrations,
});
}
this.setUpUnhandledRejectionListener();
}

async report(userFeedback: string, feedbackCategory: string, userEmail?: string, tags?: Tags): Promise<void> {
async report(
userFeedback: string,
feedbackCategory: string,
userEmail?: string,
tags?: Tags
): Promise<void> {
const combinedTags = {...this.tags, ...tags};
Sentry.captureEvent({
message: userFeedback,
Expand Down Expand Up @@ -57,18 +75,23 @@ export class SentryErrorReporter implements OutlineErrorReporter {
// Chrome is the only browser that supports the unhandledrejection event.
// This is fine for Android, but will not work in iOS.
const unhandledRejection = 'unhandledrejection';
window.addEventListener(unhandledRejection, (event: PromiseRejectionEvent) => {
const reason = event.reason;
const msg = reason.stack ? reason.stack : reason;
Sentry.addBreadcrumb({message: msg, category: unhandledRejection});
});
window.addEventListener(
unhandledRejection,
(event: PromiseRejectionEvent) => {
const reason = event.reason;
const msg = reason.stack ? reason.stack : reason;
Sentry.addBreadcrumb({message: msg, category: unhandledRejection});
}
);
}
}

// Returns a list of Sentry browser integrations that maintains the default integrations,
// but replaces the Breadcrumbs integration with a custom one that only collects console statements.
// See https://docs.sentry.io/platforms/javascript/configuration/integrations/default/
export function getSentryBrowserIntegrations(defaultIntegrations: SentryIntegration[]): SentryIntegration[] {
export function getSentryBrowserIntegrations(
defaultIntegrations: SentryIntegration[]
): SentryIntegration[] {
const integrations = defaultIntegrations.filter(integration => {
return integration.name !== 'Breadcrumbs';
});
Expand Down

0 comments on commit 9504c16

Please sign in to comment.