Skip to content

Commit

Permalink
Update naming convention (#312)
Browse files Browse the repository at this point in the history
* chore: update naming convention to include X-bla or x-bla

* chore: remove excludes
  • Loading branch information
jkoenig134 authored Nov 14, 2024
1 parent 79d6366 commit b218207
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
34 changes: 34 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,40 @@
{
"assertFunctionNames": ["expect", "*.executeTests", "validateSchema"]
}
],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "default",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow"
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "enumMember",
"format": ["PascalCase"]
},
{
"selector": "classProperty",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow"
},
{
"selector": "property",
"format": null,
"custom": {
"regex": "^(@type|@version|@context|(\\$?[a-z0-9]+)([A-Z][a-z0-9]*)*)(\\.(@type|@version|@context|[a-z0-9]+([A-Z][a-z0-9]*)*))*|[xX]-[a-zA-Z]+(-[a-zA-Z]+)*$",
"match": true
}
}
]
}
}
2 changes: 1 addition & 1 deletion packages/sdk/src/ConnectorClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ConnectorClient {
const axiosInstance = axios.create({
baseURL: config.baseUrl,
headers: {
"X-API-KEY": config.apiKey // eslint-disable-line @typescript-eslint/naming-convention
"X-API-KEY": config.apiKey
},
httpAgent: config.httpAgent,
httpsAgent: config.httpsAgent,
Expand Down
1 change: 0 additions & 1 deletion src/modules/webhooks/WebhooksModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export default class WebhooksModule extends ConnectorRuntimeModule<WebhooksModul
let headers = webhook.target.headers;

const correlationId = correlator.getId();
// eslint-disable-next-line @typescript-eslint/naming-convention
if (correlationId) headers = { ...headers, "x-correlation-id": correlationId };

const response = await this.axios.post(url, payload, { headers });
Expand Down
5 changes: 1 addition & 4 deletions test/correlationId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ describe("test the correlation ids", () => {
},
peer: account2Address
},
// eslint-disable-next-line @typescript-eslint/naming-convention
{ headers: { "x-correlation-id": customCorrelationId } }
);

await connectorClient1._eventBus?.waitForEvent("consumption.outgoingRequestCreated", (event: any) => {
return event.headers["x-correlation-id"] === customCorrelationId;
});
await connectorClient1._eventBus?.waitForEvent("consumption.outgoingRequestCreated", (event: any) => event.headers["x-correlation-id"] === customCorrelationId);
});
});
6 changes: 1 addition & 5 deletions test/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ beforeAll(async () => {
axiosClient = axios.create({
baseURL: baseUrl,
validateStatus: (_) => true,
// eslint-disable-next-line @typescript-eslint/naming-convention
headers: { "X-API-KEY": launcher.apiKey }
});
}, getTimeout(30000));
Expand All @@ -20,10 +19,7 @@ afterAll(() => launcher.stop());

describe("Errors", () => {
test("http error 401", async () => {
const response = await axiosClient.get<any>("/api/v2/Files", {
// eslint-disable-next-line @typescript-eslint/naming-convention
headers: { "X-API-KEY": "invalid" }
});
const response = await axiosClient.get<any>("/api/v2/Files", { headers: { "X-API-KEY": "invalid" } });
expect(response.status).toBe(401);
validateSchema(ValidationSchema.Error, response.data.error);
});
Expand Down

0 comments on commit b218207

Please sign in to comment.