Skip to content

A template for TypeScript packages, compatible with ES6 and CommonJS

License

Notifications You must be signed in to change notification settings

plato-app/es-typescript-package

Repository files navigation

Template: TypeScript ES6/CommonJS Package

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.

Features

Metadata

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 in package.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 from package.json (if you intend to publish to npm)
  • Replace this README.md with your own!

Usage

Formatting & Linting

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:

About

A template for TypeScript packages, compatible with ES6 and CommonJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published