diff --git a/web/.eslintrc.yml b/web/.eslintrc.yml new file mode 100644 index 0000000..e43938d --- /dev/null +++ b/web/.eslintrc.yml @@ -0,0 +1,15 @@ +env: + browser: true + es2021: true +extends: + - 'plugin:vue/essential' + - standard +parserOptions: + ecmaVersion: 12 + parser: '@typescript-eslint/parser' + sourceType: module +plugins: + - vue + - '@typescript-eslint' +rules: + indent: ["error", 4] diff --git a/web/package.json b/web/package.json index ae1647d..3bbe454 100644 --- a/web/package.json +++ b/web/package.json @@ -4,15 +4,25 @@ "scripts": { "dev": "vite", "build": "vue-tsc --noEmit && vite build", - "serve": "vite preview" + "serve": "vite preview", + "lint": "eslint \"src/**\"", + "format": "eslint --fix \"src/**\"" }, "dependencies": { "vue": "^3.0.5", "vue-router": "^4.0.6" }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^4.22.0", + "@typescript-eslint/parser": "^4.22.0", "@vitejs/plugin-vue": "^1.2.1", "@vue/compiler-sfc": "^3.0.5", + "eslint": "^7.25.0", + "eslint-config-standard": "^16.0.2", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.3.1", + "eslint-plugin-vue": "^7.9.0", "typescript": "^4.1.3", "vite": "^2.2.1", "vue-tsc": "^0.0.25" diff --git a/web/src/App.vue b/web/src/App.vue index ca4df88..f19b1c3 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,5 +1,5 @@ @@ -10,8 +10,8 @@ import Nav from './components/Nav.vue' export default defineComponent({ name: 'App', components: { - Nav, - }, + Nav + } }) diff --git a/web/src/api/ivago.ts b/web/src/api/ivago.ts index 3d9375d..4c01856 100644 --- a/web/src/api/ivago.ts +++ b/web/src/api/ivago.ts @@ -3,11 +3,11 @@ export interface Street { city: string } -export async function search(search_term: string): Promise { - var base_url = import.meta.env.VITE_ENDPOINT as string +export async function search (search_term: string): Promise { + const base_url = import.meta.env.VITE_ENDPOINT as string - var r = await fetch(`${base_url}/ivago/search?` + new URLSearchParams({ - q: search_term, + const r = await fetch(`${base_url}/ivago/search?` + new URLSearchParams({ + q: search_term })) if (!r.ok) { diff --git a/web/src/components/HelloWorld.vue b/web/src/components/HelloWorld.vue index 12f05c8..1ddbac8 100644 --- a/web/src/components/HelloWorld.vue +++ b/web/src/components/HelloWorld.vue @@ -15,18 +15,18 @@ import { Street, Ivago } from '../api/ivago' export default defineComponent({ name: 'HelloWorld', - data() { + data () { return { - street: "", - results: [] as Street[], + street: '', + results: [] as Street[] } }, methods: { - onSubmit() { + onSubmit () { new Ivago(import.meta.env.VITE_ENDPOINT as string).search(this.$data.street) .then(res => { - this.$data.results = res; - }); + this.$data.results = res + }) } } }) diff --git a/web/src/components/Home.vue b/web/src/components/Home.vue index f5cc87a..cdb41ed 100644 --- a/web/src/components/Home.vue +++ b/web/src/components/Home.vue @@ -8,6 +8,6 @@ import { defineComponent } from 'vue' export default defineComponent({ - name: 'Home', + name: 'Home' }) diff --git a/web/src/components/Ivago.vue b/web/src/components/Ivago.vue index 77c6042..be2779b 100644 --- a/web/src/components/Ivago.vue +++ b/web/src/components/Ivago.vue @@ -3,7 +3,7 @@
    -
  • {{ item.name }}
  • +
  • {{ item.name }} ({{ item.city }})

{{ msg }}

@@ -11,31 +11,31 @@ diff --git a/web/src/main.ts b/web/src/main.ts index af7463e..daff2db 100644 --- a/web/src/main.ts +++ b/web/src/main.ts @@ -1,6 +1,6 @@ -import { createApp } from 'vue'; -import App from './App.vue'; -import router from './router'; +import { createApp } from 'vue' +import App from './App.vue' +import router from './router' const app = createApp(App) app.use(router) diff --git a/web/src/router.ts b/web/src/router.ts index 2d7fa58..2668326 100644 --- a/web/src/router.ts +++ b/web/src/router.ts @@ -1,21 +1,21 @@ -import { createWebHistory, createRouter } from "vue-router"; -import Home from './components/Home.vue'; -import Ivago from './components/Ivago.vue'; +import { createWebHistory, createRouter } from 'vue-router' +import Home from './components/Home.vue' +import Ivago from './components/Ivago.vue' const routes = [ { - path: "/", - component: Home, + path: '/', + component: Home }, { - path: "/ivago", - component: Ivago, - }, -]; + path: '/ivago', + component: Ivago + } +] const router = createRouter({ history: createWebHistory(), - routes, -}); + routes +}) -export default router; +export default router