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.
npm install gtsVerified import paths — ran on the pinned version, not inferred.
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.
Update your ESLint configuration file from `.eslintrc.js` to `eslint.config.js` and adapt it to the new flat config array format, typically using `module.exports = [...require('gts')];`.Run `gts fix` to automatically reformat your codebase to the new `trailingComma: "all"` style. Review changes carefully.
Ensure all Promises returned from async functions or API calls are properly handled, either by awaiting them, chaining with `.then()`/`.catch()`, or explicitly ignoring them if intended (though generally discouraged). Example: `await someAsyncCall();` or `someAsyncCall().catch(err => console.error(err));`.
Review your project's TypeScript build process and `tsconfig.json` files to ensure compatibility with `composite: true`. This may require adjusting `references` or build commands.
Ensure your project's `package.json` specifies `engines.node` to `>=18` and `"typescript": ">=5"` in your `devDependencies` or `dependencies`. Upgrade Node.js and TypeScript if necessary.
Migrate your ESLint configuration to the new flat config format in `eslint.config.js` as described in the v7.0.0 breaking changes. Example: `module.exports = [...require('gts')];`Ensure your `tsconfig.json`'s `compilerOptions.lib` includes appropriate types for your Node.js version. gts v6.0.2 fixed an issue related to `lib` support for Node 18+.
Upgrade TypeScript in your project to version 5 or greater. For example: `npm install typescript@latest --save-dev` or `yarn add typescript@latest --dev`.
Mark the Promise-returning function as `async` in your ESLint configuration or custom rules to correctly handle asynchronous operations. If this is in your application code, ensure promises are handled.