如何关闭此Eslint错误“预期在html标签前后换行”?

时间:2019-02-09 05:10:58

标签: eslint prettier

我正在使用nuxt JS,每次运行“ npm run dev”时,都会出现此错误:

       7:40  warning  Expected 1 line break after opening tag (`<v-card-title>`), but no line breaks found    vue/singleline-html-element-content-newline
      17:81  warning  Expected 1 line break before closing tag (`</v-card-title>`), but no line breaks found  vue/singleline-html-element-content-newline
      20:14  warning  Expected 1 line break after opening tag (`<p>`), but no line breaks found               vue/multiline-html-element-content-newline
      23:12  warning  Expected 1 line break after opening tag (`<a>`), but no line breaks found               vue/multiline-html-element-content-newline
      23:25  warning  Expected 1 line break before closing tag (`</a>`), but no line breaks found             vue/multiline-html-element-content-newline
      23:30  warning  Expected 1 line break before closing tag (`</p>`), but no line breaks found             vue/multiline-html-element-content-newline
      24:14  warning  Expected 1 line break after opening tag (`<p>`), but no line breaks found               vue/multiline-html-element-content-newline
      28:12  warning  Expected 1 line break after opening tag (`<a>`), but no line breaks found               vue/multiline-html-element-content-newline
      28:19  warning  Expected 1 line break before closing tag (`</a>`), but no line breaks found             vue/multiline-html-element-content-newline
      28:24  warning  Expected 1 line break before closing tag (`</p>`), but no line breaks found             vue/multiline-html-element-content-newline
      29:14  warning  Expected 1 line break after opening tag (`<p>`), but no line breaks found               vue/multiline-html-element-content-newline
      33:12  warning  Expected 1 line break after opening tag (`<a>`), but no line breaks found               vue/multiline-html-element-content-newline
      33:23  warning  Expected 1 line break before closing tag (`</a>`), but no line breaks found             vue/multiline-html-element-content-newline
      33:28  warning  Expected 1 line break before closing tag (`</p>`), but no line breaks found             vue/multiline-html-element-content-newline
      42:12  warning  Expected 1 line break after opening tag (`<a>`), but no line breaks found               vue/multiline-html-element-content-newline
      42:30  warning  Expected 1 line break before closing tag (`</a>`), but no line breaks found             vue/multiline-html-element-content-newline
      47:12  warning  Expected 1 line break after opening tag (`<a>`), but no line breaks found               vue/multiline-html-element-content-newline
      47:23  warning  Expected 1 line break before closing tag (`</a>`), but no line breaks found             vue/multiline-html-element-content-newline
      56:12  warning  Expected 1 line break after opening tag (`<v-btn>`), but no line breaks found           vue/multiline-html-element-content-newline
      56:20  warning  Expected 1 line break before closing tag (`</v-btn>`), but no line breaks found         vue/multiline-html-element-content-newline

如何关闭此错误?

2 个答案:

答案 0 :(得分:3)

好的,解决了这个问题。该错误是由于

  

eslint-plugin-vue

因此,我在eslintrc.js文件中添加了以下代码

'vue/singleline-html-element-content-newline': 'off',
'vue/multiline-html-element-content-newline': 'off',

答案 1 :(得分:1)

此警告表示您应避免使用单行标签。例如,代替

<nuxt-link to="/test">Another page</nuxt-link>

只需使用此:

<nuxt-link to="/test">
  Another page
</nuxt-link>