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.
Under the covers, we use eslint to enforce the style guide and provide automated fixes, and prettier to re-format code. To use the shared eslint configuration, create an eslint.config.js in your project directory, and extend the shared config:
module.exports = [
...require('gts'),
];
If you don’t want to use the gts CLI, you can drop down to using the module as a basic eslint config, and just use the eslint cli:
$ eslint --fix
This opens the ability to use the vast eslint ecosystem including custom rules, and tools like the VSCode plugin for eslint:
gts
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:
gts fixand say goodbye to messy or inconsistent code.Under the covers, we use eslint to enforce the style guide and provide automated fixes, and prettier to re-format code.
Getting Started
The easiest way to get started is to run:
How it works
When you run the
npx gts initcommand, it’s going to do a few things for you:tsconfig.jsonfile to your project that uses the Google TypeScript Style.package.json.package.json:lint: 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,posttestandprepare: 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:
Working with eslint
Under the covers, we use eslint to enforce the style guide and provide automated fixes, and prettier to re-format code. To use the shared
eslintconfiguration, create aneslint.config.jsin your project directory, and extend the shared config:If you don’t want to use the
gtsCLI, you can drop down to using the module as a basiceslintconfig, and just use theeslintcli:This opens the ability to use the vast
eslintecosystem including custom rules, and tools like the VSCode plugin for eslint:Badge
Show your love for
gtsand include a badge!Supported Node.js Versions
Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.
Can I use gts with the pre-commit framework?
Yes! You can put the following in your
.pre-commit-config.yamlfile:License
Apache-2.0
Made with ❤️ by the Google Node.js team.