Skip to content

Latest commit

 

History

History
94 lines (67 loc) · 2.21 KB

no-useless-mustaches.md

File metadata and controls

94 lines (67 loc) · 2.21 KB
pageClass sidebarDepth title description since
rule-details
0
vue/no-useless-mustaches
disallow unnecessary mustache interpolations
v7.0.0

vue/no-useless-mustaches

disallow unnecessary mustache interpolations

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 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.

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

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

🔧 Options

{
  "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

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

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

"ignoreStringEscape": true

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

👫 Related Rules

🚀 Version

This rule was introduced in eslint-plugin-vue v7.0.0

🔍 Implementation