Skip to content

Latest commit

 

History

History
120 lines (91 loc) · 2.65 KB

File metadata and controls

120 lines (91 loc) · 2.65 KB

ts-no-unnecessary-template-expression

Catches unnecessary template expressions such as string expressions within a template literal.

Options

A single options object has the following properties.

enableFixer

Whether to enable the fixer. Defaults to true.

Context everywhere
Tags ``
Recommended false
Settings
Options enableFixer

Failing examples

The following patterns are considered problems:

/**
 * @type {`A${'B'}`}
 */
// Message: Found an unnecessary string literal within a template.

/**
 * @type {`A${'B'}`}
 */
// "jsdoc/ts-no-unnecessary-template-expression": ["error"|"warn", {"enableFixer":false}]
// Message: Found an unnecessary string literal within a template.

/**
 * @type {(`A${'B'}`)}
 */
// Message: Found an unnecessary string literal within a template.

/**
 * @type {`A${'B'}`|SomeType}
 */
// Message: Found an unnecessary string literal within a template.

/**
 * @type {`${B}`}
 */
// Message: Found a lone template expression within a template.

/**
 * @type {`${B}`}
 */
// "jsdoc/ts-no-unnecessary-template-expression": ["error"|"warn", {"enableFixer":false}]
// Message: Found a lone template expression within a template.

/**
 * @type {`A${'B'}${'C'}`}
 */
// Message: Found an unnecessary string literal within a template.

/**
 * @type {`A${'B'}C`}
 */
// Message: Found an unnecessary string literal within a template.

/**
 * @type {`${'B'}`}
 */
// Message: Found an unnecessary string literal within a template.

/**
 * @type {(`${B}`)}
 */
// Message: Found a lone template expression within a template.

/**
 * @type {`${B}` | number}
 */
// Message: Found a lone template expression within a template.

Passing examples

The following patterns are not considered problems:

/**
 * @type {`AB`}
 */

/**
 * @type {`A${C}B`}
 */

/**
 * @param {BadType<} someName
 */

/**
 * @param {`A${'B'}`} someName
 */
// Settings: {"jsdoc":{"mode":"jsdoc"}}