chore: fix linting (#544)

* fix: eslint (server)

* fix: eslint (client)

* commit package lock file

* fix linting
This commit is contained in:
Philip Okugbe
2024-12-09 14:51:31 +00:00
committed by GitHub
parent e6bf4cdd6c
commit 532001fd82
22 changed files with 1076 additions and 245 deletions

View File

@ -1,25 +0,0 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};

View File

@ -0,0 +1,34 @@
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
/** @type {import('eslint').Linter.Config[]} */
export default [
js.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
ignores: ['eslint.config.mjs'],
},
{
languageOptions: {
globals: { ...globals.node, ...globals.jest },
sourceType: 'module',
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'prefer-rest-params': 'off',
'no-useless-catch': 'off',
'no-useless-escape': 'off',
},
},
];

View File

@ -76,6 +76,7 @@
"ws": "^8.18.0"
},
"devDependencies": {
"@eslint/js": "^9.16.0",
"@nestjs/cli": "^10.4.8",
"@nestjs/schematics": "^10.2.3",
"@nestjs/testing": "^10.4.9",
@ -90,11 +91,9 @@
"@types/pg": "^8.11.10",
"@types/supertest": "^6.0.2",
"@types/ws": "^8.5.13",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.13.0",
"jest": "^29.7.0",
"kysely-codegen": "^0.17.0",
"prettier": "^3.4.1",
@ -105,7 +104,8 @@
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.7.2"
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0"
},
"jest": {
"moduleFileExtensions": [

View File

@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { customAlphabet } = require('fix-esm').require('nanoid');
const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';

View File

@ -52,7 +52,7 @@ export class AttachmentService {
// passing attachmentId to allow for updating diagrams
// instead of creating new files for each save
if (opts?.attachmentId) {
let existingAttachment = await this.attachmentRepo.findById(
const existingAttachment = await this.attachmentRepo.findById(
opts.attachmentId,
);
if (!existingAttachment) {

View File

@ -24,7 +24,9 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
try {
accessToken = JSON.parse(req.cookies?.authTokens)?.accessToken;
} catch {}
} catch {
throw new BadRequestException('Failed to parse access token');
}
return accessToken || this.extractTokenFromHeader(req);
},

View File

@ -5,7 +5,8 @@ import { InjectKysely } from 'nestjs-kysely';
import { KyselyDB } from '@docmost/db/types/kysely.types';
import { sql } from 'kysely';
import { PageRepo } from '@docmost/db/repos/page/page.repo';
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const tsquery = require('pg-tsquery')();
@Injectable()

View File

@ -33,13 +33,13 @@ export async function executeWithPagination<O, DB, TB extends keyof DB>(
.select((eb) => eb.ref(deferredJoinPrimaryKey).as('primaryKey'))
.execute()
// @ts-expect-error TODO: Fix the type here later
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
.then((rows) => rows.map((row) => row.primaryKey));
qb = qb
.where((eb) =>
primaryKeys.length > 0
? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
?
eb(deferredJoinPrimaryKey, 'in', primaryKeys as any)
: eb(sql`1`, '=', 0),
)

View File

@ -42,7 +42,7 @@ export class ExportService {
content: [{ type: 'text', text: getPageTitle(page.title) }],
};
let prosemirrorJson: any = getProsemirrorContent(page.content);
const prosemirrorJson: any = getProsemirrorContent(page.content);
if (page.title) {
prosemirrorJson.content.unshift(titleNode);

View File

@ -25,7 +25,7 @@ export const mailDriverConfigProvider = {
const driver = environmentService.getMailDriver().toLocaleLowerCase();
switch (driver) {
case MailOption.SMTP:
case MailOption.SMTP: {
let auth = undefined;
if (
environmentService.getSmtpUsername() &&
@ -44,9 +44,10 @@ export const mailDriverConfigProvider = {
connectionTimeout: 30 * 1000, // 30 seconds
auth,
secure: environmentService.getSmtpSecure(),
ignoreTLS: environmentService.getSmtpIgnoreTLS()
ignoreTLS: environmentService.getSmtpIgnoreTLS(),
} as SMTPTransport.Options,
};
}
case MailOption.Postmark:
return {

View File

@ -41,7 +41,7 @@ export const storageDriverConfigProvider = {
};
case StorageOption.S3:
const s3Config = {
{ const s3Config = {
driver,
config: {
region: environmentService.getAwsS3Region(),
@ -68,7 +68,7 @@ export const storageDriverConfigProvider = {
};
}
return s3Config;
return s3Config; }
default:
throw new Error(`Unknown storage driver: ${driver}`);