feat(bun): adding the configuration for better developpement

This commit is contained in:
Raphael 2025-10-14 00:26:56 +02:00 committed by Raphaël
parent 6e154a8e60
commit ac1abbabc7
5 changed files with 137 additions and 62 deletions

3
bun-types.d.ts vendored Normal file
View file

@ -0,0 +1,3 @@
/// <reference types="bun-types" />
/// <reference types="discord.js" />
/// <reference types="node" />

2
bunfig.toml Normal file
View file

@ -0,0 +1,2 @@
[alias]
"@lib" = "./src/lib"

View file

@ -1,55 +1,78 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import js from "@eslint/js";
import ts from "typescript-eslint";
export default [
js.configs.recommended,
...ts.configs.recommended,
{
languageOptions: {
ecmaVersion: 'latest',
},
rules: {
'arrow-spacing': ['warn', { before: true, after: true }],
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': 'error',
'comma-style': 'error',
curly: ['error', 'multi-line', 'consistent'],
'dot-location': ['error', 'property'],
'handle-callback-err': 'off',
indent: ['error', 'tab'],
'keyword-spacing': 'error',
'max-nested-callbacks': ['error', { max: 4 }],
'max-statements-per-line': ['error', { max: 2 }],
'no-console': 'off',
'no-empty-function': 'error',
'no-floating-decimal': 'error',
'no-inline-comments': 'error',
'no-lonely-if': 'error',
'no-multi-spaces': 'error',
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }],
'no-shadow': ['error', { allow: ['err', 'resolve', 'reject'] }],
'no-trailing-spaces': ['error'],
'no-var': 'error',
'no-undef': 'off',
'object-curly-spacing': ['error', 'always'],
'prefer-const': 'error',
quotes: ['error', 'single'],
semi: ['error', 'always'],
'space-before-blocks': 'error',
'space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
},
],
'space-in-parens': 'error',
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'spaced-comment': 'error',
yoda: 'error',
},
},
js.configs.recommended,
...ts.configs.recommended,
{
languageOptions: {
ecmaVersion: "latest",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: import.meta.dirname,
},
},
ignores: [
'**/dist/**',
'**/node_modules/**',
'bun-types.d.ts',
'eslint.config.js',
'package.json',
'tsconfig.json',
'bunfig.toml',
],
rules: {
"arrow-spacing": ["warn", { before: true, after: true }],
"brace-style": ["error", "stroustrup", { allowSingleLine: true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
curly: ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"handle-callback-err": "off",
indent: ["error", "tab"],
"keyword-spacing": "error",
"max-nested-callbacks": ["error", { max: 4 }],
"max-statements-per-line": ["error", { max: 2 }],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { max: 2, maxEOF: 1, maxBOF: 0 }],
"no-shadow": ["error", { allow: ["err", "resolve", "reject"] }],
"no-trailing-spaces": ["error"],
"no-var": "error",
"no-undef": "off",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
quotes: ["error", "single"],
semi: ["error", "always"],
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
{
anonymous: "never",
named: "never",
asyncArrow: "always",
},
],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
yoda: "error",
// TypeScript rules - less strict for better DX
"@typescript-eslint/no-unsafe-*": "off",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/no-deprecated": "warn",
"@typescript-eslint/no-misused-promises": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-unnecessary-condition": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn",
},
},
];

View file

@ -4,7 +4,10 @@
"type": "module",
"scripts": {
"dev": "bun --watch src/index.ts",
"build": "bun build src/index.ts --outdir dist --target bun",
"debug": "bun --watch src/index.ts --debug",
"lint": "bunx eslint src --ext .ts,.js --fix || watch -n 0.5 bunx eslint src --ext .ts,.js",
"lint:fix": "bunx eslint src --ext .ts,.js --fix",
"type-check": "bunx tsc --noEmit",
"prepare": "husky"
},
"private": true,
@ -14,23 +17,27 @@
]
},
"devDependencies": {
"@types/bun": "latest",
"eslint": "^9.36.0",
"@types/bun": "^1.3.0",
"@types/node": "^24.7.2",
"eslint": "^9.37.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"husky": "^9.1.7",
"lint-staged": "^16.2.3",
"lint-staged": "^16.2.4",
"prettier": "^3.6.2",
"prisma": "^6.16.3",
"typescript-eslint": "^8.45.0"
"prisma": "^6.17.1",
"typescript-eslint": "^8.46.1"
},
"peerDependencies": {
"typescript": "^5.9.2"
"typescript": "^5.9.3"
},
"dependencies": {
"@prisma/client": "^6.16.3",
"discord.js": "^14.22.1",
"@discordjs/builders": "^1.12.2",
"@prisma/client": "^6.17.1",
"chalk": "^5.6.2",
"discord.js": "^15.0.0-dev.1760227315-180dd60c6",
"dotenv": "^17.2.3",
"mariadb": "^3.4.5"
"mariadb": "^3.4.5",
"module-alias": "^2.2.3"
}
}

40
tsconfig.json Normal file
View file

@ -0,0 +1,40 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"baseUrl": "./src",
"paths": {
"@lib/*": ["lib/*"]
},
"sourceMap": true,
"removeComments": false,
"preserveConstEnums": true,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"types": ["node", "discord.js", "bun-types"],
"strict": true,
"noImplicitAny": false,
"strictNullChecks": true,
"strictBindCallApply": true,
"alwaysStrict": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"allowJs": true,
"isolatedModules": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"pretty": true,
"newLine": "lf",
"useDefineForClassFields": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}