Skip to content

Commit 2f3b2ec

Browse files
authored
Initial commit
0 parents  commit 2f3b2ec

12 files changed

+195
-0
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 4
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# based on Sindre Sorhus `node-module-boilerplate`:
2+
# https://github.com/sindresorhus/node-module-boilerplate/blob/9b8dc81a35acfbd3b75f7f19c9679e4f83b36df3/.gitattributes
3+
* text=auto eol=lf

.github/workflows/main.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Node.js ${{ matrix.node-version }}
8+
runs-on: ubuntu-latest
9+
strategy:
10+
# `fail-fast` is set to `false` because we won't know which Node versions are failing and which are passing
11+
fail-fast: false
12+
matrix:
13+
# https://nodejs.dev/en/about/releases/
14+
node-version:
15+
- 18
16+
- 20
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
- run: yarn install
23+
- run: yarn test

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
coverage/
3+
4+
# as Sindre Sorhus
5+
yarn.lock
6+
7+
*.js
8+
*.d.ts

.npmrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# for open-source libraries — don't use a lock file
2+
# - 😃 as Sindre Sorhus
3+
package-lock=false

index.ts

Whitespace-only changes.

license

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Antonio Stoilkov hello@astoilkov.com https://astoilkov.com
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.

package.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "{{data.name}}",
3+
"version": "0.1.0",
4+
"description": "{{data.description}}",
5+
"license": "MIT",
6+
"repository": "astoilkov/{{data.name}}",
7+
"funding": "https://github.com/sponsors/astoilkov",
8+
"author": {
9+
"name": "Antonio Stoilkov",
10+
"email": "hello@astoilkov.com",
11+
"url": "https://astoilkov.com"
12+
},
13+
"keywords": [
14+
"{{data.keywords}}"
15+
],
16+
"type": "module",
17+
"exports": {
18+
"types": "./index.d.ts",
19+
"default": "./index.js"
20+
},
21+
"sideEffects": false,
22+
"engines": {
23+
"node": ">=16"
24+
},
25+
"scripts": {
26+
"build": "tsc",
27+
"test": "yarn run build && vitest run --coverage",
28+
"release": "np"
29+
},
30+
"files": [
31+
"index.js",
32+
"index.d.ts",
33+
"src/*.js",
34+
"src/*.d.ts"
35+
],
36+
"devDependencies": {
37+
"@vitest/coverage-v8": "^0.33.0",
38+
"jsdom": "^22.1.0",
39+
"np": "^8.0.4",
40+
"prettier": "^3.0.3",
41+
"typescript": "^5.2.2",
42+
"vitest": "^0.34.6"
43+
}
44+
}

readme.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# `{{data.name}}`
2+
3+
> {{data.description}}
4+
5+
[![Gzipped Size](https://img.shields.io/bundlephobia/minzip/{{data.name}})](https://bundlephobia.com/result?p={{data.name}})
6+
[![Build Status](https://img.shields.io/github/actions/workflow/status/astoilkov/{{data.name}}/main.yml?branch=main)](https://github.com/astoilkov/{{data.name}}/actions/workflows/main.yml)
7+
8+
## Install
9+
10+
```bash
11+
npm install {{data.name}}
12+
```
13+
14+
## Why
15+
16+
## Usage
17+
18+
## API
19+
20+
## Alternatives
21+
22+
## Related

test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { describe, expect, test } from "vitest";
2+
3+
describe("{{data.name}}", () => {
4+
test("", () => {
5+
expect(true).toBe(true);
6+
});
7+
});

tsconfig.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
5+
// previously "CommonJS", we now use "ES2015" to transpile TypeScript to "export default"
6+
// instead of "exports.default ="
7+
"module": "ES2020",
8+
9+
"esModuleInterop": true,
10+
11+
// From what I understand while reading the docs "classic" was introduced first and "classic" is by
12+
// default(except when "module": "commonjs") because of backwards compatibility.
13+
//
14+
// From the docs: "node module resolution is the most-commonly used in the TypeScript community and is
15+
// recommended for most projects."
16+
"moduleResolution": "node",
17+
18+
// the npm package include ".js" files only so we need ".d.ts" files to be generated
19+
"declaration": true,
20+
21+
// - ℹ️ https://www.typescriptlang.org/tsconfig#isolatedModules
22+
// - 😃 Deno requires "isolatedModules" to be set to `true`
23+
// - 😃 the stricter version - I always prefer the stricter version
24+
// - 😃 probably the future
25+
"isolatedModules": true,
26+
27+
// strict options ensuring more stable code
28+
"strict": true,
29+
"noUnusedLocals": true,
30+
"noUnusedParameters": true,
31+
"allowUnreachableCode": false,
32+
"noUncheckedIndexedAccess": true,
33+
"noFallthroughCasesInSwitch": true,
34+
"exactOptionalPropertyTypes": true,
35+
"forceConsistentCasingInFileNames": true
36+
},
37+
"include": ["index.ts"]
38+
}

vitest.config.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
// run tests on root and in /test folder with .ts and .tsx extensions
6+
include: ["./test.ts?(x)", "./test/**/**.ts?(x)"],
7+
8+
// restores original implementation (after each test is finished) when calling
9+
// `jest.spyOn()` inside of a test: https://vitest.dev/config/#restoremocks
10+
restoreMocks: true,
11+
12+
// adds jsdom (https://github.com/jsdom/jsdom) APIs to tests
13+
environment: "jsdom",
14+
},
15+
});

0 commit comments

Comments
 (0)