generated from 2BAD/ts-lib-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5b3f6f4
Showing
22 changed files
with
7,542 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{md,snap}] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
root: true | ||
|
||
parser: '@typescript-eslint/parser' | ||
parserOptions: | ||
project: true | ||
|
||
settings: | ||
import/resolver: | ||
typescript: true | ||
node: true | ||
|
||
ignorePatterns: | ||
- 'build' | ||
- 'vitest.config.ts' | ||
|
||
plugins: | ||
- '@typescript-eslint' | ||
- 'prettier' | ||
- 'import' | ||
|
||
extends: | ||
- 'eslint:recommended' | ||
- 'plugin:@typescript-eslint/recommended-type-checked' | ||
- 'plugin:@typescript-eslint/stylistic-type-checked' | ||
- 'plugin:@typescript-eslint/strict-type-checked' | ||
- 'standard-with-typescript' | ||
- 'plugin:promise/recommended' | ||
- 'plugin:import/recommended' | ||
- 'plugin:import/typescript' | ||
- 'plugin:n/recommended' | ||
- 'plugin:prettier/recommended' | ||
- 'plugin:jsdoc/recommended-typescript-error' | ||
- 'plugin:vitest/all' | ||
|
||
rules: | ||
'@typescript-eslint/consistent-type-definitions': ['error', 'type'] | ||
'@typescript-eslint/strict-boolean-expressions': ['error', allowNullableObject: true] | ||
'@typescript-eslint/promise-function-async': 'off' | ||
'import/no-default-export': 'error' | ||
'import/no-unresolved': 'error' | ||
# disabled since it's already covered by the 'import/no-unresolved' | ||
'n/no-missing-import': 'off' | ||
'jsdoc/require-jsdoc': ['error', { 'require': { 'FunctionExpression': true, 'ArrowFunctionExpression': true } }] | ||
'jsdoc/require-returns': 'off' | ||
'jsdoc/require-throws': 'error' | ||
'jsdoc/require-param': ['error', checkDestructured: false] | ||
'jsdoc/check-param-names': ['error', checkDestructured: false] | ||
'jsdoc/tag-lines': ['error', 'any', startLines: 1] | ||
'jsdoc/require-hyphen-before-param-description': 'error' | ||
'vitest/no-hooks': ['error', 'allow': ['afterEach']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": ["config:base", "schedule:weekly", "group:allNonMajor", ":pinAllExceptPeerDependencies"], | ||
"rebaseWhen": "behind-base-branch", | ||
"commitMessageLowerCase": "auto", | ||
"lockFileMaintenance": { | ||
"enabled": true, | ||
"automerge": true, | ||
"schedule": "after 4am on monday" | ||
}, | ||
"packageRules": [ | ||
{ | ||
"matchUpdateTypes": ["minor", "patch"], | ||
"matchDepTypes": ["dependencies", "devDependencies", "action"], | ||
"automerge": true, | ||
"automergeType": "branch", | ||
"schedule": "after 4am on monday" | ||
}, | ||
{ | ||
"matchUpdateTypes": ["major"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '*.md' | ||
|
||
jobs: | ||
test: | ||
name: node@${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: ['18', '20'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run check | ||
- run: npm run test:unit | ||
- uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
flags: unit | ||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Publish | ||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: 'package.json' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- run: npm publish --provenance --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Unit | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '*.md' | ||
|
||
jobs: | ||
test: | ||
name: node@${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: ['18', '20'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run test:unit | ||
- uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
flags: unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## Windows | ||
Thumbs.db | ||
Desktop.ini | ||
$RECYCLE.BIN/ | ||
|
||
## OS X | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
Icon | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
## Editors and IDE | ||
*.sublime* | ||
*.code-workspace | ||
|
||
## Node.js | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
*.swp | ||
pids | ||
logs | ||
results | ||
tmp | ||
node_modules | ||
npm-debug.log | ||
|
||
## Build | ||
build | ||
|
||
## Coverage reports | ||
coverage | ||
|
||
## API keys and secrets | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/swcrc", | ||
"test": ".*\\.ts$", | ||
"exclude": [".*\\.test.ts$"], | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true | ||
}, | ||
"target": "esnext", | ||
"baseUrl": "./source", | ||
"paths": { | ||
"~/*": ["./*"] | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"editorconfig.editorconfig", | ||
"esbenp.prettier-vscode", | ||
"zixuanchen.vitest-explorer" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "always", | ||
"source.organizeImports": "always" | ||
}, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
### Breaking Changes | ||
|
||
### Added | ||
|
||
### Fixed | ||
|
||
### Changed | ||
|
||
### Removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 2BAD | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# TS Lib Starter | ||
|
||
A lightweight and customizable starter kit for building TypeScript libraries. It comes with ESM support, flexible configuration options, extensive ESLint rules, and built-in Github Actions integration to automate the build checks, tests, and package publishing process. With TypeScript path aliases and speedy test capabilities, developers can easily create high-quality, performant libraries using this starter kit. | ||
|
||
# ✨ Features | ||
|
||
- 🔥 **ESM First** | ||
- 📝 **Extensive ESLint Rules** | ||
- :octocat: **Github Actions** | ||
- 🪢 **Typescript Path Aliases** | ||
- 🏎️ **Super Fast Tests** | ||
|
||
# Using this template | ||
|
||
- Search `ts-lib-starter` and replace it with your custom package name. | ||
- Search `2BAD` and replace it with your name. (be careful not to replace `@2bad/tsconfig` references) | ||
|
||
# Package Choices | ||
|
||
The packages chosen for this project include some of the most popular and widely used tools for TypeScript development: | ||
|
||
- **typescript**: a superset of JavaScript that adds type annotations to improve code quality, readability, and maintainability. | ||
- **eslint**: a tool for identifying and reporting on patterns found in code. It's highly configurable and can be customized according to different coding standards. Comes preconfigured with plugins for linting tests, jsdoc blocks, and TypeScript itself. | ||
- **prettier**: an opinionated code formatter that ensures consistent formatting across the entire codebase. | ||
- **npm-run-all**: a CLI tool that allows you to run multiple npm scripts sequentially or in parallel. | ||
- **tsc-alias**: a TypeScript plugin that provides easy-to-use aliases for import statements without requiring complex configurations in Webpack or other build tools. | ||
- **vitest**: a testing framework that includes functionality for both unit and integration tests. | ||
|
||
# NPM Scripts | ||
|
||
Here are the npm scripts included in this project: | ||
|
||
- **build**: cleans the ./build directory, compiles TypeScript code to JavaScript, and applies aliases. | ||
- **format:check**: checks if TypeScript files are formatted according to Prettier standards. | ||
- **format:fix**: automatically fixes formatting issues using Prettier. | ||
- **lint**: lints TypeScript files with eslint (including tests and jsdoc blocks). | ||
- **lint:fix**: automatically fixes linting errors found by eslint. | ||
- **prepublishOnly**: prepares for publishing by running the build scripts. | ||
- **preversion**: runs clean, lint, test, and build scripts before publishing a new version. |
Oops, something went wrong.