diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 619b8e4..3c8ff00 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,4 +30,8 @@ jobs: - run: pnpm install --frozen-lockfile - - run: pnpm run lint + - run: pnpm exec biome lint + + - name: Check formatting + if: always() + run: pnpm run format:check diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..51efe54 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,12 @@ +.next/ +out/ +build/ +public/rss/ +pnpm-lock.yaml + +# git submodule, formatted by its own repo +lib/app_localization/ + +# generated: contentful CLI export, crowdin exports +contentful/export.json +locales/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..c2b6eb1 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + 'singleQuote': true, + 'printWidth': 100, + 'trailingComma': 'es5', + 'embeddedLanguageFormatting': 'off', +} diff --git a/README.md b/README.md index ce612c9..a4382e0 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ pnpm install 5. Signup for a free [Contentful](https://www.contentful.com/) account and create an organisation and within that create a space. We called our organization **Session** and the space **Website**. - - For the site to build correctly you need to import our Content models and assets into your Contentful space. We have created some example content so you can get comfortable with our Contentful setup. - Add your `space ID` and `content management token` inside of [contentful/config.json](contentful/config.json) diff --git a/knip.config.js b/knip.config.js index d3ea7fd..9f1194e 100644 --- a/knip.config.js +++ b/knip.config.js @@ -1,8 +1,4 @@ export default { - entry: [ - 'pages/**/*.{js,ts,tsx}', - 'app/**/*.{js,ts,tsx}', - 'src/pages/**/*.{js,ts,tsx}', - ], + entry: ['pages/**/*.{js,ts,tsx}', 'app/**/*.{js,ts,tsx}', 'src/pages/**/*.{js,ts,tsx}'], project: ['**/*.{js,ts,tsx}', '!node_modules/**'], }; diff --git a/next.config.js b/next.config.js index 3b0bc68..12d9446 100644 --- a/next.config.js +++ b/next.config.js @@ -2,51 +2,50 @@ const withSvgr = require('@newhighsco/next-plugin-svgr'); const isDev = process.env.NODE_ENV === 'development'; -const baseCsp = (isDev) => [ - "default-src 'self'", - `script-src 'self' ${isDev ? "'unsafe-eval' 'unsafe-inline'" : "'unsafe-inline'"} *.ctfassets.net *.youtube.com *.twitter.com donorbox.org`, - "child-src 'self' *.ctfassets.net *.youtube.com player.vimeo.com *.twitter.com donorbox.org", - "style-src 'self' 'unsafe-inline' *.googleapis.com", - "img-src 'self' blob: data: *.ctfassets.net *.youtube.com *.twitter.com", - "media-src 'self' *.youtube.com", - "connect-src *", - "font-src 'self' blob: data: fonts.gstatic.com maxcdn.bootstrapcdn.com", - "worker-src 'self' blob:", -].join('; '); +const baseCsp = (isDev) => + [ + "default-src 'self'", + `script-src 'self' ${isDev ? "'unsafe-eval' 'unsafe-inline'" : "'unsafe-inline'"} *.ctfassets.net *.youtube.com *.twitter.com donorbox.org`, + "child-src 'self' *.ctfassets.net *.youtube.com player.vimeo.com *.twitter.com donorbox.org", + "style-src 'self' 'unsafe-inline' *.googleapis.com", + "img-src 'self' blob: data: *.ctfassets.net *.youtube.com *.twitter.com", + "media-src 'self' *.youtube.com", + 'connect-src *', + "font-src 'self' blob: data: fonts.gstatic.com maxcdn.bootstrapcdn.com", + "worker-src 'self' blob:", + ].join('; '); // Donate page uses a wide-open CSP — Donorbox dynamically loads PayPal, Stripe, // Google Maps, reCAPTCHA, FingerprintJS and other SDKs at runtime that are // impossible to fully enumerate. We lock down only what we can safely restrict // (no arbitrary workers, no data: scripts) and leave the rest open. -const donateCsp = (isDev) => [ - "default-src *", - `script-src * 'unsafe-inline' ${isDev ? "'unsafe-eval'" : ""}`, - "style-src * 'unsafe-inline'", - "img-src * blob: data:", - "font-src * blob: data:", - "frame-src *", - "connect-src *", - "child-src * blob:", - "worker-src 'self' blob:", -].join('; '); +const donateCsp = (isDev) => + [ + 'default-src *', + `script-src * 'unsafe-inline' ${isDev ? "'unsafe-eval'" : ''}`, + "style-src * 'unsafe-inline'", + 'img-src * blob: data:', + 'font-src * blob: data:', + 'frame-src *', + 'connect-src *', + 'child-src * blob:', + "worker-src 'self' blob:", + ].join('; '); const redirects = [ { source: '/android', - destination: - 'https://play.google.com/store/apps/details?id=network.loki.messenger', + destination: 'https://play.google.com/store/apps/details?id=network.loki.messenger', permanent: true, }, { source: '/apk', - destination: - 'https://github.com/session-foundation/session-android/releases', + destination: 'https://github.com/session-foundation/session-android/releases', permanent: true, }, { source: '/iphone', - destination: - 'https://apps.apple.com/app/session-private-messenger/id1470168868?ls=1', + destination: 'https://apps.apple.com/app/session-private-messenger/id1470168868?ls=1', permanent: true, }, { @@ -58,27 +57,29 @@ const redirects = [ const isTranslateMode = process.env.NEXT_PUBLIC_TRANSLATION_MODE === 'true'; -process.env.ENVIRONMENT_FALLBACK = 'en' +process.env.ENVIRONMENT_FALLBACK = 'en'; // TODO: enable all available locales as we get them fully translated -const locales = !isTranslateMode ? [ - 'en', // English - 'zh-CN', // Chinese Simplified - // 'zh-TW', // Chinese Traditional - 'cs', // Czech - 'nl', // Dutch - 'fr', // French - 'de', // German - 'hi', // Hindi - // 'hu', // Hungarian - 'it', // Italian - 'ja', // Japanese - 'pl', // Polish - // 'pt', // Portuguese - // 'ro', // Romanian - 'es', // Spanish - // 'sv', // Swedish -] : ['ach']; +const locales = !isTranslateMode + ? [ + 'en', // English + 'zh-CN', // Chinese Simplified + // 'zh-TW', // Chinese Traditional + 'cs', // Czech + 'nl', // Dutch + 'fr', // French + 'de', // German + 'hi', // Hindi + // 'hu', // Hungarian + 'it', // Italian + 'ja', // Japanese + 'pl', // Polish + // 'pt', // Portuguese + // 'ro', // Romanian + 'es', // Spanish + // 'sv', // Swedish + ] + : ['ach']; // @ts-check /** @type {import('next').NextConfig} */ @@ -108,10 +109,8 @@ const nextConfig = { CONTENTFUL_PREVIEW_TOKEN: process.env.CONTENTFUL_PREVIEW_TOKEN, CAMPAIGN_MONITOR_CLIENT_ID: process.env.CAMPAIGN_MONITOR_CLIENT_ID, CAMPAIGN_MONITOR_API_KEY: process.env.CAMPAIGN_MONITOR_API_KEY, - CAMPAIGN_MONITOR_LIST_SESSION_ID: - process.env.CAMPAIGN_MONITOR_LIST_SESSION_ID, - CAMPAIGN_MONITOR_LIST_MARKET_RESEARCH_ID: - process.env.CAMPAIGN_MONITOR_LIST_MARKET_RESEARCH_ID, + CAMPAIGN_MONITOR_LIST_SESSION_ID: process.env.CAMPAIGN_MONITOR_LIST_SESSION_ID, + CAMPAIGN_MONITOR_LIST_MARKET_RESEARCH_ID: process.env.CAMPAIGN_MONITOR_LIST_MARKET_RESEARCH_ID, MAILERLITE_API_KEY: process.env.MAILERLITE_API_KEY, MAILERLITE_GROUP_ID: process.env.MAILERLITE_GROUP_ID, NEXT_PUBLIC_TRANSLATION_MODE: process.env.NEXT_PUBLIC_TRANSLATION_MODE, diff --git a/package.json b/package.json index eb1ed1e..9f96ed9 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,10 @@ "build:staging": "NEXT_PUBLIC_SITE_ENV=development NODE_ENV=production next build", "start": "NEXT_PUBLIC_SITE_ENV=production NODE_ENV=production next start --hostname 127.0.0.1", "start:staging": "NEXT_PUBLIC_SITE_ENV=development NODE_ENV=production next start --hostname 127.0.0.1", - "lint": "biome lint", - "lint:fix": "biome lint --write", - "format": "biome format --write", + "lint": "biome lint && prettier --check .", + "lint:fix": "biome lint --write && prettier --write .", + "format": "prettier --write .", + "format:check": "prettier --check .", "check": "biome check", "check:fix": "biome check --write" }, @@ -63,6 +64,7 @@ "contentful-cli": "^1.8.17", "cssnano": "^4.1.11", "postcss": "^8.2.13", + "prettier": "3.7.4", "tailwindcss": "^2.2.15", "tailwindcss-selection-variant": "^0.1.0", "typescript": "5.8.3" diff --git a/pages/[slug].tsx b/pages/[slug].tsx index 9fcff81..62533db 100644 --- a/pages/[slug].tsx +++ b/pages/[slug].tsx @@ -43,7 +43,7 @@ function shouldBuildSlug(slug: string): boolean { } } - console.log(forbiddenWords) + console.log(forbiddenWords); for (const w of forbiddenWords) { if (slug.includes(w)) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6f514e6..f848e0a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -151,6 +151,9 @@ importers: postcss: specifier: ^8.2.13 version: 8.5.6 + prettier: + specifier: 3.7.4 + version: 3.7.4 tailwindcss: specifier: ^2.2.15 version: 2.2.19(autoprefixer@10.4.21(postcss@8.5.6))(postcss@8.5.6) @@ -3835,6 +3838,11 @@ packages: engines: {node: '>=10.13.0'} hasBin: true + prettier@3.7.4: + resolution: {integrity: sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==} + engines: {node: '>=14'} + hasBin: true + pretty-hrtime@1.0.3: resolution: {integrity: sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==} engines: {node: '>= 0.8'} @@ -8882,6 +8890,8 @@ snapshots: prettier@2.8.8: {} + prettier@3.7.4: {} + pretty-hrtime@1.0.3: {} process-nextick-args@2.0.1: {} diff --git a/styles/globals.css b/styles/globals.css index 0a19a0e..bdfa2f6 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -14,7 +14,7 @@ --gray-light: #55595c; --gray-DEFAULT: #3a3a3a; --gray-dark: #333132; - --border: #DFDFDF; + --border: #dfdfdf; --radius: 0.625rem; --background: oklch(1 0 0); --foreground: oklch(0.145 0 0); @@ -52,8 +52,7 @@ @font-face { font-family: 'PublicSans'; font-display: swap; - src: url('../public/assets/fonts/PublicSans/PublicSans-VariableFont_wght.ttf') - format('truetype'); + src: url('../public/assets/fonts/PublicSans/PublicSans-VariableFont_wght.ttf') format('truetype'); font-weight: 100 900; font-style: normal; } @@ -72,8 +71,7 @@ @font-face { font-family: 'SpaceMono'; font-display: swap; - src: url('../public/assets/fonts/SpaceMono/SpaceMono-Regular.ttf') - format('truetype'); + src: url('../public/assets/fonts/SpaceMono/SpaceMono-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; } @@ -82,8 +80,7 @@ @font-face { font-family: 'SpaceMono'; font-display: swap; - src: url('../public/assets/fonts/SpaceMono/SpaceMono-Bold.ttf') - format('truetype'); + src: url('../public/assets/fonts/SpaceMono/SpaceMono-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; } @@ -92,8 +89,7 @@ @font-face { font-family: 'SpaceMono'; font-display: swap; - src: url('../public/assets/fonts/SpaceMono/SpaceMono-Italic.ttf') - format('truetype'); + src: url('../public/assets/fonts/SpaceMono/SpaceMono-Italic.ttf') format('truetype'); font-weight: 400; font-style: italic; } @@ -102,8 +98,7 @@ @font-face { font-family: 'SpaceMono'; font-display: swap; - src: url('../public/assets/fonts/SpaceMono/SpaceMono-BoldItalic.ttf') - format('truetype'); + src: url('../public/assets/fonts/SpaceMono/SpaceMono-BoldItalic.ttf') format('truetype'); font-weight: 700; font-style: italic; } diff --git a/tailwind.config.js b/tailwind.config.js index 586450e..4575a3f 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -49,8 +49,8 @@ module.exports = { dark: 'var(--gray-dark)', }, border: { - DEFAULT: 'var(--border)' - } + DEFAULT: 'var(--border)', + }, }, height: { 120: '30rem', // for larger images @@ -80,8 +80,5 @@ module.exports = { transitionDuration: ['group-hover'], }, }, - plugins: [ - require('@tailwindcss/forms'), - require('tailwindcss-selection-variant'), - ], + plugins: [require('@tailwindcss/forms'), require('tailwindcss-selection-variant')], }; diff --git a/tsconfig.json b/tsconfig.json index b9ea7c4..bc56881 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,8 +21,6 @@ // "noUnusedParameters": true, /* report errors on unused parameters (again, suggested for clean code writing) */ "incremental": true }, - "include": [ - "global.d.ts", - "next-env.d.ts", "additional.d.ts", "**/*.ts", "**/*.tsx"], + "include": ["global.d.ts", "next-env.d.ts", "additional.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules", ".next", "out"] }