mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-09 22:50:05 +00:00
Manually fix more linter errors
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
e659999b3d
commit
8875cba0f3
4 changed files with 65 additions and 59 deletions
22
.eslintrc.js
22
.eslintrc.js
|
@ -1,14 +1,14 @@
|
||||||
// https://eslint.org/docs/user-guide/configuring
|
// https://eslint.org/docs/user-guide/configuring
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'root': true,
|
root: true,
|
||||||
'parserOptions': {
|
parserOptions: {
|
||||||
parser: 'babel-eslint',
|
parser: 'babel-eslint',
|
||||||
},
|
},
|
||||||
'env': {
|
env: {
|
||||||
browser: true,
|
browser: true,
|
||||||
},
|
},
|
||||||
'extends': [
|
extends: [
|
||||||
/*
|
/*
|
||||||
* https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
|
* https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
|
||||||
* consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
|
* consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
|
||||||
|
@ -18,12 +18,13 @@ module.exports = {
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
],
|
],
|
||||||
// required to lint *.vue files
|
// required to lint *.vue files
|
||||||
'plugins': ['vue'],
|
plugins: ['vue'],
|
||||||
'globals': {
|
globals: {
|
||||||
|
Go: true,
|
||||||
process: true,
|
process: true,
|
||||||
},
|
},
|
||||||
// add your custom rules here
|
// add your custom rules here
|
||||||
'rules': {
|
rules: {
|
||||||
'array-bracket-newline': ['error', { multiline: true }],
|
'array-bracket-newline': ['error', { multiline: true }],
|
||||||
'array-bracket-spacing': ['error'],
|
'array-bracket-spacing': ['error'],
|
||||||
'arrow-body-style': ['error', 'as-needed'],
|
'arrow-body-style': ['error', 'as-needed'],
|
||||||
|
@ -38,7 +39,7 @@ module.exports = {
|
||||||
'dot-location': ['error', 'property'],
|
'dot-location': ['error', 'property'],
|
||||||
'dot-notation': ['error'],
|
'dot-notation': ['error'],
|
||||||
'eol-last': ['error', 'always'],
|
'eol-last': ['error', 'always'],
|
||||||
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
|
'eqeqeq': ['error', 'always', { null: 'ignore' }],
|
||||||
'func-call-spacing': ['error', 'never'],
|
'func-call-spacing': ['error', 'never'],
|
||||||
'function-paren-newline': ['error', 'multiline'],
|
'function-paren-newline': ['error', 'multiline'],
|
||||||
'generator-star-spacing': ['off'], // allow async-await
|
'generator-star-spacing': ['off'], // allow async-await
|
||||||
|
@ -73,11 +74,6 @@ module.exports = {
|
||||||
'quote-props': ['error', 'consistent-as-needed', { keywords: false }],
|
'quote-props': ['error', 'consistent-as-needed', { keywords: false }],
|
||||||
'quotes': ['error', 'single', { allowTemplateLiterals: true }],
|
'quotes': ['error', 'single', { allowTemplateLiterals: true }],
|
||||||
'semi': ['error', 'never'],
|
'semi': ['error', 'never'],
|
||||||
'sort-imports': ['error', {
|
|
||||||
ignoreCase: true,
|
|
||||||
ignoreDeclarationSort: false,
|
|
||||||
ignoreMemberSort: false,
|
|
||||||
}],
|
|
||||||
'sort-keys': ['error', 'asc', { caseSensitive: true, natural: false }],
|
'sort-keys': ['error', 'asc', { caseSensitive: true, natural: false }],
|
||||||
'space-before-blocks': ['error', 'always'],
|
'space-before-blocks': ['error', 'always'],
|
||||||
'spaced-comment': ['warn', 'always'],
|
'spaced-comment': ['warn', 'always'],
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -37,6 +37,13 @@ lint-fix:
|
||||||
node:10-alpine \
|
node:10-alpine \
|
||||||
sh -exc "apk add python && npm ci && npx eslint --fix src"
|
sh -exc "apk add python && npm ci && npx eslint --fix src"
|
||||||
|
|
||||||
|
lint-watch:
|
||||||
|
docker run --rm -i \
|
||||||
|
-v "$(CURDIR):/src" \
|
||||||
|
-w "/src" \
|
||||||
|
node:10-alpine \
|
||||||
|
sh -exc "apk add python && npm ci && while true; do npx eslint src || true; sleep 5; done"
|
||||||
|
|
||||||
.PHONY: bindata.go
|
.PHONY: bindata.go
|
||||||
bindata.go: build_vue
|
bindata.go: build_vue
|
||||||
go-bindata -o bindata.go dist/...
|
go-bindata -o bindata.go dist/...
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import BootstrapVue from 'bootstrap-vue'
|
import BootstrapVue from 'bootstrap-vue'
|
||||||
import Vuex from 'vuex'
|
// import Vuex from 'vuex'
|
||||||
import VueClipboard from 'vue-clipboard2'
|
import VueClipboard from 'vue-clipboard2'
|
||||||
import VueShortkey from 'vue-shortkey'
|
import VueShortkey from 'vue-shortkey'
|
||||||
|
|
||||||
|
@ -39,10 +39,10 @@ const go = new Go()
|
||||||
WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject)
|
WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject)
|
||||||
.then(async obj => await go.run(obj.instance))
|
.then(async obj => await go.run(obj.instance))
|
||||||
|
|
||||||
const instance = new Vue({
|
window.instance = new Vue({
|
||||||
store,
|
|
||||||
render: h => h(App),
|
|
||||||
mounted: () => store.dispatch('reload_users'),
|
mounted: () => store.dispatch('reload_users'),
|
||||||
|
render: h => h(App),
|
||||||
|
store,
|
||||||
}).$mount('#app')
|
}).$mount('#app')
|
||||||
|
|
||||||
// Wait for the cryptocore to be loaded (which makes encryption available)
|
// Wait for the cryptocore to be loaded (which makes encryption available)
|
||||||
|
|
|
@ -7,40 +7,6 @@ import uuidv4 from 'uuid/v4'
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
|
||||||
/*
|
|
||||||
*account_info: {
|
|
||||||
* data: [{
|
|
||||||
* "title": "Test entry",
|
|
||||||
* "username": "testuser",
|
|
||||||
* "password": "quitesecretpass",
|
|
||||||
* "url": "https://example.com",
|
|
||||||
* "comment": "",
|
|
||||||
* "tags": "",
|
|
||||||
* "id": "f106cdd5-7b52-4c51-a386-6f2016ee70c8",
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* "title": "Test entry 2",
|
|
||||||
* "username": "testuser",
|
|
||||||
* "password": "quitesecretpass",
|
|
||||||
* "url": "https://example.com",
|
|
||||||
* "comment": "",
|
|
||||||
* "tags": "foobar",
|
|
||||||
* "id": "e956814f-c7dd-4730-b383-624f8bbc6923",
|
|
||||||
* },
|
|
||||||
* ],
|
|
||||||
* data_raw: "",
|
|
||||||
* loaded: "Luzifer",
|
|
||||||
* master_password: "foobar",
|
|
||||||
* selected: null,
|
|
||||||
*},
|
|
||||||
*accounts: ["Luzifer"],
|
|
||||||
*/
|
|
||||||
account_info: {},
|
|
||||||
accounts: [],
|
|
||||||
cryptocore_available: false,
|
|
||||||
filter: null,
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
add_entry(context, entry) {
|
add_entry(context, entry) {
|
||||||
|
@ -51,7 +17,7 @@ export default new Vuex.Store({
|
||||||
|
|
||||||
decrypt_data(context) {
|
decrypt_data(context) {
|
||||||
// Do not try to decrypt empty data
|
// Do not try to decrypt empty data
|
||||||
if (context.state.account_info.data_raw == '') {
|
if (context.state.account_info.data_raw === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +79,7 @@ export default new Vuex.Store({
|
||||||
|
|
||||||
register(context, data) {
|
register(context, data) {
|
||||||
axios.post('/register', data)
|
axios.post('/register', data)
|
||||||
.then(response => {
|
.then(() => {
|
||||||
context.dispatch('reload_users', data.username)
|
context.dispatch('reload_users', data.username)
|
||||||
})
|
})
|
||||||
.catch(error => console.log(error))
|
.catch(error => console.log(error))
|
||||||
|
@ -125,7 +91,7 @@ export default new Vuex.Store({
|
||||||
const users = []
|
const users = []
|
||||||
for (const user in response.data) {
|
for (const user in response.data) {
|
||||||
const login_state = response.data[user]
|
const login_state = response.data[user]
|
||||||
if (login_state == 'logged-in') {
|
if (login_state === 'logged-in') {
|
||||||
users.push(user)
|
users.push(user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,9 +117,9 @@ export default new Vuex.Store({
|
||||||
}).then(checksum => {
|
}).then(checksum => {
|
||||||
axios.put(`/user/${context.state.account_info.loaded}/data`, {
|
axios.put(`/user/${context.state.account_info.loaded}/data`, {
|
||||||
checksum,
|
checksum,
|
||||||
old_checksum: context.state.account_info.checksum,
|
|
||||||
data: context.state.account_info.data_raw,
|
data: context.state.account_info.data_raw,
|
||||||
}).then(response => {
|
old_checksum: context.state.account_info.checksum,
|
||||||
|
}).then(() => {
|
||||||
context.commit('update_checksum', checksum)
|
context.commit('update_checksum', checksum)
|
||||||
})
|
})
|
||||||
.catch(error => console.log(error))
|
.catch(error => console.log(error))
|
||||||
|
@ -164,7 +130,7 @@ export default new Vuex.Store({
|
||||||
sign_in(context, auth) {
|
sign_in(context, auth) {
|
||||||
console.log(auth)
|
console.log(auth)
|
||||||
axios.post('/login', auth)
|
axios.post('/login', auth)
|
||||||
.then(response => {
|
.then(() => {
|
||||||
context.dispatch('reload_users', auth.username)
|
context.dispatch('reload_users', auth.username)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
@ -178,12 +144,13 @@ export default new Vuex.Store({
|
||||||
|
|
||||||
sign_out(context) {
|
sign_out(context) {
|
||||||
axios.post(`/user/${context.state.account_info.loaded}/logout`)
|
axios.post(`/user/${context.state.account_info.loaded}/logout`)
|
||||||
.then(response => {
|
.then(() => {
|
||||||
context.dispatch('reload_users')
|
context.dispatch('reload_users')
|
||||||
})
|
})
|
||||||
.catch(error => console.log(error))
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
filtered_entries: state => {
|
filtered_entries: state => {
|
||||||
if (state.filter === '' || state.filter === null) {
|
if (state.filter === '' || state.filter === null) {
|
||||||
|
@ -214,13 +181,14 @@ export default new Vuex.Store({
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
for (const item of state.account_info.data) {
|
for (const item of state.account_info.data) {
|
||||||
if (item.id == state.account_info.selected) {
|
if (item.id === state.account_info.selected) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
account_loaded(state, account_info) {
|
account_loaded(state, account_info) {
|
||||||
state.account_info = account_info
|
state.account_info = account_info
|
||||||
|
@ -279,4 +247,39 @@ export default new Vuex.Store({
|
||||||
state.filter = value
|
state.filter = value
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
state: {
|
||||||
|
/*
|
||||||
|
*account_info: {
|
||||||
|
* data: [{
|
||||||
|
* "title": "Test entry",
|
||||||
|
* "username": "testuser",
|
||||||
|
* "password": "quitesecretpass",
|
||||||
|
* "url": "https://example.com",
|
||||||
|
* "comment": "",
|
||||||
|
* "tags": "",
|
||||||
|
* "id": "f106cdd5-7b52-4c51-a386-6f2016ee70c8",
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* "title": "Test entry 2",
|
||||||
|
* "username": "testuser",
|
||||||
|
* "password": "quitesecretpass",
|
||||||
|
* "url": "https://example.com",
|
||||||
|
* "comment": "",
|
||||||
|
* "tags": "foobar",
|
||||||
|
* "id": "e956814f-c7dd-4730-b383-624f8bbc6923",
|
||||||
|
* },
|
||||||
|
* ],
|
||||||
|
* data_raw: "",
|
||||||
|
* loaded: "Luzifer",
|
||||||
|
* master_password: "foobar",
|
||||||
|
* selected: null,
|
||||||
|
*},
|
||||||
|
*accounts: ["Luzifer"],
|
||||||
|
*/
|
||||||
|
account_info: {},
|
||||||
|
accounts: [],
|
||||||
|
cryptocore_available: false,
|
||||||
|
filter: null,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue