Skip to content

Commit

Permalink
Enable eslint rule explicit-function-return-type (#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archinowsk committed Jul 7, 2024
1 parent 398465f commit b92cc7b
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ module.exports = {
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{ allowExpressions: true },
],
"@typescript-eslint/require-array-sort-compare": [
"error",
{ ignoreStringArrays: true },
Expand Down
6 changes: 6 additions & 0 deletions client/eslint-config-client.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@
],
"@typescript-eslint/no-explicit-any": ["error"],
"@typescript-eslint/explicit-module-boundary-types": ["error"],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"@typescript-eslint/require-array-sort-compare": [
"error",
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "client/views/my-program-items/myProgramItemsSlice";
import { RaisedCard } from "client/components/RaisedCard";
import { getIsInGroup } from "client/views/group/groupUtils";
import { SignupQuestion } from "shared/types/models/settings";

interface Props {
programItems: readonly ProgramItem[];
Expand Down Expand Up @@ -46,7 +47,9 @@ export const AllProgramItemsList = ({ programItems }: Props): ReactElement => {
(state) => state.admin.signupQuestions,
);

const getPublicSignupQuestion = (programItemId: string) =>
const getPublicSignupQuestion = (
programItemId: string,
): SignupQuestion | undefined =>
signupQuestions.find(
(s) => s.programItemId === programItemId && !s.private,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Props {
export const ProgramItemInfo = ({ programItem }: Props): ReactElement => {
const { t } = useTranslation();

const formatTime = () => {
const formatTime = (): string => {
const hours = Math.floor(programItem.mins / 60);
const minutes = Math.round((programItem.mins / 60 - hours) * 60);

Expand Down
6 changes: 6 additions & 0 deletions server/eslint-config-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@
],
"@typescript-eslint/no-explicit-any": ["error"],
"@typescript-eslint/explicit-module-boundary-types": ["error"],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"@typescript-eslint/require-array-sort-compare": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion server/src/kompassi/getProgramItemsFromKompassi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const getProgramItemsFromKompassi = async (
: makeSuccessResult(programItems);
};

const getProgramItemId = (programItem: unknown) => {
const getProgramItemId = (programItem: unknown): unknown => {
return !!programItem &&
typeof programItem === "object" &&
"slug" in programItem
Expand Down
2 changes: 2 additions & 0 deletions server/src/utils/sentry-winston-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ eslint-disable
@typescript-eslint/no-floating-promises,
@typescript-eslint/no-unnecessary-condition,
@typescript-eslint/consistent-indexed-object-style,
@typescript-eslint/explicit-function-return-type,
promise/catch-or-return,
promise/always-return,
curly
Expand Down Expand Up @@ -170,6 +171,7 @@ eslint-enable
@typescript-eslint/no-floating-promises,
@typescript-eslint/no-unnecessary-condition,
@typescript-eslint/consistent-indexed-object-style,
@typescript-eslint/explicit-function-return-type,
promise/catch-or-return,
promise/always-return,
curly
Expand Down
4 changes: 2 additions & 2 deletions shared/utils/signupTimes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe(`Direct signup with signup windows`, () => {
const testLarp = { ...testProgramItem, programType: ProgramType.LARP };
const testLarp2 = { ...testProgramItem2, programType: ProgramType.LARP };

const assertSignupTime = (startTime: string, signupTime: string) => {
const assertSignupTime = (startTime: string, signupTime: string): void => {
const signupStartTime = getDirectSignupStartTime({
...testLarp,
startTime,
Expand Down Expand Up @@ -263,7 +263,7 @@ describe(`Direct signup with rolling signup`, () => {
programType: ProgramType.WORKSHOP,
};

const assertSignupTime = (startTime: string, signupTime: string) => {
const assertSignupTime = (startTime: string, signupTime: string): void => {
const signupStartTime = getDirectSignupStartTime({
...testWorkshop,
startTime,
Expand Down
2 changes: 2 additions & 0 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ const { defineConfig } = require("@yarnpkg/types"); // eslint-disable-line @type
// https://yarnpkg.com/features/constraints

// Enforce that the engines.node field is properly set in all workspaces
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const enforceConsistentEnginesNodeValue = ({ Yarn }) => {
for (const workspace of Yarn.workspaces()) {
workspace.set("engines.node", ">=20.12.2");
}
};

// Enforce that a workspaces depend on the same version of a dependency
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const enforceConsistentDependencies = ({ Yarn }) => {
for (const dependency of Yarn.dependencies()) {
if (dependency.type === `peerDependencies`) {
Expand Down

0 comments on commit b92cc7b

Please sign in to comment.