Skip to content

Commit 34d0a44

Browse files
authored
Initial commit
0 parents  commit 34d0a44

22 files changed

+8205
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: build-typecheck-test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v2
20+
21+
- name: Set node
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: lts/*
25+
26+
- name: Setup Universal Package Manager
27+
run: npm i -g @antfu/ni
28+
29+
- name: Install
30+
run: nci
31+
32+
- name: Lint
33+
run: nr lint
34+
35+
- name: Typecheck
36+
run: nr typecheck
37+
38+
- name: Test
39+
run: nr test

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.cache
2+
.DS_Store
3+
.idea
4+
*.log
5+
*.tgz
6+
coverage
7+
dist
8+
lib-cov
9+
logs
10+
node_modules
11+
temp

.husky/commit-msg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm lint-staged

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore-workspace-root-check=true
2+
shell-emulator=true

.release-it.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"git": {
3+
"changelog": "npx changelogen",
4+
"commitMessage": "chore: release v${version}",
5+
"commitArgs": "--no-verify",
6+
"tagName": "v${version}"
7+
},
8+
"github": {
9+
"release": true,
10+
"releaseName": "v${version}"
11+
},
12+
"npm": {
13+
"release": true
14+
},
15+
"hooks": {
16+
"before:init": ["git pull", "pnpm lint"],
17+
"after:bump": "npx changelogen --output CHANGELOG.md"
18+
}
19+
}

.vscode/settings.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Enable the ESlint flat config support
3+
"eslint.experimental.useFlatConfig": true,
4+
5+
// Disable the default formatter, use eslint instead
6+
"prettier.enable": false,
7+
"editor.formatOnSave": false,
8+
9+
// Auto fix
10+
"editor.codeActionsOnSave": {
11+
"source.fixAll": "explicit",
12+
"source.organizeImports": "never"
13+
},
14+
15+
// Silent the stylistic rules in you IDE, but still auto fix them
16+
"eslint.rules.customizations": [
17+
{ "rule": "style/*", "severity": "off" },
18+
{ "rule": "*-indent", "severity": "off" },
19+
{ "rule": "*-spacing", "severity": "off" },
20+
{ "rule": "*-spaces", "severity": "off" },
21+
{ "rule": "*-order", "severity": "off" },
22+
{ "rule": "*-dangle", "severity": "off" },
23+
{ "rule": "*-newline", "severity": "off" },
24+
{ "rule": "*quotes", "severity": "off" },
25+
{ "rule": "*semi", "severity": "off" }
26+
],
27+
28+
// Enable eslint for all supported languages
29+
"eslint.validate": [
30+
"javascript",
31+
"javascriptreact",
32+
"typescript",
33+
"typescriptreact",
34+
"vue",
35+
"html",
36+
"markdown",
37+
"json",
38+
"jsonc",
39+
"yaml"
40+
]
41+
}

CHANGELOG.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
# Changelog
3+
4+
All considerable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
5+
6+
## 1.0.4...main
7+
8+
[compare changes](https://github.com/mohammadGh/my-typescript-library-starter/compare/1.0.4...main)
9+
10+
### 🚀 Enhancements
11+
12+
- **build:** Relase-it tag name configured to prefix `v` ([c382d62](https://github.com/mohammadGh/my-typescript-library-starter/commit/c382d62))
13+
- **build:** Add release to github ([d35ee30](https://github.com/mohammadGh/my-typescript-library-starter/commit/d35ee30))
14+
15+
### 🩹 Fixes
16+
17+
- **build:** Exclude root config files from coverage ([ed88519](https://github.com/mohammadGh/my-typescript-library-starter/commit/ed88519))
18+
19+
### 💅 Refactors
20+
21+
- **build:** Use es module export for commitlint config ([c5fe096](https://github.com/mohammadGh/my-typescript-library-starter/commit/c5fe096))
22+
23+
### 📖 Documentation
24+
25+
- **changelog:** Add title and short desc for changelog.md file ([ada7a71](https://github.com/mohammadGh/my-typescript-library-starter/commit/ada7a71))
26+
- **readme:** Add desc for test and coverage section ([48a4e17](https://github.com/mohammadGh/my-typescript-library-starter/commit/48a4e17))
27+
28+
### ❤️ Contributors
29+
30+
31+
32+
## 1.0.3...main
33+
34+
[compare changes](https://github.com/mohammadGh/my-typescript-library-starter/compare/1.0.3...main)
35+
36+
### 🩹 Fixes
37+
38+
- **build:** Fix configuration to use changelogen tool for updating changelog.md ([2edea7d](https://github.com/mohammadGh/my-typescript-library-starter/commit/2edea7d))
39+
40+
### ❤️ Contributors
41+
42+
43+
44+
## v1.0.1
45+
46+
47+
### 🏡 Chore
48+
49+
- **init:** Initialize project with required dependency anc configuration ([0067d35](https://github.com/mohammadGh/my-typescript-library-starter/commit/0067d35))
50+
51+
### ❤️ Contributors
52+
53+
54+

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 mgh
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# my-typescript-library-starter
2+
3+
A boilerplate (template starter) for starting a TypeScript library with ease; equipped with:
4+
5+
- **ESLint**: auto fix for formatting (no Prettier needed)
6+
- **Commitizen**: conventional commit interactive-cli helper
7+
- **Husky**: enforce eslint rules, conventional commit message before each commit
8+
- **Release-it**: semantic versioning, release management and publishing to npm or github/gitlab with interactive-cli helper
9+
- **Changelogen**: auto-generated beautiful change-log based on conventional commits
10+
11+
## Usage
12+
**1) clone:** first clone the repo (our used the github green button `Use this template` on the top-right of this window and change project-related fields in package json.
13+
> [!IMPORTANT]
14+
> After cloning the repo, replace `name`, `version`, `description`, `author`, `homepage` and `repository related links` fields in `package.json` to use this template.
15+
16+
** ** Now enter repo's directory and **install dependency** using 'npm' or 'pnpm':
17+
18+
``` shell
19+
pnpm i
20+
```
21+
22+
**2)** to **build** project:
23+
``` shell
24+
pnpm build
25+
```
26+
27+
**3)** to **commit** using commitizen-cli, after adding modified files to stage, enter `pnpm commit` instead of `git commit`:
28+
``` shell
29+
git add .
30+
pnpm commit
31+
```
32+
33+
**4)** to **release** using release-it cli:
34+
``` sell
35+
pnpm release
36+
```
37+
after releasing the `change-log doc` automtically generated to `CHANGELOG.md` file at the root of the project.
38+
39+
## ESLint & ESLint Configuration
40+
We use @antfu amazing eslint configuration. Js file `eslint.config.js` configures the `eslint`. It extends antfu's configuration but you can customize it. for example if you prefer to use double-quotations for string, change this file as:
41+
42+
``` javascript
43+
import antfu from '@antfu/eslint-config'
44+
45+
export default antfu({
46+
stylistic: {
47+
quotes: 'double'
48+
},
49+
})
50+
```
51+
## Conventional Commits & Husky Hooks
52+
we use `Commitizen` for conventional commits. `husky` is used to enforce conventional commit messages with `commitlint`.
53+
54+
## Test & Test Coverage
55+
`Vitest` is used for running tests and measure test coverage.
56+
57+
`coverage-v8` is used to obtain coverage metrics.
58+
59+
The test and coverage config file is `vitest.config.ts`. for example to exclude config files in the root of project from coverage analysis, we config `vitest.config.ts` like follow:
60+
61+
```js
62+
import { configDefaults, defineConfig } from 'vitest/config'
63+
64+
export default defineConfig({
65+
test: {
66+
coverage: {
67+
exclude: [
68+
...configDefaults.exclude,
69+
'*.config.js',
70+
'*.config.ts',
71+
],
72+
},
73+
},
74+
})
75+
```
76+
77+
## Release-it for Releasing
78+
We use `release-it` for version management and publish to anywhere (npm or github). We also use its hooks to execute any command we need to test, build, and publish our project.
79+
80+
## Auto Changelog based on Conventional Commits
81+
We use `changelogen` to generate beautiful changelogs using Conventional Commits.
82+
83+
## License
84+
[MIT](./LICENSE) License

build.config.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineBuildConfig } from 'unbuild'
2+
3+
export default defineBuildConfig({
4+
entries: [
5+
'src/index',
6+
],
7+
declaration: true,
8+
clean: true,
9+
rollup: {
10+
emitCJS: true,
11+
},
12+
})

commitlint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default { extends: ['@commitlint/config-conventional'] }

eslint.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @ts-check
2+
import antfu from '@antfu/eslint-config'
3+
4+
export default antfu(
5+
{
6+
ignores: [
7+
// eslint ignore globs here
8+
],
9+
},
10+
{
11+
rules: {
12+
// overrides
13+
},
14+
},
15+
)

0 commit comments

Comments
 (0)