JS.VUE.NO.EXTRA.PARENS

Disallow unnecessary parentheses

This rule is the same rule as core [no-extra-parens] rule but it applies to the expressions in <template>.

Rule Details

This rule restricts the use of parentheses to only where they are necessary.
This rule extends the core [no-extra-parens] rule and applies it to the <template>. This rule also checks some Vue.js syntax.

{'vue/no-extra-parens': ['error']}

Copy
<template>
  <!-- GOOD -->
  <div :class="foo + bar" />
  {{ foo + bar }}
  {{ foo + bar | filter }}
  <!-- BAD -->
  <div :class="(foo + bar)" />
  {{ (foo + bar) }}
  {{ (foo + bar) | filter }}
</template>

Further Reading

  • [no-extra-parens]

  • https://eslint.org/docs/rules/no-extra-parens

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/