(arg: T) {
+ arg;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'noUselessTemplateExpression',
+ line: 3,
+ column: 14,
+ endColumn: 17,
+ },
+ ],
+ },
+
+ {
+ code: "`${'`'}`;",
+ output: "'`';",
+ errors: [
+ {
+ messageId: 'noUselessTemplateExpression',
+ },
+ ],
+ },
+
+ {
+ code: "`back${'`'}tick`;",
+ output: '`back\\`tick`;',
+ errors: [
+ {
+ messageId: 'noUselessTemplateExpression',
+ },
+ ],
+ },
+
+ {
+ code: "`dollar${'${`this is test`}'}sign`;",
+ output: '`dollar\\${\\`this is test\\`}sign`;',
+ errors: [
+ {
+ messageId: 'noUselessTemplateExpression',
+ },
+ ],
+ },
+
+ {
+ code: '`complex${\'`${"`${test}`"}`\'}case`;',
+ output: '`complex\\`\\${"\\`\\${test}\\`"}\\`case`;',
+ errors: [
+ {
+ messageId: 'noUselessTemplateExpression',
+ },
+ ],
+ },
+
+ {
+ code: "`some ${'\\\\${test}'} string`;",
+ output: '`some \\\\\\${test} string`;',
+ errors: [
+ {
+ messageId: 'noUselessTemplateExpression',
+ },
+ ],
+ },
+
+ {
+ code: "`some ${'\\\\`'} string`;",
+ output: '`some \\\\\\` string`;',
+ errors: [
+ {
+ messageId: 'noUselessTemplateExpression',
+ },
+ ],
+ },
+ ],
+});
diff --git a/packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts b/packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
index d443c4ff729d..06eacb1e31e6 100644
--- a/packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
+++ b/packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
@@ -143,7 +143,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`1`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 5,
@@ -155,7 +155,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`1`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 6,
@@ -167,7 +167,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`/a/`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 7,
@@ -180,7 +180,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`1`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -190,7 +190,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: `'a';`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -200,7 +200,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: `"a";`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -210,7 +210,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: `'a' + 'b';`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -220,7 +220,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`true`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 8,
@@ -233,7 +233,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`true`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -243,7 +243,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`null`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 8,
@@ -256,7 +256,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`null`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -266,7 +266,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`undefined`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 13,
@@ -279,7 +279,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`undefined`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -289,7 +289,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`Infinity`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 12,
@@ -302,7 +302,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`NaN`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 7,
@@ -315,13 +315,13 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`a b`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 7,
},
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 11,
endColumn: 14,
@@ -334,10 +334,10 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`a b`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -353,7 +353,7 @@ ruleTester.run('no-useless-template-literals', rule, {
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 3,
column: 17,
endColumn: 20,
@@ -366,7 +366,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`useless`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
},
],
@@ -377,7 +377,7 @@ ruleTester.run('no-useless-template-literals', rule, {
output: '`useless`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
},
],
@@ -394,7 +394,7 @@ declare const nested: string, interpolation: string;
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -416,17 +416,17 @@ declare const nested: string, interpolation: string;
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 4,
},
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 7,
column: 3,
endLine: 7,
},
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 7,
column: 10,
endLine: 7,
@@ -444,7 +444,7 @@ declare const nested: string, interpolation: string;
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 3,
column: 3,
endColumn: 9,
@@ -457,13 +457,13 @@ declare const nested: string, interpolation: string;
output: '`1 + 1 = 2`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 13,
},
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 17,
endColumn: 18,
@@ -476,13 +476,13 @@ declare const nested: string, interpolation: string;
output: '`a true`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 7,
},
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 11,
endColumn: 15,
@@ -501,7 +501,7 @@ declare const nested: string, interpolation: string;
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 3,
column: 12,
endColumn: 18,
@@ -520,7 +520,7 @@ declare const nested: string, interpolation: string;
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -530,7 +530,7 @@ declare const nested: string, interpolation: string;
output: "String(Symbol.for('test'));",
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 1,
column: 4,
endColumn: 30,
@@ -549,7 +549,7 @@ declare const nested: string, interpolation: string;
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 3,
column: 12,
endColumn: 24,
@@ -570,7 +570,7 @@ declare const nested: string, interpolation: string;
`,
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
line: 3,
column: 14,
endColumn: 17,
@@ -583,7 +583,7 @@ declare const nested: string, interpolation: string;
output: "'`';",
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -593,7 +593,7 @@ declare const nested: string, interpolation: string;
output: '`back\\`tick`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -603,7 +603,7 @@ declare const nested: string, interpolation: string;
output: '`dollar\\${\\`this is test\\`}sign`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -613,7 +613,7 @@ declare const nested: string, interpolation: string;
output: '`complex\\`\\${"\\`\\${test}\\`"}\\`case`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -623,7 +623,7 @@ declare const nested: string, interpolation: string;
output: '`some \\\\\\${test} string`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
@@ -633,7 +633,7 @@ declare const nested: string, interpolation: string;
output: '`some \\\\\\` string`;',
errors: [
{
- messageId: 'noUselessTemplateLiteral',
+ messageId: 'noUselessTemplateExpression',
},
],
},
diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-useless-template-expression.shot b/packages/eslint-plugin/tests/schema-snapshots/no-useless-template-expression.shot
new file mode 100644
index 000000000000..f34596f9a1a4
--- /dev/null
+++ b/packages/eslint-plugin/tests/schema-snapshots/no-useless-template-expression.shot
@@ -0,0 +1,14 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Rule schemas should be convertible to TS types for documentation purposes no-useless-template-expression 1`] = `
+"
+# SCHEMA:
+
+[]
+
+
+# TYPES:
+
+/** No options declared */
+type Options = [];"
+`;
diff --git a/packages/typescript-eslint/src/configs/all.ts b/packages/typescript-eslint/src/configs/all.ts
index efe0d16fceb8..71d701e3d1ca 100644
--- a/packages/typescript-eslint/src/configs/all.ts
+++ b/packages/typescript-eslint/src/configs/all.ts
@@ -122,7 +122,7 @@ export default (
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
- '@typescript-eslint/no-useless-template-literals': 'error',
+ '@typescript-eslint/no-useless-template-expression': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'no-throw-literal': 'off',
diff --git a/packages/typescript-eslint/src/configs/disable-type-checked.ts b/packages/typescript-eslint/src/configs/disable-type-checked.ts
index 8d2f29220aba..9be9ab93dfd3 100644
--- a/packages/typescript-eslint/src/configs/disable-type-checked.ts
+++ b/packages/typescript-eslint/src/configs/disable-type-checked.ts
@@ -42,6 +42,7 @@ export default (
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
+ '@typescript-eslint/no-useless-template-expression': 'off',
'@typescript-eslint/no-useless-template-literals': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/only-throw-error': 'off',
diff --git a/packages/typescript-eslint/src/configs/strict-type-checked-only.ts b/packages/typescript-eslint/src/configs/strict-type-checked-only.ts
index f17b5280ca49..a2dbdaab1059 100644
--- a/packages/typescript-eslint/src/configs/strict-type-checked-only.ts
+++ b/packages/typescript-eslint/src/configs/strict-type-checked-only.ts
@@ -42,7 +42,7 @@ export default (
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
- '@typescript-eslint/no-useless-template-literals': 'error',
+ '@typescript-eslint/no-useless-template-expression': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/prefer-includes': 'error',
diff --git a/packages/typescript-eslint/src/configs/strict-type-checked.ts b/packages/typescript-eslint/src/configs/strict-type-checked.ts
index ad62ee749e25..20db0da63d1b 100644
--- a/packages/typescript-eslint/src/configs/strict-type-checked.ts
+++ b/packages/typescript-eslint/src/configs/strict-type-checked.ts
@@ -69,7 +69,7 @@ export default (
'@typescript-eslint/no-unused-vars': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
- '@typescript-eslint/no-useless-template-literals': 'error',
+ '@typescript-eslint/no-useless-template-expression': 'error',
'@typescript-eslint/no-var-requires': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy