JS.VUE.NO.USELESS.MUSTACHES

Disallow unnecessary mustache interpolations

Rule Details

This rule reports mustache interpolation with a string literal value.
The mustache interpolation with a string literal value can be changed to a static contents.

{'vue/no-useless-mustaches': ['error']}

Copy
<template>
  <!-- GOOD -->
  Lorem ipsum
  {{ foo }}

  <!-- BAD -->
  {{ 'Lorem ipsum' }}
  {{ "Lorem ipsum" }}
  {{ `Lorem ipsum` }}
</template>

Options

Copy
{
  "vue/no-useless-mustaches": ["error", {
    "ignoreIncludesComment": false,
    "ignoreStringEscape": false
  }]
}
  • ignoreIncludesComment ... If true, do not report expressions containing comments. default false.
  • ignoreStringEscape ... If true, do not report string literals with useful escapes. default false.

"ignoreIncludesComment": true

{'vue/no-useless-mustaches': ['error', {ignoreIncludesComment: true}]}

Copy
<template>
  <!-- GOOD -->
  {{ 'Lorem ipsum'/* comment */ }}

  <!-- BAD -->
  {{ 'Lorem ipsum' }}
</template>

"ignoreStringEscape": true

{'vue/no-useless-mustaches': ['error', {ignoreStringEscape: true}]}

Copy
<template>
  <!-- GOOD -->
  {{ 'Lorem \n ipsum' }}
</template>

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/