Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 1.95 KB

template-tag-spacing.md

File metadata and controls

64 lines (48 loc) · 1.95 KB
pageClass sidebarDepth title description
rule-details
0
lodash-template/template-tag-spacing
enforce unified spacing in micro-template tag. (ex. 🆗 `<%= prop %>`, 🆖 `<%=prop%>`)

lodash-template/template-tag-spacing

enforce unified spacing in micro-template tag. (ex. 🆗 <%= prop %>, 🆖 <%=prop%>)

  • ⚙️ This rule is included in all of "plugin:lodash-template/recommended", "plugin:lodash-template/recommended-with-html", "plugin:lodash-template/recommended-with-script" and "plugin:lodash-template/all".
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

Rule Details

This rule aims to enforce unified spacing in micro-template interpolate/evaluate.

<% /* eslint "lodash-template/template-tag-spacing": "error" */ %>
<!-- ✓ GOOD -->
<div><%= text %></div>

<!-- ✗ BAD -->
<div><%=   text   %></div>
<div><%=text%></div>

Options

Default spacing is set to always

{
  "lodash-template/micro-template-interpolation-spacing": ["error", "always" | "never"]
}

"always" - Expect one space between expression and curly brackets.

<% /* eslint "lodash-template/template-tag-spacing": ["error", "always"] */ %>
<!-- ✓ GOOD -->
<div><%= text %></div>

<!-- ✗ BAD -->
<div><%=   text   %></div>
<div><%=text%></div>

"never" - Expect no spaces between expression and curly brackets.

<%/* eslint "lodash-template/template-tag-spacing": ["error", "never"] */%>
<!-- ✓ GOOD -->
<div><%=text%></div>

<!-- ✗ BAD -->
<div><%=   text   %></div>
<div><%= text %></div>

Implementation