build(tooling): modernize Node and TypeScript setup
This commit is contained in:
+21
-2
@@ -1,7 +1,9 @@
|
||||
/** @type {import('eslint').Linter.FlatConfig[]} */
|
||||
const prettierConfig = require('eslint-config-prettier/flat');
|
||||
|
||||
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}'],
|
||||
languageOptions: {
|
||||
@@ -88,4 +107,4 @@ const config = [
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = config;
|
||||
module.exports = [...config, prettierConfig];
|
||||
|
||||
@@ -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];
|
||||
Generated
+1341
-505
File diff suppressed because it is too large
Load Diff
+25
-22
@@ -22,23 +22,20 @@
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"directories": {
|
||||
"lib": "src"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"version:place": "node set-version.js set-ci-version",
|
||||
"version:check": "node set-version.js check-placeholder",
|
||||
"version:fix": "node set-version.js fix-placeholder",
|
||||
"lint": "eslint . --ext .ts,.tsx,.js,.cjs,.mjs",
|
||||
"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:check": "prettier --check .",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"typecheck": "tsc --noEmit --declaration --isolatedDeclarations",
|
||||
"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",
|
||||
"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"
|
||||
},
|
||||
"repository": {
|
||||
@@ -70,46 +67,52 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@jest/globals": "^30.4.1",
|
||||
"@types/ejs": "^3.1.5",
|
||||
"@types/node": "^26.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.61.1",
|
||||
"@typescript-eslint/parser": "^8.61.1",
|
||||
"eslint": "^9.39.4",
|
||||
"@types/node": "^24.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
||||
"@typescript-eslint/parser": "^8.67.0",
|
||||
"eslint": "^9.39.5",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-import-resolver-typescript": "^4.4.5",
|
||||
"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-unused-imports": "^4.4.1",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^30.4.2",
|
||||
"prettier": "^3.8.4",
|
||||
"ts-jest": "^29.4.11",
|
||||
"prettier": "^3.9.6",
|
||||
"ts-jest": "^29.4.12",
|
||||
"tsup": "^8.5.1",
|
||||
"typescript": "^6.0.3"
|
||||
"@typescript/native": "npm:typescript@^7.0.2",
|
||||
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@discordjs/voice": "^0.19.2",
|
||||
"@snazzah/davey": "^0.1.12",
|
||||
"ffmpeg-static": "^5.3.0",
|
||||
"libsodium-wrappers": "^0.8.4",
|
||||
"opusscript": "^0.0.8",
|
||||
"prism-media": "^1.3.5"
|
||||
"opusscript": "^0.0.8"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@discordjs/opus": {
|
||||
"optional": true
|
||||
},
|
||||
"ffmpeg-static": {
|
||||
"optional": true
|
||||
},
|
||||
"libsodium-wrappers": {
|
||||
"opusscript": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"overrides": {
|
||||
"esbuild": "^0.28.1"
|
||||
"@discordjs/node-pre-gyp": {
|
||||
"tar": "^7.5.22"
|
||||
},
|
||||
"esbuild": "^0.28.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.22.3"
|
||||
"node": "24.x"
|
||||
},
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
|
||||
@@ -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);
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": false,
|
||||
"emitDeclarationOnly": true,
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "tests/**/*.ts", "tsup.config.ts"]
|
||||
}
|
||||
|
||||
+5
-14
@@ -1,31 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"module": "Node16",
|
||||
"moduleResolution": "node16",
|
||||
"resolveJsonModule": true,
|
||||
"target": "ES2024",
|
||||
"lib": ["ES2024"],
|
||||
"module": "Node20",
|
||||
"types": [],
|
||||
"rootDir": "./",
|
||||
"outDir": "./dist",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictBindCallApply": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"alwaysStrict": true,
|
||||
"isolatedModules": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"useUnknownInCatchVariables": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmitOnError": true
|
||||
},
|
||||
"include": ["src"],
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"isolatedModules": true,
|
||||
"outDir": "./dist-test"
|
||||
"outDir": "./dist-test",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "tests/**/*.ts", "tsup.config.ts"]
|
||||
}
|
||||
|
||||
+6
-1
@@ -3,7 +3,12 @@ import { defineConfig } from 'tsup';
|
||||
export default defineConfig({
|
||||
format: ['cjs', 'esm'],
|
||||
entry: ['./src/index.ts'],
|
||||
dts: false,
|
||||
dts: {
|
||||
compilerOptions: {
|
||||
// tsup's declaration bundler still sets the removed baseUrl option internally.
|
||||
ignoreDeprecations: '6.0',
|
||||
},
|
||||
},
|
||||
shims: true,
|
||||
skipNodeModulesBundle: true,
|
||||
clean: true,
|
||||
|
||||
Reference in New Issue
Block a user