Tagged template literals likeDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt
Use this file to discover all available pages before exploring further.
sql, gql, and html are often whitespace-insensitive β the consuming library strips leading indentation before processing the string. Despite this, developers frequently write these templates with indentation that doesnβt match the surrounding code, making them jarring to read. This rule automatically realigns multiline template literals to match the indentation of the code around them.
| Recommended | β
recommended |
| Fixable | π§ Auto-fixable |
| Suggestions | β |
Configuration options
The rule accepts an options object controlling which template literals are checked.tags
Type: string[]Default:
["outdent", "dedent", "gql", "sql", "html", "styled"]
Tagged template literal names (or member expression paths like styled.div) that should be indented.
functions
Type: string[]Default:
["dedent", "stripIndent"]
Names of utility functions whose template literal arguments should be indented.
selectors
Type: string[]Default:
[]
Arbitrary ESLint selectors matching template literals to check. Use this to target templates not covered by tags or functions.
comments
Type: string[]Default:
["HTML", "indent"]
Block comment strings (case-insensitive) that, when placed immediately before a template literal, mark it for indentation checking.
indent
Type: string | integer
Override the indentation unit used inside the template. By default the rule infers tabs or spaces from the surrounding code. Provide a number for spaces, or a whitespace string for custom indentation.
This rule is commonly set to
"warn" rather than "error" since it is a purely stylistic concern and its autofix is always safe to apply.