Registry / testing / gts
library7.0.0jsnpmunverified

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 gts
INSTALL
IMPORT
SIG · GTS
G
gts
testingjavascriptv7.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESLint configuration
module.exports = [...require('gts')];
import gts from 'gts';
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.
CLI usage
npx gts init
The primary way to interact with gts for project setup and running lint/fix commands.
Pre-commit hook
repos: - repo: https://github.com/google/gts rev: '' # Use the sha / tag you want to point at hooks: - id: gts
Integration with the pre-commit framework, specify a specific tag or commit SHA for `rev`.

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
gts --version
Debug
Known issues
breakinggts 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.
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')];`.
affects: >=7.0.0
breakinggts 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.
fix
Run `gts fix` to automatically reformat your codebase to the new `trailingComma: "all"` style. Review changes carefully.
affects: >=6.0.0
breakinggts 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.
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));`.
affects: >=6.0.0
breakinggts 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.
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.
affects: >=6.0.0
gotchagts 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.
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.
affects: >=6.0.1
Errors
Common errors & fixes
Error: Failed to load config "gts" from "/path/to/project/.eslintrc.js"
Attempting to use gts v7+ with the old ESLint `.eslintrc.js` configuration format.
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')];`
TS2728: Cannot find type definition file for 'node'.
TypeScript's `lib` configuration in `tsconfig.json` is incorrect for the Node.js version being targeted.
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+.
warning " > gts@6.0.1" has unmet peer dependency "typescript@>=5".
Your project's `typescript` version does not meet the `gts` peer dependency requirement.
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`.
Error: A Promise-returning function provided to rule, 'no-floating-promises', is not marked async.
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`.
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.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
typescriptrequiredPeer dependency for TypeScript language features and compilation.
Agent activity
6 hits · last 30 days
node
6
Resources
gts — npm install gts · libregistry