From c436cb52b124e2691749ca51f55c4e2f91004709 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 12 Jun 2023 14:26:52 +0200 Subject: [PATCH] corrected file endings or removed them where possible --- backend/jest.config.js | 8 ++-- backend/src/config/index.ts | 4 +- backend/src/config/logos.ts | 2 +- backend/src/config/metadata.ts | 2 +- backend/src/constants/categories.ts | 2 +- backend/src/constants/groups.ts | 2 +- backend/src/constants/registration.ts | 2 +- backend/src/db/factories.ts | 4 +- .../src/middleware/helpers/email/sendMail.ts | 2 +- .../helpers/email/templateBuilder.spec.ts | 2 +- .../helpers/email/templateBuilder.ts | 4 +- backend/src/middleware/languages/languages.ts | 2 +- backend/src/middleware/xssMiddleware.ts | 2 +- backend/src/models/index.ts | 40 +++++++++---------- backend/src/schema/resolvers/embeds.ts | 2 +- .../resolvers/helpers/filterForMutedUsers.ts | 2 +- backend/src/schema/resolvers/index.ts | 2 +- backend/src/schema/types/type/FILED.gql | 2 +- backend/tsconfig.json | 2 +- 19 files changed, 44 insertions(+), 44 deletions(-) diff --git a/backend/jest.config.js b/backend/jest.config.js index 38c59916d..8a04fdfad 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -2,17 +2,17 @@ module.exports = { verbose: true, collectCoverage: true, collectCoverageFrom: [ - '**/*.js', + '**/*.ts', '!**/node_modules/**', '!**/test/**', '!**/build/**', - '!**/src/**/?(*.)+(spec|test).js?(x)' + '!**/src/**/?(*.)+(spec|test).ts?(x)' ], coverageThreshold: { global: { lines: 57, }, }, - testMatch: ['**/src/**/?(*.)+(spec|test).js?(x)'], - setupFilesAfterEnv: ['/test/setup.js'] + testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'], + setupFilesAfterEnv: ['/test/setup.ts'] } diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 3dcf2bb83..d1dca3781 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -1,6 +1,6 @@ import dotenv from 'dotenv' -import emails from './emails.js' -import metadata from './metadata.js' +import emails from './emails' +import metadata from './metadata' // Load env file if (require.resolve) { diff --git a/backend/src/config/logos.ts b/backend/src/config/logos.ts index d093c7b46..41b83b30c 100644 --- a/backend/src/config/logos.ts +++ b/backend/src/config/logos.ts @@ -1,4 +1,4 @@ -// this file is duplicated in `backend/src/config/logos.js` and `webapp/constants/logos.js` and replaced on rebranding +// this file is duplicated in `backend/src/config/logos` and `webapp/constants/logos.js` and replaced on rebranding // this are the paths in the webapp export default { LOGO_HEADER_PATH: '/img/custom/logo-horizontal.svg', diff --git a/backend/src/config/metadata.ts b/backend/src/config/metadata.ts index d40308e80..282fcb655 100644 --- a/backend/src/config/metadata.ts +++ b/backend/src/config/metadata.ts @@ -1,4 +1,4 @@ -// this file is duplicated in `backend/src/config/metadata.js` and `webapp/constants/metadata.js` and replaced on rebranding +// this file is duplicated in `backend/src/config/metadata` and `webapp/constants/metadata.js` and replaced on rebranding export default { APPLICATION_NAME: 'ocelot.social', APPLICATION_SHORT_NAME: 'ocelot', diff --git a/backend/src/constants/categories.ts b/backend/src/constants/categories.ts index 0d61a041a..6365d268a 100644 --- a/backend/src/constants/categories.ts +++ b/backend/src/constants/categories.ts @@ -1,4 +1,4 @@ -// this file is duplicated in `backend/src/constants/metadata.js` and `webapp/constants/metadata.js` +// this file is duplicated in `backend/src/constants/metadata` and `webapp/constants/metadata.js` export const CATEGORIES_MIN = 1 export const CATEGORIES_MAX = 3 diff --git a/backend/src/constants/groups.ts b/backend/src/constants/groups.ts index aec19eac5..b1c305add 100644 --- a/backend/src/constants/groups.ts +++ b/backend/src/constants/groups.ts @@ -1,3 +1,3 @@ -// this file is duplicated in `backend/src/constants/group.js` and `webapp/constants/group.js` +// this file is duplicated in `backend/src/constants/group` and `webapp/constants/group.js` export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 50 // with removed HTML tags export const DESCRIPTION_EXCERPT_HTML_LENGTH = 250 // with removed HTML tags diff --git a/backend/src/constants/registration.ts b/backend/src/constants/registration.ts index 9e63e478e..a08be3521 100644 --- a/backend/src/constants/registration.ts +++ b/backend/src/constants/registration.ts @@ -1,4 +1,4 @@ -// this file is duplicated in `backend/src/config/metadata.js` and `webapp/constants/metadata.js` +// this file is duplicated in `backend/src/config/metadata` and `webapp/constants/metadata.js` export default { NONCE_LENGTH: 5, INVITE_CODE_LENGTH: 6, diff --git a/backend/src/db/factories.ts b/backend/src/db/factories.ts index 6ec7f49b2..4ec34e289 100644 --- a/backend/src/db/factories.ts +++ b/backend/src/db/factories.ts @@ -4,8 +4,8 @@ import { hashSync } from 'bcryptjs' import { Factory } from 'rosie' import { faker } from '@faker-js/faker' import { getDriver, getNeode } from './neo4j' -import CONFIG from '../config/index.js' -import generateInviteCode from '../schema/resolvers/helpers/generateInviteCode.js' +import CONFIG from '../config/index' +import generateInviteCode from '../schema/resolvers/helpers/generateInviteCode' const neode = getNeode() diff --git a/backend/src/middleware/helpers/email/sendMail.ts b/backend/src/middleware/helpers/email/sendMail.ts index 60cc2078e..359efc91e 100644 --- a/backend/src/middleware/helpers/email/sendMail.ts +++ b/backend/src/middleware/helpers/email/sendMail.ts @@ -1,5 +1,5 @@ import CONFIG from '../../../config' -import { cleanHtml } from '../../../middleware/helpers/cleanHtml.js' +import { cleanHtml } from '../../../middleware/helpers/cleanHtml' import nodemailer from 'nodemailer' import { htmlToText } from 'nodemailer-html-to-text' diff --git a/backend/src/middleware/helpers/email/templateBuilder.spec.ts b/backend/src/middleware/helpers/email/templateBuilder.spec.ts index d5b0edf21..cb516c0a9 100644 --- a/backend/src/middleware/helpers/email/templateBuilder.spec.ts +++ b/backend/src/middleware/helpers/email/templateBuilder.spec.ts @@ -1,5 +1,5 @@ import CONFIG from '../../../config' -import logosWebapp from '../../../config/logos.js' +import logosWebapp from '../../../config/logos' import { signupTemplate, emailVerificationTemplate, diff --git a/backend/src/middleware/helpers/email/templateBuilder.ts b/backend/src/middleware/helpers/email/templateBuilder.ts index bf174ef48..78d7a9bf9 100644 --- a/backend/src/middleware/helpers/email/templateBuilder.ts +++ b/backend/src/middleware/helpers/email/templateBuilder.ts @@ -1,7 +1,7 @@ import mustache from 'mustache' import CONFIG from '../../../config' -import metadata from '../../../config/metadata.js' -import logosWebapp from '../../../config/logos.js' +import metadata from '../../../config/metadata' +import logosWebapp from '../../../config/logos' import * as templates from './templates' import * as templatesEN from './templates/en' diff --git a/backend/src/middleware/languages/languages.ts b/backend/src/middleware/languages/languages.ts index 087252975..83d4e424c 100644 --- a/backend/src/middleware/languages/languages.ts +++ b/backend/src/middleware/languages/languages.ts @@ -1,5 +1,5 @@ import LanguageDetect from 'languagedetect' -import { removeHtmlTags } from '../helpers/cleanHtml.js' +import { removeHtmlTags } from '../helpers/cleanHtml' const setPostLanguage = (text) => { const lngDetector = new LanguageDetect() diff --git a/backend/src/middleware/xssMiddleware.ts b/backend/src/middleware/xssMiddleware.ts index 9b15e9712..ede0cc199 100644 --- a/backend/src/middleware/xssMiddleware.ts +++ b/backend/src/middleware/xssMiddleware.ts @@ -1,5 +1,5 @@ import walkRecursive from '../helpers/walkRecursive' -import { cleanHtml } from '../middleware/helpers/cleanHtml.js' +import { cleanHtml } from '../middleware/helpers/cleanHtml' // exclamation mark separetes field names, that should not be sanitized const fields = [ diff --git a/backend/src/models/index.ts b/backend/src/models/index.ts index 2368f9f71..c75ad31ef 100644 --- a/backend/src/models/index.ts +++ b/backend/src/models/index.ts @@ -2,37 +2,37 @@ // module that is not browser-compatible. Node's `fs` module is server-side only declare var Cypress: any | undefined export default { - Image: typeof Cypress !== 'undefined' ? require('./Image.js') : require('./Image.js').default, - Badge: typeof Cypress !== 'undefined' ? require('./Badge.js') : require('./Badge.js').default, - User: typeof Cypress !== 'undefined' ? require('./User.js') : require('./User.js').default, - Group: typeof Cypress !== 'undefined' ? require('./Group.js') : require('./Group.js').default, + Image: typeof Cypress !== 'undefined' ? require('./Image') : require('./Image').default, + Badge: typeof Cypress !== 'undefined' ? require('./Badge') : require('./Badge').default, + User: typeof Cypress !== 'undefined' ? require('./User') : require('./User').default, + Group: typeof Cypress !== 'undefined' ? require('./Group') : require('./Group').default, EmailAddress: typeof Cypress !== 'undefined' - ? require('./EmailAddress.js') - : require('./EmailAddress.js').default, + ? require('./EmailAddress') + : require('./EmailAddress').default, UnverifiedEmailAddress: typeof Cypress !== 'undefined' - ? require('./UnverifiedEmailAddress.js') - : require('./UnverifiedEmailAddress.js').default, + ? require('./UnverifiedEmailAddress') + : require('./UnverifiedEmailAddress').default, SocialMedia: typeof Cypress !== 'undefined' - ? require('./SocialMedia.js') - : require('./SocialMedia.js').default, - Post: typeof Cypress !== 'undefined' ? require('./Post.js') : require('./Post.js').default, + ? require('./SocialMedia') + : require('./SocialMedia').default, + Post: typeof Cypress !== 'undefined' ? require('./Post') : require('./Post').default, Comment: - typeof Cypress !== 'undefined' ? require('./Comment.js') : require('./Comment.js').default, + typeof Cypress !== 'undefined' ? require('./Comment') : require('./Comment').default, Category: - typeof Cypress !== 'undefined' ? require('./Category.js') : require('./Category.js').default, - Tag: typeof Cypress !== 'undefined' ? require('./Tag.js') : require('./Tag.js').default, + typeof Cypress !== 'undefined' ? require('./Category') : require('./Category').default, + Tag: typeof Cypress !== 'undefined' ? require('./Tag') : require('./Tag').default, Location: - typeof Cypress !== 'undefined' ? require('./Location.js') : require('./Location.js').default, + typeof Cypress !== 'undefined' ? require('./Location') : require('./Location').default, Donations: - typeof Cypress !== 'undefined' ? require('./Donations.js') : require('./Donations.js').default, - Report: typeof Cypress !== 'undefined' ? require('./Report.js') : require('./Report.js').default, + typeof Cypress !== 'undefined' ? require('./Donations') : require('./Donations').default, + Report: typeof Cypress !== 'undefined' ? require('./Report') : require('./Report').default, Migration: - typeof Cypress !== 'undefined' ? require('./Migration.js') : require('./Migration.js').default, + typeof Cypress !== 'undefined' ? require('./Migration') : require('./Migration').default, InviteCode: typeof Cypress !== 'undefined' - ? require('./InviteCode.js') - : require('./InviteCode.js').default, + ? require('./InviteCode') + : require('./InviteCode').default, } diff --git a/backend/src/schema/resolvers/embeds.ts b/backend/src/schema/resolvers/embeds.ts index 016352950..a75365ec7 100644 --- a/backend/src/schema/resolvers/embeds.ts +++ b/backend/src/schema/resolvers/embeds.ts @@ -1,4 +1,4 @@ -import scrape from './embeds/scraper.js' +import scrape from './embeds/scraper' import { undefinedToNullResolver } from './helpers/Resolver' export default { diff --git a/backend/src/schema/resolvers/helpers/filterForMutedUsers.ts b/backend/src/schema/resolvers/helpers/filterForMutedUsers.ts index 5094039ee..1d1369e0d 100644 --- a/backend/src/schema/resolvers/helpers/filterForMutedUsers.ts +++ b/backend/src/schema/resolvers/helpers/filterForMutedUsers.ts @@ -1,4 +1,4 @@ -import { getMutedUsers } from '../users.js' +import { getMutedUsers } from '../users' import { mergeWith, isArray } from 'lodash' export const filterForMutedUsers = async (params, context) => { diff --git a/backend/src/schema/resolvers/index.ts b/backend/src/schema/resolvers/index.ts index 3d3a91d68..57a29a05a 100644 --- a/backend/src/schema/resolvers/index.ts +++ b/backend/src/schema/resolvers/index.ts @@ -1,5 +1,5 @@ import path from 'path' import { fileLoader, mergeResolvers } from 'merge-graphql-schemas' -const resolversArray = fileLoader(path.join(__dirname, './!(*.spec).js')) +const resolversArray = fileLoader(path.join(__dirname, './!(*.spec).ts')) export default mergeResolvers(resolversArray) diff --git a/backend/src/schema/types/type/FILED.gql b/backend/src/schema/types/type/FILED.gql index 85eca951e..27c9539de 100644 --- a/backend/src/schema/types/type/FILED.gql +++ b/backend/src/schema/types/type/FILED.gql @@ -5,7 +5,7 @@ type FILED { submitter: User } -# this list equals the strings of an array in file "webapp/constants/modals.js" +# this list equals the strings of an array in file "webapp/constants/modals" enum ReasonCategory { other discrimination_etc diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 719a053d2..a38aa35dc 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -107,5 +107,5 @@ "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, "include": ["./src/**/*"], - "exclude": ["./src/**/*.spec.ts", "./src/**/*.spec.js"] + "exclude": ["./src/**/*.spec.ts"] }