Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
552a36c
chore: remove @stylistic/eslint-plugin from devDependencies and updat…
tomast1337 Sep 26, 2025
ccc1e50
build: fix typo in `start` script for frontend
Bentroen Sep 28, 2025
e4ab68d
chore: add missing `outDir` property to `tsconfig.base.json`
Bentroen Sep 28, 2025
cb73492
chore: remove workbench color customizations from VS Code settings file
Bentroen Sep 28, 2025
a238ce7
chore: enforce `eslint.useFlatConfig` in VS Code settings
Bentroen Sep 28, 2025
7d2db0f
chore: remove unused `tests` package
Bentroen Sep 28, 2025
7f61f41
chore: adjust ESLint dependencies in global `package.json`
Bentroen Sep 28, 2025
c7e6eb2
chore: remove `eslint-config-prettier` and `eslint-plugin-prettier`
Bentroen Sep 28, 2025
986c01a
chore: add `types/jest` to global dependencies
Bentroen Sep 28, 2025
c8cb2ab
chore: adjust ESLint config to use modern definition
Bentroen Sep 28, 2025
4b09277
chore: remove @typescript-eslint` packages in favor of monorepo install
Bentroen Sep 28, 2025
7073aa3
chore: adjust ESLint included files config
Bentroen Sep 28, 2025
ba1b7b1
fix: adjust ESLint import validation from error to warn
Bentroen Sep 28, 2025
fb4ef98
chore: treat `@nbw/**` imports as internal
Bentroen Sep 28, 2025
21b48c9
chore: remove invalid css and json Prettier configs
Bentroen Sep 28, 2025
57606f2
chore: use `.mjs` extension in ESLint config
Bentroen Sep 28, 2025
0a610fc
fix: remove file type filter on lint
Bentroen Sep 28, 2025
337cd93
style: format and lint codebase with Prettier + ESLint
Bentroen Sep 28, 2025
e456484
chore: run Prettier on pre-commit hook via `husky` and `lint-staged`
Bentroen Sep 28, 2025
163da29
chore: rename `prettier` script to `format`
Bentroen Sep 28, 2025
7a17c9e
chore: add linting commit to `.git-blame-ignore-revs`
Bentroen Sep 28, 2025
4cd0908
chore: add CI test setup script and update workflow for test environment
tomast1337 Sep 30, 2025
7e56b63
chore: remove test CI setup script and clean up workflow environment …
tomast1337 Sep 30, 2025
8d64b7b
test: refactor S3Client mock in FileService tests for clarity and res…
tomast1337 Sep 30, 2025
5480860
fix: set default value for allowDownload in SongUploadService
tomast1337 Sep 30, 2025
c9b2ea9
fix: update import path for SongFileType in UploadSong.context.tsx
tomast1337 Sep 30, 2025
652a807
fix: update import for undefined from zod and adjust file assignment …
tomast1337 Sep 30, 2025
1805cac
fix: simplify ad hide button logic and improve error handling for ad …
tomast1337 Sep 30, 2025
7f15299
chore: add ESLint environment declaration for browser in adasync.js
tomast1337 Sep 30, 2025
b478f5c
chore: add ESLint environment declaration for browser in adasync.js
tomast1337 Sep 30, 2025
6b92ca2
revert: #b478f5c7dd7bff1aaba656c0b18c8b4dd44b4cbb
tomast1337 Sep 30, 2025
131366a
chore: add browser-specific ESLint configuration for public files
tomast1337 Sep 30, 2025
54f7c73
chore: update lint workflow to ensure correct branch handling and set…
tomast1337 Sep 30, 2025
d160e07
chore: update lint workflow to include permissions and improve branch…
tomast1337 Sep 30, 2025
719f373
🔧 Auto-fix: ESLint formatting and fixes
actions-user Sep 30, 2025
ecae6fe
Remove ESLint environment comment from adasync.js
tomast1337 Oct 5, 2025
dd7dded
Add error logging for ad loading
tomast1337 Oct 5, 2025
c9024d3
Remove auto-commit steps from linter workflow
tomast1337 Oct 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
THUMBNAIL_URL: ${{ vars.THUMBNAIL_URL }}

Expand All @@ -21,6 +24,7 @@ jobs:
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Install bun
uses: oven-sh/setup-bun@v2
Expand All @@ -45,6 +49,14 @@ jobs:
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Ensure we're on the correct branch
if [ "${{ github.event_name }}" = "pull_request" ]; then
BRANCH_NAME="${{ github.head_ref }}"
git checkout $BRANCH_NAME || git checkout -b $BRANCH_NAME
else
BRANCH_NAME="${{ github.ref_name }}"
git checkout $BRANCH_NAME || git checkout -b $BRANCH_NAME
fi
git add .
git commit -m "🔧 Auto-fix: ESLint formatting and fixes"
git push
git push origin $BRANCH_NAME
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

- name: Install bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { UserModule } from './user/user.module';
imports: [
ConfigModule.forRoot({
isGlobal: true,
envFilePath: ['.env.development', '.env.production'],
envFilePath: ['.env.test', '.env.development', '.env.production'],
validate,
}),
//DatabaseModule,
Expand Down
22 changes: 14 additions & 8 deletions apps/backend/src/file/file.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { beforeEach, describe, expect, it, jest, mock } from 'bun:test';

import { FileService } from './file.service';

mock.module('@aws-sdk/client-s3', () => {
const mS3Client = {
send: jest.fn(),
};
// Create a mock S3Client instance
const mockS3Client = {
send: jest.fn(),
};

mock.module('@aws-sdk/client-s3', () => {
return {
S3Client: jest.fn(() => mS3Client),
S3Client: jest.fn(() => mockS3Client),
GetObjectCommand: jest.fn(),
PutObjectCommand: jest.fn(),
HeadBucketCommand: jest.fn(),
Expand All @@ -31,6 +32,10 @@ describe('FileService', () => {
let s3Client: S3Client;

beforeEach(async () => {
// Reset the mock before each test
mockS3Client.send.mockClear();
mockS3Client.send.mockResolvedValue({});

const module: TestingModule = await Test.createTestingModule({
providers: [
FileService,
Expand Down Expand Up @@ -62,8 +67,7 @@ describe('FileService', () => {
}).compile();

fileService = module.get<FileService>(FileService);

s3Client = new S3Client({});
s3Client = mockS3Client as any;
});

it('should be defined', () => {
Expand All @@ -72,13 +76,15 @@ describe('FileService', () => {

describe('verifyBucket', () => {
it('should verify the buckets successfully', async () => {
// The constructor already called verifyBucket, so we expect 2 calls from constructor
// When we call verifyBucket again, we expect 2 more calls (total 4)
(s3Client.send as jest.Mock)
.mockResolvedValueOnce({}) // Mock for the first bucket
.mockResolvedValueOnce({}); // Mock for the second bucket

await fileService['verifyBucket']();

// Ensure the mock was called twice
// Ensure the mock was called 4 times total (2 from constructor + 2 from explicit call)
expect(s3Client.send).toHaveBeenCalledTimes(4);
});

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/song/song-upload/song-upload.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class SongUploadService {
song.originalAuthor = removeExtraSpaces(body.originalAuthor);
song.description = removeExtraSpaces(body.description);
song.category = body.category;
song.allowDownload = true || body.allowDownload; //TODO: implement allowDownload;
song.allowDownload = true; //|| body.allowDownload; //TODO: implement allowDownload;
song.visibility = body.visibility;
song.license = body.license;

Expand Down
1 change: 1 addition & 0 deletions apps/frontend/public/adasync.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env browser */
var e = document.createElement('div');
e.id = 'F4uONjE2hMik';
e.style.display = 'none';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ const HideAdButton = ({
<button
className='h-6 w-3'
onClick={() => {
(setIsHidden(true),
setTimeout(
() => {
setIsHidden(false);
},
1000 * 60 * 5,
)); // Reappers after 5 minutes
setIsHidden(true);
setTimeout(() => {
setIsHidden(false);
}, 1000 * 60 * 5); // Reappears after 5 minutes
}}
>
<FontAwesomeIcon
Expand Down Expand Up @@ -62,7 +59,7 @@ const AdTemplate = ({
try {
(window.adsbygoogle = window.adsbygoogle || []).push({});
} catch (e) {
console.error(e);
// Silently handle ad loading errors
}
}
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useForm,
} from 'react-hook-form';
import toaster from 'react-hot-toast';
import { undefined } from 'zod';
import { undefined as zodUndefined } from 'zod';

import type { UploadSongDtoType } from '@nbw/database';
import { parseSongFromBuffer } from '@nbw/song';
Expand Down Expand Up @@ -147,7 +147,7 @@ export const EditSongProvider = ({
license: formMethods.getValues().license as UploadSongDtoType['license'],
category: formMethods.getValues()
.category as UploadSongDtoType['category'],
file: undefined,
file: zodUndefined,
};

// TODO: this comparison is not needed. Use isDirty field from react-hook-form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
import { toast } from 'react-hot-toast';

import { BG_COLORS, THUMBNAIL_CONSTANTS } from '@nbw/config';
import { parseSongFromBuffer } from '@nbw/song';
import { SongFileType } from '@nbw/song/src/types';
import { parseSongFromBuffer, SongFileType } from '@nbw/song';
import axiosInstance from '@web/lib/axios';
import { InvalidTokenError, getTokenLocal } from '@web/lib/axios/token.utils';

Expand Down
9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default defineConfig(
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
caughtErrors: 'none', // Allow unused error variables in catch blocks
},
],
'lines-between-class-members': [
Expand Down Expand Up @@ -100,6 +101,14 @@ export default defineConfig(
},
},

// Browser-specific configuration for public files
{
files: ['**/public/**/*.{js,jsx,mjs,cjs}'],
languageOptions: {
globals: { ...globals.browser, ...globals.es2021 },
},
},

// React specific configuration
{
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
Expand Down