Add eslint-plugin-vue

This commit is contained in:
KevinNThomas
2021-07-17 15:57:05 -07:00
parent 1871ea9eb7
commit 6479b32063
11 changed files with 4908 additions and 3394 deletions

11
.editorconfig Normal file
View File

@@ -0,0 +1,11 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

21
.eslintrc.js Normal file
View File

@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: {
node: true
},
parserOptions: {
ecmaVersion: 2020
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
},
extends: [
'plugin:vue/essential',
'@vue/standard'
]
}

7801
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,17 @@
{ {
"name": "noisedash", "name": "noisedash",
"version": "1.0.0", "version": "1.0.0",
"private": true,
"description": "Self-hosted web ambient noise generator", "description": "Self-hosted web ambient noise generator",
"author": "KevinThomas0 <me@kevinthomas.dev>", "author": "KevinThomas0 <me@kevinthomas.dev>",
"private": true,
"scripts": { "scripts": {
"build": "node build/build.js",
"lint": "vue-cli-service lint",
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"unit": "jest --config test/unit/jest.conf.js --coverage",
"test": "npm run unit",
"lint": "eslint --ext .js,.vue src test/unit",
"server": "node server/app", "server": "node server/app",
"build": "node build/build.js" "start": "npm run dev",
"test": "npm run unit",
"unit": "jest --config test/unit/jest.conf.js --coverage"
}, },
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
@@ -22,6 +22,8 @@
"vue-router": "^3.0.1" "vue-router": "^3.0.1"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-eslint": "^4.5.13",
"@vue/eslint-config-standard": "^5.1.2",
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",
"babel-core": "^6.22.1", "babel-core": "^6.22.1",
"babel-eslint": "^8.2.1", "babel-eslint": "^8.2.1",
@@ -38,15 +40,13 @@
"chalk": "^2.0.1", "chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1", "copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0", "css-loader": "^0.28.0",
"eslint": "^4.15.0", "eslint": "^6.7.2",
"eslint-config-standard": "^10.2.1", "eslint-friendly-formatter": "^4.0.1",
"eslint-friendly-formatter": "^3.0.0", "eslint-plugin-import": "^2.20.2",
"eslint-loader": "^1.7.1", "eslint-plugin-node": "^11.1.0",
"eslint-plugin-import": "^2.7.0", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-node": "^5.2.0", "eslint-plugin-standard": "^4.0.0",
"eslint-plugin-promise": "^3.4.0", "eslint-plugin-vue": "^6.2.2",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0", "extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4", "file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1", "friendly-errors-webpack-plugin": "^1.6.1",
@@ -74,13 +74,13 @@
"webpack-dev-server": "^2.9.1", "webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0" "webpack-merge": "^4.1.0"
}, },
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
"last 2 versions", "last 2 versions",
"not ie <= 8" "not ie <= 8"
] ],
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
}
} }

View File

@@ -7,12 +7,12 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
msg: "The superheros", msg: 'The superheros'
}; }
}, }
}; }
</script> </script>
<style scoped> <style scoped>
h1, h1,

View File

@@ -7,12 +7,12 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
msg: "Hello World!", msg: 'Hello World!'
}; }
}, }
}; }
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped> <style scoped>

View File

@@ -21,44 +21,44 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
email: "", email: '',
password: "", password: ''
}; }
}, },
methods: { methods: {
handleSubmit(e) { handleSubmit (e) {
e.preventDefault(); e.preventDefault()
if (this.password.length > 0) { if (this.password.length > 0) {
this.$http this.$http
.post("http://localhost:3000/login", { .post('http://localhost:3000/login', {
email: this.email, email: this.email,
password: this.password, password: this.password
}) })
.then((response) => { .then((response) => {
let is_admin = response.data.user.is_admin; const isAdmin = response.data.user.isAdmin
localStorage.setItem("user", JSON.stringify(response.data.user)); localStorage.setItem('user', JSON.stringify(response.data.user))
localStorage.setItem("jwt", response.data.token); localStorage.setItem('jwt', response.data.token)
if (localStorage.getItem("jwt") != null) { if (localStorage.getItem('jwt') != null) {
this.$emit("loggedIn"); this.$emit('loggedIn')
if (this.$route.params.nextUrl != null) { if (this.$route.params.nextUrl != null) {
this.$router.push(this.$route.params.nextUrl); this.$router.push(this.$route.params.nextUrl)
} else { } else {
if (is_admin == 1) { if (isAdmin === 1) {
this.$router.push("admin"); this.$router.push('admin')
} else { } else {
this.$router.push("dashboard"); this.$router.push('dashboard')
} }
} }
} }
}) })
.catch(function (error) { .catch(function (error) {
console.error(error.response); console.error(error.response)
}); })
} }
}, }
}, }
}; }
</script> </script>

