gxmari007 / vite-plugin-eslint

🚨 ESLint plugin for vite
MIT License
266 stars 44 forks source link

Parsing error: Unexpected token : #21

Closed Droutin closed 2 years ago

Droutin commented 2 years ago

Describe the bug 🐛

image

16:23:27 [vite] Internal server error: C:\Projekty\Vengex\ProductivityApp\src\router\index.ts 4:13 error Parsing error: Unexpected token :

router/index.ts

import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import HomePage from "../views/HomePage.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "home",
    component: HomePage,
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;

vite.config.js

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import eslintPlugin from "vite-plugin-eslint";

export default defineConfig({
  plugins: [eslintPlugin(), vue()],
});

main.ts

import { createApp } from "vue";
import App from "./App.vue";
import Router from "./router";
import "./index.css";

const vue = createApp(App);

vue.use(Router);

vue.mount("#app");

package.json

{
  "name": "productivityapp",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc --noEmit && vite build",
    "preview": "vite preview",
    "format": "prettier --config .prettierrc . --write"
  },
  "dependencies": {
    "vue": "^3.2.25",
    "vue-router": "^4.0.12"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^2.1.0",
    "autoprefixer": "^10.4.2",
    "eslint": "^8.7.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-vue": "^8.3.0",
    "postcss": "^8.4.5",
    "prettier": "^2.5.1",
    "tailwindcss": "^3.0.15",
    "typescript": "^4.5.5",
    "vite": "^2.7.13",
    "vite-plugin-eslint": "^1.3.0",
    "vue-tsc": "^0.31.1"
  }
}

.eslintrc.js

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: ["eslint:recommended", "plugin:vue/vue3-essential", "prettier"],
  parserOptions: {
    ecmaVersion: 2021,
  },
  rules: {},
};
ModyQyW commented 2 years ago

https://github.com/vuejs/vue-eslint-parser and https://eslint.vuejs.org/user-guide/#usage may help.