Skip to content

Commit

Permalink
Fix lint and tsc
Browse files Browse the repository at this point in the history
  • Loading branch information
typeofweb committed Oct 28, 2022
1 parent 16326bf commit 2ca1de2
Show file tree
Hide file tree
Showing 16 changed files with 206 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ yarn-error.log*

# turbo
.turbo

*.tsbuildinfo
2 changes: 1 addition & 1 deletion apps/api/modules/auth/auth.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const authRoutesPlugin: FastifyPluginAsync = async (fastify) => {
throw fastify.httpErrors.unauthorized();
}

request.session.destroy();
await request.session.destroy();

return reply.status(204).send();
},
Expand Down
1 change: 0 additions & 1 deletion apps/api/modules/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const auth: FastifyPluginAsync = async (fastify, options) => {
await fastify.register(import('@fastify/cookie'));
await fastify.register(import('@fastify/session'), {
cookieName: 'session',
unsignSignedCookie: true,
secret: getConfig('COOKIE_PASSWORD'),
store: sessionStore as FastifySessionPlugin.SessionStore,
rolling: true,
Expand Down
6 changes: 3 additions & 3 deletions apps/api/modules/auth/githubAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default authRoutesPlugin;
async function getGitHubProfile(fastify: FastifyInstance, gitHubCredentials: OAuth2Token) {
const res = await fetch('https://api.github.com/user', {
headers: {
Authorization: `token ${gitHubCredentials.access_token}`,
Authorization: `token ${gitHubCredentials.token.access_token}`,
},
});

Expand All @@ -101,7 +101,7 @@ async function getGitHubProfile(fastify: FastifyInstance, gitHubCredentials: OAu
async function getGitHubPrimaryEmail(fastify: FastifyInstance, gitHubCredentials: OAuth2Token) {
const res = await fetch('https://api.github.com/user/emails', {
headers: {
Authorization: `token ${gitHubCredentials.access_token}`,
Authorization: `token ${gitHubCredentials.token.access_token}`,
},
});

Expand All @@ -124,7 +124,7 @@ async function getGitHubPrimaryEmail(fastify: FastifyInstance, gitHubCredentials
}

function getName(gitHubUser: GitHubUser) {
const [firstName, ...rest] = (gitHubUser.name ?? '').split(' ');
const [firstName = '', ...rest] = (gitHubUser.name ?? '').split(' ');
return {
firstName,
lastName: rest.join(' '),
Expand Down
2 changes: 1 addition & 1 deletion apps/api/modules/auth/prismaSessionStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import FastifySessionPlugin from '@fastify/session';
import { PrismaClient } from '@prisma/client';
import type * as Fastify from 'fastify';
import ms from 'ms';
Expand Down Expand Up @@ -61,6 +60,7 @@ export class PrismaSessionStore {
return callback();
}
// @todo ?
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return callback(null, { data: sessionDb });
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/modules/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const db: FastifyPluginAsync = async (fastify, options) => {
}
}

originalErrorHandler(error, request, reply);
return originalErrorHandler(error, request, reply);
});
};

Expand Down
4 changes: 2 additions & 2 deletions apps/api/modules/db/prismaErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,14 @@ export interface QueryParameterLimitExceeded extends Prisma.PrismaClientKnownReq
*/
export interface MissingFullTextSearchIndex extends Prisma.PrismaClientKnownRequestError {
code: 'P2030';
meta: {};
meta: Record<string, unknown>;
}
/**
* Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set. https://pris.ly/d/mongodb-replica-set
*/
export interface MongoReplicaSetRequired extends Prisma.PrismaClientKnownRequestError {
code: 'P2031';
meta: {};
meta: Record<string, unknown>;
}
/**
* Error converting field \"{field}\" of expected non-nullable type \"{expected_type}\", found incompatible value of \"{found}\".
Expand Down
2 changes: 1 addition & 1 deletion apps/api/modules/questions/questions.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function validateCategory(fastify: FastifyInstance, category: strin
export async function validateLevels(fastify: FastifyInstance, levels: string[] | undefined) {
const validLevels = await fastify.questionsGetLevels();
if (levels && !levels.every((level) => validLevels.includes(level))) {
throw fastify.httpErrors.badRequest(`Invalid levels: ${levels}`);
throw fastify.httpErrors.badRequest(`Invalid levels: ${levels.join(', ')}`);
}
}

Expand Down
5 changes: 3 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
"devDependencies": {
"@types/ms": "0.7.31",
"@types/node": "18.11.7",
"typescript": "4.8.4",
"eslint-config-devfaq": "workspace:*",
"tsconfig": "workspace:*"
"tsconfig": "workspace:*",
"typescript": "4.8.4"
},
"dependencies": {
"@fastify/cookie": "8.3.0",
"@fastify/oauth2": "6.1.0",
"@fastify/sensible": "5.1.1",
"@fastify/session": "10.0.2",
"@fastify/swagger": "8.1.0",
"@fastify/swagger-ui": "1.1.0",
"@fastify/type-provider-typebox": "2.3.0",
"@prisma/client": "4.5.0",
"@sinclair/typebox": "0.24.51",
Expand Down
4 changes: 2 additions & 2 deletions apps/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const fastify = Fastify({
}).withTypeProvider<TypeBoxTypeProvider>();

await fastify.register(import('@fastify/sensible'));
await fastify.register(import('@fastify/swagger'), {
await fastify.register(import('@fastify/swagger'));
await fastify.register(import('@fastify/swagger-ui'), {
routePrefix: '/documentation',
uiConfig: {
docExpansion: 'full',
},
exposeRoute: true,
});
await fastify.register(import('./modules/db/db.js'));
await fastify.register(import('./modules/auth/auth.js'));
Expand Down
3 changes: 3 additions & 0 deletions apps/web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
},
rules: {
'@next/next/no-html-link-for-pages': ['error'],
},
};
11 changes: 9 additions & 2 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "tsconfig/nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"format": "prettier --write ."
"format": "prettier --write .",
"check-types": "turbo run check-types"
},
"devDependencies": {
"eslint-config-devfaq": "workspace:*",
Expand Down
5 changes: 5 additions & 0 deletions packages/eslint-config-devfaq/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ module.exports = {
},
},
ignorePatterns: ['build/', '.turbo/', 'dist/', 'node_modules/', '*.js', '*.jsx'],
rules: {
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@next/next/no-html-link-for-pages': ['off'],
},
};
Loading

0 comments on commit 2ca1de2

Please sign in to comment.