Add typescript stuff

This commit is contained in:
Garrett Mills 2021-11-19 14:13:32 -06:00
parent 0b89af10d3
commit 103ab3979a
7 changed files with 1277 additions and 124 deletions

4
.eslintignore Normal file
View File

@ -0,0 +1,4 @@
node_modules
lib
dist

114
.eslintrc.json Normal file
View File

@ -0,0 +1,114 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
],
"semi": [
"error",
"never"
],
"no-console": "error",
"curly": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"no-alert": "error",
"no-caller": "error",
"no-constructor-return": "error",
"no-eval": "error",
"no-implicit-coercion": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-return-await": "error",
"no-throw-literal": "error",
"no-useless-call": "error",
"radix": "error",
"yoda": "error",
"@typescript-eslint/no-shadow": "error",
"brace-style": "error",
"camelcase": "error",
"comma-dangle": [
"error",
"always-multiline"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"comma-style": [
"error",
"last"
],
"computed-property-spacing": [
"error",
"never"
],
"eol-last": "error",
"func-call-spacing": [
"error",
"never"
],
"keyword-spacing": [
"error",
{
"before": true,
"after": true
}
],
"lines-between-class-members": "error",
"max-params": [
"error",
4
],
"new-parens": [
"error",
"always"
],
"newline-per-chained-call": "error",
"no-trailing-spaces": "error",
"no-underscore-dangle": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"object-property-newline": "error",
"prefer-exponentiation-operator": "error",
"prefer-object-spread": "error",
"spaced-comment": [
"error",
"always"
],
"prefer-const": "error",
"@typescript-eslint/no-explicit-any": "off"
}
}

212
.gitignore vendored
View File

@ -9,9 +9,6 @@
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
@ -74,155 +71,122 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# ---> Linux
*~
# ---> Node
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# KDE directory preferences
.directory
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Linux trash folder which might appear on any partition or disk
.Trash-*
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# Coverage directory used by tools like istanbul
coverage
*.lcov
# ---> Windows
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# nyc test coverage
.nyc_output
# Dump file
*.stackdump
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Folder config file
[Dd]esktop.ini
# Bower dependency directory (https://bower.io/)
bower_components
# Recycle Bin used on file shares
$RECYCLE.BIN/
# node-waf configuration
.lock-wscript
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Windows shortcuts
*.lnk
# Dependency directories
node_modules/
jspm_packages/
# ---> macOS
# General
.DS_Store
.AppleDouble
.LSOverride
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# Icon must end with two \r
Icon
# TypeScript cache
*.tsbuildinfo
# Thumbnails
._*
# Optional npm cache directory
.npm
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Optional eslint cache
.eslintcache
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# ---> Vim
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Optional REPL history
.node_repl_history
# Session
Session.vim
Sessionx.vim
# Output of 'npm pack'
*.tgz
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# Yarn Integrity file
.yarn-integrity
# ---> Emacs
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# dotenv environment variables file
.env
.env.test
# Org-mode
.org-id-locations
*_archive
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# flymake-mode
*_flymake.*
# Next.js build output
.next
out
# eshell files
/eshell/history
/eshell/lastdir
# Nuxt.js build / generate output
.nuxt
dist
# elpa packages
/elpa/
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# reftex files
*.rel
# vuepress build output
.vuepress/dist
# AUCTeX auto folder
/auto/
# Serverless directories
.serverless/
# cask packages
.cask/
dist/
# FuseBox cache
.fusebox/
# Flycheck
flycheck_*.el
# DynamoDB Local files
.dynamodb/
# server auth directory
/server/
# TernJS port file
.tern-port
# projectiles files
.projectile
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# directory configuration
.dir-locals.el
# network security
/network-security.data
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
/lib

43
package.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "template-npm-typescript",
"version": "0.1.0",
"description": "A template for NPM packages built with TypeScript",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"directories": {
"lib": "lib"
},
"scripts": {
"build": "pnpm run lint && rimraf lib && tsc",
"app": "pnpm run build && node lib/index.js",
"prepare": "pnpm run build",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint --fix . --ext .ts"
},
"files": [
"lib/**/*"
],
"prepare": "pnpm run build",
"postversion": "git push && git push --tags",
"repository": {
"type": "git",
"url": "https://code.garrettmills.dev/garrettmills/template-npm-typescript"
},
"author": "Garrett Mills <shout@garrettmills.dev>",
"license": "MIT",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"eslint": "^8.2.0"
},
"dependencies": {
"@types/rimraf": "^3.0.2",
"@types/uuid": "^8.3.3",
"dotenv": "^10.0.0",
"mkdirp": "^1.0.4",
"rimraf": "^3.0.2",
"ts-node": "^10.4.0",
"typescript": "^4.5.2",
"uuid": "^8.3.2"
}
}

1012
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

3
src/index.ts Normal file
View File

@ -0,0 +1,3 @@
export const HELLO_WORLD = 'Hello, World!'

13
tsconfig.json Normal file
View File

@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"include": ["src"],
"exclude": ["node_modules"]
}