- 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_TOKENcontaining 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
strictmode enabled.- All lint flags enabled:
-
.tsbuildinfocache setup, output discretely intonode_modules/.cache -
Base
tsconfig.jsonshared acrosstests,src, andts-node. -
ts-patchsetup for enhanced language features:typescript-transform-pathsfor a working tsconfigpathsconfig!ts-nodeconfiguration 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).
declarationso your users can power their intellisense with your packages typings.declarationMapenabled to make your published source code be navigated to when your users use "go to definition".package.jsontypeVersionsused to emit only one set of declaration files shared by both CJS and ESM builds.sourceMapenabled to allow your users' tools to base off the source for e.g. stack traces instead of the less informative derived built JS.importHelpersenabled 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-prettieris 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
cleanto remove cache and dist filesbuildthat runscleanbeforehandprepublishOnlythat runsbuildbeforehandformatto quickly runprettierandformat-importsover whole codebaselintto quickly runeslintover 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_modulesfornodeLinker - Plugins:
plugin-outdatedBring backoutdatedcommand from Yarn 1.plugin-typescriptfor painless@typesconsumptions (e.g. You probably forget how to pull down@typespackages for already-scoped npm packages, doesn't matter now).plugin-interactive-toolsfor some slick in-terminal project maintenance.
CJS+ESM Hybrid package build (see Dr. Axel's article about this)
- Use
exportsfield to give support to both modernimportand legacyrequireconsumers using Node 12.x and up. For details about theexportsfield refer to the Official Node.js Docs about it. - Use
mainfield for legacy versions of Node (before12.x) requiring the CJS build. - Use
modulefield for legacy bundlers importing the ESM build.
- Optimize project search by ignoring
dist-cjs/dist-esmdirectories. - Enable
typescript.enablePromptUseWorkspaceTsdkso that oneself and collaborators will get prompted to use the workspace version of TypeScript instead of the one in the editor.
- Using
markdown-toc