google/gts


☂️ TypeScript style guide, formatter, and linter.

https://github.com/google/gts

License: Apache-2.0

Language: TypeScript

Keywords: formatter, google, linter, typescript


gts

Google TypeScript Style

NPM Version CircleCI Dependency Status Known Vulnerabilities codecov TypeScript Style Guide

gts is Google's TypeScript style guide, and the configuration for our formatter, linter, and automatic code fixer. No lint rules to edit, no configuration to update, no more bike shedding over syntax.

To borrow from standardjs:

  • No configuration. The easiest way to enforce consistent style in your project. Just drop it in.
  • Automatically format code. Just run gts fix and say goodbye to messy or inconsistent code.
  • Catch style issues & programmer errors early. Save precious code review time by eliminating back-and-forth between reviewer & contributor.
  • Opinionated, but not to a fault. We recommend you use the default configuration, but if you need to customize compiler or linter config, you can.

Under the covers, we use eslint to enforce the style guide and provide automated fixes, and prettier to re-format code.

Getting Started

The easiest way to get started is to run:

npx gts init

How it works

When you run the npx gts init command, it's going to do a few things for you:

  • Adds an opinionated tsconfig.json file to your project that uses the Google TypeScript 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.
  • If a source folder is not already present it will add a default template project.

Individual files

The commands above will all run in the scope of the current folder. Some commands can be run on individual files:

gts check index.ts
gts check one.ts two.ts three.ts
gts check *.ts

Working with eslint

Under the covers, we use eslint to enforce the style guide and provide automated fixes, and prettier to re-format code. To use the shared eslint configuration, create an .eslintrc in your project directory, and extend the shared config:

---
extends:
  - './node_modules/gts'

If you don't want to use the gts CLI, you can drop down to using the module as a basic eslint config, and just use the eslint cli:

$ eslint --fix

This opens the ability to use the vast eslint ecosystem including custom rules, and tools like the VSCode plugin for eslint:

Badge

Show your love for gts and include a badge!

Code Style: Google

[![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts)

License

Apache-2.0


Made with ❤️ by the Google Node.js team.

NOTE: This is not an official Google product.

Project Statistics

Sourcerank 17
Repository Size 2 MB
Stars 2,112
Forks 89
Watchers 40
Open issues 5
Dependencies 446
Contributors 22
Tags 24
Created
Last updated
Last pushed

Top Contributors See all

Ali Ijaz Sheikh Renovate Bot renovate[bot] greenkeeper[bot] Justin Beckwith Jinwoo Lee Kelvin Jin Benjamin E. Coe Maxim Mazurok Viktor Karpov Fedor Korotkov Ryan Day Grant Timmerman release-please[bot] Alex Eagle lee-tammy jsamar17 Daniel Wang Chris Arnesen Marcin Maciaszczyk

Packages Referencing this Repo

gts
Google TypeScript Style
Latest release 2.0.0-alpha.2 - Updated - 2.11K stars

Recent Tags See all

v1.1.2 November 20, 2019
v1.1.1 November 18, 2019
v1.1.0 July 30, 2019
v1.0.0 April 25, 2019
v1.0.0-0 February 26, 2019
v0.9.0 November 13, 2018
v0.8.0 July 12, 2018
0.8.0 July 12, 2018
v0.7.1 June 19, 2018
v0.7.0 June 18, 2018
v0.6.0 May 08, 2018
v0.5.4 March 02, 2018
v0.5.3 January 02, 2018
v0.5.2 December 13, 2017
v0.5.1 November 08, 2017

Something wrong with this page? Make a suggestion

Last synced: 2019-11-20 23:29:28 UTC

Login to resync this repository