View File

@@ -29,7 +29,7 @@
<label for="password-confirm">Is this an administrator account?</label> <label for="password-confirm">Is this an administrator account?</label>
<div> <div>
<select v-model="is_admin"> <select v-model="isAdmin">
<option value="1">Yes</option> <option value="1">Yes</option>
<option value="0">No</option> <option value="0">No</option>
</select> </select>
@@ -44,57 +44,58 @@
<script> <script>
export default { export default {
props: ["nextUrl"], props: ['nextUrl'],
data() { data () {
return { return {
name: "", name: '',
email: "", email: '',
password: "", password: '',
password_confirmation: "", password_confirmation: '',
is_admin: null, isAdmin: null
}; }
}, },
methods: { methods: {
handleSubmit(e) { handleSubmit (e) {
e.preventDefault(); e.preventDefault()
if ( if (
this.password === this.password_confirmation && this.password === this.password_confirmation &&
this.password.length > 0 this.password.length > 0
) { ) {
let url = "http://localhost:3000/register"; let url = 'http://localhost:3000/register'
if (this.is_admin != null || this.is_admin == 1) if (this.isAdmin != null || this.isAdmin === 1) {
url = "http://localhost:3000/register-admin"; url = 'http://localhost:3000/register-admin'
}
this.$http this.$http
.post(url, { .post(url, {
name: this.name, name: this.name,
email: this.email, email: this.email,
password: this.password, password: this.password,
is_admin: this.is_admin, isAdmin: this.isAdmin
}) })
.then((response) => { .then((response) => {
localStorage.setItem("user", JSON.stringify(response.data.user)); localStorage.setItem('user', JSON.stringify(response.data.user))
localStorage.setItem("jwt", response.data.token); localStorage.setItem('jwt', response.data.token)
if (localStorage.getItem("jwt") != null) { if (localStorage.getItem('jwt') != null) {
this.$emit("loggedIn"); this.$emit('loggedIn')
if (this.$route.params.nextUrl != null) { if (this.$route.params.nextUrl != null) {
this.$router.push(this.$route.params.nextUrl); this.$router.push(this.$route.params.nextUrl)
} else { } else {
this.$router.push("/"); this.$router.push('/')
} }
} }
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error)
}); })
} else { } else {
this.password = ""; this.password = ''
this.passwordConfirm = ""; this.passwordConfirm = ''
return alert("Passwords do not match"); return alert('Passwords do not match')
} }
}, }
}, }
}; }
</script> </script>

View File

@@ -7,12 +7,12 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
msg: "The commoners", msg: 'The commoners'
}; }
}, }
}; }
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->

View File

@@ -5,7 +5,7 @@ import App from './App'
import router from './router' import router from './router'
import Axios from 'axios' import Axios from 'axios'
Vue.prototype.$http = Axios; Vue.prototype.$http = Axios
Vue.config.productionTip = false Vue.config.productionTip = false

View File

@@ -8,7 +8,7 @@ import Admin from '@/components/Admin'
Vue.use(Router) Vue.use(Router)
let router = new Router({ const router = new Router({
mode: 'history', mode: 'history',
routes: [ routes: [
{ {
@@ -46,9 +46,9 @@ let router = new Router({
component: Admin, component: Admin,
meta: { meta: {
requiresAuth: true, requiresAuth: true,
is_admin: true isAdmin: true
}
} }
},
] ]
}) })
@@ -60,12 +60,11 @@ router.beforeEach((to, from, next) => {
params: { nextUrl: to.fullPath } params: { nextUrl: to.fullPath }
}) })
} else { } else {
let user = JSON.parse(localStorage.getItem('user')) const user = JSON.parse(localStorage.getItem('user'))
if (to.matched.some(record => record.meta.is_admin)) { if (to.matched.some(record => record.meta.isAdmin)) {
if (user.is_admin == 1) { if (user.isAdmin === 1) {
next() next()
} } else {
else {
next({ name: 'userboard' }) next({ name: 'userboard' })
} }
} else { } else {
@@ -75,8 +74,7 @@ router.beforeEach((to, from, next) => {
} else if (to.matched.some(record => record.meta.guest)) { } else if (to.matched.some(record => record.meta.guest)) {
if (localStorage.getItem('jwt') == null) { if (localStorage.getItem('jwt') == null) {
next() next()
} } else {
else {
next({ name: 'userboard' }) next({ name: 'userboard' })
} }
} else { } else {