ognjenjevremovic / ts-style

☂️ TypeScript style guide, formatter, and linter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gts - Google TypeScript style

NPM Version Build Status Dependency Status devDependency Status Known Vulnerabilities codecov

NOTE: This repo is a work-in-progress and is not ready for general use just yet. This is not an official Google product.

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.

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

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 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.

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

License

See LICENSE.md

About

☂️ TypeScript style guide, formatter, and linter.

License:Apache License 2.0


Languages

Language:TypeScript 89.4%Language:JavaScript 9.8%Language:Shell 0.8%