Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
The gts (Google TypeScript Style) npm package is a toolkit for setting up and maintaining a consistent TypeScript code style in your projects. It includes configurations for TypeScript, ESLint, and Prettier, and provides scripts for formatting and linting your code.
Setup
Initializes a new TypeScript project with Google TypeScript Style configurations. This command sets up the necessary configuration files and dependencies.
npx gts init
Linting
Runs ESLint with the Google TypeScript Style configurations to check for code style issues and potential errors in your TypeScript code.
npx gts lint
Formatting
Formats your TypeScript code according to the Google TypeScript Style guidelines using Prettier. This command can also fix some linting issues automatically.
npx gts fix
TypeScript Compilation
Compiles your TypeScript code to JavaScript using the TypeScript compiler with the configurations provided by gts.
npx gts build
ESLint is a widely-used tool for identifying and fixing problems in JavaScript and TypeScript code. While gts uses ESLint under the hood, ESLint itself is more flexible and can be configured to use various style guides and rulesets.
Prettier is an opinionated code formatter that supports many languages, including TypeScript. gts uses Prettier for formatting, but Prettier can be used independently or with other style guides.
TSLint is a linter specifically for TypeScript. Although it has been deprecated in favor of ESLint, it was previously a popular choice for TypeScript projects. gts uses ESLint, which is now the recommended tool for linting TypeScript.
typescript-eslint is a set of tools that allows ESLint to run on TypeScript code. It provides the necessary parser and plugins to lint TypeScript effectively. gts uses typescript-eslint as part of its setup.
Google TypeScript Style
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 fix
and 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.
The easiest way to get started is to run:
npx gts init
When you run the npx gts init
command, it's going to do a few things for you:
tsconfig.json
file 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
, posttest
and prepare
: convenience integrations.The commands above will all run in the scope of the current folder. Some commands can be run on individual files:
gts lint index.ts
gts lint one.ts two.ts three.ts
gts lint *.ts
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 .eslintrc
in your project directory, and extend the shared config:
---
extends:
- './node_modules/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:
Show your love for gts
and include a badge!
[![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts)
Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.
Yes! You can put the following in your .pre-commit-config.yaml
file:
repos:
- repo: https://github.com/google/gts
rev: '' # Use the sha / tag you want to point at
hooks:
- id: gts
Made with ❤️ by the Google Node.js team.
NOTE: This is not an official Google product.
FAQs
Google TypeScript Style
We found that gts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.