From fc1883a6c391f1cf897de122d90aaee9782f380b Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sun, 24 May 2026 22:36:41 +0200 Subject: [PATCH] feat: setup stricter linting --- .golangci.yml | 41 +++++++++++++++++++++++++++++++++++++++++ eslint.config.ts | 17 ++++++++++++++--- justfile | 8 +++++++- lefthook.yml | 2 +- package.json | 5 ++++- tsconfig.json | 2 +- 6 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..0d01c47 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,41 @@ +run: + timeout: 5m + +output: + sort-results: true + +linters: + disable-all: true + enable: + - errcheck + - exportloopref + - govet + - ineffassign + - revive + - staticcheck + - typecheck + - unconvert + - unused + +linters-settings: + revive: + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: early-return + - name: error-naming + - name: error-return + - name: exported + - name: if-return + - name: increment-decrement + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: unnecessary-stmt + - name: var-declaration + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 diff --git a/eslint.config.ts b/eslint.config.ts index 261be59..9b6635e 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -2,27 +2,38 @@ import tseslint from '@typescript-eslint/eslint-plugin'; import tsParser from '@typescript-eslint/parser'; import prettier from 'eslint-plugin-prettier'; import eslintConfigPrettier from 'eslint-config-prettier'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const tsconfigRootDir = path.dirname(fileURLToPath(import.meta.url)); export default [ { ignores: ['dist/**', 'node_modules/**', 'server', '*.js'], }, { - files: ['**/*.ts'], + files: ['static/**/*.ts'], plugins: { '@typescript-eslint': tseslint, prettier, }, languageOptions: { parser: tsParser, + parserOptions: { + project: ['./tsconfig.json'], + tsconfigRootDir, + }, }, rules: { ...eslintConfigPrettier.rules, - '@typescript-eslint/no-explicit-any': 'off', + ...tseslint.configs.recommended.rules, + ...tseslint.configs.stylistic.rules, + '@typescript-eslint/no-explicit-any': 'error', '@typescript-eslint/no-unused-vars': [ - 'warn', + 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }, ], + '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }], 'prettier/prettier': 'error', }, }, diff --git a/justfile b/justfile index 8550c92..a91001f 100644 --- a/justfile +++ b/justfile @@ -7,7 +7,13 @@ fmt: go fmt ./... lint: - go fmt ./... && go vet ./... + golangci-lint run + +lint-ts: + bun run lint:ts + +lint-go: + bun run lint:go test: go test ./... diff --git a/lefthook.yml b/lefthook.yml index 27f2d6f..1ffd72e 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -13,7 +13,7 @@ 'commands': { 'go-fmt': { 'run': 'go fmt ./...' }, - 'go-vet': { 'run': 'go vet ./...' }, + 'go-lint': { 'run': 'golangci-lint run' }, 'go-test': { 'run': 'go test ./...' }, 'ts-typecheck': { 'run': 'bunx tsc -p tsconfig.json --noEmit' }, 'build-assets': { 'run': 'bun run build:assets' }, diff --git a/package.json b/package.json index c02360b..ae277b9 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,10 @@ "typecheck": "bunx tsc -p tsconfig.json --noEmit", "build:assets": "bun run build:css && bun run build:ts", "format": "bunx prettier . --write", - "lint": "bunx eslint . --fix" + "lint": "bun run lint:ts && bun run lint:go", + "lint:ts": "bunx eslint . --max-warnings 0", + "lint:ts:fix": "bunx eslint . --fix", + "lint:go": "golangci-lint run" }, "devDependencies": { "@tailwindcss/cli": "^4.2.4", diff --git a/tsconfig.json b/tsconfig.json index 0b8f55a..131ff78 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,5 +11,5 @@ "removeComments": false, "skipLibCheck": true }, - "include": ["static/*.ts"] + "include": ["eslint.config.ts", "static/**/*.ts"] }