Skip to content

Commit

Permalink
feat: giant prettier + eslint run
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah committed Sep 22, 2023
1 parent 6e23422 commit 6becd94
Show file tree
Hide file tree
Showing 431 changed files with 36,208 additions and 31,598 deletions.
11 changes: 10 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
"files": ["{package,project}.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
"@nx/dependency-checks": [
"error",
{
"buildTargets": ["build"],
"checkMissingDependencies": true,
"checkObsoleteDependencies": true,
"checkVersionMismatches": true,
"ignoredDependencies": ["tslib"]
}
]
}
},
{
Expand Down
14 changes: 7 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "apps/strapi"
interval: 'weekly'

- package-ecosystem: 'npm'
directory: 'apps/strapi'
schedule:
interval: "weekly"
interval: 'weekly'
16 changes: 7 additions & 9 deletions .github/workflows/todo.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: "Workflow"
on: ["push"]
name: 'Workflow'
on: ['push']
jobs:
build:
runs-on: "ubuntu-latest"
runs-on: 'ubuntu-latest'
steps:
- uses: "actions/checkout@v3"
- uses: 'actions/checkout@v3'
with:
fetch-depth: 0


- name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v4.5"
id: "todo"

- name: 'TODO to Issue'
uses: 'alstr/todo-to-issue-action@v4.5'
id: 'todo'
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
/docs
/.bundle
/.git
.next
dist

README.md
2 changes: 1 addition & 1 deletion apps/convert-e2e/src/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
// ***********************************************************

// Import commands.ts using ES2015 syntax:
import './commands'
import './commands.js'
2 changes: 1 addition & 1 deletion apps/convert/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"typescript.tsdk": "../../node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
}
16 changes: 4 additions & 12 deletions apps/convert/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"targets": {
"build": {
"executor": "@nx/next:build",
"outputs": [
"{options.outputPath}"
],
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/apps/convert"
Expand Down Expand Up @@ -47,9 +45,7 @@
},
"test": {
"executor": "@nx/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}"
],
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/convert/jest.config.ts",
"passWithNoTests": true
Expand All @@ -63,13 +59,9 @@
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"apps/convert/**/*.{ts,tsx,js,jsx}"
]
"lintFilePatterns": ["apps/convert/**/*.{ts,tsx,js,jsx}"]
}
}
},
Expand Down
30 changes: 12 additions & 18 deletions apps/convert/src/env/client.mjs
Original file line number Diff line number Diff line change
@@ -1,46 +1,40 @@
// @ts-check
import { clientSchema } from "./schema.mjs";
import { clientSchema } from './schema.mjs'

/**
* You can't destruct `process.env` as a regular object, so we do
* a workaround. This is because Next.js evaluates this at build time,
* and only used environment variables are included in the build.
* @type {{ [key: string]: string | undefined; }}
*/
let clientEnv = {};
Object.keys(clientSchema.shape).forEach(
(key) => (clientEnv[key] = process.env[key]),
);
let clientEnv = {}
Object.keys(clientSchema.shape).forEach((key) => (clientEnv[key] = process.env[key]))

const _clientEnv = clientSchema.safeParse(clientEnv);
const _clientEnv = clientSchema.safeParse(clientEnv)

export const formatErrors = (
/** @type {import('zod').ZodFormattedError<Map<string,string>,string>} */
errors,
) =>
Object.entries(errors)
.map(([name, value]) => {
if (value && "_errors" in value)
return `${name}: ${value._errors.join(", ")}\n`;
if (value && '_errors' in value) return `${name}: ${value._errors.join(', ')}\n`
})
.filter(Boolean);
.filter(Boolean)

if (!_clientEnv.success) {
console.error(
"❌ Invalid environment variables:\n",
...formatErrors(_clientEnv.error.format()),
);
throw new Error("Invalid environment variables");
console.error('❌ Invalid environment variables:\n', ...formatErrors(_clientEnv.error.format()))
throw new Error('Invalid environment variables')
}

for (let key of Object.keys(_clientEnv.data)) {
if (!key.startsWith("NEXT_PUBLIC_")) {
if (!key.startsWith('NEXT_PUBLIC_')) {
console.warn(
`❌ Invalid public environment variable name: ${key}. It must begin with 'NEXT_PUBLIC_'`,
);
)

throw new Error("Invalid public environment variable name");
throw new Error('Invalid public environment variable name')
}
}

export const env = _clientEnv.data;
export const env = _clientEnv.data
12 changes: 5 additions & 7 deletions apps/convert/src/env/schema.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// @ts-check
import { z } from "zod";
import { z } from 'zod'

/**
* Specify your server-side environment variables schema here.
* This way you can ensure the app isn't built with invalid env vars.
*/
export const serverSchema = z.object({
NODE_ENV: z.enum(["development", "test", "production"]),
NODE_ENV: z.enum(['development', 'test', 'production']),
NEXTAUTH_SECRET:
process.env.NODE_ENV === "production"
? z.string().min(1)
: z.string().min(1).optional(),
process.env.NODE_ENV === 'production' ? z.string().min(1) : z.string().min(1).optional(),
NEXTAUTH_URL: z.preprocess(
// This makes Vercel deployments not fail if you don't set NEXTAUTH_URL
// Since NextAuth.js automatically uses the VERCEL_URL if present.
Expand All @@ -24,7 +22,7 @@ export const serverSchema = z.object({
AZURE_SECRET: z.string(),
AZURE_TENANT_ID: z.string(),
// ORCID_ACCESS_SECRET: z.string(),
});
})

/**
* Specify your client-side environment variables schema here.
Expand All @@ -33,4 +31,4 @@ export const serverSchema = z.object({
*/
export const clientSchema = z.object({
// NEXT_PUBLIC_CLIENTVAR: z.string(),
});
})
27 changes: 11 additions & 16 deletions apps/convert/src/env/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,31 @@
* This file is included in `/next.config.mjs` which ensures the app isn't built with invalid env vars.
* It has to be a `.mjs`-file to be imported there.
*/
import { serverSchema } from "./schema.mjs";
import { env as clientEnv, formatErrors } from "./client.mjs";
import { serverSchema } from './schema.mjs'
import { env as clientEnv, formatErrors } from './client.mjs'

