惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
The Hacker News
The Hacker News
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
T
Tenable Blog
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
P
Privacy & Cybersecurity Law Blog
Know Your Adversary
Know Your Adversary
T
The Exploit Database - CXSecurity.com
Latest news
Latest news
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
Intezer
F
Fortinet All Blogs
Engineering at Meta
Engineering at Meta
Simon Willison's Weblog
Simon Willison's Weblog
The Register - Security
The Register - Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
L
Lohrmann on Cybersecurity
C
Cyber Attacks, Cyber Crime and Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
H
Help Net Security
T
Threat Research - Cisco Blogs
D
DataBreaches.Net
S
Schneier on Security
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
P
Privacy International News Feed
S
Secure Thoughts
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recorded Future
Recorded Future
C
Cybersecurity and Infrastructure Security Agency CISA
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
人人都是产品经理
人人都是产品经理
NISL@THU
NISL@THU
博客园 - Franky
T
Tor Project blog
G
GRAHAM CLULEY
博客园 - 【当耐特】
Jina AI
Jina AI
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
A
About on SuperTechFans
Hacker News - Newest:
Hacker News - Newest: "LLM"

Prettier Blog

Prettier 3.9: Major parser upgrades and Formatting improvements Prettier 3.8: Support for Angular v21.1 Prettier 3.7: Improved formatting consistency and new plugin features! Prettier 3.6: Experimental fast CLI and new OXC and Hermes plugins! Prettier 3.5: New objectWrap option, experimentalOperatorPosition option and TS config file support! Prettier 3.4: A lot of bug fixes Prettier 3.3: New Flow features and a lot of bug fixes Prettier 3.2: Support JSONC and Angular’s ICU expression Prettier's CLI: A Performance Deep Dive $20k Bounty was Claimed! Prettier 3.1: New experimental ternaries formatting and Angular control flow syntax! A curious case of the ternaries Prettier 3.0: Hello, ECMAScript Modules! Prettier 2.8: improve --cache CLI option and TypeScript 4.9 satisfies operator! Prettier 2.7: new --cache CLI option and TypeScript 4.7 syntax! Prettier 2.6: new singleAttributePerLine option and new JavaScript features! Prettier begins paying maintainers Prettier 2.5: TypeScript 4.5 and MDX v2 comment syntax! Prettier 2.4: new bracketSameLine option and TypeScript 4.4 support! Prettier 2.3. In which assignments are consistent, short keys non-breaking, and Handlebars official
Prettier for Ruby goes v1.0 🎉
Kevin Newton · 2020-12-11 · via Prettier Blog

After 1500 commits and 50 releases since July 2018, we're happy to announce that we've just released v1.0 of Prettier for Ruby. In this blog post, we'd like to give a short overview of how the plugin works, its philosophy, and what to expect in the future.

How does it work?

Prettier for Ruby works through Prettier's plugin API. Its parse function works by spawning a Ruby process and using Ruby's own parser (known as Ripper). After tracking all of the various node types, comments, location information, and other various metadata, it returns a built abstract syntax tree (AST) to the Prettier process. Finally it converts that AST into Prettier's intermediate representation (known as Doc) before allowing Prettier to handle printing it back out.

Philosophy

The Ruby plugin attempts to be satisfied with as many varieties of code as possible. For instance, if you decide to a call a method with or without parentheses, the plugin will allow this and honor your selection. For a couple of instances where the Ruby community has entrenched itself into some strong opinions, however, options are provided. These include:

  • rubyArrayLiteral - By default, the Ruby plugin will convert arrays of simple strings and symbols to their equivalent array literal syntax (%w and %i, respectively). If you disable this option, it will leave them alone.
  • rubyHashLabel - This option is for the fans of the hash rocket. By default, the Ruby plugin will print out your hash keys consistently, i.e., it will use labels if it can for every key, otherwise it will use hash rockets for every key. If you disable the default behavior, every key in hashes will always use hash rockets.
  • rubyModifier - For the users that really dislike the modifier form of if, unless, while, and until, this option is for you.
  • rubySingleQuote - The default behavior is to use single quotes where it makes sense, and otherwise to use double quotes. With this option you can reverse that behavior.
  • rubyToProc - This option allows Prettier to convert statements like array.map { |elem| elem.to_s } to array.map(&:to_s). It is disabled by default because it technically changes the arity of block, which can break reflection code.

The plugin additionally supports various Prettier core options, including:

  • printWidth - This defaults to 80 characters, but you can make the line longer if you prefer.
  • tabWidth - This defaults to 2 characters.
  • trailingComma - This defaults to "none", but you can choose "all" to introduce trailing commas into array literals, hash literals, and argument lists that span multiple lines.

In general the style of Prettier will match that of the Ruby style guide, i.e., the default Rubocop configuration. However, while you're using Prettier you might just find that you want to turn off the Formatting/* rules from Rubocop anyway as it will speed up your linter runs.

What's next

Going forward, we're going to be working on a couple of things:

  • Support for the new syntax coming out with Ruby 3, including rightward assignment and more pattern matching.
  • Better performance, as in these experiments.
  • Support for the Ruby language in Prettier's playground.
  • Support for HTML ERB templates as another plugin, as in this experiment.

Today, you can try the plugin from the command line by following the instructions in the README. Definitely report any bugs that you find, we're working diligently to make sure they're squashed as soon as they come up. Also feel free to get started contributing to the project itself if you're interested.