sonarjs/no-nested-template-literals
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-nested-template-literals": "error",
},
},
];let color = "red";
let count = 3;
let message = `I have ${color ? `${count} ${color}` : count} apples`; // Noncompliant; nested template strings not easy to readlet color = "red";
let count = 3;
let apples = color ? `${count} ${color}` : count;
let message = `I have ${apples} apples`;Examples from the ESLint documentation.
sonarjs/no-nested-template-literals
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-nested-template-literals": "error",
},
},
];Oxlint does not have this rule.
nursery/noNestedTemplateLiterals
nursery · since 2.6.0
{
"linter": {
"rules": {
"nursery": {
"noNestedTemplateLiterals": "error"
}
}
}
}Alternatives in regular expressions should be grouped when used with anchors
Arguments to built-in functions should match documented types
Callbacks of array methods should have return statements
Assertions should be placed inside test cases or hooks