Something seems to be amiss with the Vue.js eslint configuration. Can you help

I am just starting out with vueJs. I attempted to use this basic code in my vue project to update the data of a component:

    <template>
        <div>
            <h1> {{ message }}
            <h2> Hello {{ firstname }} {{ lastname }} from {{ from }} ! </h2>
            <label> Firstname : <input type="text" v-model="person.firstname" /> </label>
            <label> Lastname : <input type="text" v-model="person.lastname" /> </label>
            <label> Message : <input type="text" v-model="message" /> </label>
        </div>
    </template>

    <script>
    export default {
      data () {
          person: {
            firstname: 'John',
            lastname: 'Doe'
          },
          message: 'Welcome!'
      }
    }
    </script>

Upon testing, I encountered this error message:

Failed to compile.

./src/components/Hello.vue?vue&type=script&lang=js& (./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Hello.vue?vue&type=script&lang=js&)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\Users\1900780\Documents\Afpa\Ressources\PHP\vueJs1\myproject\src\components\Hello.vue: Unexpected token, expected ";" (16:16)

  14 |       person: {
  15 |         firstname: 'John',
> 16 |         lastname: 'Doe'
     |                 ^
  17 |       },
  18 |       message: 'Welcome!'
  19 |   }
    at Object.raise (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:7013:17)
    at Object.unexpected (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:8384:16)
    at Object.semicolon (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:8366:40)
    at Object.parseExpressionStatement (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:11193:10)
    at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:10792:19)
    at Object.parseStatement (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:10658:17)
    at Object.parseLabeledStatement (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:11185:22)
    at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:10790:19)
    at Object.parseStatement (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:10658:17)
    at Object.parseBlockOrModuleBlockBody (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:11234:25)
    at Object.parseBlockBody (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:11221:10)
    at Object.parseBlock (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:11205:10)
    at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:10734:21)
    at Object.parseStatement (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:10658:17)
    at Object.parseLabeledStatement (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:11185:22)
    at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\@babel\parser\lib\index.js:10790:19)

I am using @vue/cli 4.1.2 along with webpack. Here is a snippet from my package.json file:

    {
      "name": "myproject",
      "version": "0.1.0",
      "private": true,
      "scripts": {
        "serve": "vue-cli-service serve",
        "build": "vue-cli-service build",
        "lint": "vue-cli-service lint"
      },
      "dependencies": {
        "core-js": "^3.4.4",
        "vue": "^2.6.10"
      },
      "devDependencies": {
        "@vue/cli-plugin-babel": "^4.1.0",
        "@vue/cli-plugin-eslint": "^4.1.0",
        "@vue/cli-service": "^4.1.0",
        "babel-eslint": "^10.0.3",
        "eslint": "^5.16.0",
        "eslint-plugin-vue": "^5.0.0",
        "vue-template-compiler": "^2.6.10"
      },
      "eslintConfig": {
        "root": true,
        "env": {
          "node": true
        },
        "extends": [
          "plugin:vue/essential",
          "eslint:recommended"
        ],
        "rules": {},
        "parserOptions": {
          "parser": "babel-eslint",
          "ecmaVersion": 6
        }
      },
      "browserslist": [
        "> 1%",
        "last 2 versions"
      ]
    }

I have checked my code and it seems correct. I'm not sure why this error is occurring. Is there any specific configuration required for the babel parser? Where can I find the config file? I added an ecma version in the package.json file configuration, but it doesn't seem to be solving the issue. Any assistance on this matter would be highly appreciated.

Answer №1

Oops! I completely overlooked including the return statement:

