Skip to content

Commit

Permalink
chore: fixing eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Oct 7, 2024
1 parent d904cb1 commit 1a2c3e2
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export default tsEslint.config({
"sonarjs/different-types-comparison": "off",
"sonarjs/sonar-prefer-regexp-exec": "off",
"sonarjs/function-return-type": "off",
"sonarjs/no-misleading-array-reverse": "off",
"sonarjs/slow-regex": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/naming-convention": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class ContentEvaluatorModule implements Module {
}

_getRewardForComment(comment: GithubCommentScore, relevance: number) {
let reward = new Decimal(comment?.score?.reward || 0);
let reward = new Decimal(comment?.score?.reward ?? 0);

if (comment?.score?.formatting && comment.score.multiplier && comment.score.words) {
let totalRegexReward = new Decimal(0);
Expand Down
7 changes: 3 additions & 4 deletions src/parser/formatting-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export class FormattingEvaluatorModule implements Module {
for (const key of Object.keys(result)) {
const currentElement = result[key];
const comments = currentElement.comments || [];
for (let i = 0; i < comments.length; i++) {
const comment = comments[i];
for (const comment of comments) {
const { formatting, words } = this._getFormattingScore(comment);
const multiplierFactor = this._multipliers?.[comment.type] ?? { multiplier: 0 };
const formattingTotal = this._calculateFormattingTotal(formatting, words, multiplierFactor).toDecimalPlaces(2);
Expand Down Expand Up @@ -111,13 +110,13 @@ export class FormattingEvaluatorModule implements Module {
const res = this._classifyTagsWithWordCount(temp.window.document.body, comment.type);
return { formatting: res.formatting, words: res.words };
} else {
throw new Error(`Could not create DOM for comment [${comment}]`);
throw new Error(`Could not create DOM for comment [${JSON.stringify(comment)}]`);
}
}

_countWordsFromRegex(text: string, wordValue = 0): WordResult {
const match = text.trim().match(new RegExp(wordRegex, "g"));
const wordCount = match?.length || 0;
const wordCount = match?.length ?? 0;
const result = new Decimal(wordCount).pow(this._wordCountExponent).mul(wordValue).toDecimalPlaces(2).toNumber();
return {
wordCount,
Expand Down
6 changes: 3 additions & 3 deletions src/parser/github-comment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ export class GithubCommentModule implements Module {
<td>
<details>
<summary>
${new Decimal(commentScore.score?.words?.result || 0).add(new Decimal(commentScore.score?.formatting?.result || 0))}
${new Decimal(commentScore.score?.words?.result ?? 0).add(new Decimal(commentScore.score?.formatting?.result ?? 0))}
</summary>
<pre>${formatting}</pre>
</details>
</td>
<td>${commentScore.score?.relevance || "-"}</td>
<td>${commentScore.score?.reward || "-"}</td>
<td>${commentScore.score?.relevance ?? "-"}</td>
<td>${commentScore.score?.reward ?? "-"}</td>
</tr>`;
}

Expand Down
6 changes: 3 additions & 3 deletions src/parser/permit-generation-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class PermitGenerationModule implements Module {
evmNetworkId: configuration.evmNetworkId,
erc20RewardToken: configuration.erc20RewardToken,
};
const issueId = Number(payload.issueUrl.match(/[0-9]+$/)?.[0]);
const issueId = Number(payload.issueUrl.match(/\d+$/)?.[0]);
payload.issue = {
node_id: program.eventPayload.issue.node_id,
};
Expand Down Expand Up @@ -192,7 +192,7 @@ export class PermitGenerationModule implements Module {
// - user.comments[].reward
const feeRateDecimal = new Decimal(100).minus(env.PERMIT_FEE_RATE).div(100);
let permitFeeAmountDecimal = new Decimal(0);
for (const [_, rewardResult] of Object.entries(result)) {
for (const [, rewardResult] of Object.entries(result)) {
// accumulate total permit fee amount
const totalAfterFee = new Decimal(rewardResult.total).mul(feeRateDecimal).toNumber();
permitFeeAmountDecimal = permitFeeAmountDecimal.add(new Decimal(rewardResult.total).minus(totalAfterFee));
Expand Down Expand Up @@ -250,7 +250,7 @@ export class PermitGenerationModule implements Module {
locationId = locationData.id;
}
if (!locationId) {
throw new Error(`Failed to retrieve the related location from issue ${issue}`);
throw new Error(`Failed to retrieve the related location from issue ${JSON.stringify(issue)}`);
}
return locationId;
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/user-extractor-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class UserExtractorModule implements Module {
}

_getTaskMultiplier(issue: GitHubIssue) {
return new Decimal(1).div(issue.assignees?.length || 1);
return new Decimal(1).div(issue.assignees?.length ?? 1);
}

async transform(data: Readonly<IssueActivity>, result: Result): Promise<Result> {
Expand Down
2 changes: 2 additions & 0 deletions tests/__mocks__/@octokit/plugin-paginate-graphql.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

module.exports = {
paginateGraphQL() {
return {
Expand Down
2 changes: 2 additions & 0 deletions tests/process.issue.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable sonarjs/no-nested-functions */

import fs from "fs";
import { http, HttpResponse } from "msw";
import configuration from "../src/configuration/config-reader";
Expand Down
2 changes: 2 additions & 0 deletions tests/rewards.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable sonarjs/no-nested-functions */

import { drop } from "@mswjs/data";
import fs from "fs";
import { http, HttpResponse } from "msw";
Expand Down
1 change: 1 addition & 0 deletions tests/truncate-data.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-nested-functions */
import { drop } from "@mswjs/data";
import "../src/parser/command-line";
import { db } from "./__mocks__/db";
Expand Down

0 comments on commit 1a2c3e2

Please sign in to comment.