/**
* You can't destruct `process.env` as a regular object, so we do
* a workaround. This is because Next.js evaluates this at build time,
* and only used environment variables are included in the build.
* @type {{ [key: string]: string | undefined; }}
*/
let serverEnv = {};
Object.keys(serverSchema.shape).forEach(
(key) => (serverEnv[key] = process.env[key]),
);
let serverEnv = {}
Object.keys(serverSchema.shape).forEach((key) => (serverEnv[key] = process.env[key]))

const _serverEnv = serverSchema.safeParse(serverEnv);
const _serverEnv = serverSchema.safeParse(serverEnv)

if (!_serverEnv.success) {
console.error(
"❌ Invalid environment variables:\n",
...formatErrors(_serverEnv.error.format()),
);
throw new Error("Invalid environment variables");
console.error('❌ Invalid environment variables:\n', ...formatErrors(_serverEnv.error.format()))
throw new Error('Invalid environment variables')
}

for (let key of Object.keys(_serverEnv.data)) {
if (key.startsWith("NEXT_PUBLIC_")) {
console.warn("❌ You are exposing a server-side env-variable:", key);
if (key.startsWith('NEXT_PUBLIC_')) {
console.warn('❌ You are exposing a server-side env-variable:', key)

throw new Error("You are exposing a server-side env-variable");
throw new Error('You are exposing a server-side env-variable')
}
}

export const env = { ..._serverEnv.data, ...clientEnv };
export const env = { ..._serverEnv.data, ...clientEnv }
12 changes: 2 additions & 10 deletions apps/convert/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"types": [
"jest",
"node"
]
"types": ["jest", "node"]
},
"include": [
"**/*.ts",
Expand All @@ -25,10 +22,5 @@
"next.config.mjs",
"../../apps/convert/.next/types/**/*.ts"
],
"exclude": [
"node_modules",
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts"
]
"exclude": ["node_modules", "jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
4 changes: 1 addition & 3 deletions apps/converter-frontend/components/ext-icon/ext-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { defaultStyles, FileIcon } from 'react-file-icon'
/* eslint-disable-next-line */
export interface ExtIconProps {}

export const WordIcon = () => (
<FileIcon extension="docx" {...defaultStyles.docx} />
)
export const WordIcon = () => <FileIcon extension="docx" {...defaultStyles.docx} />

export const JATSIcon = () => (
<FileIcon
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React, { forwardRef } from 'react'
import {
Text,
Group,
Avatar,
SelectItemProps as OldSelectItemProps,
} from '@mantine/core'
import { Text, Group, Avatar, SelectItemProps as OldSelectItemProps } from '@mantine/core'
/* eslint-disable-next-line */
export interface SelectItemProps extends OldSelectItemProps {
description: string
Expand All @@ -24,7 +19,7 @@ export const SelectItem = forwardRef<HTMLDivElement, SelectItemProps>(
</div>
</Group>
</div>
)
),
)

export default SelectItem
12 changes: 11 additions & 1 deletion apps/converter-frontend/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
{
"name": "",
"short_name": "",
"icons": [
{ "src": "/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" }
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
5 changes: 2 additions & 3 deletions apps/converter-frontend/utils/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ export const setCookie = (
res: NextApiResponse,
name: string,
value: unknown,
options: CookieSerializeOptions = {}
options: CookieSerializeOptions = {},
) => {
const stringValue =
typeof value === 'object' ? `j:${JSON.stringify(value)}` : String(value)
const stringValue = typeof value === 'object' ? `j:${JSON.stringify(value)}` : String(value)

if (options.maxAge) {
options.expires = new Date(Date.now() + options.maxAge)
Expand Down
4 changes: 1 addition & 3 deletions apps/converter-frontend/utils/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export const fetcher = (resource: string, init: RequestInit) =>
fetch(resource, { headers: { 'Access-Control-Allow-Origin': '*' } }).then(
(res) => res.json()
)
fetch(resource, { headers: { 'Access-Control-Allow-Origin': '*' } }).then((res) => res.json())
14 changes: 4 additions & 10 deletions apps/converter-frontend/utils/forgeCookie.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { AxiosResponse } from 'axios'
import { NextApiRequest } from 'next'

export const replaceCookieRes = (
response: AxiosResponse,
endpoint: string | string[]
) => {
export const replaceCookieRes = (response: AxiosResponse, endpoint: string | string[]) => {
const cookie = response.headers['set-cookie']
const myCookie = (Array.isArray(cookie) ? cookie[0] : cookie)?.replace(
/domain=(.*)$/,
`domain=${(Array.isArray(endpoint) ? endpoint[0] : endpoint)?.replace(
/https:\/\/(.*?)\/.*/,
'$1'
)}`
'$1',
)}`,
)
return myCookie ? [myCookie] : ''
}

export const getSID = (cookie: string | string[]) => {
return (Array.isArray(cookie) ? cookie[0] : cookie).replace(
/.*?OJSSID=(.*?);.*/,
'$1'
)
return (Array.isArray(cookie) ? cookie[0] : cookie).replace(/.*?OJSSID=(.*?);.*/, '$1')
}
Loading

0 comments on commit 6becd94

Please sign in to comment.