Skip to content

Commit 1e04d3d

Browse files
committed
Enforce strict ESLint block formatting
1 parent 92c4599 commit 1e04d3d

38 files changed

Lines changed: 1171 additions & 183 deletions

eslint.config.mjs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import eslint from "@eslint/js";
2+
import stylistic from "@stylistic/eslint-plugin";
23
import { defineConfig } from "eslint/config";
34
import eslintConfigPrettier from "eslint-config-prettier";
45
import vitest from "@vitest/eslint-plugin";
56
import tseslint from "typescript-eslint";
67

78
export default defineConfig(
8-
{ ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/", "**/expo-plugin/", "**/react-native.config.*"] },
9+
{
10+
ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/", "**/expo-plugin/", "**/react-native.config.*"]
11+
},
912
eslint.configs.recommended,
1013
{
1114
extends: tseslint.configs.recommendedTypeChecked,
@@ -27,11 +30,63 @@ export default defineConfig(
2730
"@typescript-eslint/no-duplicate-type-constituents": "off",
2831
"@typescript-eslint/restrict-plus-operands": "off",
2932
"@typescript-eslint/no-unused-vars": "error",
30-
"@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true }],
31-
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }]
33+
"@typescript-eslint/no-unused-expressions": [
34+
"error",
35+
{
36+
allowShortCircuit: true
37+
}
38+
],
39+
"@typescript-eslint/no-misused-promises": [
40+
"error",
41+
{
42+
checksVoidReturn: false
43+
}
44+
]
45+
}
46+
},
47+
{
48+
files: ["scripts/**/*.mjs"],
49+
...tseslint.configs.disableTypeChecked,
50+
languageOptions: {
51+
...tseslint.configs.disableTypeChecked.languageOptions,
52+
globals: {
53+
console: "readonly",
54+
process: "readonly"
55+
}
3256
}
3357
},
3458
eslintConfigPrettier,
59+
{
60+
plugins: {
61+
"@stylistic": stylistic
62+
},
63+
rules: {
64+
curly: ["error", "all"],
65+
"@stylistic/object-curly-newline": [
66+
"error",
67+
{
68+
ObjectExpression: {
69+
minProperties: 1
70+
}
71+
}
72+
],
73+
"@stylistic/brace-style": [
74+
"error",
75+
"1tbs",
76+
{
77+
allowSingleLine: false
78+
}
79+
],
80+
"padding-line-between-statements": [
81+
"error",
82+
{
83+
blankLine: "always",
84+
prev: "block-like",
85+
next: ["if", "while", "for", "do"]
86+
}
87+
]
88+
}
89+
},
3590
{
3691
files: ["**/test/**/*.ts"],
3792
plugins: vitest.configs.recommended.plugins,

package-lock.json

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
],
3131
"devDependencies": {
3232
"@eslint/js": "^10.0.1",
33+
"@stylistic/eslint-plugin": "^5.10.0",
3334
"@vitest/eslint-plugin": "^1.6.19",
3435
"eslint": "^10.4.1",
3536
"eslint-config-prettier": "^10.1.8",

packages/angularjs/src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ angular
1010
"$ExceptionlessClient",
1111
($location: ng.ILocationService, $q: ng.IQService, $ExceptionlessClient: BrowserExceptionlessClient) => {
1212
return {
13-
responseError: function responseError(response: ng.IHttpResponse<{ Message?: string }>) {
13+
responseError: function responseError(
14+
response: ng.IHttpResponse<{
15+
Message?: string;
16+
}>
17+
) {
1418
if (response.status === 404) {
1519
void $ExceptionlessClient.submitNotFound(response.config.url);
1620
} else if (response.status !== 401) {
@@ -48,7 +52,13 @@ angular
4852
function decorateRegularCall(property: string, logLevel: string) {
4953
const previousFn = $delegate[property];
5054
return ($delegate[property] = (...args: string[]) => {
51-
if ((angular as { mock?: unknown }).mock) {
55+
if (
56+
(
57+
angular as {
58+
mock?: unknown;
59+
}
60+
).mock
61+
) {
5262
$delegate[property].logs = [];
5363
}
5464

packages/browser/src/plugins/BrowserErrorPlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export class BrowserErrorPlugin implements IEventPlugin {
5959

6060
const items: ParameterInfo[] = [];
6161
for (const param of params) {
62-
items.push({ name: param });
62+
items.push({
63+
name: param
64+
});
6365
}
6466

6567
return items;

packages/browser/src/plugins/BrowserGlobalHandlerPlugin.ts

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@ import { ExceptionlessClient, IEventPlugin, PluginContext, toError } from "@exce
22

33
declare let $: (document: Document) => {
44
ajaxError: {
5-
(document: (event: Event, xhr: { responseText: string; status: number }, settings: { data: unknown; url: string }, error: string) => void): void;
5+
(
6+
document: (
7+
event: Event,
8+
xhr: {
9+
responseText: string;
10+
status: number;
11+
},
12+
settings: {
13+
data: unknown;
14+
url: string;
15+
},
16+
error: string
17+
) => void
18+
): void;
619
};
720
};
821

@@ -29,7 +42,13 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
2942
if (!(reason instanceof Error)) {
3043
try {
3144
// Check for reason in legacy CustomEvents (https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent)
32-
const detailReason = (<{ detail?: { reason: string } }>event).detail?.reason;
45+
const detailReason = (<
46+
{
47+
detail?: {
48+
reason: string;
49+
};
50+
}
51+
>event).detail?.reason;
3352
if (detailReason) {
3453
reason = detailReason;
3554
}
@@ -54,21 +73,34 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
5473
});
5574

5675
if (typeof $ !== "undefined" && $(document)) {
57-
$(document).ajaxError((_: Event, xhr: { responseText: string; status: number }, settings: { data: unknown; url: string }, error: string) => {
58-
if (xhr.status === 404) {
59-
// TODO: Handle async
60-
void this._client?.submitNotFound(settings.url);
61-
} else if (xhr.status !== 401) {
62-
// TODO: Handle async
63-
void this._client
64-
?.createUnhandledException(toError(error), "JQuery.ajaxError")
65-
.setSource(settings.url)
66-
.setProperty("status", xhr.status)
67-
.setProperty("request", settings.data)
68-
.setProperty("response", xhr.responseText?.slice(0, 1024))
69-
.submit();
76+
$(document).ajaxError(
77+
(
78+
_: Event,
79+
xhr: {
80+
responseText: string;
81+
status: number;
82+
},
83+
settings: {
84+
data: unknown;
85+
url: string;
86+
},
87+
error: string
88+
) => {
89+
if (xhr.status === 404) {
90+
// TODO: Handle async
91+
void this._client?.submitNotFound(settings.url);
92+
} else if (xhr.status !== 401) {
93+
// TODO: Handle async
94+
void this._client
95+
?.createUnhandledException(toError(error), "JQuery.ajaxError")
96+
.setSource(settings.url)
97+
.setProperty("status", xhr.status)
98+
.setProperty("request", settings.data)
99+
.setProperty("response", xhr.responseText?.slice(0, 1024))
100+
.submit();
101+
}
70102
}
71-
});
103+
);
72104
}
73105

74106
return Promise.resolve();
@@ -90,6 +122,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
90122
if (errorName) {
91123
name = errorName;
92124
}
125+
93126
if (errorMessage) {
94127
msg = errorMessage;
95128
}

packages/browser/test/plugins/BrowserErrorPlugin.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ describe("BrowserErrorPlugin", () => {
5656
const error = {
5757
someProperty: "Test"
5858
};
59-
await processError(new Error("Error With Cause", { cause: error }));
59+
await processError(
60+
new Error("Error With Cause", {
61+
cause: error
62+
})
63+
);
6064
const additionalData = getAdditionalData(context.event);
6165
expect(additionalData).not.toBeNull();
6266
expect(additionalData?.cause).toStrictEqual(error);

packages/browser/test/plugins/BrowserIgnoreExtensionErrorsPlugin.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ describe("BrowserIgnoreExtensionErrorsPlugin", () => {
2222
const eventContext = new EventContext();
2323
eventContext.setException(error);
2424

25-
const context = new EventPluginContext(client, { type: "error" }, eventContext);
25+
const context = new EventPluginContext(
26+
client,
27+
{
28+
type: "error"
29+
},
30+
eventContext
31+
);
2632

2733
await plugin.run(context);
2834
return context;

packages/core/src/EventBuilder.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export class EventBuilder {
8787
public setUserIdentity(identity: string): EventBuilder;
8888
public setUserIdentity(identity: string, name: string): EventBuilder;
8989
public setUserIdentity(userInfoOrIdentity: UserInfo | string, name?: string): EventBuilder {
90-
const userInfo = typeof userInfoOrIdentity !== "string" ? userInfoOrIdentity : { identity: userInfoOrIdentity, name };
90+
const userInfo =
91+
typeof userInfoOrIdentity !== "string"
92+
? userInfoOrIdentity
93+
: {
94+
identity: userInfoOrIdentity,
95+
name
96+
};
9197
if (!userInfo || (!userInfo.identity && !userInfo.name)) {
9298
return this;
9399
}
@@ -121,7 +127,9 @@ export class EventBuilder {
121127
*/
122128
public setManualStackingInfo(signatureData: Record<string, string>, title?: string): EventBuilder {
123129
if (signatureData) {
124-
const stack: ManualStackingInfo = { signature_data: signatureData };
130+
const stack: ManualStackingInfo = {
131+
signature_data: signatureData
132+
};
125133
if (title) {
126134
stack.title = title;
127135
}
@@ -139,7 +147,9 @@ export class EventBuilder {
139147
*/
140148
public setManualStackingKey(manualStackingKey: string, title?: string): EventBuilder {
141149
if (manualStackingKey) {
142-
const data = { ManualStackingKey: manualStackingKey };
150+
const data = {
151+
ManualStackingKey: manualStackingKey
152+
};
143153
this.setManualStackingInfo(data, title);
144154
}
145155

packages/core/src/ExceptionlessClient.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,13 @@ export class ExceptionlessClient {
195195
}
196196

197197
public createEvent(context?: EventContext): EventBuilder {
198-
return new EventBuilder({ date: new Date() }, this, context);
198+
return new EventBuilder(
199+
{
200+
date: new Date()
201+
},
202+
this,
203+
context
204+
);
199205
}
200206

201207
/**
@@ -264,7 +270,10 @@ export class ExceptionlessClient {
264270
return;
265271
}
266272

267-
const userDescription: UserDescription = { email_address: email, description };
273+
const userDescription: UserDescription = {
274+
email_address: email,
275+
description
276+
};
268277
const response = await this.config.services.submissionClient.submitUserDescription(referenceId, userDescription);
269278
if (!response.success) {
270279
this.config.services.log.error(`Failed to submit user email and description for event "${referenceId}": ${response.status} ${response.message}`);

0 commit comments

Comments
 (0)