template-literal-format
Enforce newline-boundary formatting for multiline template literals.
Targeted pattern scopeโ
This rule targets multiline template literals only.
It requires the template content to have boundary newlines:
- the first quasi starts with
\n - the last quasi ends with
\n
What this rule reportsโ
This rule reports multiline template literals that do not start and end on their own lines.
It provides an autofix that normalizes indentation in the template body.
Why this rule existsโ
Boundary-newline formatting makes multiline templates more readable and stable across indentation changes.
โ Incorrectโ
const text = `line one
line two`;
โ Correctโ
const text = `
line one
line two
`;
Behavior and migration notesโ
This rule is autofixable.
The fixer adds required boundary newlines and normalizes content indentation based on minimum detected indent.
Optionsโ
This rule has no options.
Additional examplesโ
const sql = `SELECT *
FROM users`;
// โ reported
const sqlNormalized = `
SELECT *
FROM users
`;
// โ
valid
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/template-literal-format": "error",
},
},
];
When not to use itโ
Disable this rule if your formatter already enforces a different multiline template style.
Package documentationโ
Rule catalog ID: R073
Further readingโ
Adoption resourcesโ
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.