- Quick Start
- Features
- TypeScript
- ESLint
- Ava
- Dripip
- Simple succinct friendly low-barrier issue templates
- Prettier
- npm scripts for development lifecycle
- CI with GitHub Actions
- Renovate
- Yarn 2
- [CJS+ESM Hybrid package build (see Dr. Axel's article about this)](#cjsesm-hybrid-package-build-see-dr-axels-article-about-thishttps2alitycom201910hybrid-npm-packageshtml)
- VSCode Settings
- Readme Table of Contents
Project template for TypeScript libraries
-
Setup a clone of this repo:
gh repo clone prisma-labs/mockapie <your package name> && cd <your package name> && yarn
-
Run the bootstrap script:
yarn ts-node scripts/bootstrap \ --orgAndRepo '<your org>/<your repo>' \ --developerName '<your full name>' \ --packageName '<your package name>' \ --createGithubRepo
-
Setup a repo secret called
NPM_TOKEN
containing an npm token for CI package publishing.
Example:
gh repo clone prisma-labs/mockapie foobar \
&& cd foobar \
&& yarn \
&& yarn bootstrap \
--orgAndRepo 'jasonkuhrt/foobar' \
--developerName 'Jason Kuhrt' \
--packageName 'foobar' \
--createGithubRepo
TypeScript for Type Safety & Productivity
-
Optimal settings for the safety of your implementation
strict
mode enabled.- All lint flags enabled:
-
.tsbuildinfo
cache setup, output discretely intonode_modules/.cache
-
Base
tsconfig.json
shared acrosstests
,src
, andts-node
. -
ts-patch
setup for enhanced language features:typescript-transform-paths
for a working tsconfigpaths
config!ts-node
configuration taken care of.- Intentional avoidance of
ttypescript
-
Optimal output setup for your users
- Target ES2019 which Node as low as version 12 has good support for (Kangax compatibility table).
declaration
so your users can power their intellisense with your packages typings.declarationMap
enabled to make your published source code be navigated to when your users use "go to definition".package.json
typeVersions
used to emit only one set of declaration files shared by both CJS and ESM builds.sourceMap
enabled to allow your users' tools to base off the source for e.g. stack traces instead of the less informative derived built JS.importHelpers
enabled to minimize build size.
ESLint For Linting
- TypeScript integration
- TS type-checker powered eslint checks enabled
- Prettier integration using just
eslint-config-prettier
.eslint-plugin-prettier
is not used to avoid lint noise and slower run time. Prettier is expected to be run by your IDE and your CI and if really needed you manually viayarn format
. - Setup as a CI check for PRs
- Always display as warning to keep IDE error feedback for TypeScript (CI enforces warnings).
- Auto-fixable import sorting
Ava for Testing
Dripip for Releasing
- Emojis
✈️ - Feature / bug / docs / something-else
- Config to display discussions link right in new issue type listing UI
Prettier for code formatting
- Prisma Labs config preset, 110 line width
- Setup as a CI check for PRs
- VSCode extension in recommended extensions list so that when collaborators open the project they'll get prompted to install it if they haven't already.
- npm script
clean
to remove cache and dist filesbuild
that runsclean
beforehandprepublishOnly
that runsbuild
beforehandformat
to quickly runprettier
andformat-imports
over whole codebaselint
to quickly runeslint
over whole codebase
- Separate trunk and pull-request (PR) workflows.
- Dependency install cache enabled.
- On PR:
- Prettier Check
- Lint Check
- Tests across matrix of mac/linux/windows for Node 14/16
- On trunk:
- Tests across matrix of mac/linux/windows for Node 14/16
- Automated canary release
Renovate configuration
- JSON Schema setup for optimal intellisense
- Group all non-major devDependency updates into single PR (which "chore" conventional commit type)
- Group all major devDependency updates into single PR (with "chore" conventional commit type)
- Group all non-major dependency updates into single PR (with "deps" conventional commit type)
- Each major dependency update in own PR (with "deps" conventional commit type)
Yarn 2 for package management
- Painless/familiar workflow via
node_modules
fornodeLinker
- Plugins:
plugin-outdated
Bring backoutdated
command from Yarn 1.plugin-typescript
for painless@types
consumptions (e.g. You probably forget how to pull down@types
packages for already-scoped npm packages, doesn't matter now).plugin-interactive-tools
for some slick in-terminal project maintenance.
CJS+ESM Hybrid package build (see Dr. Axel's article about this)
- Use
exports
field to give support to both modernimport
and legacyrequire
consumers using Node 12.x and up. For details about theexports
field refer to the Official Node.js Docs about it. - Use
main
field for legacy versions of Node (before12.x
) requiring the CJS build. - Use
module
field for legacy bundlers importing the ESM build.
- Optimize project search by ignoring
dist-cjs
/dist-esm
directories. - Enable
typescript.enablePromptUseWorkspaceTsdk
so that oneself and collaborators will get prompted to use the workspace version of TypeScript instead of the one in the editor.
- Using
markdown-toc