export default {
  data () {
    return {
      user: {
        firstName: 'Jane',
        lastName: 'Smith'
      },
      welcomeMessage: 'Greetings!'
    }
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubles emerge when incorporating the AOS library into main.js in Vue 3

Hey there! I'm currently incorporating the Aos library into my Vue 3 project and encountering issues. import App from './App.vue' import AOS from 'aos' import 'aos/dist/aos.css' import { createApp } from "vue" ...

Combine all of Nuxt.js into one output file

Currently, I am working with a basic Nuxt.js application and I am curious to know if it is feasible to compile the output into a single file, combining all the .js and .css files altogether? I came across a solution for achieving this using just Vue.js as ...

Displaying HTML content fetched from a database in Vue

I am currently developing a blog application that utilizes Vue.js for the frontend and Node.js for the backend. For the content creation part of the blog, I have implemented a rich text editor called vue2-editor on the frontend. The goal is to store this ...

Simultaneous Vue components

Here's an example of a string: "Greetings Earthlings! I come in peace." Along with a set of words. ["Greetings", "Earthlings", "peace"] I want to automate the process of enclosing matching words within Vue components. For instance, it should look ...

When compiling, VUE fails to load page content

I am facing an issue with my VUE program that works perfectly locally but fails to work after compiling. The main concept is to load content from other files within the initial VUE App.vue file, specifically the Home.vue file App.vue <template> & ...

Remove repeated selections in a dropdown menu using Vue JS

Could someone offer me some assistance, please? I have 3 dropdown menus that need to display specific subjects based on previous selections. One issue I'm facing is how to remove the initial selection in menu one from both menu two and menu three? I ...

What is the best method to retrieve the v-model values of v-for components when iterating with numeric indices?

Within my template, I have form-group components that are being iterated over based on the value of a select element (an integer). My goal is to access the values of these iterated v-models, but I am struggling to get it right. TEMPLATE <b-form-g ...

Vue Multiselect: Leveraging nested objects for custom options

I have been working with the Vue Multiselect Custom Option Template and I am trying to use the name property as customLabel. Typically, this would be a straightforward task by just using 'name', but in this scenario, the property I need is nested ...

What causes the undefined value of "this" in the Vue Composition API setup function?

A Vue component I've created is using v3's composition API: <template> <input type="checkbox" v-model="playing" id="playing" @input="$emit('play', $event.target.value)" /> <labe ...

Understanding eventBus value listening in Vue.jsWould you like to learn how to

I've encountered an issue while trying to retrieve the search input value. Below is how I'm sending values using the event bus: import eventBus from "../../../services/eventBus"; export default { name: "Navbar", data() { return ...

Vue dynamic class binding using computed properties

I've been attempting to pass a class from a parent component to a child component using a computed switch case within a slot. Parent: <template> <mcTooltip :elementType="'text'"><p>Test</p></mcTooltip&g ...

The build process encounters an issue with initializing Sentry's Vuejs (with Typescript) Integration

While attempting to build my (vue-cli-3 based) Vuejs project using gitlab-runner on my local machine, an error occurs: 98% after emitting CopyPlugin ERROR Failed to compile with 1 errors ... Property 'util' is missing in type 'VueConstruct ...

Efficiently sending VueJS data to a separate script

I am in the process of transitioning an existing site to VueJS, but I have encountered a roadblock when it comes to finding the best method to accomplish this task. The site currently utilizes D3-Funnel (https://github.com/jakezatecky/d3-funnel) to genera ...

Vue-apollo fails to fill in the data object

Currently, I am delving into the world of vue-apollo in conjunction with nuxt utilizing the @nuxtjs/apollo module. My operational GraphQL server is up and running on localhost:4000. Let me share the code snippet that I have written: <template> < ...

Error: Cannot locate module: Vue not found, incorrect path specified

I am facing an issue with my webpack configuration. I have placed my webpack.config.js and node_modules in a subfolder. When attempting to run the command npm run build, I encounter the following error: ERROR in ../public/Vue/Components/Rating.vue Module n ...

Dealing with errors such as "Failed to load chunk" can be resolved by implementing lazy-loading and code-splitting techniques

Our team is currently working on a Vue.js application using Vue CLI 3, Vue Router, and Webpack. The routes are lazy-loaded and the chunk file names include a hash for cache busting purposes. So far, everything has been running smoothly. However, we encoun ...

"Embracing Micro-frontends: Building dynamic web applications using a variety of frontend

I am currently facing a software architecture dilemma. My extensive monolithic web application is built using PHP and backbone js, but I am eager to integrate a new front-end framework like react/vue. The question arises about the best approach to tackle t ...

Flatten information from an object containing multiple objects within an array

In my current project using Vue, I am making an API call to retrieve data from my Laravel backend (nova). The returned data is structured in the following way. The data consists of an array, which contains arrays of objects. Each array represents a record ...

Utilizing Vue.js to dynamically add a class through computed properties

As a beginner in Vue.js, I want to dynamically add or remove classes based on certain conditions. Specifically, I am trying to remove the success class when the total sum exceeds 25, but for some reason the color is not changing as expected. Can anyone p ...

Compiling Vue with TypeScript: Troubleshooting common errors

Using Vue Components with Templates Multiple Times in TypeScript I am working on utilizing a component with a template multiple times within another component. The code is split between a .html file and a .ts file. The .html file structure is as follows: ...