Skip to content

Commit b78f753

Browse files
authored
Initial commit
0 parents  commit b78f753

26 files changed

+5706
-0
lines changed

Diff for: .editorconfig

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

Diff for: .eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cache/
2+
coverage/
3+
dist/
4+
node_modules/
5+
private/

Diff for: .eslintrc.json

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"root": true,
3+
"extends": ["@webdeveric/eslint-config-ts", "plugin:import/recommended", "plugin:import/typescript", "prettier"],
4+
"env": {
5+
"es6": true,
6+
"node": true
7+
},
8+
"parserOptions": {
9+
"project": ["./tsconfig.json"],
10+
"EXPERIMENTAL_useProjectService": true
11+
},
12+
"settings": {
13+
"import/extensions": [".ts", ".mts", ".cts", ".js", ".json"],
14+
"import/resolver": {
15+
"typescript": {
16+
"project": "./tsconfig.json"
17+
},
18+
"node": {
19+
"extensions": [".js", ".ts", ".mts", ".cts"]
20+
}
21+
},
22+
"import/parsers": {
23+
"@typescript-eslint/parser": [".ts", ".mts", ".cts"]
24+
}
25+
},
26+
"rules": {
27+
"import/first": "error",
28+
"import/no-absolute-path": "error",
29+
"import/no-cycle": "error",
30+
"import/no-deprecated": "error",
31+
"import/no-extraneous-dependencies": [
32+
"error",
33+
{
34+
"devDependencies": ["./vitest.config.mts", "./lint-staged.config.mjs", "./test/**/*"]
35+
}
36+
],
37+
"import/no-relative-packages": "error",
38+
"import/no-self-import": "error",
39+
"import/no-unresolved": "error",
40+
"import/no-useless-path-segments": [
41+
"error",
42+
{
43+
"noUselessIndex": false
44+
}
45+
],
46+
"import/order": [
47+
"error",
48+
{
49+
"alphabetize": {
50+
"order": "asc",
51+
"caseInsensitive": true
52+
},
53+
"groups": ["builtin", "external", "internal", "parent", ["sibling", "index"], "type"],
54+
"newlines-between": "always"
55+
}
56+
],
57+
"sort-imports": "off"
58+
},
59+
"overrides": [
60+
{
61+
"files": ["**/*.test.ts"],
62+
"rules": {
63+
"@typescript-eslint/no-explicit-any": "off"
64+
}
65+
}
66+
]
67+
}

Diff for: .github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @webdeveric

Diff for: .github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [webdeveric]

Diff for: .github/workflows/node.js.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Node.js CI
2+
3+
on: [push]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
ci:
11+
name: Continuous Integration
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: pnpm/action-setup@v3
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: ".nvmrc"
20+
cache: "pnpm"
21+
- name: Installing dependencies
22+
run: pnpm install
23+
- name: Linting
24+
run: pnpm lint
25+
- name: Type checking
26+
run: pnpm typecheck
27+
- name: Testing
28+
run: pnpm coverage
29+
- name: Building
30+
run: pnpm build

Diff for: .gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cache/
2+
coverage/
3+
dist/
4+
node_modules/
5+
private/

Diff for: .husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no lint-staged -- --config "$(dirname "$0")/../lint-staged.config.mjs"

Diff for: .npmrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://pnpm.io/npmrc
2+
# node-linker=hoisted
3+
# symlink=false
4+
# shared-workspace-lockfile=false
5+
auto-install-peers=true
6+
enable-pre-post-scripts=true
7+
engine-strict=true

Diff for: .nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

Diff for: .prettierignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.vscode/
2+
cache/
3+
coverage/
4+
dist/
5+
node_modules/
6+
private/
7+
.editorconfig
8+
.npmrc
9+
.nvmrc
10+
.prettierignore
11+
pnpm-lock.yaml

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Eric King
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.

Diff for: cspell.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"words": ["CODEOWNERS", "nvmrc", "postbuild", "tsbuildinfo", "typecheck", "vitest", "webdeveric"],
5+
"flagWords": [],
6+
"ignorePaths": ["pnpm-lock.yaml", "node_modules", ".vscode"],
7+
"languageSettings": [
8+
{
9+
"languageId": "commit-msg",
10+
"ignoreRegExpList": ["/^#.*/gm"]
11+
}
12+
]
13+
}

