Skip to content
☂️ TypeScript style guide, formatter, and linter.
TypeScript JavaScript
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github build: test node 14 and bundle codecov (#512) May 18, 2020
src fix: better error message for broken tsconfig.json (#501) Jun 9, 2020
template docs: example template compile fix (#434) Mar 30, 2020
test feat: generate .eslintignore when running init (#521) Jun 9, 2020
.eslintignore fix: align back to the google style guide (#440) Feb 4, 2020
.eslintrc.json fix(deps): update typescript-eslint monorepo to v3 (major) (#528) Jun 9, 2020
.gitignore build: configuring windows build with kokoro (#328) May 1, 2019
.mocharc.json chore: use updated mocha config (#438) Feb 3, 2020
.prettierrc.json fix: enable trailing comma (#470) Mar 26, 2020
CHANGELOG.md chore: release 2.0.2 (#505) May 11, 2020
CODE_OF_CONDUCT.md fix: add Code of Conduct (#262) Feb 12, 2019
CONTRIBUTING.md feat: initial version Aug 1, 2017
LICENSE feat: initial version Aug 1, 2017
README.md fix: throw an error if running with an unsupported version of nodejs (#… Apr 27, 2020
package-lock.json chore(deps): lock file maintenance (#533) Jun 16, 2020
package.json chore(deps): update dependency mocha to v8 (#529) Jun 10, 2020
renovate.json chore: remove gitAuthor from renovate.json (#229) Nov 27, 2018
tsconfig-google.json fix!: drop support for node 8 (#422) Jan 13, 2020
tsconfig.json feat!: use eslint instead of tslint (#400) Jan 13, 2020

README.md

gts

Google TypeScript Style

NPM Version GitHub Actions 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)

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.

License

Apache-2.0


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

NOTE: This is not an official Google product.

You can’t perform that action at this time.