diff --git a/backend/package.json b/backend/package.json index d694603..0a7ed10 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,7 +4,8 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "nodemon --exec ts-node src/index.ts" + "lint": "eslint .", + "start": "npm run lint && nodemon --exec ts-node src/index.ts" }, "keywords": [], "author": "raquelsr", diff --git a/backend/src/schema/mutations/User.ts b/backend/src/schema/mutations/User.ts index 7b28966..500b982 100644 --- a/backend/src/schema/mutations/User.ts +++ b/backend/src/schema/mutations/User.ts @@ -1,16 +1,16 @@ import { GraphQLString } from 'graphql'; import { Users } from '../../entities/Users'; -import { User } from '../types/User'; +import { CreateUserPayload, User } from '../types/User'; export const CREATE_USER = { type: User, args: { - name: {type: GraphQLString}, - lastName: {type: GraphQLString}, - country: {type: GraphQLString}, - role: {type: GraphQLString} + name: { type: GraphQLString }, + lastName: { type: GraphQLString }, + country: { type: GraphQLString }, + role: { type: GraphQLString } }, - resolve: async (_: any, args: any) => { + resolve: async (_: unknown, args: CreateUserPayload) => { const { name, lastName, country, role } = args; const result = await Users.insert({ diff --git a/backend/src/schema/queries/User.ts b/backend/src/schema/queries/User.ts index c161f5d..855486d 100644 --- a/backend/src/schema/queries/User.ts +++ b/backend/src/schema/queries/User.ts @@ -1,7 +1,7 @@ import { GraphQLList } from 'graphql'; import { Users } from '../../entities/Users'; import { Countries } from '../../entities/Countries'; -import { getUsersByCountrySuccessPayload, getTUsersByRoleSuccessPayload, UserRegistrationStatistics, UsersByCountry, UsersByRole, User } from '../types/User'; +import { GetUsersByCountrySuccessPayload, GetTUsersByRoleSuccessPayload, UserRegistrationStatistics, UsersByCountry, UsersByRole, User } from '../types/User'; import { Roles } from '../../entities/Roles'; @@ -31,7 +31,7 @@ export const GET_USER_REGISTRATION_STATISTICS = { export const GET_USERS_BY_COUNTRY = { type: new GraphQLList(UsersByCountry), resolve: async () => { - const result: getUsersByCountrySuccessPayload[] = []; + const result: GetUsersByCountrySuccessPayload[] = []; const countries = await Countries.find(); const users = await Users.find(); countries.map(country => { @@ -50,7 +50,7 @@ export const GET_USERS_BY_COUNTRY = { export const GET_USERS_BY_ROLE = { type: new GraphQLList(UsersByRole), resolve: async () => { - const result: getTUsersByRoleSuccessPayload[] = []; + const result: GetTUsersByRoleSuccessPayload[] = []; const roles = await Roles.find(); const users = await Users.find(); roles.map(role => { diff --git a/backend/src/schema/types/User.ts b/backend/src/schema/types/User.ts index 3b362c1..ba16cef 100644 --- a/backend/src/schema/types/User.ts +++ b/backend/src/schema/types/User.ts @@ -56,14 +56,21 @@ export const UsersByRole = new GraphQLObjectType({ } }); -export type getUsersByCountrySuccessPayload = { +export type GetUsersByCountrySuccessPayload = { country: string; totalCount: number; percentage: number; } -export type getTUsersByRoleSuccessPayload = { +export type GetTUsersByRoleSuccessPayload = { role: string; totalCount: number; percentage: number; +} + +export type CreateUserPayload = { + name: string; + lastName: string; + country: string; + role: string; } \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index ff8306b..f77852f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -23,7 +23,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "lint": "eslint src/**/*.ts src/**/*.tsx" }, "eslintConfig": { "extends": [ diff --git a/frontend/src/components/BarChart.tsx b/frontend/src/components/BarChart.tsx index a4b3e1f..62810b3 100644 --- a/frontend/src/components/BarChart.tsx +++ b/frontend/src/components/BarChart.tsx @@ -3,7 +3,7 @@ import { BarChart as BarChartRechart, Bar, CartesianGrid, Legend, Tooltip, XAxis import { LayoutType } from 'recharts/types/util/types'; export type BarChartProps = { - data: any[]; + data: unknown[]; dataKey: string; xAxisKeys?: string; yAxisKeys?: string; diff --git a/frontend/src/components/LineChart.tsx b/frontend/src/components/LineChart.tsx index 1e9c5ff..20adb41 100644 --- a/frontend/src/components/LineChart.tsx +++ b/frontend/src/components/LineChart.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { LineChart as LineChartRechart, Line, CartesianGrid, XAxis, YAxis } from 'recharts'; export type LineChartProps = { - data: any[]; + data: unknown[]; dataKey: string; xAxisKeys: string; } diff --git a/frontend/src/components/PieChart.tsx b/frontend/src/components/PieChart.tsx index 840cd08..9a7e30f 100644 --- a/frontend/src/components/PieChart.tsx +++ b/frontend/src/components/PieChart.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { Label, LabelList, Pie, PieChart as PieChartRechart } from 'recharts'; export type PieChartProps = { - data: any[]; + data: unknown[]; dataKey: string; nameKey: string; } diff --git a/frontend/src/components/RadarChart.tsx b/frontend/src/components/RadarChart.tsx index 6a6a25f..5efbd45 100644 --- a/frontend/src/components/RadarChart.tsx +++ b/frontend/src/components/RadarChart.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { RadarChart as RadarChartRechart, PolarAngleAxis, PolarRadiusAxis, PolarGrid, Radar, Legend } from 'recharts'; type RadarChartProps = { - data: any[]; + data: unknown[]; } export const RadarChart: React.FC = ({ data }) => {