--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx var foo = `bar`; var foo1 = `bar `; var foo = `back\rtick`; var foo = `back\ntick`; var foo = `back\u2028tick` var foo = `back\u2029tick`; var foo = `back\\\\\ntick`; var foo = `\n`; function foo() { `use strict`; foo(); } var foo = `foo\\nbar`; var foo = `foo\\\nbar`; var foo = `foo\\\\\\\nbar`; ``` # Diagnostics ``` invalid.js:1:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. > 1 │ var foo = `bar`; │ ^^^^^ 2 │ var foo1 = `bar `; 3 │ var foo = `back\rtick`; i Unsafe fix: Replace with string literal 1 │ - var·foo·=·`bar`; 1 │ + var·foo·=·"bar"; 2 2 │ var foo1 = `bar `; 3 3 │ var foo = `back\rtick`; ``` ``` invalid.js:2:12 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 1 │ var foo = `bar`; > 2 │ var foo1 = `bar `; │ ^^^^^^ 3 │ var foo = `back\rtick`; 4 │ var foo = `back\ntick`; i Unsafe fix: Replace with string literal 1 1 │ var foo = `bar`; 2 │ - var·foo1·=·`bar·`; 2 │ + var·foo1·=·"bar·"; 3 3 │ var foo = `back\rtick`; 4 4 │ var foo = `back\ntick`; ``` ``` invalid.js:3:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 1 │ var foo = `bar`; 2 │ var foo1 = `bar `; > 3 │ var foo = `back\rtick`; │ ^^^^^^^^^^^^ 4 │ var foo = `back\ntick`; 5 │ var foo = `back\u2028tick` i Unsafe fix: Replace with string literal 1 1 │ var foo = `bar`; 2 2 │ var foo1 = `bar `; 3 │ - var·foo·=·`back\rtick`; 3 │ + var·foo·=·"back\rtick"; 4 4 │ var foo = `back\ntick`; 5 5 │ var foo = `back\u2028tick` ``` ``` invalid.js:4:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 2 │ var foo1 = `bar `; 3 │ var foo = `back\rtick`; > 4 │ var foo = `back\ntick`; │ ^^^^^^^^^^^^ 5 │ var foo = `back\u2028tick` 6 │ var foo = `back\u2029tick`; i Unsafe fix: Replace with string literal 2 2 │ var foo1 = `bar `; 3 3 │ var foo = `back\rtick`; 4 │ - var·foo·=·`back\ntick`; 4 │ + var·foo·=·"back\ntick"; 5 5 │ var foo = `back\u2028tick` 6 6 │ var foo = `back\u2029tick`; ``` ``` invalid.js:5:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 3 │ var foo = `back\rtick`; 4 │ var foo = `back\ntick`; > 5 │ var foo = `back\u2028tick` │ ^^^^^^^^^^^^^^^^ 6 │ var foo = `back\u2029tick`; 7 │ var foo = `back\\\\\ntick`; i Unsafe fix: Replace with string literal 3 3 │ var foo = `back\rtick`; 4 4 │ var foo = `back\ntick`; 5 │ - var·foo·=·`back\u2028tick` 5 │ + var·foo·=·"back\u2028tick" 6 6 │ var foo = `back\u2029tick`; 7 7 │ var foo = `back\\\\\ntick`; ``` ``` invalid.js:6:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 4 │ var foo = `back\ntick`; 5 │ var foo = `back\u2028tick` > 6 │ var foo = `back\u2029tick`; │ ^^^^^^^^^^^^^^^^ 7 │ var foo = `back\\\\\ntick`; 8 │ var foo = `\n`; i Unsafe fix: Replace with string literal 4 4 │ var foo = `back\ntick`; 5 5 │ var foo = `back\u2028tick` 6 │ - var·foo·=·`back\u2029tick`; 6 │ + var·foo·=·"back\u2029tick"; 7 7 │ var foo = `back\\\\\ntick`; 8 8 │ var foo = `\n`; ``` ``` invalid.js:7:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 5 │ var foo = `back\u2028tick` 6 │ var foo = `back\u2029tick`; > 7 │ var foo = `back\\\\\ntick`; │ ^^^^^^^^^^^^^^^^ 8 │ var foo = `\n`; 9 │ function foo() { `use strict`; foo(); } i Unsafe fix: Replace with string literal 5 5 │ var foo = `back\u2028tick` 6 6 │ var foo = `back\u2029tick`; 7 │ - var·foo·=·`back\\\\\ntick`; 7 │ + var·foo·=·"back\\\\\ntick"; 8 8 │ var foo = `\n`; 9 9 │ function foo() { `use strict`; foo(); } ``` ``` invalid.js:8:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 6 │ var foo = `back\u2029tick`; 7 │ var foo = `back\\\\\ntick`; > 8 │ var foo = `\n`; │ ^^^^ 9 │ function foo() { `use strict`; foo(); } 10 │ var foo = `foo\\nbar`; i Unsafe fix: Replace with string literal 6 6 │ var foo = `back\u2029tick`; 7 7 │ var foo = `back\\\\\ntick`; 8 │ - var·foo·=·`\n`; 8 │ + var·foo·=·"\n"; 9 9 │ function foo() { `use strict`; foo(); } 10 10 │ var foo = `foo\\nbar`; ``` ``` invalid.js:9:18 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 7 │ var foo = `back\\\\\ntick`; 8 │ var foo = `\n`; > 9 │ function foo() { `use strict`; foo(); } │ ^^^^^^^^^^^^ 10 │ var foo = `foo\\nbar`; 11 │ var foo = `foo\\\nbar`; i Unsafe fix: Replace with string literal 7 7 │ var foo = `back\\\\\ntick`; 8 8 │ var foo = `\n`; 9 │ - function·foo()·{·`use·strict`;·foo();·} 9 │ + function·foo()·{·"use·strict";·foo();·} 10 10 │ var foo = `foo\\nbar`; 11 11 │ var foo = `foo\\\nbar`; ``` ``` invalid.js:10:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 8 │ var foo = `\n`; 9 │ function foo() { `use strict`; foo(); } > 10 │ var foo = `foo\\nbar`; │ ^^^^^^^^^^^ 11 │ var foo = `foo\\\nbar`; 12 │ var foo = `foo\\\\\\\nbar`; i Unsafe fix: Replace with string literal 8 8 │ var foo = `\n`; 9 9 │ function foo() { `use strict`; foo(); } 10 │ - var·foo·=·`foo\\nbar`; 10 │ + var·foo·=·"foo\\nbar"; 11 11 │ var foo = `foo\\\nbar`; 12 12 │ var foo = `foo\\\\\\\nbar`; ``` ``` invalid.js:11:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 9 │ function foo() { `use strict`; foo(); } 10 │ var foo = `foo\\nbar`; > 11 │ var foo = `foo\\\nbar`; │ ^^^^^^^^^^^^ 12 │ var foo = `foo\\\\\\\nbar`; i Unsafe fix: Replace with string literal 9 9 │ function foo() { `use strict`; foo(); } 10 10 │ var foo = `foo\\nbar`; 11 │ - var·foo·=·`foo\\\nbar`; 11 │ + var·foo·=·"foo\\\nbar"; 12 12 │ var foo = `foo\\\\\\\nbar`; ``` ``` invalid.js:12:11 lint/style/noUnusedTemplateLiteral FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not use template literals if interpolation and special-character handling are not needed. 10 │ var foo = `foo\\nbar`; 11 │ var foo = `foo\\\nbar`; > 12 │ var foo = `foo\\\\\\\nbar`; │ ^^^^^^^^^^^^^^^^ i Unsafe fix: Replace with string literal 10 10 │ var foo = `foo\\nbar`; 11 11 │ var foo = `foo\\\nbar`; 12 │ - var·foo·=·`foo\\\\\\\nbar`; 12 │ + var·foo·=·"foo\\\\\\\nbar"; ```