build(tooling): modernize Node and TypeScript setup

This commit is contained in:
2026-08-24 14:12:04 +02:00
parent 58d77b9771
commit d750e5fe3f
10 changed files with 1403 additions and 592 deletions
+21 -2
View File
@@ -1,7 +1,9 @@
/** @type {import('eslint').Linter.FlatConfig[]} */ /** @type {import('eslint').Linter.FlatConfig[]} */
const prettierConfig = require('eslint-config-prettier/flat');
const config = [ const config = [
{ {
ignores: ['dist/', 'node_modules/'], ignores: ['coverage/', 'dist/', 'node_modules/'],
}, },
{ {
@@ -77,6 +79,23 @@ const config = [
}, },
}, },
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parserOptions: {
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
},
rules: {
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
},
},
{ {
files: ['**/*.{js,cjs}'], files: ['**/*.{js,cjs}'],
languageOptions: { languageOptions: {
@@ -88,4 +107,4 @@ const config = [
}, },
]; ];
module.exports = config; module.exports = [...config, prettierConfig];
-25
View File
@@ -1,25 +0,0 @@
/** @type {import('eslint').Linter.FlatConfig[]} */
const base = require('./eslint.config.cjs');
const typeAwareLayer = {
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: require('@typescript-eslint/parser'),
parserOptions: {
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
},
plugins: {
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
},
rules: {
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-misused-promises': ['warn', { checksVoidReturn: false }],
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
},
};
module.exports = [...base, typeAwareLayer];
+1341 -505
View File
File diff suppressed because it is too large Load Diff
+25 -22
View File
@@ -22,23 +22,20 @@
"files": [ "files": [
"dist" "dist"
], ],
"directories": { "sideEffects": false,
"lib": "src"
},
"scripts": { "scripts": {
"version:place": "node set-version.js set-ci-version", "version:place": "node set-version.js set-ci-version",
"version:check": "node set-version.js check-placeholder", "version:check": "node set-version.js check-placeholder",
"version:fix": "node set-version.js fix-placeholder", "version:fix": "node set-version.js fix-placeholder",
"lint": "eslint . --ext .ts,.tsx,.js,.cjs,.mjs", "lint": "eslint . --ext .ts,.tsx,.js,.cjs,.mjs",
"lint:fix": "eslint . --ext .ts,.tsx,.js,.cjs,.mjs --fix", "lint:fix": "eslint . --ext .ts,.tsx,.js,.cjs,.mjs --fix",
"lint:types": "eslint . --config eslint.config.typeaware.cjs --ext .ts,.tsx",
"format": "prettier --write .", "format": "prettier --write .",
"format:check": "prettier --check .", "format:check": "prettier --check .",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit --declaration --isolatedDeclarations",
"test": "jest --runInBand", "test": "jest --runInBand",
"check": "npm run version:check && npm run format:check && npm run lint && npm run lint:types && npm run typecheck && npm run test", "check": "npm run version:check && npm run format:check && npm run lint && npm run typecheck && npm run test",
"fix": "npm run version:fix && npm run format && npm run lint:fix", "fix": "npm run version:fix && npm run format && npm run lint:fix",
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsup && tsc -p tsconfig.build.json && node scripts/copy-dts.cjs", "build": "tsup",
"prepare": "husky" "prepare": "husky"
}, },
"repository": { "repository": {
@@ -70,46 +67,52 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@discordjs/opus": "^0.10.0",
"@jest/globals": "^30.4.1", "@jest/globals": "^30.4.1",
"@types/ejs": "^3.1.5", "@types/ejs": "^3.1.5",
"@types/node": "^26.0.0", "@types/node": "^24.0.0",
"@typescript-eslint/eslint-plugin": "^8.61.1", "@typescript-eslint/eslint-plugin": "^8.67.0",
"@typescript-eslint/parser": "^8.61.1", "@typescript-eslint/parser": "^8.67.0",
"eslint": "^9.39.4", "eslint": "^9.39.5",
"eslint-config-prettier": "^10.1.8", "eslint-config-prettier": "^10.1.8",
"eslint-import-resolver-typescript": "^4.4.5", "eslint-import-resolver-typescript": "^4.4.5",
"eslint-plugin-import": "^2.32.0", "eslint-plugin-import": "^2.32.0",
"eslint-plugin-n": "^18.1.0", "eslint-plugin-n": "^18.3.0",
"eslint-plugin-promise": "^7.3.0", "eslint-plugin-promise": "^7.3.0",
"eslint-plugin-unused-imports": "^4.4.1", "eslint-plugin-unused-imports": "^4.4.1",
"husky": "^9.1.7", "husky": "^9.1.7",
"jest": "^30.4.2", "jest": "^30.4.2",
"prettier": "^3.8.4", "prettier": "^3.9.6",
"ts-jest": "^29.4.11", "ts-jest": "^29.4.12",
"tsup": "^8.5.1", "tsup": "^8.5.1",
"typescript": "^6.0.3" "@typescript/native": "npm:typescript@^7.0.2",
"typescript": "npm:@typescript/typescript6@^6.0.2"
}, },
"peerDependencies": { "peerDependencies": {
"@discordjs/opus": "^0.10.0",
"@discordjs/voice": "^0.19.2", "@discordjs/voice": "^0.19.2",
"@snazzah/davey": "^0.1.12",
"ffmpeg-static": "^5.3.0", "ffmpeg-static": "^5.3.0",
"libsodium-wrappers": "^0.8.4", "opusscript": "^0.0.8"
"opusscript": "^0.0.8",
"prism-media": "^1.3.5"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@discordjs/opus": {
"optional": true
},
"ffmpeg-static": { "ffmpeg-static": {
"optional": true "optional": true
}, },
"libsodium-wrappers": { "opusscript": {
"optional": true "optional": true
} }
}, },
"overrides": { "overrides": {
"esbuild": "^0.28.1" "@discordjs/node-pre-gyp": {
"tar": "^7.5.22"
},
"esbuild": "^0.28.2"
}, },
"engines": { "engines": {
"node": ">=22.22.3" "node": "24.x"
}, },
"private": false, "private": false,
"publishConfig": { "publishConfig": {
-11
View File
@@ -1,11 +0,0 @@
const { copyFileSync, existsSync } = require('node:fs');
const { join } = require('node:path');
const declarationFile = join(__dirname, '..', 'dist', 'index.d.ts');
const esmDeclarationFile = join(__dirname, '..', 'dist', 'index.d.mts');
if (!existsSync(declarationFile)) {
throw new Error(`Missing declaration file: ${declarationFile}`);
}
copyFileSync(declarationFile, esmDeclarationFile);
-10
View File
@@ -1,10 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
"rootDir": "./src"
},
"include": ["src/**/*.ts"]
}
+3
View File
@@ -1,4 +1,7 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["src/**/*.ts", "tests/**/*.ts", "tsup.config.ts"] "include": ["src/**/*.ts", "tests/**/*.ts", "tsup.config.ts"]
} }
+5 -14
View File
@@ -1,31 +1,22 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2022", "target": "ES2024",
"lib": ["ES2022"], "lib": ["ES2024"],
"module": "Node16", "module": "Node20",
"moduleResolution": "node16",
"resolveJsonModule": true,
"types": [], "types": [],
"rootDir": "./", "rootDir": "./",
"outDir": "./dist", "outDir": "./dist",
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"strict": true, "strict": true,
"noImplicitAny": true, "isolatedModules": true,
"strictNullChecks": true, "erasableSyntaxOnly": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"alwaysStrict": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"noUncheckedIndexedAccess": true, "noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true, "exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"useUnknownInCatchVariables": true,
"skipLibCheck": true,
"noEmitOnError": true "noEmitOnError": true
}, },
"include": ["src"], "include": ["src"],
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"isolatedModules": true, "outDir": "./dist-test",
"outDir": "./dist-test" "skipLibCheck": true
}, },
"include": ["src/**/*.ts", "tests/**/*.ts", "tsup.config.ts"] "include": ["src/**/*.ts", "tests/**/*.ts", "tsup.config.ts"]
} }
+6 -1
View File
@@ -3,7 +3,12 @@ import { defineConfig } from 'tsup';
export default defineConfig({ export default defineConfig({
format: ['cjs', 'esm'], format: ['cjs', 'esm'],
entry: ['./src/index.ts'], entry: ['./src/index.ts'],
dts: false, dts: {
compilerOptions: {
// tsup's declaration bundler still sets the removed baseUrl option internally.
ignoreDeprecations: '6.0',
},
},
shims: true, shims: true,
skipNodeModulesBundle: true, skipNodeModulesBundle: true,
clean: true, clean: true,