Skip to content

Latest commit

 

History

History
43 lines (24 loc) · 1.2 KB

File metadata and controls

43 lines (24 loc) · 1.2 KB

Linter Rule: Prefer double quotes for HTML Attribute values

Rule: html-attribute-double-quotes

Description

Prefer using double quotes (") around HTML attribute values instead of single quotes (').

Exception: Single quotes are allowed when the attribute value contains double quotes, as this avoids the need for escaping.

Rationale

Double quotes are the most widely used and expected style for HTML attributes. Consistent use of double quotes improves readability, reduces visual noise when mixing with embedded Ruby (which often uses single quotes), and avoids escaping conflicts when embedding attribute values that contain single quotes.

Examples

✅ Good

<input type="text" autocomplete="off">

<a href="/profile">Profile</a>

<div data-action="click->dropdown#toggle"></div>

<!-- Exception: Single quotes allowed when value contains double quotes -->
<div id='"hello"' title='Say "Hello" to the world'></div>

🚫 Bad

<input type='text' autocomplete="off">

<a href='/profile'>Profile</a>

<div data-action='click->dropdown#toggle'></div>

References