{"id":10984,"library":"gts","title":"Google TypeScript Style","description":"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.","status":"active","version":"7.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/google/gts","tags":["javascript","typescript","linter","formatter","google"],"install":[{"cmd":"npm install gts","lang":"bash","label":"npm"},{"cmd":"yarn add gts","lang":"bash","label":"yarn"},{"cmd":"pnpm add gts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for TypeScript language features and compilation.","package":"typescript","optional":false}],"imports":[{"note":"gts exports an array of ESLint configurations for consumption in `eslint.config.js` (new flat config format since v7) or `.eslintrc.js` (legacy). It is not typically imported for programmatic execution of functions or classes.","wrong":"import gts from 'gts';","symbol":"ESLint configuration","correct":"module.exports = [...require('gts')];"},{"note":"The primary way to interact with gts for project setup and running lint/fix commands.","symbol":"CLI usage","correct":"npx gts init"},{"note":"Integration with the pre-commit framework, specify a specific tag or commit SHA for `rev`.","symbol":"Pre-commit hook","correct":"repos:\n  - repo: https://github.com/google/gts\n    rev: '' # Use the sha / tag you want to point at\n    hooks:\n      - id: gts"}],"quickstart":{"code":"// Initialize a new TypeScript project with gts\n// Run these commands in your terminal:\n// mkdir my-gts-project\n// cd my-gts-project\n// npm init -y\n// npx gts init\n\n// This command initializes gts, adding necessary devDependencies,\n// creating configuration files (tsconfig.json, .eslintrc.js, .prettierrc.json),\n// and adding standard scripts to your package.json (e.g., 'lint', 'fix', 'compile').\n// It also creates a default `src/index.ts` if no source directory exists.\n\n// Example src/index.ts content after initialization:\n// export function greet(name: string): string {\n//   return `Hello, ${name}!`;\n// }\n//\n// async function main() {\n//   const message = greet('TypeScript');\n//   console.log(message);\n//   // Example of an ignored promise that would now be an error in gts v6+\n//   // Promise.resolve().then(() => console.log('async task'));\n// }\n//\n// main().catch(console.error);\n\n// To lint and fix issues after adding or modifying code:\n// npm run lint\n// npm run fix\n\n// To compile your project:\n// npm run compile","lang":"typescript","description":"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."},"warnings":[{"fix":"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')];`.","message":"gts v7.0.0 migrated to ESLint's new flat config format (eslint.config.js). Projects using older `.eslintrc.js` files with gts may require updates to their ESLint configuration.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Run `gts fix` to automatically reformat your codebase to the new `trailingComma: \"all\"` style. Review changes carefully.","message":"gts v6.0.0 updated the default Prettier configuration to include `trailingComma: \"all\"`. This will reformat code for projects that previously used a different `trailingComma` setting or no explicit setting.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"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));`.","message":"gts v6.0.0 changed the `no-floating-promises` ESLint rule severity to `error`. This means any Promise returned from an async function that is not explicitly handled (e.g., awaited, `.then()`, `.catch()`) will now cause a build failure.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"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.","message":"gts v6.0.0 set `composite: true` in `tsconfig-google.json`. This TypeScript configuration change affects how projects are built, particularly in monorepos or projects with multiple `tsconfig.json` files.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"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.","message":"gts requires Node.js version 18 or greater and TypeScript version 5 or greater as a peer dependency. Using older versions will lead to installation or runtime issues.","severity":"gotcha","affected_versions":">=6.0.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"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')];`","cause":"Attempting to use gts v7+ with the old ESLint `.eslintrc.js` configuration format.","error":"Error: Failed to load config \"gts\" from \"/path/to/project/.eslintrc.js\""},{"fix":"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+.","cause":"TypeScript's `lib` configuration in `tsconfig.json` is incorrect for the Node.js version being targeted.","error":"TS2728: Cannot find type definition file for 'node'."},{"fix":"Upgrade TypeScript in your project to version 5 or greater. For example: `npm install typescript@latest --save-dev` or `yarn add typescript@latest --dev`.","cause":"Your project's `typescript` version does not meet the `gts` peer dependency requirement.","error":"warning \" > gts@6.0.1\" has unmet peer dependency \"typescript@>=5\"."},{"fix":"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.","cause":"An async function is being used as an ESLint rule callback without being explicitly marked as `async`, leading to a false positive for `no-floating-promises`.","error":"Error: A Promise-returning function provided to rule, 'no-floating-promises', is not marked async."}],"ecosystem":"npm"}