Paul Krill
Editor at Large

New tool forces JavaScript code correctness

news
Jan 17, 20171 min

The Prettier formatting tool ensures outputted JavaScript conforms to a consistent style

With a tool called Prettier, JavaScript formatting will get a consistent style.

An opinionated JavaScript formatter inspired by the refmt tool for formatting code, Prettier removes original styling and ensures outputted JavaScript conforms to a consistent style.

“Prettier gets rid of all original styling and guarantees consistency by parsing JavaScript into an AST (abstract syntax tree) and pretty-printing the AST,” developer James Long said. He noted that the tool makes it easier to write code however a developer wants because it can be instantly formatted correctly afterward.

Prettier takes JavaScript as input and outputs formatted JavaScript. Still in beta, Prettier tries to support all JavaScript language features, including those that are not standardized. It uses the Babylon parser by default with all language features enabled, but it will also work with the Facebook Flow parser with the useFlowParser API or --flow-parser CLI option. Prettier has advanced support for language features from ECMAScript 2017, JSX, and Flow.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author