feat: setup stricter linting
This commit is contained in:
41
.golangci.yml
Normal file
41
.golangci.yml
Normal file
@@ -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
|
||||||
@@ -2,27 +2,38 @@ import tseslint from '@typescript-eslint/eslint-plugin';
|
|||||||
import tsParser from '@typescript-eslint/parser';
|
import tsParser from '@typescript-eslint/parser';
|
||||||
import prettier from 'eslint-plugin-prettier';
|
import prettier from 'eslint-plugin-prettier';
|
||||||
import eslintConfigPrettier from 'eslint-config-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 [
|
export default [
|
||||||
{
|
{
|
||||||
ignores: ['dist/**', 'node_modules/**', 'server', '*.js'],
|
ignores: ['dist/**', 'node_modules/**', 'server', '*.js'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['**/*.ts'],
|
files: ['static/**/*.ts'],
|
||||||
plugins: {
|
plugins: {
|
||||||
'@typescript-eslint': tseslint,
|
'@typescript-eslint': tseslint,
|
||||||
prettier,
|
prettier,
|
||||||
},
|
},
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
parser: tsParser,
|
parser: tsParser,
|
||||||
|
parserOptions: {
|
||||||
|
project: ['./tsconfig.json'],
|
||||||
|
tsconfigRootDir,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
...eslintConfigPrettier.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': [
|
'@typescript-eslint/no-unused-vars': [
|
||||||
'warn',
|
'error',
|
||||||
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
|
||||||
],
|
],
|
||||||
|
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
|
||||||
'prettier/prettier': 'error',
|
'prettier/prettier': 'error',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
8
justfile
8
justfile
@@ -7,7 +7,13 @@ fmt:
|
|||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
go fmt ./... && go vet ./...
|
golangci-lint run
|
||||||
|
|
||||||
|
lint-ts:
|
||||||
|
bun run lint:ts
|
||||||
|
|
||||||
|
lint-go:
|
||||||
|
bun run lint:go
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test ./...
|
go test ./...
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
'commands':
|
'commands':
|
||||||
{
|
{
|
||||||
'go-fmt': { 'run': 'go fmt ./...' },
|
'go-fmt': { 'run': 'go fmt ./...' },
|
||||||
'go-vet': { 'run': 'go vet ./...' },
|
'go-lint': { 'run': 'golangci-lint run' },
|
||||||
'go-test': { 'run': 'go test ./...' },
|
'go-test': { 'run': 'go test ./...' },
|
||||||
'ts-typecheck': { 'run': 'bunx tsc -p tsconfig.json --noEmit' },
|
'ts-typecheck': { 'run': 'bunx tsc -p tsconfig.json --noEmit' },
|
||||||
'build-assets': { 'run': 'bun run build:assets' },
|
'build-assets': { 'run': 'bun run build:assets' },
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
"typecheck": "bunx tsc -p tsconfig.json --noEmit",
|
"typecheck": "bunx tsc -p tsconfig.json --noEmit",
|
||||||
"build:assets": "bun run build:css && bun run build:ts",
|
"build:assets": "bun run build:css && bun run build:ts",
|
||||||
"format": "bunx prettier . --write",
|
"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": {
|
"devDependencies": {
|
||||||
"@tailwindcss/cli": "^4.2.4",
|
"@tailwindcss/cli": "^4.2.4",
|
||||||
|
|||||||
@@ -11,5 +11,5 @@
|
|||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"include": ["static/*.ts"]
|
"include": ["eslint.config.ts", "static/**/*.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user