9.3 Style-related tools
The following tools exist to support various aspects of Google Style.
9.3.1 Closure Compiler
This program performs type checking and other checks,optimizations and other transformations (such as ECMAScript 6 to ECMAScript 5code lowering).
9.3.2 clang-format
This program reformatsJavaScript source code into Google Style, and also follows a number ofnon-required but frequently readability-enhancing formatting practices.The output produced by clang-format
is compliant with the style guide.
clang-format
is not required. Authors are allowed to change its output, andreviewers are allowed to ask for such changes; disputes are worked out in theusual way. However, subtrees may choose to opt in to such enforcement locally.
9.3.3 Closure compiler linter
This program checks for avariety of missteps and anti-patterns.
9.3.4 Conformance framework
The JS Conformance Framework is a tool that is part of the Closure Compiler thatprovides developers a simple means to specify a set of additional checks to berun against their code base above the standard checks. Conformance checks can,for example, forbid access to a certain property, or calls to a certainfunction, or missing type information (unknowns).
These rules are commonly used to enforce critical restrictions (such as definingglobals, which could break the codebase) and security patterns (such as usingeval
or assigning to innerHTML
), or more loosely to improve code quality.
For additional information see the official documentation for theJS Conformance Framework.