This repository is a template for JavaScript packages written in TypeScript and distributed via services like npm.
In order to be compatible with as many consumers as possible, the package's TypeScript code is complied to both CommonJS and "ES6" module formats. This allows the package to be consumed by runtimes like Node.js or parsed by bundlers like rollup.js.
- 🎨 Code formatting via Prettier
- 🏗️ TypeScript transpilation
- 👕 TypeScript linting via eslint
- 🧪 TypeScript unit test runner via tape, which produces Test Anything Protocol
- 📝 TypeScript documentation generation via TypeDoc
- 👷 Continuous Integration via GitHub Actions
- 📄 MIT license
There's always some metadata to update when using boilerplate code, so make sure to do the following:
- Update the package's
name
,version
,description
,author
, etc inpackage.json
- Update the
LICENSE.md
with the appropriate year and owner - Update the
CHANGELOG.md
with your package's changes (see keep a changelog) - Remove the
private: true
flag frompackage.json
(if you intend to publish to npm) - Replace this
README.md
with your own!
A combination of EditorConfig, Prettier, and ESLint are used to keep the code base formatted consistently and adhering to best practices.
In short, EditorConfig informs your editor of the basic file formatting (indentation, line endings, etc), Prettier formats the code with a consistent style, and ESLint checks for bad practices, typing issues, and so on.
To format the code (according to EditorConfig and Prettier settings):
yarn format
To lint the code (using a Prettier format check and ESLint):
yarn lint
It is highly recommended to install editor plugins/integrations in order to make code formatting and linting as seamless as possible. It's much easier to catch violations at edit-time, rather than downstream when builds fail.
Editor integrations: