diff --git a/build.ts b/build.ts index 5a90932..057f593 100644 --- a/build.ts +++ b/build.ts @@ -4,8 +4,8 @@ import { join } from 'path'; import chalk from 'chalk'; function getFiles(baseDir: string, dir?: string, filesArr?: string[]) { - dir = dir || baseDir; - filesArr = filesArr || []; + dir = dir ?? baseDir; + filesArr = filesArr ?? []; const files = readdirSync(dir); for (const file of files) { const name = join(dir, file); @@ -18,6 +18,8 @@ function getFiles(baseDir: string, dir?: string, filesArr?: string[]) { return filesArr; } +console.clear(); + console.log(chalk.cyan('Linting code...\n')); const lintOutput = await $`bunx eslint ./src/`.nothrow().text(); if (lintOutput) { @@ -25,6 +27,13 @@ if (lintOutput) { process.exit(1); } +console.log(chalk.cyan('Type-checking code...\n')); +const tscOutput = await $`bunx tsc`.nothrow().text(); +if (tscOutput) { + console.error(tscOutput); + process.exit(1); +} + console.log(chalk.cyan('Removing old build artifacts...\n')); await $`rm -rf ./public/resources/scripts/ ./public/assets.json ./public/sw.js ./public/sw-full.js`.quiet(); diff --git a/bun.lockb b/bun.lockb index 8c868d3..626f617 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/eslint.config.js b/eslint.config.js index 277aeba..cad2d16 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -4,15 +4,24 @@ import tseslint from 'typescript-eslint'; export default tseslint.config( eslint.configs.recommended, ...tseslint.configs.strict, + ...tseslint.configs.stylisticTypeChecked, { + languageOptions: { + parserOptions: { + projectService: true, + project: './tsconfig.json', + tsconfigRootDir: import.meta.dirname, + }, + }, rules: { '@typescript-eslint/ban-ts-comment': [ - 'error', { + 'error', + { 'ts-expect-error': false, 'ts-nocheck': false, 'ts-check': true, }, ], }, - } + }, ); diff --git a/index.ts b/index.ts index e0ed6fe..5ddbbb4 100644 --- a/index.ts +++ b/index.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import { join } from 'path'; import { env } from 'bun'; import express, { json, urlencoded } from 'express'; @@ -14,7 +15,7 @@ import serveStatic from 'serve-static'; import { indexRouter } from './routes/index.ts'; const BASE_DIR = join(import.meta.dir, 'public'); -const PORT = env.PORT || 3000; +const PORT = env.PORT ?? 3000; const debugLogger = debug('app:server'); const isDev = env.NODE_ENV === 'development'; diff --git a/package.json b/package.json index ccb7b48..4e860bf 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@types/compression": "^1.7.5", "@types/debug": "^4.1.12", "@types/errorhandler": "^1.5.3", + "@types/eslint__js": "^8.42.3", "@types/morgan": "^1.9.9", "@types/semver": "^7.5.8", "@types/serve-favicon": "^2.5.7", diff --git a/routes/index.ts b/routes/index.ts index b8fedc7..9574359 100644 --- a/routes/index.ts +++ b/routes/index.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import { Router } from 'express'; const indexRouter = Router(); diff --git a/src/resources/scripts/main.ts b/src/resources/scripts/main.ts index 2560cc8..c5dfe7e 100644 --- a/src/resources/scripts/main.ts +++ b/src/resources/scripts/main.ts @@ -330,9 +330,8 @@ if (window.location.pathname === '/') { googleAdsPush.text = '(adsbygoogle = window.adsbygoogle || []).push({});'; document.body.appendChild(googleAdsPush); - const adsContainers = document.getElementsByClassName('ads-container'); - for (let i = 0; i < adsContainers.length; i++) { - const adsContainer = adsContainers[i] as HTMLElement; + const adsContainers = Array.from(document.getElementsByClassName('ads-container')) as HTMLElement[]; + for (const adsContainer of adsContainers) { adsContainer.style.display = 'flex'; } }); diff --git a/src/sw-full.ts b/src/sw-full.ts index 64a4d95..e8fe422 100644 --- a/src/sw-full.ts +++ b/src/sw-full.ts @@ -53,7 +53,7 @@ self.addEventListener('activate', (event) => { self.addEventListener('fetch', (event) => { event.respondWith( caches.match(event.request).then((response) => { - return response || fetch(event.request); + return response ?? fetch(event.request); }) ); }); diff --git a/tsconfig.json b/tsconfig.json index cc394f6..2895e1d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,4 @@ { "extends": ["@tsconfig/bun", "@tsconfig/strictest"], - "compilerOptions": { - "rootDir": "src", - "outDir": "public", - "moduleDetection": "auto", - "allowImportingTsExtensions": false, - "noEmit": false, - "removeComments": true - }, - "include": ["src"] + "exclude": ["node_modules", "public"] }