eslint-plugin-vue: Parsing error: Unexpected token <

Tell us about your environment

  • ESLint Version: v5.11.1
  • Node Version: v10.14.2
  • npm Version: 6.4.1

What parser (default, Babel-ESLint, etc.) are you using?

  • .eslintrc.js

Please show your full configuration:

Configuration
module.exports = {
    root: true,
    parserOptions: {
        "parser": "babel-eslint", 
        "sourceType": "module",
        "ecmaVersion": 6
    },
    env: {
        browser: true,
        node: true,
        es6: true,
    },
    extends: ["eslint:recommended"],

    // add your custom rules here
    //it is base on https://github.com/vuejs/eslint-config-vue
    rules: {
        "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
        "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
        "no-undef": "off",
        "no-unused-vars": "off",
        "no-redeclare": "off",
        "no-empty": "off",
        "indent": ["warn", 4],
        'vue/max-attributes-per-line': 'off', 
        'vue/order-in-components': 'off',
        'vue/html-end-tags': 'off',
    }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

vue code

<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'App' 
};
</script>

run ESLint :

eslint --fix "./src/**/*.{js,vue}"

What did you expect to happen?

good running

What actually happened? Please include the actual, raw output from ESLint.

D:\_Me\-COMPANY-JiTeng-\src\App.vue : 
 1:1  error  Parsing error: Unexpected token <

Are you willing to submit a pull request to fix this bug?

image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (3 by maintainers)

Commits related to this issue

Most upvoted comments

You can use the following settings.

"extends": ["plugin:vue/base"]

https://eslint.vuejs.org/user-guide/#faq

parser: 'vue-eslint-parser', // Adding this line works perfectly
extends: [
        'plugin:vue/base',
        'eslint:recommended',
        'plugin:vue/vue3-recommended', 
        'plugin:vue/essential',
        'plugin:@typescript-eslint/recommended',     // caused by this line
        'plugin:prettier/recommended',
        'eslint-config-prettier'
    ],

Hi @PLQin! Please take a look at the installation instruction https://eslint.vuejs.org/user-guide/#installation You’re not extending configuration that this plugin provides.

Nice, have good, through the set to "extends" : [" plugin: vue/base "] solved my problem ;

thank you !~ 👍

You can use the following settings.

"extends": ["plugin:vue/base"]

https://eslint.vuejs.org/user-guide/#faq

Thanks! it works like charm!

You can use the following settings.

"extends": ["plugin:vue/base"]

https://eslint.vuejs.org/user-guide/#faq

Thank you <3000