Diff for: lint-staged.config.mjs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { relative } from 'node:path';
2+
import { cwd } from 'node:process';
3+
4+
/**
5+
* @type {(filenames: string[]) => string[]>}
6+
*/
7+
const relativeFilenames = filenames => {
8+
const root = cwd();
9+
10+
return filenames.map(file => relative(root, file));
11+
};
12+
13+
/**
14+
* @type {Record<string, string | (filenames: string[]) => string | string[] | Promise<string | string[]>}
15+
*/
16+
export default {
17+
'*.{js,cjs,mjs,ts,cts,mts}': ['eslint --fix', 'prettier --write'],
18+
'*.{json,md}': 'prettier --write',
19+
'*': filenames => {
20+
const files = relativeFilenames(filenames);
21+
22+
return [
23+
`cspell lint --no-progress --no-summary --no-must-find-files ${files.join(' ')}`,
24+
`sh -c 'echo "${files.join('\n')}" | cspell --show-context stdin'`, // Spell check file names.
25+
];
26+
},
27+
};

Diff for: package.json

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"name": "@webdeveric/dual-ts-package-template",
3+
"description": "",
4+
"version": "0.0.0",
5+
"keywords": [],
6+
"author": "Eric King <[email protected]> (https://webdeveric.com/)",
7+
"private": false,
8+
"publishConfig": {
9+
"access": "public"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/webdeveric/dual-ts-package-template.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/webdeveric/dual-ts-package-template/issues"
17+
},
18+
"license": "MIT",
19+
"packageManager": "[email protected]+sha256.e1f9e8d1a16607a46dd3c158b5f7a7dc7945501d1c6222d454d63d033d1d918f",
20+
"sideEffects": false,
21+
"engines": {
22+
"node": ">=20.0.0"
23+
},
24+
"type": "module",
25+
"main": "./dist/mjs/index.js",
26+
"types": "./dist/types/index.d.ts",
27+
"exports": {
28+
".": {
29+
"types": "./dist/types/index.d.ts",
30+
"require": "./dist/cjs/index.js",
31+
"import": "./dist/mjs/index.js"
32+
},
33+
"./*": {
34+
"types": "./dist/types/*.d.ts",
35+
"require": "./dist/cjs/*.js",
36+
"import": "./dist/mjs/*.js"
37+
},
38+
"./package.json": "./package.json"
39+
},
40+
"files": [
41+
"dist"
42+
],
43+
"scripts": {
44+
"clean": "rimraf ./dist/",
45+
"prebuild": "pnpm clean",
46+
"build": "tsc --build tsconfig.cjs.json tsconfig.mjs.json --force",
47+
"validate": "validate-package-exports --check --verify --info",
48+
"postbuild": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json && echo '{\"type\":\"module\"}' > ./dist/mjs/package.json && pnpm validate",
49+
"typecheck": "tsc --build --verbose",
50+
"lint": "eslint ./*.{js,cjs,mjs,ts,cts,mts} ./src/ ./test/ --ext .ts,.mjs,.cjs",
51+
"test": "vitest",
52+
"coverage": "vitest run -c vitest.config.mts --coverage",
53+
"spellcheck": "cspell './{.github,src,test}/**/*.{ts,json}' './*.{js,json,md,mjs,mts}' './package.json' --no-progress",
54+
"prepublishOnly": "pnpm typecheck && pnpm spellcheck && pnpm lint && pnpm coverage && pnpm build",
55+
"format": "prettier --write ./*.{js,json,md,mjs,mts} ./src/ ./test/",
56+
"prepare": "husky"
57+
},
58+
"prettier": "@webdeveric/prettier-config",
59+
"devDependencies": {
60+
"@types/node": "^20.14.9",
61+
"@vitest/coverage-v8": "^1.6.0",
62+
"@webdeveric/eslint-config-ts": "^0.8.0",
63+
"@webdeveric/prettier-config": "^0.2.1",
64+
"cspell": "^8.9.1",
65+
"eslint": "^8.57.0",
66+
"eslint-config-prettier": "^9.1.0",
67+
"eslint-import-resolver-typescript": "^3.6.1",
68+
"eslint-plugin-import": "^2.29.1",
69+
"husky": "^9.0.11",
70+
"lint-staged": "^15.2.7",
71+
"prettier": "^3.3.2",
72+
"rimraf": "^5.0.7",
73+
"typescript": "^5.5.2",
74+
"validate-package-exports": "^0.5.0",
75+
"vitest": "^1.6.0"
76+
}
77+
}

0 commit comments

Comments
 (0)