Skip to content

Commit a1e5909

Browse files
NONE: Re-enable lint rules (#2587)
* NONE: Re-enable lint rules * Address feedback
1 parent 78c3ca4 commit a1e5909

File tree

7 files changed

+19
-21
lines changed

7 files changed

+19
-21
lines changed

.eslintrc.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@
115115
"@typescript-eslint/require-await": "off",
116116
"@typescript-eslint/await-thenable": "off",
117117
"@typescript-eslint/no-misused-promises": "off",
118-
"@typescript-eslint/no-explicit-any": "off"
118+
"@typescript-eslint/no-explicit-any": "off",
119+
"@typescript-eslint/no-unnecessary-condition": "off"
119120
}
120121
},
121122
{
@@ -124,7 +125,10 @@
124125
"src/jira/**",
125126
"src/models/**",
126127
"src/sync/**",
127-
"src/transforms/**"
128+
"src/transforms/**",
129+
"src/util/**",
130+
"src/sqs/**",
131+
"src/middleware/**"
128132
],
129133
"rules": {
130134
// To be removed later
@@ -133,13 +137,7 @@
133137
"@typescript-eslint/no-unsafe-member-access": "off",
134138
"@typescript-eslint/no-unsafe-return": "off",
135139
"@typescript-eslint/no-unsafe-call": "off",
136-
"@typescript-eslint/no-explicit-any": "off"
137-
}
138-
},
139-
{
140-
"files": ["src/**/*.ts", "test/**/*.ts"],
141-
"rules": {
142-
// TODO: Re-enable gradually
140+
"@typescript-eslint/no-explicit-any": "off",
143141
"@typescript-eslint/no-unnecessary-condition": "off"
144142
}
145143
}

src/config/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Transforms<T, K extends keyof T = keyof T> = {
2323
};
2424

2525
const transforms: Transforms<EnvVars> = {
26-
MICROS_ENV: (value?: string) => EnvironmentEnum[value || ""] as EnvironmentEnum || EnvironmentEnum.development,
26+
MICROS_ENV: (value?: string) => EnvironmentEnum[value || ""] as EnvironmentEnum | undefined || EnvironmentEnum.development,
2727
MICROS_GROUP: (value?: string) => value || "",
2828
NODE_ENV: () => nodeEnv,
2929
S3_DUMPS_BUCKET_NAME: (value?: string) => value ?? "",
@@ -40,7 +40,7 @@ const transforms: Transforms<EnvVars> = {
4040
if (!parsed) {
4141
return [];
4242
}
43-
if (parsed && !Array.isArray(parsed)) {
43+
if (!Array.isArray(parsed)) {
4444
return [parsed];
4545
}
4646
return parsed;

src/config/statsd.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export const elapsedTimeMetrics = (
9393
) => {
9494
const elapsedTimeInMs = hrtimer();
9595
const method = req.method;
96+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
9697
(req.log || logger).debug({
9798
method: req.method,
9899
path: req.path,
@@ -103,8 +104,9 @@ export const elapsedTimeMetrics = (
103104
res.once("finish", () => {
104105
const elapsedTime = elapsedTimeInMs();
105106
const statusCode = `${res.statusCode}`;
106-
const path = (req.baseUrl || "") + ((req.route as { path?: string; })?.path || "/*");
107+
const path = (req.baseUrl || "") + ((req.route as { path?: string; } | undefined)?.path || "/*");
107108
const tags = { path, method, statusCode };
109+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
108110
(req.log || logger).debug(`${method} request executed in ${elapsedTime} with status ${statusCode} path ${path}`);
109111

110112
//Count response time metric

src/rest/middleware/error/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const RestErrorHandler = (err: Error, req: Request, res: Response<ApiErro
3838

3939
const logErrorOrWarning = (err: Error, req: Request) => {
4040

41-
const httpStatus = parseInt(err["status"] as string ?? "") || parseInt(err["httpStatus"] as string ?? "") || 500;
41+
const httpStatus = parseInt(err["status"] as string | undefined ?? "") || parseInt(err["httpStatus"] as string| undefined ?? "") || 500;
4242
const extraInfo = {
4343
httpStatus,
4444
method: req.method,

src/services/micros/lifecycle.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import EventEmitter from "events";
44
import { getLogger } from "config/logger";
55

66
const logger = getLogger("micros.lifecycle");
7-
let client: Consumer;
7+
let client: Consumer | undefined;
88

99
// Create a single event emitter for all listeners
1010
const eventEmitter = new EventEmitter();
@@ -36,6 +36,8 @@ export const listenToMicrosLifecycle = (active: Callback, inactive: Callback): v
3636
}
3737
try {
3838
const lifecycleData: LifecycleData = JSON.parse(data.Body) as LifecycleData;
39+
// validate that the data has the required fields
40+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
3941
if (lifecycleData.Type === undefined || lifecycleData.Subject === undefined || lifecycleData.Message === undefined) {
4042
logger.error({ data }, "Lifecycle event missing required data, skipping.");
4143
return;

src/services/user-config-service.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const getRepoConfigFromGitHub = async (gitHubInstallationClient: GitHubInstallat
9494
/**
9595
* Iterates through environment patterns and returns true if any environment contains too many patterns to test against.
9696
*/
97-
const hasTooManyPatternsPerEnvironment = (config: Config): boolean => {
97+
const hasTooManyPatternsPerEnvironment = (config: Config | undefined): boolean => {
9898
const environmentMapping = config?.deployments?.environmentMapping;
9999
if (!environmentMapping) {
100100
return false;
@@ -113,7 +113,7 @@ const convertYamlToUserConfig = (input: string | undefined, logger: Logger): Con
113113
return {};
114114
}
115115

116-
const config: Config = YAML.parse(input) as Config;
116+
const config = YAML.parse(input) as Config | undefined;
117117
logger.info("User config file yaml content parsed successfully");
118118

119119
const configDeployments = config?.deployments;
@@ -131,11 +131,6 @@ const convertYamlToUserConfig = (input: string | undefined, logger: Logger): Con
131131
}
132132
}
133133

134-
135-
if (!deployments) {
136-
throw new Error(`Invalid .jira/config.yml structure`);
137-
}
138-
139134
// Trim the input data to only include the required attributes
140135
const output = { deployments } ;
141136

test/setup/matchers/to-be-called-with-delay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare namespace jest {
88

99
expect.extend({
1010
toBeCalledWithDelaySec: async (received: jest.Mock<unknown>, expectedDelaySec: number) => {
11+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1112
const actual = received.mock?.calls[0][0].DelaySeconds as number;
1213
const pass = actual == expectedDelaySec;
1314
const message = () => `Expected parameter to have DelaySeconds = ${expectedDelaySec} ${pass ? "" : `but was ${actual}`}`;

0 commit comments

Comments
 (0)