What is gts?
The gts (Google TypeScript Style) npm package is a toolkit for setting up and maintaining a consistent TypeScript code style in your projects. It includes configurations for TypeScript, ESLint, and Prettier, and provides scripts for formatting and linting your code.
What are gts's main functionalities?
Setup
Initializes a new TypeScript project with Google TypeScript Style configurations. This command sets up the necessary configuration files and dependencies.
npx gts init
Linting
Runs ESLint with the Google TypeScript Style configurations to check for code style issues and potential errors in your TypeScript code.
npx gts lint
Formatting
Formats your TypeScript code according to the Google TypeScript Style guidelines using Prettier. This command can also fix some linting issues automatically.
npx gts fix
TypeScript Compilation
Compiles your TypeScript code to JavaScript using the TypeScript compiler with the configurations provided by gts.
npx gts build
Other packages similar to gts
eslint
ESLint is a widely-used tool for identifying and fixing problems in JavaScript and TypeScript code. While gts uses ESLint under the hood, ESLint itself is more flexible and can be configured to use various style guides and rulesets.
prettier
Prettier is an opinionated code formatter that supports many languages, including TypeScript. gts uses Prettier for formatting, but Prettier can be used independently or with other style guides.
tslint
TSLint is a linter specifically for TypeScript. Although it has been deprecated in favor of ESLint, it was previously a popular choice for TypeScript projects. gts uses ESLint, which is now the recommended tool for linting TypeScript.
typescript-eslint
typescript-eslint is a set of tools that allows ESLint to run on TypeScript code. It provides the necessary parser and plugins to lint TypeScript effectively. gts uses typescript-eslint as part of its setup.
gts - Google TypeScript style
NOTE: This repo is a work-in-progress and is not ready for general use just yet. This is not an official Google product.
This repository is Google's default TypeScript configuration. Made with ❤️ by the Google Node.js team.
Getting Started
If you're already using npm@5.3+ (bundled with Node 8.3+), run:
npx gts init
Still on an older version of npm? We got ya! In a directory with your package.json
run:
npm install --save-dev gts typescript@2.x
$(npm bin)/gts init
How this works
- Adds a
tsconfig.json
file to your project that uses the Google TS Style. - Adds the necessary devDependencies to your
package.json
. - Adds scripts to your
package.json
:
check
: Lints and checks for formatting problems.fix
: Automatically fixes formatting and linting problems (if possible).clean
: Removes output files.compile
: Compiles the source code using TypeScript compiler.pretest
, posttest
and prepare
: convenience integrations.
License
See LICENSE.md