init repo from library-template

This commit is contained in:
2025-09-11 09:45:24 +02:00
commit 30970d257d
11 changed files with 123 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
package-lock.json
._*
.idea/
.DS_Store
node_modules/
dist/
+7
View File
@@ -0,0 +1,7 @@
.woodpecker/
test/
.gitignore
README.md
.prettierignore
.prettierrc
eslint.config.ts
+4
View File
@@ -0,0 +1,4 @@
.woodpecker
node_modules
test
dist
+11
View File
@@ -0,0 +1,11 @@
{
"arrowParens": "avoid",
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": false,
"printWidth": 120,
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "none"
}
+19
View File
@@ -0,0 +1,19 @@
when:
- path:
include: ['src/**/*.ts']
steps:
install:
image: node
when:
- event: [pull_request, push, manual]
commands:
- npm install
test:
image: oven/bun:alpine
when:
- event: [pull_request, push, manual]
depends_on: install
commands:
- bun test
+8
View File
@@ -0,0 +1,8 @@
# Library template
Basic template to create a TypeScript library that works properly when included
## How to split in multiple file
Technically, there is nothing to do, but if you want to allow sub-imports, you have to :
1. In `package.json`, under `exports`, add `"./submodule": "./src/submodule.ts"`
2. In `tsconfig.json`, under `paths`, add `"lib-name/*": ["./src/*"]`
+15
View File
@@ -0,0 +1,15 @@
import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import {defineConfig, globalIgnores} from 'eslint/config'
export default defineConfig([
tseslint.configs.recommended,
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
plugins: {js},
extends: ['js/recommended'],
languageOptions: {globals: {...globals.browser, ...globals.node}}
},
globalIgnores(['dist'])
])
+33
View File
@@ -0,0 +1,33 @@
{
"scripts": {
"check": "clear ; npm run typecheck && npm run lint && npx prettier -c **/*.{js,jsx,ts,tsx} && clear && echo 'OK'",
"fmt": "prettier --write **/*.{js,jsx,ts,tsx}",
"lint": "eslint **/*.{js,jsx,ts,tsx}",
"test": "bun test",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"log": "git+https://git.pband.ch/typescript/log.git"
},
"devDependencies": {
"@eslint/js": "^9.35.0",
"@types/bun": "^1.2.21",
"bun": "^1.2.21",
"eslint": "^9.35.0",
"globals": "^16.4.0",
"jiti": "^2.5.1",
"prettier": "^3.6.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.43.0"
},
"name": "lib-template",
"version": "1.0.0",
"type": "module",
"main": "./src/index.ts",
"exports": {
".": "./src/index.ts"
}
}
+3
View File
@@ -0,0 +1,3 @@
export function greet() {
console.log('Hello, world!')
}
+3
View File
@@ -0,0 +1,3 @@
import {test} from 'bun:test'
test('Basic test', () => 'Hello, world!')
+14
View File
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "node",
"declaration": true,
"outDir": "dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src"]
}