Eslint-plugin-vue: Beta incorrectly flags rule valid-template-root for pug templates

Created on 24 Aug 2017  路  3Comments  路  Source: vuejs/eslint-plugin-vue

Tell us about your environment
Ubuntu 16.04 Gnome 3

  • ESLint Version:
    3.19.0
  • eslint-plugin-vue Version:
    beta (v3.12.0)
  • Node Version:
    6.11.0

Please show your full configuration:

// http://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module'
  },
  env: {
    browser: true,
  },
  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
  // https://github.com/vuejs/eslint-plugin-vue
  extends: [
    'standard',
    'plugin:vue/recommended'
  ],
  // required to lint *.vue files
  plugins: [
    'html'
  ],
  'settings': {
      'html/html-extensions': ['.html'],  // don't include .vue
  },
  // add your custom rules here
  'rules': {
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
  }
}

What did you do? Please include the actual source code causing the issue.


<template lang="pug">
.example
  | blah blah blah
</template>

<script>
export default {
  data () {
    return {

    }
  }
}
</script>

What did you expect to happen?
When I had beta v3.8.0, no linter errors occurred. After beta v3.9.0 and above, the linter error occurs in all pug templates: valid-template-root.

What actually happened? Please include the actual, raw output from ESLint.
I get an valid-template-root error for all my pug templates. It seems the latest beta updates now think that the root element is text when it is actually valid pug markup.

accepted proposition bug upstream issue

Most helpful comment

@prograhammer for now eslint-plugin-vue supports only html -> https://github.com/mysticatea/vue-eslint-parser

i think we should consider adding check if type set as lang is set to "html" or not set at all

All 3 comments

@prograhammer for now eslint-plugin-vue supports only html -> https://github.com/mysticatea/vue-eslint-parser

i think we should consider adding check if type set as lang is set to "html" or not set at all

Thank you for this report.

Yes, vue-eslint-parser has not support PUG yet.
This is a bug of vue-eslint-parser.
ast.templateBody should be undefined if the <template> is not HTML. But it exists as one Text node currently.

Now, pug is still not being ignored.

image

{
  "name": "xxx",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "build:preview": "vue-cli-service build --report --mode=preview",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "mockjs": "^1.0.1-beta3",
    "vue": "^2.5.17",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.1.0",
    "@vue/cli-plugin-eslint": "^3.1.0",
    "@vue/cli-service": "^3.1.0",
    "@vue/eslint-config-prettier": "^4.0.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0-0",
    "pug": "^2.0.3",
    "pug-plain-loader": "^1.0.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.2",
    "vue-template-compiler": "^2.5.17"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "@vue/prettier"
    ],
    "rules": {
      "prettier/prettier": [
        "warn",
        {
          "singleQuote": true,
          "semi": false,
          "trailingComma": "none"
        }
      ]
    },
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

apertureless picture apertureless  路  4Comments

armano2 picture armano2  路  4Comments

soullivaneuh picture soullivaneuh  路  3Comments

filipalacerda picture filipalacerda  路  4Comments

rodrigoabb picture rodrigoabb  路  3Comments