Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov authored Aug 15, 2024
0 parents commit e906744
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# based on Sindre Sorhus `node-module-boilerplate`:
# https://github.com/sindresorhus/node-module-boilerplate/blob/9b8dc81a35acfbd3b75f7f19c9679e4f83b36df3/.gitattributes
* text=auto eol=lf
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
# `fail-fast` is set to `false` because we won't know which Node versions are failing and which are passing
fail-fast: false
matrix:
# https://nodejs.dev/en/about/releases/
node-version:
- 18
- 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: yarn test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
coverage/

# as Sindre Sorhus
yarn.lock

*.js
*.d.ts
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# for open-source libraries — don't use a lock file
# - 😃 as Sindre Sorhus
package-lock=false
Empty file added index.ts
Empty file.
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Antonio Stoilkov [email protected] https://astoilkov.com

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.
47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "{{data.name}}",
"version": "0.0.0",
"description": "{{data.description}}",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/astoilkov/{{data.name}}"
},
"funding": "https://github.com/sponsors/astoilkov",
"author": {
"name": "Antonio Stoilkov",
"email": "[email protected]",
"url": "https://astoilkov.com"
},
"keywords": [
"{{data.keywords}}"
],
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=16"
},
"scripts": {
"build": "tsc",
"test": "yarn build && vitest run --coverage",
"release": "yarn build && np"
},
"files": [
"index.js",
"index.d.ts",
"src/**/*.js",
"src/**/*.d.ts"
],
"devDependencies": {
"@vitest/coverage-v8": "^2.0.3",
"jsdom": "^24.1.0",
"np": "^10.0.6",
"prettier": "^3.3.3",
"typescript": "^5.5.3",
"vitest": "^2.0.3"
}
}
22 changes: 22 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# `{{data.name}}`

> {{data.description}}
[![Gzipped Size](https://img.shields.io/bundlephobia/minzip/{{data.name}})](https://bundlephobia.com/result?p={{data.name}})
[![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)

## Install

```bash
npm install {{data.name}}
```

## Why

## Usage

## API

## Alternatives

## Related
7 changes: 7 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, expect, test } from "vitest";

describe("{{data.name}}", () => {
test("", () => {
expect(true).toBe(true);
});
});
35 changes: 35 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",

"esModuleInterop": true,

// From what I understand while reading the docs "classic" was introduced first and "classic" is by
// default(except when "module": "commonjs") because of backwards compatibility.
//
// From the docs: "node module resolution is the most-commonly used in the TypeScript community and is
// recommended for most projects."
"moduleResolution": "node",

// the npm package include ".js" files only so we need ".d.ts" files to be generated
"declaration": true,

// - ℹ️ https://www.typescriptlang.org/tsconfig#isolatedModules
// - 😃 Deno requires "isolatedModules" to be set to `true`
// - 😃 the stricter version - I always prefer the stricter version
// - 😃 probably the future
"isolatedModules": true,

// strict options ensuring more stable code
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowUnreachableCode": false,
"noUncheckedIndexedAccess": true,
"noFallthroughCasesInSwitch": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true
},
"include": ["index.ts"]
}
21 changes: 21 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
// run tests on root and in /test folder with .ts and .tsx extensions
include: ["./test.ts?(x)", "./test/**/**.ts?(x)"],

// restores original implementation (after each test is finished) when calling
// `jest.spyOn()` inside of a test: https://vitest.dev/config/#restoremocks
restoreMocks: true,

// adds jsdom (https://github.com/jsdom/jsdom) APIs to tests
environment: "jsdom",

coverage: {
enabled: true,
extension: "js",
include: ["src/**/*"],
},
},
});

0 comments on commit e906744

Please sign in to comment.