Skip to content

Commit 93b09e1

Browse files
authored
Enforce strict ESLint block formatting (#185)
* Enforce strict ESLint block formatting * Trim incidental type formatting and test formatter stability * Run ESLint fixes in the documented formatting workflow * Remove ESLint policy tests and dedicated test wiring
1 parent 92c4599 commit 93b09e1

34 files changed

Lines changed: 961 additions & 155 deletions

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ npm test
3232
# Lint (ESLint + Prettier check)
3333
npm run lint
3434

35-
# Auto-format with Prettier
35+
# Auto-format with ESLint fixes followed by Prettier
3636
npm run format
3737

3838
# Clean all build outputs
@@ -107,7 +107,7 @@ All framework packages (`react`, `vue`, `angularjs`) depend on `browser`, which
107107

108108
### Style & Formatting
109109

110-
- Run `npm run format` (Prettier) to auto-format code
110+
- Run `npm run format` (ESLint fixes followed by Prettier) to auto-format code
111111
- Run `npm run lint` (ESLint + Prettier check) to verify
112112
- Match existing file style; minimize diffs
113113
- No code comments unless necessary—code should be self-explanatory

‎eslint.config.mjs‎

Lines changed: 47 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,52 @@ 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+
]
3245
}
3346
},
3447
eslintConfigPrettier,
48+
{
49+
plugins: {
50+
"@stylistic": stylistic
51+
},
52+
rules: {
53+
curly: ["error", "all"],
54+
"@stylistic/object-curly-newline": [
55+
"error",
56+
{
57+
ObjectExpression: {
58+
minProperties: 1
59+
}
60+
}
61+
],
62+
"@stylistic/brace-style": [
63+
"error",
64+
"1tbs",
65+
{
66+
allowSingleLine: false
67+
}
68+
],
69+
"padding-line-between-statements": [
70+
"error",
71+
{
72+
blankLine: "always",
73+
prev: "block-like",
74+
next: ["if", "while", "for", "do"]
75+
}
76+
]
77+
}
78+
},
3579
{
3680
files: ["**/test/**/*.ts"],
3781
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint:eslint": "eslint .",
1212
"lint:prettier": "prettier --check .",
1313
"lint:fix": "eslint . --fix",
14-
"format": "prettier --write .",
14+
"format": "npm run lint:fix && prettier --write .",
1515
"test": "vitest run",
1616
"test:watch": "vitest",
1717
"version": "npm --no-git-tag-version --workspaces=true version",
@@ -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/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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
9090
if (errorName) {
9191
name = errorName;
9292
}
93+
9394
if (errorMessage) {
9495
msg = errorMessage;
9596
}

‎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)