Google TypeScript Style

7.0.0 · active · verified Sun Apr 19

gts (Google TypeScript Style) is an opinionated, zero-configuration linter, formatter, and automatic code fixer for TypeScript projects, maintained by the Google Node.js team. Currently at version 7.0.0, the package sees a regular release cadence with several updates annually, incorporating dependency bumps and style rule adjustments. Its core differentiators are its commitment to a single, enforced Google style without requiring manual configuration, leveraging ESLint for linting and Prettier for formatting under the hood. It aims to eliminate style bikeshedding and catch common programmer errors early in the development cycle, providing a consistent code style across projects. While primarily used via its CLI (`npx gts init`), it also exposes its ESLint configuration for direct integration.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize a new TypeScript project with `gts`, explaining the setup steps and how to run the generated linting, formatting, and compilation scripts.

// Initialize a new TypeScript project with gts
// Run these commands in your terminal:
// mkdir my-gts-project
// cd my-gts-project
// npm init -y
// npx gts init

// This command initializes gts, adding necessary devDependencies,
// creating configuration files (tsconfig.json, .eslintrc.js, .prettierrc.json),
// and adding standard scripts to your package.json (e.g., 'lint', 'fix', 'compile').
// It also creates a default `src/index.ts` if no source directory exists.

// Example src/index.ts content after initialization:
// export function greet(name: string): string {
//   return `Hello, ${name}!`;
// }
//
// async function main() {
//   const message = greet('TypeScript');
//   console.log(message);
//   // Example of an ignored promise that would now be an error in gts v6+
//   // Promise.resolve().then(() => console.log('async task'));
// }
//
// main().catch(console.error);

// To lint and fix issues after adding or modifying code:
// npm run lint
// npm run fix

// To compile your project:
// npm run compile

view raw JSON →